brick-engine-js 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.local.example +2 -0
- package/.github/workflows/publish.yml +73 -0
- package/.prettierignore +2 -0
- package/.prettierrc.json +8 -0
- package/README.adoc +84 -0
- package/dist/8e23286c2fdf41fd795f.svg +32 -0
- package/dist/CNAME +1 -0
- package/dist/app.js +2 -0
- package/dist/app.js.map +1 -0
- package/dist/brick-engine.js +2 -0
- package/dist/brick-engine.js.map +1 -0
- package/dist/config/configs.d.ts +180 -0
- package/dist/config/configs.test.d.ts +1 -0
- package/dist/config/env.d.ts +2 -0
- package/dist/config/env.test.d.ts +1 -0
- package/dist/config/styles.d.ts +0 -0
- package/dist/core/Game.d.ts +107 -0
- package/dist/core/Game.test.d.ts +1 -0
- package/dist/core/InitialStateSnapshot.d.ts +19 -0
- package/dist/core/InitialStateSnapshot.test.d.ts +1 -0
- package/dist/core/helpers/CellHelper.d.ts +13 -0
- package/dist/core/helpers/CellHelper.test.d.ts +1 -0
- package/dist/core/helpers/ControlInputHandlerHelper.d.ts +32 -0
- package/dist/core/helpers/ControlInputHandlerHelper.test.d.ts +1 -0
- package/dist/core/helpers/CoordinateHelper.d.ts +54 -0
- package/dist/core/helpers/CoordinateHelper.test.d.ts +1 -0
- package/dist/core/helpers/InterfaceIdentifierHelper.d.ts +7 -0
- package/dist/core/helpers/InterfaceIdentifierHelper.test.d.ts +1 -0
- package/dist/core/helpers/RelativeValuesHelper.d.ts +23 -0
- package/dist/core/helpers/RelativeValuesHelper.test.d.ts +1 -0
- package/dist/core/module/control/GameControl.d.ts +62 -0
- package/dist/core/module/control/GameControl.test.d.ts +1 -0
- package/dist/core/module/control/GameControlKeyBinding.d.ts +36 -0
- package/dist/core/module/control/GameControlKeyBinding.test.d.ts +1 -0
- package/dist/core/module/grid/GameGrid.d.ts +399 -0
- package/dist/core/module/grid/GameGrid.test.d.ts +1 -0
- package/dist/core/module/grid/GameHudGrid.d.ts +24 -0
- package/dist/core/module/grid/GameHudGrid.test.d.ts +1 -0
- package/dist/core/module/grid/engines/GridAnalysisEngine.d.ts +29 -0
- package/dist/core/module/grid/engines/GridAnalysisEngine.test.d.ts +1 -0
- package/dist/core/module/grid/engines/GridLineEngine.d.ts +56 -0
- package/dist/core/module/grid/engines/GridLineEngine.test.d.ts +1 -0
- package/dist/core/module/grid/engines/GridMovementEngine.d.ts +29 -0
- package/dist/core/module/grid/engines/GridMovementEngine.test.d.ts +1 -0
- package/dist/core/module/grid/engines/GridRegionEngine.d.ts +26 -0
- package/dist/core/module/grid/engines/GridRegionEngine.test.d.ts +1 -0
- package/dist/core/module/grid/engines/GridTransformEngine.d.ts +24 -0
- package/dist/core/module/grid/engines/GridTransformEngine.test.d.ts +1 -0
- package/dist/core/module/renderer/DisplayRenderer.d.ts +51 -0
- package/dist/core/module/renderer/DisplayRenderer.test.d.ts +1 -0
- package/dist/core/module/renderer/GameRenderer.d.ts +59 -0
- package/dist/core/module/renderer/GameRenderer.test.d.ts +1 -0
- package/dist/core/module/renderer/HudRenderer.d.ts +56 -0
- package/dist/core/module/renderer/HudRenderer.test.d.ts +1 -0
- package/dist/core/module/score/GameScore.d.ts +117 -0
- package/dist/core/module/score/GameScore.test.d.ts +1 -0
- package/dist/core/module/session/GameSession.d.ts +20 -0
- package/dist/core/module/session/GameSession.test.d.ts +1 -0
- package/dist/core/module/sound/GameSound.d.ts +85 -0
- package/dist/core/module/sound/GameSound.test.d.ts +1 -0
- package/dist/core/module/state/GameState.d.ts +172 -0
- package/dist/core/module/state/GameState.test.d.ts +1 -0
- package/dist/core/module/text/GameText.d.ts +87 -0
- package/dist/core/module/text/GameText.test.d.ts +1 -0
- package/dist/core/module/time/GameTime.d.ts +76 -0
- package/dist/core/module/time/GameTime.test.d.ts +1 -0
- package/dist/core/types/Interfaces.d.ts +53 -0
- package/dist/core/types/Types.d.ts +114 -0
- package/dist/core/types/enums.d.ts +106 -0
- package/dist/core/types/modules.d.ts +723 -0
- package/dist/css/app.743066d8e4172b0e73f9.css +824 -0
- package/dist/css/app.743066d8e4172b0e73f9.css.map +1 -0
- package/dist/docs/GAME_DEVELOPER_GUIDE.html +727 -0
- package/dist/docs/brick-engine-guide.html +610 -0
- package/dist/docs/diagrams/lifecycle.mmd +19 -0
- package/dist/docs/documentation_style_guide.html +994 -0
- package/dist/docs/getting-started.html +648 -0
- package/dist/docs/images/lifecycle.svg +1 -0
- package/dist/docs/index.html +593 -0
- package/dist/docs/jsdoc_standard.html +656 -0
- package/dist/docs/publishing.html +573 -0
- package/dist/docs/reference/enums/Color.html +533 -0
- package/dist/docs/reference/enums/ControlEventType.html +505 -0
- package/dist/docs/reference/enums/ControlKey.html +529 -0
- package/dist/docs/reference/enums/FontAlignment.html +545 -0
- package/dist/docs/reference/enums/FontSize.html +517 -0
- package/dist/docs/reference/enums/Sound.html +558 -0
- package/dist/docs/reference/enums/StateProperty.html +525 -0
- package/dist/docs/reference/helpers/CellHelper.html +520 -0
- package/dist/docs/reference/helpers/ControlInputHandlerHelper.html +569 -0
- package/dist/docs/reference/helpers/CoordinateHelper.html +703 -0
- package/dist/docs/reference/helpers/RelativeValuesHelper.html +560 -0
- package/dist/docs/reference/interfaces/Debuggable.html +501 -0
- package/dist/docs/reference/interfaces/GameModules.html +544 -0
- package/dist/docs/reference/interfaces/Initializable.html +495 -0
- package/dist/docs/reference/interfaces/RendererInitializable.html +517 -0
- package/dist/docs/reference/interfaces/StateSyncable.html +542 -0
- package/dist/docs/reference/interfaces/modules/Control.html +648 -0
- package/dist/docs/reference/interfaces/modules/Grid.html +1256 -0
- package/dist/docs/reference/interfaces/modules/Renderer.html +522 -0
- package/dist/docs/reference/interfaces/modules/RendererComposite.html +577 -0
- package/dist/docs/reference/interfaces/modules/Score.html +669 -0
- package/dist/docs/reference/interfaces/modules/Session.html +585 -0
- package/dist/docs/reference/interfaces/modules/State.html +897 -0
- package/dist/docs/reference/interfaces/modules/Text.html +668 -0
- package/dist/docs/reference/interfaces/modules/Time.html +684 -0
- package/dist/docs/reference/modules/Debugger.html +579 -0
- package/dist/docs/reference/modules/DisplayRenderer.html +557 -0
- package/dist/docs/reference/modules/Game.html +909 -0
- package/dist/docs/reference/modules/GameControl.html +716 -0
- package/dist/docs/reference/modules/GameGrid.html +1910 -0
- package/dist/docs/reference/modules/GameHudGrid.html +508 -0
- package/dist/docs/reference/modules/GameMenu.html +538 -0
- package/dist/docs/reference/modules/GameRenderer.html +589 -0
- package/dist/docs/reference/modules/GameScore.html +664 -0
- package/dist/docs/reference/modules/GameSession.html +533 -0
- package/dist/docs/reference/modules/GameSound.html +636 -0
- package/dist/docs/reference/modules/GameState.html +922 -0
- package/dist/docs/reference/modules/GameText.html +701 -0
- package/dist/docs/reference/modules/GameTime.html +696 -0
- package/dist/docs/reference/modules/HudRenderer.html +568 -0
- package/dist/docs/reference/modules/InitialStateSnapshot.html +557 -0
- package/dist/docs/reference/modules/SessionModal.html +520 -0
- package/dist/docs/reference/types/Axis.html +505 -0
- package/dist/docs/reference/types/Cell.html +514 -0
- package/dist/docs/reference/types/ControlCallback.html +488 -0
- package/dist/docs/reference/types/Coordinate.html +510 -0
- package/dist/docs/reference/types/GameEntry.html +514 -0
- package/dist/docs/reference/types/GameEvent.html +514 -0
- package/dist/docs/reference/types/Piece.html +506 -0
- package/dist/docs/reference/types/RendererMetrics.html +514 -0
- package/dist/docs/reference/types/Vector.html +509 -0
- package/dist/docs/testing_best_practices.html +770 -0
- package/dist/favicon.ico +0 -0
- package/dist/fonts/digital-7.monoitalic.ttf +0 -0
- package/dist/images/cell.svg +32 -0
- package/dist/images/close.png +0 -0
- package/dist/images/games.png +0 -0
- package/dist/images/github.png +0 -0
- package/dist/images/letter-a.png +0 -0
- package/dist/images/letter-d.png +0 -0
- package/dist/images/letter-j.png +0 -0
- package/dist/images/letter-s.png +0 -0
- package/dist/images/letter-w.png +0 -0
- package/dist/images/meta-image.png +0 -0
- package/dist/images/number-1.png +0 -0
- package/dist/images/number-2.png +0 -0
- package/dist/images/number-3.png +0 -0
- package/dist/images/number-4.png +0 -0
- package/dist/images/number-5.png +0 -0
- package/dist/images/number-6.png +0 -0
- package/dist/images/splash.gif +0 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.html +1 -0
- package/dist/index.test.d.ts +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.test.d.ts +1 -0
- package/dist/menu/GameMenu.d.ts +15 -0
- package/dist/menu/GameMenu.test.d.ts +1 -0
- package/dist/menu/GameMenuSingleton.d.ts +6 -0
- package/dist/menu/GameMenuSingleton.test.d.ts +1 -0
- package/dist/menu/GameRepository.d.ts +7 -0
- package/dist/menu/GameRepository.test.d.ts +1 -0
- package/dist/menu/manager/GameManager.d.ts +6 -0
- package/dist/menu/manager/GameManager.test.d.ts +1 -0
- package/dist/sounds/sound_00.wav +0 -0
- package/dist/sounds/sound_01.wav +0 -0
- package/dist/sounds/sound_02.wav +0 -0
- package/dist/sounds/sound_03.wav +0 -0
- package/dist/sounds/sound_04.wav +0 -0
- package/dist/sounds/sound_05.wav +0 -0
- package/dist/sounds/sound_06.wav +0 -0
- package/dist/sounds/sound_07.wav +0 -0
- package/dist/sounds/sound_08.wav +0 -0
- package/dist/sounds/sound_09.wav +0 -0
- package/dist/sounds/sound_10.wav +0 -0
- package/dist/sounds/sound_11.wav +0 -0
- package/dist/sounds/sound_12.wav +0 -0
- package/dist/sounds/sound_13.wav +0 -0
- package/dist/sounds/sound_14.wav +0 -0
- package/dist/sounds/sound_15.wav +0 -0
- package/dist/types/interfaces.d.ts +5 -0
- package/dist/vendor/p5.min.js +1 -0
- package/dist/view/Debugger.d.ts +12 -0
- package/dist/view/Debugger.test.d.ts +1 -0
- package/dist/view/GameView.d.ts +101 -0
- package/dist/view/GameView.test.d.ts +1 -0
- package/dist/view/SessionModal.d.ts +12 -0
- package/dist/view/SessionModal.test.d.ts +4 -0
- package/dist/view/components/layout/ButtonLayout.d.ts +25 -0
- package/dist/view/components/layout/ButtonLayout.test.d.ts +1 -0
- package/dist/view/components/layout/ContainerLayout.d.ts +23 -0
- package/dist/view/components/layout/ContainerLayout.test.d.ts +1 -0
- package/dist/view/components/layout/FrameLayout.d.ts +11 -0
- package/dist/view/components/layout/FrameLayout.test.d.ts +1 -0
- package/dist/view/components/ui/BigButton.d.ts +13 -0
- package/dist/view/components/ui/BigButton.test.d.ts +1 -0
- package/dist/view/components/ui/Button.d.ts +12 -0
- package/dist/view/components/ui/Button.test.d.ts +1 -0
- package/dist/view/components/ui/Canvas.d.ts +22 -0
- package/dist/view/components/ui/Canvas.test.d.ts +1 -0
- package/dist/view/components/ui/SmallButton.d.ts +13 -0
- package/dist/view/components/ui/SmallButton.test.d.ts +1 -0
- package/dist/view/theme/applyColors.d.ts +10 -0
- package/dist/view/theme/applyColors.test.d.ts +1 -0
- package/dist/view/theme/dimensions.d.ts +13 -0
- package/dist/view/theme/dimensions.test.d.ts +1 -0
- package/docs/GAME_DEVELOPER_GUIDE.adoc +167 -0
- package/docs/brick-engine-guide.adoc +87 -0
- package/docs/diagrams/lifecycle.mmd +19 -0
- package/docs/documentation_style_guide.adoc +210 -0
- package/docs/getting-started.adoc +147 -0
- package/docs/images/lifecycle.svg +1 -0
- package/docs/jsdoc_standard.adoc +109 -0
- package/docs/publishing.adoc +58 -0
- package/docs/reference/enums/Color.adoc +35 -0
- package/docs/reference/enums/ControlEventType.adoc +28 -0
- package/docs/reference/enums/ControlKey.adoc +34 -0
- package/docs/reference/enums/FontAlignment.adoc +43 -0
- package/docs/reference/enums/FontSize.adoc +31 -0
- package/docs/reference/enums/Sound.adoc +42 -0
- package/docs/reference/enums/StateProperty.adoc +33 -0
- package/docs/reference/helpers/CellHelper.adoc +37 -0
- package/docs/reference/helpers/ControlInputHandlerHelper.adoc +57 -0
- package/docs/reference/helpers/CoordinateHelper.adoc +118 -0
- package/docs/reference/helpers/RelativeValuesHelper.adoc +53 -0
- package/docs/reference/interfaces/Debuggable.adoc +29 -0
- package/docs/reference/interfaces/GameModules.adoc +35 -0
- package/docs/reference/interfaces/Initializable.adoc +24 -0
- package/docs/reference/interfaces/RendererInitializable.adoc +33 -0
- package/docs/reference/interfaces/StateSyncable.adoc +41 -0
- package/docs/reference/interfaces/modules/Control.adoc +98 -0
- package/docs/reference/interfaces/modules/Grid.adoc +411 -0
- package/docs/reference/interfaces/modules/Renderer.adoc +34 -0
- package/docs/reference/interfaces/modules/RendererComposite.adoc +57 -0
- package/docs/reference/interfaces/modules/Score.adoc +107 -0
- package/docs/reference/interfaces/modules/Session.adoc +66 -0
- package/docs/reference/interfaces/modules/State.adoc +290 -0
- package/docs/reference/interfaces/modules/Text.adoc +110 -0
- package/docs/reference/interfaces/modules/Time.adoc +119 -0
- package/docs/reference/modules/Debugger.adoc +71 -0
- package/docs/reference/modules/DisplayRenderer.adoc +55 -0
- package/docs/reference/modules/Game.adoc +256 -0
- package/docs/reference/modules/GameControl.adoc +139 -0
- package/docs/reference/modules/GameGrid.adoc +794 -0
- package/docs/reference/modules/GameHudGrid.adoc +38 -0
- package/docs/reference/modules/GameMenu.adoc +39 -0
- package/docs/reference/modules/GameRenderer.adoc +79 -0
- package/docs/reference/modules/GameScore.adoc +138 -0
- package/docs/reference/modules/GameSession.adoc +43 -0
- package/docs/reference/modules/GameSound.adoc +111 -0
- package/docs/reference/modules/GameState.adoc +318 -0
- package/docs/reference/modules/GameText.adoc +139 -0
- package/docs/reference/modules/GameTime.adoc +141 -0
- package/docs/reference/modules/HudRenderer.adoc +56 -0
- package/docs/reference/modules/InitialStateSnapshot.adoc +47 -0
- package/docs/reference/modules/SessionModal.adoc +34 -0
- package/docs/reference/types/Axis.adoc +28 -0
- package/docs/reference/types/Cell.adoc +29 -0
- package/docs/reference/types/ControlCallback.adoc +23 -0
- package/docs/reference/types/Coordinate.adoc +29 -0
- package/docs/reference/types/GameEntry.adoc +29 -0
- package/docs/reference/types/GameEvent.adoc +29 -0
- package/docs/reference/types/Piece.adoc +32 -0
- package/docs/reference/types/RendererMetrics.adoc +29 -0
- package/docs/reference/types/Vector.adoc +28 -0
- package/docs/testing_best_practices.adoc +190 -0
- package/eslint.config.mjs +29 -0
- package/package.json +54 -0
- package/public/CNAME +1 -0
- package/public/docs/GAME_DEVELOPER_GUIDE.html +727 -0
- package/public/docs/brick-engine-guide.html +610 -0
- package/public/docs/diagrams/lifecycle.mmd +19 -0
- package/public/docs/documentation_style_guide.html +994 -0
- package/public/docs/getting-started.html +648 -0
- package/public/docs/images/lifecycle.svg +1 -0
- package/public/docs/index.html +593 -0
- package/public/docs/jsdoc_standard.html +656 -0
- package/public/docs/publishing.html +573 -0
- package/public/docs/reference/enums/Color.html +533 -0
- package/public/docs/reference/enums/ControlEventType.html +505 -0
- package/public/docs/reference/enums/ControlKey.html +529 -0
- package/public/docs/reference/enums/FontAlignment.html +545 -0
- package/public/docs/reference/enums/FontSize.html +517 -0
- package/public/docs/reference/enums/Sound.html +558 -0
- package/public/docs/reference/enums/StateProperty.html +525 -0
- package/public/docs/reference/helpers/CellHelper.html +520 -0
- package/public/docs/reference/helpers/ControlInputHandlerHelper.html +569 -0
- package/public/docs/reference/helpers/CoordinateHelper.html +703 -0
- package/public/docs/reference/helpers/RelativeValuesHelper.html +560 -0
- package/public/docs/reference/interfaces/Debuggable.html +501 -0
- package/public/docs/reference/interfaces/GameModules.html +544 -0
- package/public/docs/reference/interfaces/Initializable.html +495 -0
- package/public/docs/reference/interfaces/RendererInitializable.html +517 -0
- package/public/docs/reference/interfaces/StateSyncable.html +542 -0
- package/public/docs/reference/interfaces/modules/Control.html +648 -0
- package/public/docs/reference/interfaces/modules/Grid.html +1256 -0
- package/public/docs/reference/interfaces/modules/Renderer.html +522 -0
- package/public/docs/reference/interfaces/modules/RendererComposite.html +577 -0
- package/public/docs/reference/interfaces/modules/Score.html +669 -0
- package/public/docs/reference/interfaces/modules/Session.html +585 -0
- package/public/docs/reference/interfaces/modules/State.html +897 -0
- package/public/docs/reference/interfaces/modules/Text.html +668 -0
- package/public/docs/reference/interfaces/modules/Time.html +684 -0
- package/public/docs/reference/modules/Debugger.html +579 -0
- package/public/docs/reference/modules/DisplayRenderer.html +557 -0
- package/public/docs/reference/modules/Game.html +909 -0
- package/public/docs/reference/modules/GameControl.html +716 -0
- package/public/docs/reference/modules/GameGrid.html +1910 -0
- package/public/docs/reference/modules/GameHudGrid.html +508 -0
- package/public/docs/reference/modules/GameMenu.html +538 -0
- package/public/docs/reference/modules/GameRenderer.html +589 -0
- package/public/docs/reference/modules/GameScore.html +664 -0
- package/public/docs/reference/modules/GameSession.html +533 -0
- package/public/docs/reference/modules/GameSound.html +636 -0
- package/public/docs/reference/modules/GameState.html +922 -0
- package/public/docs/reference/modules/GameText.html +701 -0
- package/public/docs/reference/modules/GameTime.html +696 -0
- package/public/docs/reference/modules/HudRenderer.html +568 -0
- package/public/docs/reference/modules/InitialStateSnapshot.html +557 -0
- package/public/docs/reference/modules/SessionModal.html +520 -0
- package/public/docs/reference/types/Axis.html +505 -0
- package/public/docs/reference/types/Cell.html +514 -0
- package/public/docs/reference/types/ControlCallback.html +488 -0
- package/public/docs/reference/types/Coordinate.html +510 -0
- package/public/docs/reference/types/GameEntry.html +514 -0
- package/public/docs/reference/types/GameEvent.html +514 -0
- package/public/docs/reference/types/Piece.html +506 -0
- package/public/docs/reference/types/RendererMetrics.html +514 -0
- package/public/docs/reference/types/Vector.html +509 -0
- package/public/docs/testing_best_practices.html +770 -0
- package/public/favicon.ico +0 -0
- package/public/fonts/digital-7.monoitalic.ttf +0 -0
- package/public/images/cell.svg +32 -0
- package/public/images/close.png +0 -0
- package/public/images/games.png +0 -0
- package/public/images/github.png +0 -0
- package/public/images/letter-a.png +0 -0
- package/public/images/letter-d.png +0 -0
- package/public/images/letter-j.png +0 -0
- package/public/images/letter-s.png +0 -0
- package/public/images/letter-w.png +0 -0
- package/public/images/meta-image.png +0 -0
- package/public/images/number-1.png +0 -0
- package/public/images/number-2.png +0 -0
- package/public/images/number-3.png +0 -0
- package/public/images/number-4.png +0 -0
- package/public/images/number-5.png +0 -0
- package/public/images/number-6.png +0 -0
- package/public/images/splash.gif +0 -0
- package/public/index.html +15 -0
- package/public/sounds/sound_00.wav +0 -0
- package/public/sounds/sound_01.wav +0 -0
- package/public/sounds/sound_02.wav +0 -0
- package/public/sounds/sound_03.wav +0 -0
- package/public/sounds/sound_04.wav +0 -0
- package/public/sounds/sound_05.wav +0 -0
- package/public/sounds/sound_06.wav +0 -0
- package/public/sounds/sound_07.wav +0 -0
- package/public/sounds/sound_08.wav +0 -0
- package/public/sounds/sound_09.wav +0 -0
- package/public/sounds/sound_10.wav +0 -0
- package/public/sounds/sound_11.wav +0 -0
- package/public/sounds/sound_12.wav +0 -0
- package/public/sounds/sound_13.wav +0 -0
- package/public/sounds/sound_14.wav +0 -0
- package/public/sounds/sound_15.wav +0 -0
- package/public/style/body.css +86 -0
- package/public/style/buttons.css +233 -0
- package/public/style/debugger.css +117 -0
- package/public/style/sessionModal.css +155 -0
- package/public/style/sourceCodeAndCommands.css +74 -0
- package/public/style/splash.css +13 -0
- package/public/style/theme.css +137 -0
- package/scripts/generate-diagrams.sh +20 -0
- package/scripts/generate-docs.js +111 -0
- package/src/client-game.d.ts +1 -0
- package/src/config/configs.test.ts +20 -0
- package/src/config/configs.ts +197 -0
- package/src/config/env.test.ts +59 -0
- package/src/config/env.ts +7 -0
- package/src/config/styles.ts +5 -0
- package/src/core/Game.test.ts +167 -0
- package/src/core/Game.ts +307 -0
- package/src/core/InitialStateSnapshot.test.ts +51 -0
- package/src/core/InitialStateSnapshot.ts +46 -0
- package/src/core/helpers/CellHelper.test.ts +33 -0
- package/src/core/helpers/CellHelper.ts +21 -0
- package/src/core/helpers/ControlInputHandlerHelper.test.ts +116 -0
- package/src/core/helpers/ControlInputHandlerHelper.ts +68 -0
- package/src/core/helpers/CoordinateHelper.test.ts +113 -0
- package/src/core/helpers/CoordinateHelper.ts +82 -0
- package/src/core/helpers/InterfaceIdentifierHelper.test.ts +122 -0
- package/src/core/helpers/InterfaceIdentifierHelper.ts +43 -0
- package/src/core/helpers/RelativeValuesHelper.test.ts +47 -0
- package/src/core/helpers/RelativeValuesHelper.ts +29 -0
- package/src/core/module/control/GameControl.test.ts +82 -0
- package/src/core/module/control/GameControl.ts +142 -0
- package/src/core/module/control/GameControlKeyBinding.test.ts +59 -0
- package/src/core/module/control/GameControlKeyBinding.ts +92 -0
- package/src/core/module/grid/GameGrid.test.ts +83 -0
- package/src/core/module/grid/GameGrid.ts +610 -0
- package/src/core/module/grid/GameHudGrid.test.ts +22 -0
- package/src/core/module/grid/GameHudGrid.ts +40 -0
- package/src/core/module/grid/engines/GridAnalysisEngine.test.ts +157 -0
- package/src/core/module/grid/engines/GridAnalysisEngine.ts +124 -0
- package/src/core/module/grid/engines/GridLineEngine.test.ts +132 -0
- package/src/core/module/grid/engines/GridLineEngine.ts +165 -0
- package/src/core/module/grid/engines/GridMovementEngine.test.ts +125 -0
- package/src/core/module/grid/engines/GridMovementEngine.ts +113 -0
- package/src/core/module/grid/engines/GridRegionEngine.test.ts +136 -0
- package/src/core/module/grid/engines/GridRegionEngine.ts +52 -0
- package/src/core/module/grid/engines/GridTransformEngine.test.ts +98 -0
- package/src/core/module/grid/engines/GridTransformEngine.ts +70 -0
- package/src/core/module/renderer/DisplayRenderer.test.ts +86 -0
- package/src/core/module/renderer/DisplayRenderer.ts +152 -0
- package/src/core/module/renderer/GameRenderer.test.ts +103 -0
- package/src/core/module/renderer/GameRenderer.ts +144 -0
- package/src/core/module/renderer/HudRenderer.test.ts +108 -0
- package/src/core/module/renderer/HudRenderer.ts +203 -0
- package/src/core/module/score/GameScore.test.ts +71 -0
- package/src/core/module/score/GameScore.ts +188 -0
- package/src/core/module/session/GameSession.test.ts +176 -0
- package/src/core/module/session/GameSession.ts +103 -0
- package/src/core/module/sound/GameSound.test.ts +117 -0
- package/src/core/module/sound/GameSound.ts +229 -0
- package/src/core/module/state/GameState.test.ts +101 -0
- package/src/core/module/state/GameState.ts +339 -0
- package/src/core/module/text/GameText.test.ts +87 -0
- package/src/core/module/text/GameText.ts +150 -0
- package/src/core/module/time/GameTime.test.ts +86 -0
- package/src/core/module/time/GameTime.ts +144 -0
- package/src/core/types/Interfaces.ts +59 -0
- package/src/core/types/Types.ts +124 -0
- package/src/core/types/enums.ts +113 -0
- package/src/core/types/modules.ts +841 -0
- package/src/index.test.ts +15 -0
- package/src/index.ts +9 -0
- package/src/main.test.ts +137 -0
- package/src/main.ts +77 -0
- package/src/menu/GameMenu.test.ts +157 -0
- package/src/menu/GameMenu.ts +124 -0
- package/src/menu/GameMenuSingleton.test.ts +26 -0
- package/src/menu/GameMenuSingleton.ts +13 -0
- package/src/menu/GameRepository.test.ts +46 -0
- package/src/menu/GameRepository.ts +47 -0
- package/src/menu/manager/GameManager.test.ts +68 -0
- package/src/menu/manager/GameManager.ts +50 -0
- package/src/types/global.d.ts +8 -0
- package/src/types/interfaces.ts +5 -0
- package/src/view/Debugger.test.ts +152 -0
- package/src/view/Debugger.ts +124 -0
- package/src/view/GameView.test.ts +95 -0
- package/src/view/GameView.ts +244 -0
- package/src/view/SessionModal.test.ts +141 -0
- package/src/view/SessionModal.ts +73 -0
- package/src/view/components/layout/ButtonLayout.test.ts +28 -0
- package/src/view/components/layout/ButtonLayout.ts +63 -0
- package/src/view/components/layout/ContainerLayout.test.ts +48 -0
- package/src/view/components/layout/ContainerLayout.ts +50 -0
- package/src/view/components/layout/FrameLayout.test.ts +24 -0
- package/src/view/components/layout/FrameLayout.ts +25 -0
- package/src/view/components/ui/BigButton.test.ts +28 -0
- package/src/view/components/ui/BigButton.ts +31 -0
- package/src/view/components/ui/Button.test.ts +30 -0
- package/src/view/components/ui/Button.ts +30 -0
- package/src/view/components/ui/Canvas.test.ts +32 -0
- package/src/view/components/ui/Canvas.ts +34 -0
- package/src/view/components/ui/SmallButton.test.ts +48 -0
- package/src/view/components/ui/SmallButton.ts +32 -0
- package/src/view/theme/applyColors.test.ts +47 -0
- package/src/view/theme/applyColors.ts +38 -0
- package/src/view/theme/dimensions.test.ts +34 -0
- package/src/view/theme/dimensions.ts +53 -0
- package/tsconfig.json +16 -0
- package/vitest.config.ts +14 -0
- package/webpack.config.js +133 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p5=function(){"use strict";const t=Math.PI,r="2.2.1",i="p2d",s="webgl",n="webgl2",a="default",o="simple",h="full",u="crosshair",l="pointer",c="move",p="text",d="wait",f=t/2,g=t,m=t/4,y=2*t,x=2*t,v=t/180,b=180/t,_="corner",w="corners",C="radius",E="right",D="left",A="center",S="top",F="bottom",T="alphabetic",M=0,k=1,I="quads",B="quad_strip",L="close",P="open",O="chord",R="pie",N="square",V="butt",U="round",z="bevel",G="miter",j="auto",$="source-over",H="destination-out",q="lighter",W="darken",X="lighten",Y="difference",K="subtract",Z="exclusion",J="multiply",Q="screen",ee="copy",te="overlay",re="hard-light",ie="soft-light",se="color-dodge",ne="color-burn",ae="threshold",oe="gray",he="opaque",ue="invert",le="posterize",ce="dilate",pe="erode",de="blur",fe="normal",ge="WORD",me="linear",ye="fill",xe="texture",ve="image",be="linear_mipmap",_e="nearest",we="repeat",Ce="clamp",Ee="mirror",De="flat",Ae="smooth",Se="#000000",Fe="#FFFFFF",Te="grid",Me="axes",ke="contain",Ie="cover",Be="unsigned-byte",Le="unsigned-int",Pe="float",Oe="half-float",Re=Symbol("include"),Ne=Symbol("exclude"),Ve=Symbol("join");var Ue=Object.freeze({__proto__:null,ADD:q,ALT:"Alt",ARROW:a,AUTO:j,AXES:Me,BACKSPACE:"Backspace",BASELINE:T,BEVEL:z,BEZIER:"bezier",BLEND:$,BLUR:de,BOLD:"bold",BOLDITALIC:"bold italic",BOTTOM:F,BURN:ne,CENTER:A,CHAR:"CHAR",CHORD:O,CLAMP:Ce,CLOSE:L,CONTAIN:ke,CONTROL:"Control",CORNER:_,CORNERS:w,COVER:Ie,CROSS:u,CURVE:"curve",DARKEST:W,DEG_TO_RAD:v,DELETE:"Delete",DIFFERENCE:Y,DILATE:ce,DODGE:se,DOWN_ARROW:"ArrowDown",EMPTY_PATH:7,ENTER:"Enter",ERODE:pe,ESCAPE:"Escape",EXCLUDE:Ne,EXCLUSION:Z,FALLBACK:"fallback",FILL:ye,FLAT:De,FLOAT:Pe,FULL:h,GRAY:oe,GRID:Te,HALF_FLOAT:Oe,HALF_PI:f,HAND:l,HARD_LIGHT:re,IMAGE:ve,IMMEDIATE:"immediate",INCLUDE:Re,INVERT:ue,ITALIC:"italic",JOIN:Ve,LABEL:"label",LANDSCAPE:"landscape",LEFT:D,LEFT_ARROW:"ArrowLeft",LIGHTEST:X,LINEAR:me,LINEAR_MIPMAP:be,LINES:k,LINE_LOOP:2,LINE_STRIP:3,MIRROR:Ee,MITER:G,MOVE:c,MULTIPLY:J,NEAREST:_e,NORMAL:fe,OPAQUE:he,OPEN:P,OPTION:"Alt",OVERLAY:te,P2D:i,P2DHDR:"p2d-hdr",PATH:8,PI:g,PIE:R,POINTS:M,PORTRAIT:"portrait",POSTERIZE:le,PROJECT:N,QUADRATIC:"quadratic",QUADS:I,QUAD_STRIP:B,QUARTER_PI:m,RADIUS:C,RAD_TO_DEG:b,REMOVE:H,REPEAT:we,REPLACE:ee,RETURN:"Enter",RIGHT:E,RIGHT_ARROW:"ArrowRight",ROUND:U,SCREEN:Q,SHIFT:"Shift",SIMPLE:o,SMOOTH:Ae,SOFT_LIGHT:ie,SQUARE:V,STROKE:"stroke",SUBTRACT:K,TAB:"Tab",TAU:y,TESS:"tess",TEXT:p,TEXTURE:xe,THRESHOLD:ae,TOP:S,TRIANGLES:4,TRIANGLE_FAN:6,TRIANGLE_STRIP:5,TWO_PI:x,UNSIGNED_BYTE:Be,UNSIGNED_INT:Le,UP_ARROW:"ArrowUp",VERSION:r,WAIT:d,WEBGL:s,WEBGL2:n,WEBGPU:"webgpu",WORD:ge,_CTX_MIDDLE:"middle",_DEFAULT_FILL:Fe,_DEFAULT_LEADMULT:1.25,_DEFAULT_STROKE:Se,_DEFAULT_TEXT_FILL:"#000000"});function ze(e,t){t.applyMatrix=function(...e){let t=e[0]instanceof Object.getPrototypeOf(Uint8Array);return Array.isArray(e[0])||t?this._renderer.applyMatrix(...e[0]):this._renderer.applyMatrix(...e),this},t.resetMatrix=function(){return this._renderer.resetMatrix(),this},t.rotate=function(e,t){return this._renderer.rotate(this._toRadians(e),t),this},t.rotateX=function(e){return this._assert3d("rotateX"),this._renderer.rotateX(this._toRadians(e)),this},t.rotateY=function(e){return this._assert3d("rotateY"),this._renderer.rotateY(this._toRadians(e)),this},t.rotateZ=function(e){return this._assert3d("rotateZ"),this._renderer.rotateZ(this._toRadians(e)),this},t.scale=function(t,r,i){if(t instanceof e.Vector){const e=t;t=e.x,r=e.y,i=e.z}else if(Array.isArray(t)){const e=t;t=e[0],r=e[1],i=e[2]||1}return isNaN(r)?r=i=t:isNaN(i)&&(i=1),this._renderer.scale(t,r,i),this},t.shearX=function(e){const t=this._toRadians(e);return this._renderer.applyMatrix(1,0,Math.tan(t),1,0,0),this},t.shearY=function(e){const t=this._toRadians(e);return this._renderer.applyMatrix(1,Math.tan(t),0,1,0,0),this},t.translate=function(e,t,r){return this._renderer.isP3D?this._renderer.translate(e,t,r):this._renderer.translate(e,t),this},t.push=function(){this._renderer.push()},t.pop=function(){this._renderer.pop()}}function Ge(e,t){t.noLoop=function(){this._loop=!1},t.loop=function(){this._loop||(this._loop=!0,this._setupDone&&this._draw())},t.isLooping=function(){return this._loop},t.redraw=async function(e){if(this._inUserDraw||!this._setupDone)return;let t=parseInt(e);(isNaN(t)||t<1)&&(t=1);const r=this._isGlobal?window:this;if("function"==typeof r.draw){void 0===r.setup&&r.scale(r._pixelDensity,r._pixelDensity);for(let e=0;e<t;e++){r.resetMatrix(),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._updateAccsOutput(),this._renderer.isP3D&&this._renderer._update(),this.frameCount=r.frameCount+1,await this._runLifecycleHook("predraw"),this._inUserDraw=!0;try{await r.draw()}finally{this._inUserDraw=!1}await this._runLifecycleHook("postdraw")}await(this._renderer.finishDraw?.())}}}function je(e,t,r){const s=[a,u,l,c,p,d];t._frameRate=0,t._lastFrameTime=window.performance.now(),t._targetFrameRate=60;const n=window.print;let o=!1;function h(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth||0}function f(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight||0}r.presetup=function(){const e=["resize"];for(const t of e)window.addEventListener(t,this[`_on${t}`].bind(this),{passive:!1,signal:this._removeSignal})},t.print=function(...e){e.length?console.log(...e):o||(n(),window.confirm("You just tried to print the webpage. Do you want to prevent this from running again?")&&(o=!0))},t.frameCount=0,t.deltaTime=0,t.focused=document.hasFocus(),t.cursor=function(e,t,r){let i="auto";const n=this._curElement.elt;if(s.includes(e))i=e;else if("string"==typeof e){let s="";"number"==typeof t&&(r="number"==typeof r?r:0,s=`${Math.max(t,0)} ${Math.max(r,0)}`),i="http://"===e.substring(0,7)||"https://"===e.substring(0,8)||/\.(cur|jpg|jpeg|gif|png|CUR|JPG|JPEG|GIF|PNG)$/.test(e)?`url(${e}) ${s}, auto`:e}n.style.cursor=i},t.frameRate=function(e){return"number"!=typeof e||e<0?this._frameRate:(this._targetFrameRate=e,0===e&&(this._frameRate=e),this)},t.getFrameRate=function(){return this.frameRate()},t.setFrameRate=function(e){return this.frameRate(e)},t.getTargetFrameRate=function(){return this._targetFrameRate},t.noCursor=function(){this._curElement.elt.style.cursor="none"},t.webglVersion=i,t.displayWidth=screen.width,t.displayHeight=screen.height,t.windowWidth=0,t.windowHeight=0,t._onresize=function(e){let t;this.windowWidth=h(),this.windowHeight=f(),"function"==typeof this._customActions.windowResized&&(t=this._customActions.windowResized(e),void 0===t||t||e.preventDefault())},t._updateWindowSize=function(){this.windowWidth=h(),this.windowHeight=f()},Object.defineProperty(t,"width",{get(){return this._renderer.width}}),Object.defineProperty(t,"height",{get(){return this._renderer.height}}),t.fullscreen=function(e){if(void 0===e)return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement;e?function(e){if(!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled))throw new Error("Fullscreen not enabled in this browser.");e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen()}(document.documentElement):document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen()},t.pixelDensity=function(e){let t;return"number"==typeof e?(e!==this._renderer._pixelDensity&&(this._renderer._pixelDensity=e),t=this,this.resizeCanvas(this.width,this.height,!0)):t=this._renderer._pixelDensity,t},t.displayDensity=()=>window.devicePixelRatio,t.getURL=()=>location.href,t.getURLPath=()=>location.pathname.split("/").filter(e=>""!==e),t.getURLParams=function(){const e=/[?&]([^&=]+)(?:[&=])([^&=]+)/gim;let t;const r={};for(;null!=(t=e.exec(location.search));)t.index===e.lastIndex&&e.lastIndex++,r[t[1]]=t[2];return r},t.worldToScreen=function(e){return"number"==typeof e&&(e=this.createVector(...arguments)),this._renderer.getWorldToScreenMatrix().multiplyAndNormalizePoint(e)},t.screenToWorld=function(e){"number"==typeof e&&(e=this.createVector(...arguments));const t=this._renderer.getWorldToScreenMatrix();if(2===e.dimensions){let r=t.mat4[14]/t.mat4[15];e=this.createVector(e.x,e.y,r)}return t.invert(t).multiplyAndNormalizePoint(e)}}function $e(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function He(e,t,r=[0,0,0]){const i=$e(e,t[0]),s=$e(e,t[1]),n=$e(e,t[2]);return r[0]=i,r[1]=s,r[2]=n,r}function qe(e){return"string"===We(e)}function We(e){return(Object.prototype.toString.call(e).match(/^\[object\s+(.*?)\]$/)[1]||"").toLowerCase()}function Xe(e,{precision:t=16,unit:r}){return Ye(e)?"none":(e=+Ke(e,t))+(r??"")}function Ye(e){return null===e}function Ke(e,t){if(0===e)return 0;let r=~~e,i=0;r&&t&&(i=1+~~Math.log10(Math.abs(r)));const s=10**(t-i);return Math.floor(e*s+.5)/s}function Ze(e,t,r){return isNaN(e)?t:isNaN(t)?e:e+(t-e)*r}function Je(e,t,r){return!e||!t||e===t||e[0]===t[0]&&e[1]===t[1]||isNaN(r)||null===r?r:Ze(t[0],t[1],function(e,t,r){return(r-e)/(t-e)}(e[0],e[1],r))}function Qe(e,t,r){return Math.max(Math.min(r,t),e)}function et(e,t){return Math.sign(e)===Math.sign(t)?e:-e}function tt(e,t){return et(Math.abs(e)**t,e)}function rt(e,t){return 0===t?0:e/t}function it(e,t){if(e instanceof t)return!0;const r=t.name;for(;e;){const t=Object.getPrototypeOf(e),i=t?.constructor?.name;if(i===r)return!0;if(!i||"Object"===i)return!1;e=t}return!1}void 0!==p5&&ze(p5,p5.prototype),void 0!==p5&&Ge(0,p5.prototype),void 0!==p5&&je(0,p5.prototype);class st{type;coordMeta;coordRange;range;constructor(e,t){if("object"==typeof e&&(this.coordMeta=e),t&&(this.coordMeta=t,this.coordRange=t.range??t.refRange),"string"==typeof e){let t=e.trim().match(/^(?<type><[a-z]+>)(\[(?<min>-?[.\d]+),\s*(?<max>-?[.\d]+)\])?$/);if(!t)throw new TypeError(`Cannot parse ${e} as a type definition.`);this.type=t.groups.type;let{min:r,max:i}=t.groups;(r||i)&&(this.range=[+r,+i])}}get computedRange(){return this.range?this.range:"<percentage>"===this.type?this.percentageRange():"<angle>"===this.type?[0,360]:null}get unit(){return"<percentage>"===this.type?"%":"<angle>"===this.type?"deg":""}resolve(e){if("<angle>"===this.type)return e;let t=this.computedRange,r=this.coordRange;return"<percentage>"===this.type&&(r??=this.percentageRange()),Je(t,r,e)}serialize(e,t){let r="<percentage>"===this.type?this.percentageRange(100):this.computedRange,i=this.unit;return Xe(e=Je(this.coordRange,r,e),{unit:i,precision:t})}toString(){let e=this.type;if(this.range){let[t="",r=""]=this.range;e+=`[${t},${r}]`}return e}percentageRange(e=1){let t;return t=this.coordMeta&&this.coordMeta.range||this.coordRange&&this.coordRange[0]>=0?[0,1]:[-1,1],[t[0]*e,t[1]*e]}static get(e,t){return it(e,this)?e:new this(e,t)}}const nt=Symbol("instance");class at{type;name;spaceCoords;coords;id;alpha;constructor(e,t=e.space){e[nt]=this,this.type="function",this.name="color",Object.assign(this,e),this.space=t,"custom"!==this.type&&(this.spaceCoords=Object.values(t.coords),this.coords||(this.coords=this.spaceCoords.map(e=>{let t=["<number>","<percentage>"];return"angle"===e.type&&t.push("<angle>"),t})),this.coords=this.coords.map((e,t)=>{let r=this.spaceCoords[t];return"string"==typeof e&&(e=e.trim().split(/\s*\|\s*/)),e.map(e=>st.get(e,r))}))}serializeCoords(e,t,r){return r=e.map((e,t)=>st.get(r?.[t]??this.coords[t][0],this.spaceCoords[t])),e.map((e,i)=>r[i].serialize(e,t))}coerceCoords(e,t){return Object.entries(this.space.coords).map(([r,i],s)=>{let n=e[s];if(Ye(n)||isNaN(n))return n;let a=t[s],o=this.coords[s].find(e=>e.type==a);if(!o){let e=i.name||r;throw new TypeError(`${a??n?.raw??n} not allowed for ${e} in ${this.name}()`)}return n=o.resolve(n),o.range&&(t[s]=o.toString()),n})}canSerialize(){return"function"===this.type||this.serialize}parse(e){return null}static get(e,...t){return!e||it(e,this)?e:e[nt]?e[nt]:new at(e,...t)}}const ot=new class{add(e,t,r){if("string"==typeof arguments[0])(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)},this);else for(var e in arguments[0])this.add(e,arguments[0][e],arguments[1])}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},ht={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function ut(e){return Array.isArray(e)?e:ht[e]}function lt(e,t,r,i={}){if(e=ut(e),t=ut(t),!e||!t)throw new TypeError(`Missing white point to convert ${e?"":"from"}${e||t?"":"/"}${t?"":"to"}`);if(e===t)return r;let s={W1:e,W2:t,XYZ:r,options:i};if(ot.run("chromatic-adaptation-start",s),s.M||(s.W1===ht.D65&&s.W2===ht.D50?s.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:s.W1===ht.D50&&s.W2===ht.D65&&(s.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),ot.run("chromatic-adaptation-end",s),s.M)return He(s.XYZ,s.M);throw new TypeError("Only Bradford CAT with white points D50 and D65 supported for now.")}var ct={gamut_mapping:"css",precision:5,deltaE:"76",verbose:"test"!==globalThis?.process?.env?.NODE_ENV?.toLowerCase(),warn:function(e){this.verbose&&globalThis?.console?.warn?.(e)}};function pt(e,t){let r,i={str:String(e)?.trim(),options:t};if(ot.run("parse-start",i),i.color)return i.color;i.parsed=function(e){if(!e)return;let t=(e=e.trim()).match(ft.function);if(t){let e=[],r=[],i=!1,s=t[1].toLowerCase(),n=t[2].replace(ft.singleArgument,(t,n)=>{let{value:a,meta:o}=function(e){let t={},r=e.match(ft.unitValue)?.[0],i=t.raw=e;return r?(t.type="%"===r?"<percentage>":"<angle>",t.unit=r,t.unitless=Number(i.slice(0,-r.length)),i=t.unitless*dt[r]):ft.number.test(i)?(i=Number(i),t.type="<number>"):"none"===i?i=null:"NaN"===i||"calc(NaN)"===i?(i=NaN,t.type="<number>"):t.type="<ident>",{value:i,meta:t}}(n);return(t.startsWith("/")||"color"!==s&&3===e.length)&&(i=!0),e.push(a),r.push(o),""});return{name:s,args:e,argMeta:r,lastAlpha:i,commas:n.includes(","),rawName:t[1],rawArgs:t[2]}}}(i.str);let s=i.options?i.options.parseMeta??i.options.meta:null;if(i.parsed){let t,n,a=i.parsed.name,o=i.parsed.args,h=o.map((e,t)=>i.parsed.argMeta[t]?.type);if("color"===a){let r=o.shift();h.shift();let s=r.startsWith("--")?r.substring(2):`--${r}`,u=[r,s];if(t=mt.findFormat({name:a,id:u,type:"function"}),!t){let t,n=r in mt.registry?r:s;if(n in mt.registry){let i=mt.registry[n].formats?.color?.id;i&&(t=`Did you mean ${e.replace("color("+r,"color("+i)}?`)}throw new TypeError(`Cannot parse ${i.str}. `+(t??"Missing a plugin?"))}n=t.space,t.id.startsWith("--")&&!r.startsWith("--")&&ct.warn(`${n.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${t.id}) instead of color(${r}).`),r.startsWith("--")&&!t.id.startsWith("--")&&ct.warn(`${n.name} is a standard space and supported in the CSS spec. Use color(${t.id}) instead of prefixed color(${r}).`)}else t=mt.findFormat({name:a,type:"function"}),n=t.space;s&&Object.assign(s,{format:t,formatId:t.name,types:h,commas:i.parsed.commas});let u=1;i.parsed.lastAlpha&&(u=i.parsed.args.pop(),s&&(s.alphaType=h.pop()));let l=t.coords.length;if(o.length!==l)throw new TypeError(`Expected ${l} coordinates for ${n.id} in ${i.str}), got ${o.length}`);o=t.coerceCoords(o,h),r={spaceId:n.id,coords:o,alpha:u}}else e:for(let e of mt.all)for(let t in e.formats){let n=e.formats[t];if("custom"!==n.type)continue;if(n.test&&!n.test(i.str))continue;let a=e.getFormat(n),o=a.parse(i.str);if(o){s&&Object.assign(s,{format:a,formatId:t}),r=o;break e}}if(!r)throw new TypeError(`Could not parse ${e} as a color. Missing a plugin?`);return r.alpha=Ye(r.alpha)?r.alpha:void 0===r.alpha?1:Qe(0,r.alpha,1),r}const dt={"%":.01,deg:1,grad:.9,rad:180/Math.PI,turn:360},ft={function:/^([a-z]+)\(((?:calc\(NaN\)|.)+?)\)$/i,number:/^([-+]?(?:[0-9]*\.)?[0-9]+(e[-+]?[0-9]+)?)$/i,unitValue:RegExp(`(${Object.keys(dt).join("|")})$`),singleArgument:/\/?\s*(none|NaN|calc\(NaN\)|[-+\w.]+(?:%|deg|g?rad|turn)?)/g};function gt(e,t){if(Array.isArray(e))return e.map(e=>gt(e,t));if(!e)throw new TypeError("Empty color reference");qe(e)&&(e=pt(e,t));let r=e.space||e.spaceId;return"string"==typeof r&&(e.space=mt.get(r)),void 0===e.alpha&&(e.alpha=1),e}class mt{constructor(e){this.id=e.id,this.name=e.name,this.base=e.base?mt.get(e.base):null,this.aliases=e.aliases,this.base&&(this.fromBase=e.fromBase,this.toBase=e.toBase);let t=e.coords??this.base.coords;for(let e in t)"name"in t[e]||(t[e].name=e);this.coords=t;let r=e.white??this.base.white??"D65";this.white=ut(r),this.formats=e.formats??{};for(let e in this.formats){let t=this.formats[e];t.type||="function",t.name||=e}this.formats.color?.id||(this.formats.color={...this.formats.color??{},id:e.cssId||this.id}),e.gamutSpace?this.gamutSpace="self"===e.gamutSpace?this:mt.get(e.gamutSpace):this.isPolar?this.gamutSpace=this.base:this.gamutSpace=this,this.gamutSpace.isUnbounded&&(this.inGamut=(e,t)=>!0),this.referred=e.referred,Object.defineProperty(this,"path",{value:yt(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),ot.run("colorspace-init-end",this)}inGamut(e,{epsilon:t=75e-6}={}){if(!this.equals(this.gamutSpace))return e=this.to(this.gamutSpace,e),this.gamutSpace.inGamut(e,{epsilon:t});let r=Object.values(this.coords);return e.every((e,i)=>{let s=r[i];if("angle"!==s.type&&s.range){if(Ye(e))return!0;let[r,i]=s.range;return(void 0===r||e>=r-t)&&(void 0===i||e<=i+t)}return!0})}get isUnbounded(){return Object.values(this.coords).every(e=>!("range"in e))}get cssId(){return this.formats?.color?.id||this.id}get isPolar(){for(let e in this.coords)if("angle"===this.coords[e].type)return!0;return!1}getFormat(e){if(!e)return null;"default"===e?e=Object.values(this.formats)[0]:"string"==typeof e&&(e=this.formats[e]);let t=at.get(e,this);return t!==e&&e.name in this.formats&&(this.formats[e.name]=t),t}equals(e){return!!e&&(this===e||this.id===e||this.id===e.id)}to(e,t){if(1===arguments.length){const r=gt(e);[e,t]=[r.space,r.coords]}if(e=mt.get(e),this.equals(e))return t;t=t.map(e=>Ye(e)?0:e);let r,i,s=this.path,n=e.path;for(let e=0;e<s.length&&s[e].equals(n[e]);e++)r=s[e],i=e;if(!r)throw new Error(`Cannot convert between color spaces ${this} and ${e}: no connection space was found`);for(let e=s.length-1;e>i;e--)t=s[e].toBase(t);for(let e=i+1;e<n.length;e++)t=n[e].fromBase(t);return t}from(e,t){if(1===arguments.length){const r=gt(e);[e,t]=[r.space,r.coords]}return(e=mt.get(e)).to(this,t)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let e=[];for(let t in this.coords){let r=this.coords[t],i=r.range||r.refRange;e.push(i?.min??0)}return e}static registry={};static get all(){return[...new Set(Object.values(mt.registry))]}static register(e,t){if(1===arguments.length&&(e=(t=arguments[0]).id),t=this.get(t),this.registry[e]&&this.registry[e]!==t)throw new Error(`Duplicate color space registration: '${e}'`);if(this.registry[e]=t,1===arguments.length&&t.aliases)for(let e of t.aliases)this.register(e,t);return t}static get(e,...t){if(!e||it(e,this))return e;if("string"===We(e)){let t=mt.registry[e.toLowerCase()];if(!t)throw new TypeError(`No color space found with id = "${e}"`);return t}if(t.length)return mt.get(...t);throw new TypeError(`${e} is not a valid color space`)}static findFormat(e,t=mt.all){if(!e)return null;"string"==typeof e&&(e={name:e});for(let r of t)for(let[t,i]of Object.entries(r.formats)){i.name??=t,i.type??="function";let s=!(e.name&&i.name!==e.name||e.type&&i.type!==e.type);if(e.id){let t=i.ids||[i.id],r=Array.isArray(e.id)?e.id:[e.id];s&&=r.some(e=>t.includes(e))}if(s){let e=at.get(i,r);return e!==i&&(r.formats[i.name]=e),e}}return null}static resolveCoord(e,t){let r,i,s=We(e);if("string"===s?e.includes(".")?[r,i]=e.split("."):[r,i]=[,e]:Array.isArray(e)?[r,i]=e:(r=e.space,i=e.coordId),r=mt.get(r),r||(r=t),!r)throw new TypeError(`Cannot resolve coordinate reference ${e}: No color space specified and relative references are not allowed here`);if(s=We(i),"number"===s||"string"===s&&i>=0){let e=Object.entries(r.coords)[i];if(e)return{space:r,id:e[0],index:i,...e[1]}}r=mt.get(r);let n=i.toLowerCase(),a=0;for(let e in r.coords){let t=r.coords[e];if(e.toLowerCase()===n||t.name?.toLowerCase()===n)return{space:r,id:e,index:a,...t};a++}throw new TypeError(`No "${i}" coordinate found in ${r.name}. Its coordinates are: ${Object.keys(r.coords).join(", ")}`)}static DEFAULT_FORMAT={type:"functions",name:"color"}}function yt(e){let t=[e];for(let r=e;r=r.base;)t.push(r);return t}var xt=new mt({id:"xyz-d65",name:"XYZ D65",coords:{x:{refRange:[0,1],name:"X"},y:{refRange:[0,1],name:"Y"},z:{refRange:[0,1],name:"Z"}},white:"D65",formats:{color:{ids:["xyz-d65","xyz"]}},aliases:["xyz"]});class vt extends mt{constructor(e){e.coords||(e.coords={r:{range:[0,1],name:"Red"},g:{range:[0,1],name:"Green"},b:{range:[0,1],name:"Blue"}}),e.base||(e.base=xt),e.toXYZ_M&&e.fromXYZ_M&&(e.toBase??=t=>{let r=He(t,e.toXYZ_M);return this.white!==this.base.white&&(r=lt(this.white,this.base.white,r)),r},e.fromBase??=t=>He(t=lt(this.base.white,this.white,t),e.fromXYZ_M)),e.referred??="display",super(e)}}function bt(e,t){e=gt(e);let r,i=mt.get(t,t?.space),s=t?.precision;return r=!i||e.space.equals(i)?e.coords.slice():i.from(e),void 0===s?r:r.map(e=>Ke(e,s))}function _t(e,t){if(e=gt(e),"alpha"===t)return e.alpha??1;let{space:r,index:i}=mt.resolveCoord(t,e.space);return bt(e,r)[i]}function wt(e,t,r,i){return e=gt(e),Array.isArray(t)&&([t,r,i]=[e.space,t,r]),t=mt.get(t),e.coords=t===e.space?r.slice():t.to(e.space,r),void 0!==i&&(e.alpha=i),e}function Ct(e,t,r){if(e=gt(e),2===arguments.length&&"object"===We(arguments[1])){let t=arguments[1];for(let r in t)Ct(e,r,t[r])}else if("function"==typeof r&&(r=r(_t(e,t))),"alpha"===t)e.alpha=r;else{let{space:i,index:s}=mt.resolveCoord(t,e.space),n=bt(e,i);n[s]=r,wt(e,i,n)}return e}wt.returns="color",Ct.returns="color";var Et=new mt({id:"xyz-d50",name:"XYZ D50",white:"D50",base:xt,fromBase:e=>lt(xt.white,"D50",e),toBase:e=>lt("D50",xt.white,e)});const Dt=216/24389,At=24/116,St=24389/27;let Ft=ht.D50;var Tt=new mt({id:"lab",name:"Lab",coords:{l:{refRange:[0,100],name:"Lightness"},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:Ft,base:Et,fromBase(e){let t=e.map((e,t)=>e/Ft[t]).map(e=>e>Dt?Math.cbrt(e):(St*e+16)/116);return[116*t[1]-16,500*(t[0]-t[1]),200*(t[1]-t[2])]},toBase(e){let[t,r,i]=e,s=[];return s[1]=(t+16)/116,s[0]=r/500+s[1],s[2]=s[1]-i/200,[s[0]>At?Math.pow(s[0],3):(116*s[0]-16)/St,e[0]>8?Math.pow((e[0]+16)/116,3):e[0]/St,s[2]>At?Math.pow(s[2],3):(116*s[2]-16)/St].map((e,t)=>e*Ft[t])},formats:{lab:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <percentage>"]}}});function Mt(e){return"number"!=typeof e?e:(e%360+360)%360}var kt=new mt({id:"lch",name:"LCH",coords:{l:{refRange:[0,100],name:"Lightness"},c:{refRange:[0,150],name:"Chroma"},h:{refRange:[0,360],type:"angle",name:"Hue"}},base:Tt,fromBase(e){if(void 0===this.ε){let e=Object.values(this.base.coords)[1].refRange,t=e[1]-e[0];this.ε=t/1e5}let[t,r,i]=e,s=Math.abs(r)<this.ε&&Math.abs(i)<this.ε,n=s?null:Mt(180*Math.atan2(i,r)/Math.PI);return[t,s?0:Math.sqrt(r**2+i**2),n]},toBase(e){let[t,r,i]=e,s=null,n=null;return Ye(i)||(r=r<0?0:r,s=r*Math.cos(i*Math.PI/180),n=r*Math.sin(i*Math.PI/180)),[t,s,n]},formats:{lch:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <angle>"]}}});const It=25**7,Bt=Math.PI,Lt=180/Bt,Pt=Bt/180;function Ot(e){const t=e*e;return t*t*t*e}function Rt(e,t,{kL:r=1,kC:i=1,kH:s=1}={}){[e,t]=gt([e,t]);let[n,a,o]=Tt.from(e),h=kt.from(Tt,[n,a,o])[1],[u,l,c]=Tt.from(t),p=kt.from(Tt,[u,l,c])[1];h<0&&(h=0),p<0&&(p=0);let d=Ot((h+p)/2),f=.5*(1-Math.sqrt(d/(d+It))),g=(1+f)*a,m=(1+f)*l,y=Math.sqrt(g**2+o**2),x=Math.sqrt(m**2+c**2),v=0===g&&0===o?0:Math.atan2(o,g),b=0===m&&0===c?0:Math.atan2(c,m);v<0&&(v+=2*Bt),b<0&&(b+=2*Bt),v*=Lt,b*=Lt;let _,w=u-n,C=x-y,E=b-v,D=v+b,A=Math.abs(E);y*x==0?_=0:A<=180?_=E:E>180?_=E-360:E<-180?_=E+360:ct.warn("the unthinkable has happened");let S,F=2*Math.sqrt(x*y)*Math.sin(_*Pt/2),T=(n+u)/2,M=(y+x)/2,k=Ot(M);S=y*x==0?D:A<=180?D/2:D<360?(D+360)/2:(D-360)/2;let I=(T-50)**2,B=1+.015*I/Math.sqrt(20+I),L=1+.045*M,P=1;P-=.17*Math.cos((S-30)*Pt),P+=.24*Math.cos(2*S*Pt),P+=.32*Math.cos((3*S+6)*Pt),P-=.2*Math.cos((4*S-63)*Pt);let O=1+.015*M*P,R=30*Math.exp(-1*((S-275)/25)**2),N=2*Math.sqrt(k/(k+It)),V=(w/(r*B))**2;return V+=(C/(i*L))**2,V+=(F/(s*O))**2,V+=-1*Math.sin(2*R*Pt)*N*(C/(i*L))*(F/(s*O)),Math.sqrt(V)}const Nt=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],Vt=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],Ut=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],zt=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var Gt=new mt({id:"oklab",name:"Oklab",coords:{l:{refRange:[0,1],name:"Lightness"},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:"D65",base:xt,fromBase(e){let t=He(e,Nt);return t[0]=Math.cbrt(t[0]),t[1]=Math.cbrt(t[1]),t[2]=Math.cbrt(t[2]),He(t,Ut,t)},toBase(e){let t=He(e,zt);return t[0]=t[0]**3,t[1]=t[1]**3,t[2]=t[2]**3,He(t,Vt,t)},formats:{oklab:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <percentage>"]}}});function jt(e,t){[e,t]=gt([e,t]);let[r,i,s]=Gt.from(e),[n,a,o]=Gt.from(t),h=r-n,u=i-a,l=s-o;return Math.sqrt(h**2+u**2+l**2)}function $t(e,t,{epsilon:r=75e-6}={}){e=gt(e),t||(t=e.space),t=mt.get(t);let i=e.coords;return t!==e.space&&(i=t.from(e)),t.inGamut(i,{epsilon:r})}function Ht(e){return{space:e.space,coords:e.coords.slice(),alpha:e.alpha}}const qt=Math.PI/180;var Wt=new mt({id:"xyz-abs-d65",cssId:"--xyz-abs-d65",name:"Absolute XYZ D65",coords:{x:{refRange:[0,9504.7],name:"Xa"},y:{refRange:[0,1e4],name:"Ya"},z:{refRange:[0,10888.3],name:"Za"}},base:xt,fromBase:e=>e.map(e=>203*e),toBase:e=>e.map(e=>e/203)});const Xt=1.15,Yt=.66,Kt=2610/16384,Zt=16384/2610,Jt=.8359375,Qt=2413/128,er=18.6875,tr=1.7*2523/32,rr=32/(1.7*2523),ir=-.56,sr=16295499532821565e-27,nr=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],ar=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],or=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],hr=[[1,.13860504327153927,.05804731615611883],[1,-.1386050432715393,-.058047316156118904],[1,-.09601924202631895,-.811891896056039]];var ur=new mt({id:"jzazbz",name:"Jzazbz",coords:{jz:{refRange:[0,1],name:"Jz"},az:{refRange:[-.21,.21]},bz:{refRange:[-.21,.21]}},base:Wt,fromBase(e){let[t,r,i]=e,s=He([Xt*t-(Xt-1)*i,Yt*r-(Yt-1)*t,i],nr).map(function(e){let t=Jt+Qt*tt(e/1e4,Kt),r=1+er*tt(e/1e4,Kt);return tt(t/r,tr)}),[n,a,o]=He(s,or);return[(1+ir)*n/(1+ir*n)-sr,a,o]},toBase(e){let[t,r,i]=e,s=He([(t+sr)/(1+ir-ir*(t+sr)),r,i],hr).map(function(e){let t=Jt-tt(e,rr),r=er*tt(e,rr)-Qt;return 1e4*tt(t/r,Zt)}),[n,a,o]=He(s,ar),h=(n+(Xt-1)*o)/Xt;return[h,(a+(Yt-1)*h)/Yt,o]},formats:{jzazbz:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <percentage>"]}}}),lr=new mt({id:"jzczhz",name:"JzCzHz",coords:{jz:{refRange:[0,1],name:"Jz"},cz:{refRange:[0,.26],name:"Chroma"},hz:{refRange:[0,360],type:"angle",name:"Hue"}},base:ur,fromBase:kt.fromBase,toBase:kt.toBase,formats:{jzczhz:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <angle>"]}}});const cr=.8359375,pr=2413/128,dr=18.6875,fr=2610/16384,gr=16384/2610,mr=32/2523,yr=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],xr=[[.5,.5,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],vr=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],br=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var _r=new mt({id:"ictcp",name:"ICTCP",coords:{i:{refRange:[0,1],name:"I"},ct:{refRange:[-.5,.5],name:"CT"},cp:{refRange:[-.5,.5],name:"CP"}},base:Wt,fromBase:e=>function(e){return He(e.map(function(e){return((cr+pr*(e/1e4)**fr)/(1+dr*(e/1e4)**fr))**78.84375}),xr)}(He(e,yr)),toBase(e){let t=function(e){return He(e,vr).map(function(e){return 1e4*(Math.max(e**mr-cr,0)/(pr-dr*e**mr))**gr})}(e);return He(t,br)},formats:{ictcp:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <percentage>"]}}});const wr=ht.D65,Cr=1/.42,Er=2*Math.PI,Dr=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],Ar=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],Sr=[[460,451,288],[460,-891,-261],[460,-220,-6300]],Fr={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},Tr={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},Mr=180/Math.PI,kr=Math.PI/180;function Ir(e,t){return e.map(e=>{const r=tt(t*Math.abs(e)*.01,.42);return 400*et(r,e)/(r+27.13)})}function Br(e,t,r,i,s){const n={};n.discounting=s,n.refWhite=e,n.surround=i;const a=e.map(e=>100*e);n.la=t,n.yb=r;const o=a[1],h=He(a,Dr);let u=Fr[n.surround];const l=u[0];n.c=u[1],n.nc=u[2];const c=(1/(5*n.la+1))**4;n.fl=c*n.la+.1*(1-c)*(1-c)*Math.cbrt(5*n.la),n.flRoot=n.fl**.25,n.n=n.yb/o,n.z=1.48+Math.sqrt(n.n),n.nbb=.725*n.n**-.2,n.ncb=n.nbb;const p=Math.max(Math.min(l*(1-1/3.6*Math.exp((-n.la-42)/92)),1),0);n.dRgb=h.map(e=>Ze(1,o/e,p)),n.dRgbInv=n.dRgb.map(e=>1/e);const d=h.map((e,t)=>e*n.dRgb[t]),f=Ir(d,n.fl);return n.aW=n.nbb*(2*f[0]+f[1]+.05*f[2]),n}const Lr=Br(wr,64/Math.PI*.2,20,"average",!1);function Pr(e,t){if(!(void 0!==e.J^void 0!==e.Q))throw new Error("Conversion requires one and only one: 'J' or 'Q'");if(!(void 0!==e.C^void 0!==e.M^void 0!==e.s))throw new Error("Conversion requires one and only one: 'C', 'M' or 's'");if(!(void 0!==e.h^void 0!==e.H))throw new Error("Conversion requires one and only one: 'h' or 'H'");if(0===e.J||0===e.Q)return[0,0,0];let r=0;r=void 0!==e.h?Mt(e.h)*kr:function(e){let t=(e%400+400)%400;const r=Math.floor(.01*t);t%=100;const[i,s]=Tr.h.slice(r,r+2),[n,a]=Tr.e.slice(r,r+2);return Mt((t*(a*i-n*s)-100*i*a)/(t*(a-n)-100*a))}(e.H)*kr;const i=Math.cos(r),s=Math.sin(r);let n=0;void 0!==e.J?n=.1*tt(e.J,.5):void 0!==e.Q&&(n=.25*t.c*e.Q/((t.aW+4)*t.flRoot));let a=0;void 0!==e.C?a=e.C/n:void 0!==e.M?a=e.M/t.flRoot/n:void 0!==e.s&&(a=4e-4*e.s**2*(t.aW+4)/t.c);const o=tt(a*Math.pow(1.64-Math.pow(.29,t.n),-.73),10/9),h=.25*(Math.cos(r+2)+3.8),u=t.aW*tt(n,2/t.c/t.z),l=5e4/13*t.nc*t.ncb*h,c=u/t.nbb,p=23*(c+.305)*rt(o,23*l+o*(11*i+108*s)),d=function(e,t){const r=100/t*2588.068098016295;return e.map(e=>{const t=Math.abs(e);return et(r*tt(t/(400-t),Cr),e)})}(He([c,p*i,p*s],Sr).map(e=>1*e/1403),t.fl);return He(d.map((e,r)=>e*t.dRgbInv[r]),Ar).map(e=>e/100)}function Or(e,t){const r=Ir(He(e.map(e=>100*e),Dr).map((e,r)=>e*t.dRgb[r]),t.fl),i=r[0]+(-12*r[1]+r[2])/11,s=(r[0]+r[1]-2*r[2])/9,n=(Math.atan2(s,i)%Er+Er)%Er,a=.25*(Math.cos(n+2)+3.8),o=tt(5e4/13*t.nc*t.ncb*rt(a*Math.sqrt(i**2+s**2),r[0]+r[1]+1.05*r[2]+.305),.9)*Math.pow(1.64-Math.pow(.29,t.n),.73),h=tt(t.nbb*(2*r[0]+r[1]+.05*r[2])/t.aW,.5*t.c*t.z),u=100*tt(h,2),l=4/t.c*h*(t.aW+4)*t.flRoot,c=o*h,p=c*t.flRoot,d=Mt(n*Mr),f=function(e){let t=Mt(e);t<=Tr.h[0]&&(t+=360);const r=function(e,t,r=0,i=e.length){for(;r<i;){const s=r+i>>1;e[s]<t?r=s+1:i=s}return r}(Tr.h,t)-1,[i,s]=Tr.h.slice(r,r+2),[n,a]=Tr.e.slice(r,r+2),o=(t-i)/n;return Tr.H[r]+100*o/(o+(s-t)/a)}(d);return{J:u,C:c,h:d,s:50*tt(t.c*o/(t.aW+4),.5),Q:l,M:p,H:f}}new mt({id:"cam16-jmh",cssId:"--cam16-jmh",name:"CAM16-JMh",coords:{j:{refRange:[0,100],name:"J"},m:{refRange:[0,105],name:"Colorfulness"},h:{refRange:[0,360],type:"angle",name:"Hue"}},base:xt,fromBase(e){void 0===this.ε&&(this.ε=Object.values(this.coords)[1].refRange[1]/1e5);const t=Or(e,Lr),r=Math.abs(t.M)<this.ε;return[t.J,r?0:t.M,r?null:t.h]},toBase:e=>Pr({J:e[0],M:e[1],h:e[2]},Lr)});const Rr=216/24389,Nr=24389/27;function Vr(e){return e>8?Math.pow((e+16)/116,3):e/Nr}const Ur=Br(ht.D65,200/Math.PI*Vr(50),100*Vr(50),"average",!1);var zr=new mt({id:"hct",name:"HCT",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},c:{refRange:[0,145],name:"Colorfulness"},t:{refRange:[0,100],name:"Tone"}},base:xt,fromBase(e){void 0===this.ε&&(this.ε=Object.values(this.coords)[1].refRange[1]/1e5);let t=function(e){const t=116*((r=e[1])>Rr?Math.cbrt(r):(Nr*r+16)/116)-16;var r;if(0===t)return[0,0,0];const i=Or(e,Ur);return[Mt(i.h),i.C,t]}(e);return t[1]<this.ε&&(t[1]=0,t[0]=null),t},toBase:e=>function(e,t){let[r,i,s]=e,n=[],a=0;if(0===s)return[0,0,0];let o=Vr(s);a=s>0?.00379058511492914*s**2+.608983189401032*s+.9155088574762233:9514440756550361e-21*s**2+.08693057439788597*s-21.928975842194614;let h=0,u=1/0;for(;h<=15;){n=Pr({J:a,C:i,h:r},t);const e=Math.abs(n[1]-o);if(e<u){if(e<=2e-12)return n;u=e}a-=(n[1]-o)*a/(2*n[1]),h+=1}return Pr({J:a,C:i,h:r},t)}(e,Ur),formats:{color:{id:"--hct",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const Gr=Math.PI/180,jr=[1,.007,.0228];function $r(e){e[1]<0&&(e=zr.fromBase(zr.toBase(e)));const t=Math.log(Math.max(1+jr[2]*e[1]*Ur.flRoot,1))/jr[2],r=e[0]*Gr,i=t*Math.cos(r),s=t*Math.sin(r);return[e[2],i,s]}var Hr={deltaE76:function(e,t){return function(e,t,r="lab"){let i=(r=mt.get(r)).from(e),s=r.from(t);return Math.sqrt(i.reduce((e,t,r)=>{let i=s[r];return Ye(t)||Ye(i)?e:e+(i-t)**2},0))}(e,t,"lab")},deltaECMC:function(e,t,{l:r=2,c:i=1}={}){[e,t]=gt([e,t]);let[s,n,a]=Tt.from(e),[,o,h]=kt.from(Tt,[s,n,a]),[u,l,c]=Tt.from(t),p=kt.from(Tt,[u,l,c])[1];o<0&&(o=0),p<0&&(p=0);let d=s-u,f=o-p,g=(n-l)**2+(a-c)**2-f**2,m=.511;s>=16&&(m=.040975*s/(1+.01765*s));let y,x=.0638*o/(1+.0131*o)+.638;Ye(h)&&(h=0),y=h>=164&&h<=345?.56+Math.abs(.2*Math.cos((h+168)*qt)):.36+Math.abs(.4*Math.cos((h+35)*qt));let v=Math.pow(o,4),b=Math.sqrt(v/(v+1900)),_=(d/(r*m))**2;return _+=(f/(i*x))**2,_+=g/(x*(b*y+1-b))**2,Math.sqrt(_)},deltaE2000:Rt,deltaEJz:function(e,t){[e,t]=gt([e,t]);let[r,i,s]=lr.from(e),[n,a,o]=lr.from(t),h=r-n,u=i-a;Ye(s)&&Ye(o)?(s=0,o=0):Ye(s)?s=o:Ye(o)&&(o=s);let l=s-o,c=2*Math.sqrt(i*a)*Math.sin(l/2*(Math.PI/180));return Math.sqrt(h**2+u**2+c**2)},deltaEITP:function(e,t){[e,t]=gt([e,t]);let[r,i,s]=_r.from(e),[n,a,o]=_r.from(t);return 720*Math.sqrt((r-n)**2+.25*(i-a)**2+(s-o)**2)},deltaEOK:jt,deltaEOK2:function(e,t){[e,t]=gt([e,t]);let[r,i,s]=Gt.from(e),[n,a,o]=Gt.from(t),h=r-n,u=2*(i-a),l=2*(s-o);return Math.sqrt(h**2+u**2+l**2)},deltaEHCT:function(e,t){[e,t]=gt([e,t]);let[r,i,s]=$r(zr.from(e)),[n,a,o]=$r(zr.from(t));return Math.sqrt((r-n)**2+(i-a)**2+(s-o)**2)}};const qr={hct:{method:"hct.c",jnd:2,deltaEMethod:"hct",blackWhiteClamp:{}},"hct-tonal":{method:"hct.c",jnd:0,deltaEMethod:"hct",blackWhiteClamp:{channel:"hct.t",min:0,max:100}}};function Wr(e,{method:t=ct.gamut_mapping,space:r,deltaEMethod:i="",jnd:s=2,blackWhiteClamp:n}={}){if(e=gt(e),qe(arguments[1])?r=arguments[1]:r||(r=e.space),$t(e,r=mt.get(r),{epsilon:0}))return e;let a;if("css"===t)a=function(e,{space:t}={}){const r=.02,i=1e-4;e=gt(e),t||(t=e.space),t=mt.get(t);const s=mt.get("oklch");if(t.isUnbounded)return Yr(e,t);const n=Yr(e,s);let a=n.coords[0];if(a>=1){const r=Yr(Xr.WHITE,t);return r.alpha=e.alpha,Yr(r,t)}if(a<=0){const r=Yr(Xr.BLACK,t);return r.alpha=e.alpha,Yr(r,t)}if($t(n,t,{epsilon:0}))return Yr(n,t);function o(e){const r=Yr(e,t),i=Object.values(t.coords);return r.coords=r.coords.map((e,t)=>{if("range"in i[t]){const[r,s]=i[t].range;return Qe(r,e,s)}return e}),r}let h=0,u=n.coords[1],l=!0,c=Ht(n),p=o(c),d=jt(p,c);if(d<r)return p;for(;u-h>i;){const e=(h+u)/2;if(c.coords[1]=e,l&&$t(c,t,{epsilon:0}))h=e;else if(p=o(c),d=jt(p,c),d<r){if(r-d<i)break;l=!1,h=e}else u=e}return p}(e,{space:r});else{if("clip"===t||$t(e,r))a=Yr(e,r);else{Object.prototype.hasOwnProperty.call(qr,t)&&({method:t,jnd:s,deltaEMethod:i,blackWhiteClamp:n}=qr[t]);let o=Rt;if(""!==i)for(let e in Hr)if("deltae"+i.toLowerCase()===e.toLowerCase()){o=Hr[e];break}0===s&&(s=1e-16);let h=Wr(Yr(e,r),{method:"clip",space:r});if(o(e,h)>s){if(n&&3===Object.keys(n).length){let t=mt.resolveCoord(n.channel),r=_t(Yr(e,t.space),t.id);if(Ye(r)&&(r=0),r>=n.max)return Yr({space:"xyz-d65",coords:ht.D65},e.space);if(r<=n.min)return Yr({space:"xyz-d65",coords:[0,0,0]},e.space)}let i=mt.resolveCoord(t),h=i.space,u=i.id,l=Yr(e,h);l.coords.forEach((e,t)=>{Ye(e)&&(l.coords[t]=0)});let c=(i.range||i.refRange)[0],p=function(e){const t=e?Math.floor(Math.log10(Math.abs(e))):0;return Math.max(parseFloat("1e"+(t-2)),1e-6)}(s),d=c,f=_t(l,u);for(;f-d>p;){let e=Ht(l);e=Wr(e,{space:r,method:"clip"}),o(l,e)-s<p?d=_t(l,u):f=_t(l,u),Ct(l,u,(d+f)/2)}a=Yr(l,r)}else a=h}if("clip"===t||!$t(a,r,{epsilon:0})){let e=Object.values(r.coords).map(e=>e.range||[]);a.coords=a.coords.map((t,r)=>{let[i,s]=e[r];return void 0!==i&&(t=Math.max(i,t)),void 0!==s&&(t=Math.min(t,s)),t})}}return r!==e.space&&(a=Yr(a,e.space)),e.coords=a.coords,e}Wr.returns="color";const Xr={WHITE:{space:Gt,coords:[1,0,0],alpha:1},BLACK:{space:Gt,coords:[0,0,0],alpha:1}};function Yr(e,t,{inGamut:r}={}){e=gt(e);let i=(t=mt.get(t)).from(e),s={space:t,coords:i,alpha:e.alpha};return r&&(s=Wr(s,!0===r?void 0:r)),s}Yr.returns="color";var Kr=new vt({id:"p3-linear",cssId:"display-p3-linear",name:"Linear P3",white:"D65",toXYZ_M:[[.4865709486482162,.26566769316909306,.1982172852343625],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],fromXYZ_M:[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]]}),Zr=new vt({id:"srgb-linear",name:"Linear sRGB",white:"D65",toXYZ_M:[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],fromXYZ_M:[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]]}),Jr={aliceblue:[240/255,248/255,1],antiquewhite:[250/255,235/255,215/255],aqua:[0,1,1],aquamarine:[127/255,1,212/255],azure:[240/255,1,1],beige:[245/255,245/255,220/255],bisque:[1,228/255,196/255],black:[0,0,0],blanchedalmond:[1,235/255,205/255],blue:[0,0,1],blueviolet:[138/255,43/255,226/255],brown:[165/255,42/255,42/255],burlywood:[222/255,184/255,135/255],cadetblue:[95/255,158/255,160/255],chartreuse:[127/255,1,0],chocolate:[210/255,105/255,30/255],coral:[1,127/255,80/255],cornflowerblue:[100/255,149/255,237/255],cornsilk:[1,248/255,220/255],crimson:[220/255,20/255,60/255],cyan:[0,1,1],darkblue:[0,0,139/255],darkcyan:[0,139/255,139/255],darkgoldenrod:[184/255,134/255,11/255],darkgray:[169/255,169/255,169/255],darkgreen:[0,100/255,0],darkgrey:[169/255,169/255,169/255],darkkhaki:[189/255,183/255,107/255],darkmagenta:[139/255,0,139/255],darkolivegreen:[85/255,107/255,47/255],darkorange:[1,140/255,0],darkorchid:[.6,50/255,.8],darkred:[139/255,0,0],darksalmon:[233/255,150/255,122/255],darkseagreen:[143/255,188/255,143/255],darkslateblue:[72/255,61/255,139/255],darkslategray:[47/255,79/255,79/255],darkslategrey:[47/255,79/255,79/255],darkturquoise:[0,206/255,209/255],darkviolet:[148/255,0,211/255],deeppink:[1,20/255,147/255],deepskyblue:[0,191/255,1],dimgray:[105/255,105/255,105/255],dimgrey:[105/255,105/255,105/255],dodgerblue:[30/255,144/255,1],firebrick:[178/255,34/255,34/255],floralwhite:[1,250/255,240/255],forestgreen:[34/255,139/255,34/255],fuchsia:[1,0,1],gainsboro:[220/255,220/255,220/255],ghostwhite:[248/255,248/255,1],gold:[1,215/255,0],goldenrod:[218/255,165/255,32/255],gray:[128/255,128/255,128/255],green:[0,128/255,0],greenyellow:[173/255,1,47/255],grey:[128/255,128/255,128/255],honeydew:[240/255,1,240/255],hotpink:[1,105/255,180/255],indianred:[205/255,92/255,92/255],indigo:[75/255,0,130/255],ivory:[1,1,240/255],khaki:[240/255,230/255,140/255],lavender:[230/255,230/255,250/255],lavenderblush:[1,240/255,245/255],lawngreen:[124/255,252/255,0],lemonchiffon:[1,250/255,205/255],lightblue:[173/255,216/255,230/255],lightcoral:[240/255,128/255,128/255],lightcyan:[224/255,1,1],lightgoldenrodyellow:[250/255,250/255,210/255],lightgray:[211/255,211/255,211/255],lightgreen:[144/255,238/255,144/255],lightgrey:[211/255,211/255,211/255],lightpink:[1,182/255,193/255],lightsalmon:[1,160/255,122/255],lightseagreen:[32/255,178/255,170/255],lightskyblue:[135/255,206/255,250/255],lightslategray:[119/255,136/255,.6],lightslategrey:[119/255,136/255,.6],lightsteelblue:[176/255,196/255,222/255],lightyellow:[1,1,224/255],lime:[0,1,0],limegreen:[50/255,205/255,50/255],linen:[250/255,240/255,230/255],magenta:[1,0,1],maroon:[128/255,0,0],mediumaquamarine:[.4,205/255,170/255],mediumblue:[0,0,205/255],mediumorchid:[186/255,85/255,211/255],mediumpurple:[147/255,112/255,219/255],mediumseagreen:[60/255,179/255,113/255],mediumslateblue:[123/255,104/255,238/255],mediumspringgreen:[0,250/255,154/255],mediumturquoise:[72/255,209/255,.8],mediumvioletred:[199/255,21/255,133/255],midnightblue:[25/255,25/255,112/255],mintcream:[245/255,1,250/255],mistyrose:[1,228/255,225/255],moccasin:[1,228/255,181/255],navajowhite:[1,222/255,173/255],navy:[0,0,128/255],oldlace:[253/255,245/255,230/255],olive:[128/255,128/255,0],olivedrab:[107/255,142/255,35/255],orange:[1,165/255,0],orangered:[1,69/255,0],orchid:[218/255,112/255,214/255],palegoldenrod:[238/255,232/255,170/255],palegreen:[152/255,251/255,152/255],paleturquoise:[175/255,238/255,238/255],palevioletred:[219/255,112/255,147/255],papayawhip:[1,239/255,213/255],peachpuff:[1,218/255,185/255],peru:[205/255,133/255,63/255],pink:[1,192/255,203/255],plum:[221/255,160/255,221/255],powderblue:[176/255,224/255,230/255],purple:[128/255,0,128/255],rebeccapurple:[.4,.2,.6],red:[1,0,0],rosybrown:[188/255,143/255,143/255],royalblue:[65/255,105/255,225/255],saddlebrown:[139/255,69/255,19/255],salmon:[250/255,128/255,114/255],sandybrown:[244/255,164/255,96/255],seagreen:[46/255,139/255,87/255],seashell:[1,245/255,238/255],sienna:[160/255,82/255,45/255],silver:[192/255,192/255,192/255],skyblue:[135/255,206/255,235/255],slateblue:[106/255,90/255,205/255],slategray:[112/255,128/255,144/255],slategrey:[112/255,128/255,144/255],snow:[1,250/255,250/255],springgreen:[0,1,127/255],steelblue:[70/255,130/255,180/255],tan:[210/255,180/255,140/255],teal:[0,128/255,128/255],thistle:[216/255,191/255,216/255],tomato:[1,99/255,71/255],turquoise:[64/255,224/255,208/255],violet:[238/255,130/255,238/255],wheat:[245/255,222/255,179/255],white:[1,1,1],whitesmoke:[245/255,245/255,245/255],yellow:[1,1,0],yellowgreen:[154/255,205/255,50/255]};let Qr=Array(3).fill("<percentage> | <number>[0, 255]"),ei=Array(3).fill("<number>[0, 255]");var ti=new vt({id:"srgb",name:"sRGB",base:Zr,fromBase:e=>e.map(e=>{let t=e<0?-1:1,r=e*t;return r>.0031308?t*(1.055*r**(1/2.4)-.055):12.92*e}),toBase:e=>e.map(e=>{let t=e<0?-1:1,r=e*t;return r<=.04045?e/12.92:t*((r+.055)/1.055)**2.4}),formats:{rgb:{coords:Qr},rgb_number:{name:"rgb",commas:!0,coords:ei,alpha:!1},color:{},rgba:{coords:Qr,commas:!0,alpha:!0},rgba_number:{name:"rgba",commas:!0,coords:ei},hex:{type:"custom",toGamut:!0,test:e=>/^#(([a-f0-9]{2}){3,4}|[a-f0-9]{3,4})$/i.test(e),parse(e){e.length<=5&&(e=e.replace(/[a-f0-9]/gi,"$&$&"));let t=[];return e.replace(/[a-f0-9]{2}/gi,e=>{t.push(parseInt(e,16)/255)}),{spaceId:"srgb",coords:t.slice(0,3),alpha:t.slice(3)[0]}},serialize:(e,t,{collapse:r=!0,alpha:i}={})=>{(!1!==i&&t<1||!0===i)&&e.push(t),e=e.map(e=>Math.round(255*e));let s=r&&e.every(e=>e%17==0);return"#"+e.map(e=>s?(e/17).toString(16):e.toString(16).padStart(2,"0")).join("")}},keyword:{type:"custom",test:e=>/^[a-z]+$/i.test(e),parse(e){let t={spaceId:"srgb",coords:null,alpha:1};if("transparent"===(e=e.toLowerCase())?(t.coords=Jr.black,t.alpha=0):t.coords=Jr[e],t.coords)return t}}}}),ri=new vt({id:"p3",cssId:"display-p3",name:"P3",base:Kr,fromBase:ti.fromBase,toBase:ti.toBase});function ii(e){return _t(e,[xt,"y"])}function si(e,t){e=gt(e),t=gt(t);let r=Math.max(ii(e),0),i=Math.max(ii(t),0);return i>r&&([r,i]=[i,r]),(r+.05)/(i+.05)}function ni(e){return e>=.022?e:e+(.022-e)**1.414}function ai(e){let t=e<0?-1:1,r=Math.abs(e);return t*Math.pow(r,2.4)}function oi(e,t){let r,i,s,n,a,o;t=gt(t),e=gt(e),t=Yr(t,"srgb"),[n,a,o]=t.coords.map(e=>Ye(e)?0:e);let h=.2126729*ai(n)+.7151522*ai(a)+.072175*ai(o);e=Yr(e,"srgb"),[n,a,o]=e.coords.map(e=>Ye(e)?0:e);let u=.2126729*ai(n)+.7151522*ai(a)+.072175*ai(o),l=ni(h),c=ni(u),p=c>l;return Math.abs(c-l)<5e-4?i=0:p?(r=c**.56-l**.57,i=1.14*r):(r=c**.65-l**.62,i=1.14*r),s=Math.abs(i)<.1?0:i>0?i-.027:i+.027,100*s}function hi(e,t,r={}){if("function"===We(i=e)&&i.rangeArgs){let[r,i]=[e,t];return hi(...r.rangeArgs.colors,{...r.rangeArgs.options,...i})}var i;let{space:s,outputSpace:n,progression:a,premultiplied:o}=r;e=gt(e),t=gt(t),e=Ht(e),t=Ht(t);let h={colors:[e,t],options:r};if(s=s?mt.get(s):mt.registry[ct.interpolationSpace]||e.space,n=n?mt.get(n):s,e=Yr(e,s),t=Yr(t,s),e=Wr(e),t=Wr(t),s.coords.h&&"angle"===s.coords.h.type){let i=r.hue=r.hue||"shorter",n=[s,"h"],[a,o]=[_t(e,n),_t(t,n)];Ye(a)&&!Ye(o)?a=o:Ye(o)&&!Ye(a)&&(o=a),[a,o]=function(e,t){let[r,i]=t,s=Ye(r),n=Ye(i);if(s&&n)return[r,i];if(s?r=i:n&&(i=r),"raw"===e)return t;r=Mt(r),i=Mt(i);let a=i-r;return"increasing"===e?a<0&&(i+=360):"decreasing"===e?a>0&&(r+=360):"longer"===e?-180<a&&a<180&&(a>0?r+=360:i+=360):"shorter"===e&&(a>180?r+=360:a<-180&&(i+=360)),[r,i]}(i,[a,o]),Ct(e,n,a),Ct(t,n,o)}return o&&(e.coords=e.coords.map(t=>t*e.alpha),t.coords=t.coords.map(e=>e*t.alpha)),Object.assign(r=>{r=a?a(r):r;let i=e.coords.map((e,i)=>Ze(e,t.coords[i],r)),h=Ze(e.alpha,t.alpha,r),u={space:s,coords:i,alpha:h};return o&&(u.coords=u.coords.map(e=>e/h)),n!==s&&(u=Yr(u,n)),u},{rangeArgs:h})}ct.interpolationSpace="lab";var ui=new mt({id:"hsl",name:"HSL",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},l:{range:[0,100],name:"Lightness"}},base:ti,fromBase:e=>{let t=Math.max(...e),r=Math.min(...e),[i,s,n]=e,[a,o,h]=[null,0,(r+t)/2],u=t-r;if(0!==u){switch(o=0===h||1===h?0:(t-h)/Math.min(h,1-h),t){case i:a=(s-n)/u+(s<n?6:0);break;case s:a=(n-i)/u+2;break;case n:a=(i-s)/u+4}a*=60}return o<0&&(a+=180,o=Math.abs(o)),a>=360&&(a-=360),[a,100*o,100*h]},toBase:e=>{let[t,r,i]=e;function s(e){let s=(e+t/30)%12,n=r*Math.min(i,1-i);return i-n*Math.max(-1,Math.min(s-3,9-s,1))}return t%=360,t<0&&(t+=360),r/=100,i/=100,[s(0),s(8),s(4)]},formats:{hsl:{coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]},hsla:{coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"],commas:!0,alpha:!0}}}),li=new mt({id:"hsv",name:"HSV",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},v:{range:[0,100],name:"Value"}},base:ti,fromBase(e){let t=Math.max(...e),r=Math.min(...e),[i,s,n]=e,[a,o,h]=[null,0,t],u=t-r;if(0!==u){switch(t){case i:a=(s-n)/u+(s<n?6:0);break;case s:a=(n-i)/u+2;break;case n:a=(i-s)/u+4}a*=60}return h&&(o=u/h),a>=360&&(a-=360),[a,100*o,100*h]},toBase(e){let[t,r,i]=e;function s(e){let s=(e+t/60)%6;return i-i*r*Math.max(0,Math.min(s,4-s,1))}return t%=360,t<0&&(t+=360),r/=100,i/=100,[s(5),s(3),s(1)]},formats:{color:{id:"--hsv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}}),ci=new mt({id:"hwb",name:"HWB",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},w:{range:[0,100],name:"Whiteness"},b:{range:[0,100],name:"Blackness"}},base:li,fromBase(e){let[t,r,i]=e;return[t,i*(100-r)/100,100-i]},toBase(e){let[t,r,i]=e;r/=100,i/=100;let s=r+i;if(s>=1)return[t,0,r/s*100];let n=1-i;return[t,100*(0===n?0:1-r/n),100*n]},formats:{hwb:{coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}}),pi=new mt({id:"oklch",name:"OkLCh",coords:{l:{refRange:[0,1],name:"Lightness"},c:{refRange:[0,.4],name:"Chroma"},h:{refRange:[0,360],type:"angle",name:"Hue"}},white:"D65",base:Gt,fromBase:kt.fromBase,toBase:kt.toBase,formats:{oklch:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <angle>"]}}}),di=new mt({id:"hsb",name:"HSB",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},b:{range:[0,100],name:"Brightness"}},base:ti,fromBase:e=>{const t=Math.max(...e),r=t-Math.min(...e);let i,s,[n,a,o]=e;return 0===r?(i=0,s=0):(s=r/t,n===t?i=(a-o)/r:a===t?i=2+(o-n)/r:o===t&&(i=4+(n-a)/r),i<0?i+=6:i>=6&&(i-=6)),[i/6*360,100*s,100*t]},toBase:fi,formats:{default:{type:"custom",serialize:(e,t)=>{const r=fi(e);let i=`rgb(${Math.round(100*r[0]*100)/100}% ${Math.round(100*r[1]*100)/100}% ${Math.round(100*r[2]*100)/100}%`;return t<1&&(i+=` / ${t}`),i+=")",i}},hsb:{coords:["<number> | <angle>","<percentage>","<percentage>"]},hsba:{coords:["<number> | <angle>","<percentage>","<percentage>"],commans:!0,lastAlpha:!0}}});function fi(e){const t=e[0]/360*6,r=e[1]/100,i=e[2]/100;let s=[];if(0===r)s=[i,i,i];else{const e=Math.floor(t),n=i*(1-r),a=i*(1-r*(t-e)),o=i*(1-r*(1+e-t));let h,u,l;1===e?(h=a,u=i,l=n):2===e?(h=n,u=i,l=o):3===e?(h=n,u=a,l=i):4===e?(h=o,u=n,l=i):5===e?(h=i,u=n,l=a):(h=i,u=o,l=n),s=[h,u,l]}return s}const gi=(e,t,r,i,s,n)=>{let a=(e-t)/(r-t)*(s-i)+i;return n&&(a=Math.max(a,Math.min(i,s)),a=Math.min(a,Math.max(i,s))),a},mi=e=>{const t=(~~(255*e)).toString(16);return t.length<2?"0"+t:t},yi=new Map;class xi{static colorMap={};static#e={};static#t={};static addColorMode(e,t){mt.register(t),xi.colorMap[e]=t.id,xi.#e[e]=Object.values(t.coords).reduce((e,t)=>(e.push(t.refRange||t.range),e),[]),xi.#e[e].push([0,1]),xi.#t[e]=t.fromGray}constructor(e,t,r,{clamp:i=!1}={}){if(this._cachedMode=t||bi,e instanceof xi){const r=t?xi.colorMap[t]:xi.colorMap[e.mode];this._initialize=()=>{this._cachedColor=Yr(e._color,r),this._cachedMode=r}}else if("object"!=typeof e||Array.isArray(e)||null===e)if("string"==typeof e[0])this._defaultStringValue=e[0],this._initialize=()=>{try{this._cachedColor=pt(e[0]);const[t]=Object.entries(xi.colorMap).find(([e,t])=>t===this._cachedColor.spaceId);this._cachedMode=t,this._cachedColor=Yr(this._cachedColor,this._cachedColor.spaceId)}catch(e){throw new Error("Invalid color string")}};else{let t;if(r)if(4===e.length)t=xi.mapColorRange(e,this._cachedMode,r,i);else if(3===e.length)t=xi.mapColorRange([e[0],e[1],e[2]],this._cachedMode,r,i),t.push(1);else if(2===e.length){t=xi.#t[this._cachedMode]?xi.#t[this._cachedMode](e[0],r,i):xi.mapColorRange([e[0],e[0],e[0]],this._cachedMode,r,i);const s=Array.isArray(r[r.length-1])?r[r.length-1]:[0,r[r.length-1]];t.push(gi(e[1],s[0],s[1],0,1,i))}else{if(1!==e.length)throw new Error("Invalid color");t=xi.#t[this._cachedMode]?xi.#t[this._cachedMode](e[0],r,i):xi.mapColorRange([e[0],e[0],e[0]],this._cachedMode,r,i),t.push(1)}else t=e;this._cachedMode===bi&&(1===t[3]?this._defaultStringValue="#"+mi(t[0])+mi(t[1])+mi(t[2]):this._defaultStringValue="#"+mi(t[0])+mi(t[1])+mi(t[2])+mi(t[3])),this._initialize=()=>{const e=xi.colorMap[this._cachedMode]||console.error("Invalid color mode"),r={space:e,coords:t.slice(0,3),alpha:t[3]};this._cachedColor=Yr(r,e)}}else{const r=t?xi.colorMap[t]:e.spaceId;this._initialize=()=>{this._cachedColor=Yr(e,r),this._cachedMode=t||Object.entries(xi.colorMap).find(([e,t])=>t===this._cachedColor.spaceId)}}}get mode(){return this._initialize&&(this._initialize(),this._initialize=void 0),this._cachedMode}get _color(){return this._initialize&&(this._initialize(),this._initialize=void 0),this._cachedColor}set _color(e){this._initialize&&(this._initialize(),this._initialize=void 0),this._cachedColor=e}static mapColorRange(e,t,r,i){const s=r.map(e=>Array.isArray(e)?e:[0,e]),n=xi.#e[t];return e.map((e,t)=>gi(e,s[t][0],s[t][1],n[t][0],n[t][1],i))}static unmapColorRange(e,t,r){const i=r.map(e=>Array.isArray(e)?e:[0,e]),s=xi.#e[t];return e.map((e,t)=>gi(e,s[t][0],s[t][1],i[t][0],i[t][1]))}#r(e){return new xi(this._color,e)}get _array(){return this._getRGBA()}array(){return this._array}lerp(e,t,r){let i=-1;for(;(i+1<this._color.space.path.length||i+1<e._color.space.path.length)&&this._color.space.path[i+1]===e._color.space.path[i+1];)i+=1;if(-1===i)throw new Error("Cannot lerp colors. No common color space found");const s=hi(this._color,e._color,{space:this._color.space.path[i].id})(t);return new xi(s,r||this.mode)}toString(e){if(void 0===e&&void 0!==this._defaultStringValue)return this._defaultStringValue;let t=e;"#rrggbb"===e&&(t="hex");const r=`${this._color.space.id}-${this._color.coords.join(",")}-${this._color.alpha}-${e}`;let i=yi.get(r);if(!i){if(i=function(e,t={}){let r,{precision:i=ct.precision,format:s,inGamut:n=!0,coords:a,alpha:o,commas:h}=t,u=gt(e),l=s,c=u.parseMeta;c&&!s&&(c.format.canSerialize()&&(s=c.format,l=c.formatId),a??=c.types,o??=c.alphaType,h??=c.commas),l&&(s=u.space.getFormat(s)??mt.findFormat(l)),s||(s=u.space.getFormat("default")??mt.DEFAULT_FORMAT,l=s.name),s&&s.space&&s.space!==u.space&&(u=Yr(u,s.space));let p=u.coords.slice();if(n||=s.toGamut,n&&!$t(u)&&(p=Wr(Ht(u),!0===n?void 0:n).coords),"custom"===s.type){if(!s.serialize)throw new TypeError(`format ${l} can only be used to parse colors, not for serialization`);r=s.serialize(p,u.alpha,t)}else{let e=s.name||"color",t=s.serializeCoords(p,i,a);if("color"===e){let e=s.id||s.ids?.[0]||u.space.cssId||u.space.id;t.unshift(e)}let n=u.alpha;void 0!==o&&"object"!=typeof o&&(o="string"==typeof o?{type:o}:{include:o});let l=o?.type??"<number>",c=!0===o?.include||!0===s.alpha||!1!==o?.include&&!1!==s.alpha&&n<1,d="";if(h??=s.commas,c){if(null!==i){let e;"<percentage>"===l&&(e="%",n*=100),n=Xe(n,{precision:i,unit:e})}d=`${h?",":" /"} ${n}`}r=`${e}(${t.join(h?", ":" ")}${d})`}return r}(this._color,{format:t}),"#rrggbb"===e){if(i=String(i),4===i.length){const e=i[1],t=i[2],r=i[3];i=`#${e}${e}${t}${t}${r}${r}`}i.length>7&&(i=i.slice(0,7)),i=i.toLowerCase()}yi.size>1e3&&yi.delete(yi.keys().next().value),yi.set(r,i)}return i}contrast(e,t="WCAG21"){if("all"!==t){let r,i;switch(t){case"WCAG21":r=si(this._color,e._color),i=4.5;break;case"APCA":r=Math.abs(oi(this._color,e._color)),i=75;break;default:return null}return r>=i}{const t=si(this._color,e._color),r=oi(this._color,e._color);return{WCAG21:{value:t,passedMinimum:t>=4.5,passedAAA:t>=7},APCA:{value:r,passedMinimum:Math.abs(r)>=75}}}}setRed(e,t=[0,1]){this._defaultStringValue=void 0,Array.isArray(t)||(t=[0,t]);const r=xi.#e[bi][0],i=gi(e,t[0],t[1],r[0],r[1]);if(this.mode===bi||this.mode===_i)this._color.coords[0]=i;else{const e=this._color.space.id,t=Yr(this._color,"srgb");t.coords[0]=i,this._color=Yr(t,e)}}setGreen(e,t=[0,1]){this._defaultStringValue=void 0,Array.isArray(t)||(t=[0,t]);const r=xi.#e[bi][1],i=gi(e,t[0],t[1],r[0],r[1]);if(this.mode===bi||this.mode===_i)this._color.coords[1]=i;else{const e=this._color.space.id,t=Yr(this._color,"srgb");t.coords[1]=i,this._color=Yr(t,e)}}setBlue(e,t=[0,1]){this._defaultStringValue=void 0,Array.isArray(t)||(t=[0,t]);const r=xi.#e[bi][2],i=gi(e,t[0],t[1],r[0],r[1]);if(this.mode===bi||this.mode===_i)this._color.coords[2]=i;else{const e=this._color.space.id,t=Yr(this._color,"srgb");t.coords[2]=i,this._color=Yr(t,e)}}setAlpha(e,t=[0,1]){this._defaultStringValue=void 0,Array.isArray(t)||(t=[0,t]);const r=xi.#e[this.mode][3],i=gi(e,t[0],t[1],r[0],r[1]);this._color.alpha=i}_getRGBA(e=[1,1,1,1]){const t=xi.#e[bi];let r=structuredClone(Yr(this._color,"srgb").coords);r.push(this._color.alpha);const i=e.map(e=>Array.isArray(e)?e:[0,e]);return r=r.map((e,r)=>gi(e,t[r][0],t[r][1],i[r][0],i[r][1])),r}_getMode(){return this.mode}_getRed(e=[0,1]){if(Array.isArray(e)||(e=[0,e]),this.mode===bi||this.mode===_i){const t=xi.#e[this.mode][0];return gi(this._color.coords[0],t[0],t[1],e[0],e[1])}{const t=xi.#e[bi][0];return gi(Yr(this._color,"srgb").coords[0],t[0],t[1],e[0],e[1])}}_getGreen(e=[0,1]){if(Array.isArray(e)||(e=[0,e]),this.mode===bi||this.mode===_i){const t=xi.#e[this.mode][1];return gi(this._color.coords[1],t[0],t[1],e[0],e[1])}{const t=xi.#e[bi][1];return gi(Yr(this._color,"srgb").coords[1],t[0],t[1],e[0],e[1])}}_getBlue(e=[0,1]){if(Array.isArray(e)||(e=[0,e]),this.mode===bi||this.mode===_i){const t=xi.#e[this.mode][2];return gi(this._color.coords[2],t[0],t[1],e[0],e[1])}{const t=xi.#e[bi][2];return gi(Yr(this._color,"srgb").coords[2],t[0],t[1],e[0],e[1])}}_getAlpha(e=[0,1]){Array.isArray(e)||(e=[0,e]);const t=xi.#e[this.mode][3];return gi(this._color.alpha,t[0],t[1],e[0],e[1])}_getHue(e=[0,360]){if(Array.isArray(e)||(e=[0,e]),this.mode===wi||this.mode===Ci){const t=xi.#e[this.mode][0];return gi(this._color.coords[0],t[0],t[1],e[0],e[1])}{const t=xi.#e[Ci][0];return gi(Yr(this._color,"hsl").coords[0],t[0],t[1],e[0],e[1])}}_getSaturation(e=[0,100]){if(Array.isArray(e)||(e=[0,e]),this.mode===wi||this.mode===Ci){const t=xi.#e[this.mode][1];return gi(this._color.coords[1],t[0],t[1],e[0],e[1])}{const t=xi.#e[Ci][1];return gi(Yr(this._color,"hsl").coords[1],t[0],t[1],e[0],e[1])}}_getBrightness(e=[0,100]){if(Array.isArray(e)||(e=[0,e]),this.mode===wi){const t=xi.#e[this.mode][2];return gi(this._color.coords[2],t[0],t[1],e[0],e[1])}{const t=xi.#e[wi][2];return gi(Yr(this._color,"hsb").coords[2],t[0],t[1],e[0],e[1])}}_getLightness(e=[0,100]){if(Array.isArray(e)||(e=[0,e]),this.mode===Ci){const t=xi.#e[this.mode][2];return gi(this._color.coords[2],t[0],t[1],e[0],e[1])}{const t=xi.#e[Ci][2];return gi(Yr(this._color,"hsl").coords[2],t[0],t[1],e[0],e[1])}}}function vi(e,t,r){e.Color=xi,ti.fromGray=ri.fromGray=function(e,t,r){const i=t.map(e=>Array.isArray(e)?e:[0,e]),s=gi(e,i[2][0],i[2][1],0,1,r);return[s,s,s]},di.fromGray=ui.fromGray=function(e,t,r){const i=t.map(e=>Array.isArray(e)?e:[0,e]);return[0,0,gi(e,i[2][0],i[2][1],0,100,r)]},ci.fromGray=function(e,t,r){const i=t.map(e=>Array.isArray(e)?e:[0,e]),s=Math.abs(i[1][0]-i[1][1])/2+Math.abs(i[2][0]-i[2][1])/2,n=gi(e,0,s,0,100);let a,o;return n<50?(o=n,a=100-n):n>=50&&(a=n,o=100-n),[0,a,o]},Tt.fromGray=kt.fromGray=Gt.fromGray=pi.fromGray=function(e,t,r){const i=t.map(e=>Array.isArray(e)?e:[0,e]);return[gi(e,i[0][0],i[0][1],0,100,r),0,0]},e.Color.addColorMode(bi,ti),e.Color.addColorMode(_i,ri),e.Color.addColorMode(wi,di),e.Color.addColorMode(Ci,ui),e.Color.addColorMode(Ei,ci),e.Color.addColorMode(Di,Tt),e.Color.addColorMode(Ai,kt),e.Color.addColorMode(Si,Gt),e.Color.addColorMode(Fi,pi),r.presetup=function(){const t=this,r=["Red","Green","Blue","Alpha"];for(let i in r){const s=r[i],n=e.Color.prototype["set"+s];e.Color.prototype["set"+s]=function(e,r){return r=r||t?._renderer?.states?.colorMaxes?.[bi][i],n.call(this,e,r)}}function i(r,i){const s=e.Color.prototype["_get"+r];e.Color.prototype["_get"+r]=function(e){if(Object.keys(i).includes(this.mode))e=e||t?._renderer?.states?.colorMaxes?.[this.mode][i[this.mode]];else{const r=Object.keys(i)[0];e=e||t?._renderer?.states?.colorMaxes?.[r][i[r]]}return s.call(this,e)}}i("Red",{[bi]:0,[_i]:0}),i("Green",{[bi]:1,[_i]:1}),i("Blue",{[bi]:2,[_i]:2}),i("Alpha",{[bi]:3,[_i]:3,[wi]:3,[Ci]:3,[Ei]:3,[Di]:3,[Ai]:3,[Si]:3,[Fi]:3}),i("Hue",{[Ci]:0,[wi]:0,[Ei]:0,[Ai]:2,[Fi]:2}),i("Saturation",{[Ci]:1,[wi]:1}),i("Brightness",{[wi]:2}),i("Lightness",{[Ci]:2})}}void 0!==p5&&vi(p5);const bi="rgb",_i="rgbhdr",wi="hsb",Ci="hsl",Ei="hwb",Di="lab",Ai="lch",Si="oklab",Fi="oklch",Ti="rgba";function Mi(e,t){t.RGB=bi,t.RGBHDR=_i,t.HSB=wi,t.HSL=Ci,t.HWB=Ei,t.LAB=Di,t.LCH=Ai,t.OKLAB=Si,t.OKLCH=Fi,t.RGBA=Ti,e.Renderer.states.colorMode=bi,e.Renderer.states.colorMaxes={[bi]:[255,255,255,255],[_i]:[255,255,255,255],[wi]:[360,100,100,1],[Ci]:[360,100,100,1],[Ei]:[360,100,100,1],[Di]:[100,[-125,125],[-125,125],1],[Ai]:[100,150,360,1],[Si]:[100,[-125,125],[-125,125],1],[Fi]:[100,150,360,1],clone:function(){const e={...this};for(const t in e)e[t]instanceof Array&&(e[t]=[...e[t]]);return e}},t.color=function(...e){if(e[0]instanceof xi)return e[0];const t=Array.isArray(e[0])?e[0]:e;return new xi(t,this._renderer.states.colorMode,this._renderer.states.colorMaxes[this._renderer.states.colorMode],{clamp:!0})},t.red=function(e){return this.color(e)._getRed()},t.green=function(e){return this.color(e)._getGreen()},t.blue=function(e){return this.color(e)._getBlue()},t.alpha=function(e){return this.color(e)._getAlpha()},t.hue=function(e){let t=Ci,r=0;return this._renderer.states.colorMode===wi||this._renderer.states.colorMode===Ci?t=this._renderer.states.colorMode:this._renderer.states.colorMode!==Ai&&this._renderer.states.colorMode!==Fi||(t=this._renderer.states.colorMode,r=2),this.color(e)._getHue(this._renderer.states.colorMaxes[t][r])},t.saturation=function(e){const t=this._renderer.states.colorMode===wi?wi:Ci;return this.color(e)._getSaturation(this._renderer.states.colorMaxes[t][1])},t.brightness=function(e){return this.color(e)._getBrightness(this._renderer.states.colorMaxes.hsb[2])},t.lightness=function(e){return this.color(e)._getLightness(this._renderer.states.colorMaxes.hsl[2])},t.lerpColor=function(e,t,r){return e.lerp(t,r,this._renderer.states.colorMode)},t.paletteLerp=function(e,t){const r=e[0];if(t<r[1])return this.color(r[0]);for(let r=1;r<e.length;r++){const i=e[r];if(t<i[1]){const s=e[r-1];return this.lerpColor(this.color(s[0]),this.color(i[0]),(t-s[1])/(i[1]-s[1]))}}return this.color(e[e.length-1][0])}}void 0!==p5&&Mi(p5,p5.prototype);class ki{constructor(e){if(e)this.DOM=e;else{const e=document.implementation.createDocument(null,"doc");this.DOM=e.createElement("root")}}getParent(){return new ki(this.DOM.parentElement)}getName(){return this.DOM.tagName}setName(e){const t=this.DOM.innerHTML,r=this.DOM.attributes,i=document.implementation.createDocument(null,"default").createElement(e);i.innerHTML=t;for(let e=0;e<r.length;e++)i.setAttribute(r[e].nodeName,r[e].nodeValue);this.DOM=i}hasChildren(){return this.DOM.children.length>0}listChildren(){const e=[];for(let t=0;t<this.DOM.childNodes.length;t++)e.push(this.DOM.childNodes[t].nodeName);return e}getChildren(e){return function(e){const t=[];for(let r=0;r<e.length;r++)t.push(new ki(e[r]));return t}(e?this.DOM.getElementsByTagName(e):this.DOM.children)}getChild(e){if("string"!=typeof e)return new ki(this.DOM.children[e]);for(const t of this.DOM.children)if(t.tagName===e)return new ki(t)}addChild(e){e instanceof ki&&this.DOM.appendChild(e.DOM)}removeChild(e){let t=-1;if("string"==typeof e){for(let r=0;r<this.DOM.children.length;r++)if(this.DOM.children[r].tagName===e){t=r;break}}else t=e;-1!==t&&this.DOM.removeChild(this.DOM.children[t])}getAttributeCount(){return this.DOM.attributes.length}listAttributes(){const e=[];for(const t of this.DOM.attributes)e.push(t.nodeName);return e}hasAttribute(e){const t={};for(const e of this.DOM.attributes)t[e.nodeName]=e.nodeValue;return!!t[e]}getNum(e,t){const r={};for(const e of this.DOM.attributes)r[e.nodeName]=e.nodeValue;return Number(r[e])||t||0}getString(e,t){const r={};for(const e of this.DOM.attributes)r[e.nodeName]=e.nodeValue;return r[e]?String(r[e]):t||null}setAttribute(e,t){this.DOM.setAttribute(e,t)}getContent(e){let t;return t=this.DOM.textContent,t=t.replace(/\s\s+/g,","),t||e||null}setContent(e){this.DOM.children.length||(this.DOM.textContent=e)}serialize(){return(new XMLSerializer).serializeToString(this.DOM)}}function Ii(e,t){e.XML=ki}void 0!==p5&&Ii(p5);class Bi{constructor(e,t){this.file=e,this._pInst=t;const r=e.type.split("/");this.type=r[0],this.subtype=r[1],this.name=e.name,this.size=e.size,this.data=void 0}static _createLoader(e,t){const r=new FileReader;return r.onload=function(r){const i=new Bi(e);if("application/json"===i.file.type)i.data=JSON.parse(r.target.result);else if("text/xml"===i.file.type){const e=(new DOMParser).parseFromString(r.target.result,"text/xml");i.data=new ki(e.documentElement)}else i.data=r.target.result;t(i)},r}static _load(e,t){if(/^text\//.test(e.type)||"application/json"===e.type)Bi._createLoader(e,t).readAsText(e);else if(/^(video|audio)\//.test(e.type)){const r=new Bi(e);r.data=URL.createObjectURL(e),t(r)}else Bi._createLoader(e,t).readAsDataURL(e)}}function Li(e,t){e.File=Bi}void 0!==p5&&Li(p5);class Pi{width;height;elt;constructor(e,t){this.elt=e,this._pInst=this._pixelsState=t,this._events={},this.width=this.elt.offsetWidth,this.height=this.elt.offsetHeight}remove(){if(this.stop){this.stop();const e=this.elt.srcObject;null!==e&&e.getTracks().forEach(e=>{e.stop()})}let e=this._pInst;if(e&&!e._elements&&e._pInst&&(e=e._pInst),e&&e._elements){const t=e._elements.indexOf(this);-1!==t&&e._elements.splice(t,1)}for(let e in this._events)this.elt.removeEventListener(e,this._events[e]);this.elt&&this.elt.parentNode&&this.elt.parentNode.removeChild(this.elt)}parent(e){return void 0===e?this.elt.parentNode:("string"==typeof e?("#"===e[0]&&(e=e.substring(1)),e=document.getElementById(e)):e instanceof Pi&&(e=e.elt),e.appendChild(this.elt),this)}child(e){return void 0===e?this.elt.childNodes:("string"==typeof e?("#"===e[0]&&(e=e.substring(1)),e=document.getElementById(e)):e instanceof Pi&&(e=e.elt),e instanceof HTMLElement&&this.elt.appendChild(e),this)}html(...e){return 0===e.length?this.elt.innerHTML:e[1]?(this.elt.insertAdjacentHTML("beforeend",e[0]),this):(this.elt.innerHTML=e[0],this)}id(e){return void 0===e?this.elt.id:(this.elt.id=e,this.width=this.elt.offsetWidth,this.height=this.elt.offsetHeight,this)}class(e){return void 0===e?this.elt.className:(this.elt.className=e,this)}addClass(e){return this.elt.className?this.hasClass(e)||(this.elt.className=this.elt.className+" "+e):this.elt.className=e,this}removeClass(e){return this.elt.classList.remove(e),this}hasClass(e){return this.elt.classList.contains(e)}toggleClass(e){return this.elt.classList.contains(e)?this.elt.classList.remove(e):this.elt.classList.add(e),this}center(e){const t=this.elt.style.display,r="none"===this.elt.style.display,i="none"===this.parent().style.display,s={x:this.elt.offsetLeft,y:this.elt.offsetTop};r&&this.show(),i&&this.parent().show(),this.elt.style.display="block",this.position(0,0);const n=Math.abs(this.parent().offsetWidth-this.elt.offsetWidth),a=Math.abs(this.parent().offsetHeight-this.elt.offsetHeight);return"both"===e||void 0===e?this.position(n/2+this.parent().offsetLeft,a/2+this.parent().offsetTop):"horizontal"===e?this.position(n/2+this.parent().offsetLeft,s.y):"vertical"===e&&this.position(s.x,a/2+this.parent().offsetTop),this.style("display",t),r&&this.hide(),i&&this.parent().hide(),this}position(...e){if(0===e.length)return{x:this.elt.offsetLeft,y:this.elt.offsetTop};{let t="absolute";return"static"!==e[2]&&"fixed"!==e[2]&&"relative"!==e[2]&&"sticky"!==e[2]&&"initial"!==e[2]&&"inherit"!==e[2]||(t=e[2]),this.elt.style.position=t,this.elt.style.left=e[0]+"px",this.elt.style.top=e[1]+"px",this.x=e[0],this.y=e[1],this}}show(){return this.elt.style.display="block",this}hide(){return this.elt.style.display="none",this}size(e,t){if(0===arguments.length)return{width:this.elt.offsetWidth,height:this.elt.offsetHeight};{let r=e,i=t;const s=j;if(r!==s||i!==s){if(r===s?r=t*this.width/this.height:i===s&&(i=e*this.height/this.width),this.elt instanceof HTMLCanvasElement){const e={},t=this.elt.getContext("2d");let s;for(s in t)e[s]=t[s];for(s in this.elt.setAttribute("width",r*this._pInst._pixelDensity),this.elt.setAttribute("height",i*this._pInst._pixelDensity),this.elt.style.width=r+"px",this.elt.style.height=i+"px",this._pInst.scale(this._pInst._pixelDensity,this._pInst._pixelDensity),e)this.elt.getContext("2d")[s]=e[s]}else this.elt.style.width=r+"px",this.elt.style.height=i+"px",this.elt.width=r,this.elt.height=i;this.width=r,this.height=i,this._pInst&&this._pInst._curElement&&this._pInst._curElement.elt===this.elt&&(this._pInst.width=r,this._pInst.height=i)}return this}}style(e,t){const r=this;if(t instanceof xi&&(t=t.toString()),void 0===t){if(-1===e.indexOf(":"))return window.getComputedStyle(r.elt).getPropertyValue(e);{const t=e.split(";");for(let e=0;e<t.length;e++){const r=t[e].split(":");r[0]&&r[1]&&(this.elt.style[r[0].trim()]=r[1].trim())}}}else if(this.elt.style[e]=t,"width"===e||"height"===e||"left"===e||"top"===e){let t=window.getComputedStyle(r.elt).getPropertyValue(e).replace(/[^\d.]/g,"");this[e]=Math.round(parseFloat(t,10))}return this}_translate(...e){this.elt.style.position="absolute";let t="";return this.elt.style.transform&&(t=this.elt.style.transform.replace(/translate3d\(.*\)/g,""),t=t.replace(/translate[X-Z]?\(.*\)/g,"")),2===e.length?this.elt.style.transform="translate("+e[0]+"px, "+e[1]+"px)":e.length>2&&(this.elt.style.transform="translate3d("+e[0]+"px,"+e[1]+"px,"+e[2]+"px)",3===e.length?this.elt.parentElement.style.perspective="1000px":this.elt.parentElement.style.perspective=e[3]+"px"),this.elt.style.transform+=t,this}_rotate(...e){let t="";return this.elt.style.transform&&(t=this.elt.style.transform.replace(/rotate3d\(.*\)/g,""),t=t.replace(/rotate[X-Z]?\(.*\)/g,"")),1===e.length?this.elt.style.transform="rotate("+e[0]+"deg)":2===e.length?this.elt.style.transform="rotate("+e[0]+"deg, "+e[1]+"deg)":3===e.length&&(this.elt.style.transform="rotateX("+e[0]+"deg)",this.elt.style.transform+="rotateY("+e[1]+"deg)",this.elt.style.transform+="rotateZ("+e[2]+"deg)"),this.elt.style.transform+=t,this}attribute(e,t){if(null==this.elt.firstChild||"checkbox"!==this.elt.firstChild.type&&"radio"!==this.elt.firstChild.type)return void 0===t?this.elt.getAttribute(e):(this.elt.setAttribute(e,t),this);if(void 0===t)return this.elt.firstChild.getAttribute(e);for(let r=0;r<this.elt.childNodes.length;r++)this.elt.childNodes[r].setAttribute(e,t)}removeAttribute(e){if(null!=this.elt.firstChild&&("checkbox"===this.elt.firstChild.type||"radio"===this.elt.firstChild.type))for(let t=0;t<this.elt.childNodes.length;t++)this.elt.childNodes[t].removeAttribute(e);return this.elt.removeAttribute(e),this}value(...e){return e.length>0?(this.elt.value=e[0],this):"range"===this.elt.type?parseFloat(this.elt.value):this.elt.value}mousePressed(e){return Pi._adjustListener("pointerdown",function(t){return this._pInst.mouseIsPressed=!0,this._pInst._activePointers.set(t.pointerId,t),this._pInst._setMouseButton(t),this._pInst._updatePointerCoords(t),e.call(this,t)},this),this}doubleClicked(e){return Pi._adjustListener("dblclick",e,this),this}mouseWheel(e){return Pi._adjustListener("wheel",e,this),this}mouseReleased(e){return Pi._adjustListener("pointerup",e,this),this}mouseClicked(e){return Pi._adjustListener("click",e,this),this}mouseMoved(e){return Pi._adjustListener("pointermove",e,this),this}mouseOver(e){return Pi._adjustListener("pointerover",e,this),this}mouseOut(e){return Pi._adjustListener("pointerout",e,this),this}dragOver(e){return Pi._adjustListener("dragover",e,this),this}dragLeave(e){return Pi._adjustListener("dragleave",e,this),this}changed(e){return Pi._adjustListener("change",e,this),this}input(e){return Pi._adjustListener("input",e,this),this}drop(e,t){if(window.File&&window.FileReader&&window.FileList&&window.Blob){if(!this._dragDisabled){this._dragDisabled=!0;const e=function(e){e.preventDefault()};this.elt.addEventListener("dragover",e),this.elt.addEventListener("dragleave",e)}Pi._attachListener("drop",function(r){r.preventDefault(),"function"==typeof t&&t.call(this,r);const i=r.dataTransfer.files;for(const t of i)Bi._load(t,e)},this)}else console.log("The File APIs are not fully supported in this browser.");return this}draggable(e){let t,r="ontouchstart"in window,i=0,s=0,n=0,a=0,o=r?"touchstart":"mousedown",h=r?"touchend":"mouseup",u=r?"touchmove":"mousemove";function l(t){if(t=t||window.event,r){const e=t.changedTouches;i=n-parseInt(e[0].clientX),s=a-parseInt(e[0].clientY),n=parseInt(e[0].clientX),a=parseInt(e[0].clientY)}else i=n-parseInt(t.clientX),s=a-parseInt(t.clientY),n=parseInt(t.clientX),a=parseInt(t.clientY);e.style.left=e.offsetLeft-i+"px",e.style.top=e.offsetTop-s+"px"}function c(){document.removeEventListener(h,c,!1),document.removeEventListener(u,l,!1)}return void 0===e?t=e=this.elt:e!==this.elt&&e.elt!==this.elt&&(e=e.elt,t=this.elt),t.addEventListener(o,function(e){if(e=e||window.event,r){const t=e.changedTouches;n=parseInt(t[0].clientX),a=parseInt(t[0].clientY)}else n=parseInt(e.clientX),a=parseInt(e.clientY);return document.addEventListener(h,c,!1),document.addEventListener(u,l,!1),!1},!1),t.style.cursor="move",this}static _adjustListener(e,t,r){return!1===t?Pi._detachListener(e,r):Pi._attachListener(e,t,r),this}static _attachListener(e,t,r){r._events[e]&&Pi._detachListener(e,r);const i=t.bind(r);r.elt.addEventListener(e,i,{capture:!1,signal:r._pInst._removeSignal}),r._events[e]=i}static _detachListener(e,t){const r=t._events[e];t.elt.removeEventListener(e,r,!1),t._events[e]=null}}function Oi(e,t){e.Element=Pi}void 0!==p5&&Oi(p5);const Ri={_toPixels(e){if(e instanceof ImageData)return e.data;if(e.getContext("2d"))return e.getContext("2d").getImageData(0,0,e.width,e.height).data;if(e.getContext("webgl")){const t=e.getContext("webgl"),r=t.drawingBufferWidth*t.drawingBufferHeight*4,i=new Uint8Array(r);return t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,i),i}},_getARGB(e,t){const r=4*t;return e[r+3]<<24&4278190080|e[r]<<16&16711680|e[r+1]<<8&65280|255&e[r+2]},_setPixels(e,t){let r=0;for(let i=0,s=e.length;i<s;i++)r=4*i,e[r+0]=(16711680&t[i])>>>16,e[r+1]=(65280&t[i])>>>8,e[r+2]=255&t[i],e[r+3]=(4278190080&t[i])>>>24},_toImageData:e=>e instanceof ImageData?e:e.getContext("2d").getImageData(0,0,e.width,e.height),_createImageData(e,t){return Ri._tmpCanvas=document.createElement("canvas"),Ri._tmpCtx=Ri._tmpCanvas.getContext("2d"),this._tmpCtx.createImageData(e,t)},apply(e,t,r){const i=e.getContext("2d"),s=i.getImageData(0,0,e.width,e.height),n=t(s,r);n instanceof ImageData?i.putImageData(n,0,0,0,0,e.width,e.height):i.putImageData(s,0,0,0,0,e.width,e.height)},threshold(e,t=.5){const r=Ri._toPixels(e),i=Math.floor(255*t);for(let e=0;e<r.length;e+=4){let t;t=.2126*r[e]+.7152*r[e+1]+.0722*r[e+2]>=i?255:0,r[e]=r[e+1]=r[e+2]=t}},gray(e){const t=Ri._toPixels(e);for(let e=0;e<t.length;e+=4){const r=.2126*t[e]+.7152*t[e+1]+.0722*t[e+2];t[e]=t[e+1]=t[e+2]=r}},opaque(e){const t=Ri._toPixels(e);for(let e=0;e<t.length;e+=4)t[e+3]=255;return t},invert(e){const t=Ri._toPixels(e);for(let e=0;e<t.length;e+=4)t[e]=255-t[e],t[e+1]=255-t[e+1],t[e+2]=255-t[e+2]},posterize(e,t=4){const r=Ri._toPixels(e);if(t<2||t>255)throw new Error("Level must be greater than 2 and less than 255 for posterize");const i=t-1;for(let e=0;e<r.length;e+=4){const s=r[e],n=r[e+1],a=r[e+2];r[e]=255*(s*t>>8)/i,r[e+1]=255*(n*t>>8)/i,r[e+2]=255*(a*t>>8)/i}},dilate(e){const t=Ri._toPixels(e);let r=0;const i=t.length?t.length/4:0,s=new Int32Array(i);let n,a,o,h,u,l,c,p,d,f,g,m,y,x,v,b,_;for(;r<i;)for(n=r,a=r+e.width;r<a;)o=h=Ri._getARGB(t,r),c=r-1,l=r+1,p=r-e.width,d=r+e.width,c<n&&(c=r),l>=a&&(l=r),p<0&&(p=0),d>=i&&(d=r),m=Ri._getARGB(t,p),g=Ri._getARGB(t,c),y=Ri._getARGB(t,d),f=Ri._getARGB(t,l),u=77*(o>>16&255)+151*(o>>8&255)+28*(255&o),v=77*(g>>16&255)+151*(g>>8&255)+28*(255&g),x=77*(f>>16&255)+151*(f>>8&255)+28*(255&f),b=77*(m>>16&255)+151*(m>>8&255)+28*(255&m),_=77*(y>>16&255)+151*(y>>8&255)+28*(255&y),v>u&&(h=g,u=v),x>u&&(h=f,u=x),b>u&&(h=m,u=b),_>u&&(h=y,u=_),s[r++]=h;Ri._setPixels(t,s)},erode(e){const t=Ri._toPixels(e);let r=0;const i=t.length?t.length/4:0,s=new Int32Array(i);let n,a,o,h,u,l,c,p,d,f,g,m,y,x,v,b,_;for(;r<i;)for(n=r,a=r+e.width;r<a;)o=h=Ri._getARGB(t,r),c=r-1,l=r+1,p=r-e.width,d=r+e.width,c<n&&(c=r),l>=a&&(l=r),p<0&&(p=0),d>=i&&(d=r),m=Ri._getARGB(t,p),g=Ri._getARGB(t,c),y=Ri._getARGB(t,d),f=Ri._getARGB(t,l),u=77*(o>>16&255)+151*(o>>8&255)+28*(255&o),v=77*(g>>16&255)+151*(g>>8&255)+28*(255&g),x=77*(f>>16&255)+151*(f>>8&255)+28*(255&f),b=77*(m>>16&255)+151*(m>>8&255)+28*(255&m),_=77*(y>>16&255)+151*(y>>8&255)+28*(255&y),v<u&&(h=g,u=v),x<u&&(h=f,u=x),b<u&&(h=m,u=b),_<u&&(h=y,u=_),s[r++]=h;Ri._setPixels(t,s)},blur(e,t){!function(e,t){const r=Ri._toPixels(e),i=e.width,s=e.height,n=i*s,a=new Int32Array(n);for(let e=0;e<n;e++)a[e]=Ri._getARGB(r,e);let o,h,u,l,c,p,d,f,g,m;const y=new Int32Array(n),x=new Int32Array(n),v=new Int32Array(n),b=new Int32Array(n);let _,w,C,E,D=0;for(function(e){let t=3.5*e|0;if(t=t<1?1:t<248?t:248,Ni!==t){Ni=t,Vi=1+Ni<<1,Ui=new Int32Array(Vi),zi=new Array(Vi);for(let e=0;e<Vi;e++)zi[e]=new Int32Array(256);let e,r,i,s;for(let e=1,n=t-1;e<t;e++){Ui[t+e]=Ui[n]=r=n*n,i=zi[t+e],s=zi[n--];for(let e=0;e<256;e++)i[e]=s[e]=r*e}e=Ui[t]=t*t,i=zi[t];for(let t=0;t<256;t++)i[t]=e*t}}(t),w=0;w<s;w++){for(_=0;_<i;_++){if(l=u=h=c=o=0,p=_-Ni,p<0)m=-p,p=0;else{if(p>=i)break;m=0}for(C=m;C<Vi&&!(p>=i);C++){const e=a[p+D];E=zi[C],c+=E[(-16777216&e)>>>24],h+=E[(16711680&e)>>16],u+=E[(65280&e)>>8],l+=E[255&e],o+=Ui[C],p++}d=D+_,y[d]=c/o,x[d]=h/o,v[d]=u/o,b[d]=l/o}D+=i}for(D=0,f=-Ni,g=f*i,w=0;w<s;w++){for(_=0;_<i;_++){if(l=u=h=c=o=0,f<0)m=d=-f,p=_;else{if(f>=s)break;m=0,d=f,p=_+g}for(C=m;C<Vi&&!(d>=s);C++)E=zi[C],c+=E[y[p]],h+=E[x[p]],u+=E[v[p]],l+=E[b[p]],o+=Ui[C],d++,p+=i;a[_+D]=c/o<<24|h/o<<16|u/o<<8|l/o}D+=i,g+=i,f++}Ri._setPixels(r,a)}(e,t)}};let Ni,Vi,Ui,zi;function Gi(e,t,r){const i=ji(t,r)[0];let s=e;if(s instanceof Blob||(s=new Blob([e])),document){const e=URL.createObjectURL(s),t=document.createElement("a");t.href=e,t.download=i,t.click(),URL.revokeObjectURL(e)}}function ji(e,t){t&&!0!==t&&"true"!==t||(t=""),e||(e="untitled");let r="";return e&&e.includes(".")&&(r=e.split(".").pop()),t&&r!==t&&(r=t,e=`${e}.${r}`),[e,r]}class $i{constructor(e,t){this.width=e,this.height=t,this.canvas=document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height,this.drawingContext=this.canvas.getContext("2d"),this._pixelsState=this,this._pixelDensity=1,this.gifProperties=null,this._modified=!1,this.pixels=[]}pixelDensity(e){return void 0!==e?(e<=0&&(e=1),this._pixelDensity=e,this.width/=e,this.height/=e,this):this._pixelDensity}_animateGif(e){const t=this.gifProperties,r=e._lastRealFrameTime||window.performance.now();if(0===t.lastChangeTime&&(t.lastChangeTime=r),t.playing){t.timeDisplayed=r-t.lastChangeTime;const e=t.frames[t.displayIndex].delay;if(t.timeDisplayed>=e){const i=Math.floor(t.timeDisplayed/e);if(t.timeDisplayed=0,t.lastChangeTime=r,t.displayIndex+=i,t.loopCount=Math.floor(t.displayIndex/t.numFrames),null!==t.loopLimit&&t.loopCount>=t.loopLimit)t.playing=!1;else{const e=t.displayIndex%t.numFrames;this.drawingContext.putImageData(t.frames[e].image,0,0),t.displayIndex=e,this.setModified(!0)}}}}loadPixels(){const e=this._pixelsState,t=this._pixelDensity,r=this.width*t,i=this.height*t,s=this.drawingContext.getImageData(0,0,r,i);e.imageData=s,this.pixels=e.pixels=s.data,this.setModified(!0)}updatePixels(e,t,r,i){const s=this._pixelsState,n=this._pixelDensity;void 0===e&&void 0===t&&void 0===r&&void 0===i&&(e=0,t=0,r=this.width,i=this.height),e*=n,t*=n,r*=n,i*=n,this.gifProperties&&(this.gifProperties.frames[this.gifProperties.displayIndex].image=s.imageData),this.drawingContext.putImageData(s.imageData,e,t,0,0,r,i),this.setModified(!0)}get(e,t,r,i){const s=this._pixelsState,n=this._pixelDensity,a=this.canvas;if(void 0===e&&void 0===t)e=t=0,r=s.width,i=s.height;else if(e*=n,t*=n,void 0===r&&void 0===i)return e<0||t<0||e>=a.width||t>=a.height?[0,0,0,0]:this._getPixel(e,t);const o=new $i(r*n,i*n);return o.pixelDensity(n),o.canvas.getContext("2d").drawImage(a,e,t,r*n,i*n,0,0,r*n,i*n),o}_getPixel(e,t){let r,i;return r=this.drawingContext.getImageData(e,t,1,1).data,i=0,[r[0],r[1],r[2],r[3]]}set(e,t,r){e=Math.floor(e),t=Math.floor(t);const i=this._pixelsState;if(r instanceof $i)this.drawingContext.save(),this.drawingContext.setTransform(1,0,0,1,0,0),this.drawingContext.scale(this._pixelDensity,this._pixelDensity),this.drawingContext.clearRect(e,t,r.width,r.height),this.drawingContext.drawImage(r.canvas,e,t),this.drawingContext.restore();else{let s=0,n=0,a=0,o=0,h=4*(t*this._pixelDensity*(this.width*this._pixelDensity)+e*this._pixelDensity);if(i.imageData||i.loadPixels(),"number"==typeof r)h<i.pixels.length&&(s=r,n=r,a=r,o=255);else if(Array.isArray(r)){if(r.length<4)throw new Error("pixel array must be of the form [R, G, B, A]");h<i.pixels.length&&(s=r[0],n=r[1],a=r[2],o=r[3])}else r instanceof p5.Color&&h<i.pixels.length&&([s,n,a,o]=r._getRGBA([255,255,255,255]));for(let r=0;r<this._pixelDensity;r++)for(let u=0;u<this._pixelDensity;u++)h=4*((t*this._pixelDensity+u)*this.width*this._pixelDensity+(e*this._pixelDensity+r)),i.pixels[h]=s,i.pixels[h+1]=n,i.pixels[h+2]=a,i.pixels[h+3]=o}this.setModified(!0)}resize(e,t){0===e&&0===t?(e=this.canvas.width,t=this.canvas.height):0===e?e=this.canvas.width*t/this.canvas.height:0===t&&(t=this.canvas.height*e/this.canvas.width),e=Math.floor(e),t=Math.floor(t);const r=document.createElement("canvas");if(r.width=e,r.height=t,this.gifProperties){const r=this.gifProperties,i=(e,t)=>{let r=0;for(let i=0;i<t.height;i++)for(let s=0;s<t.width;s++){const n=Math.floor(s*e.width/t.width);let a=4*(Math.floor(i*e.height/t.height)*e.width+n);t.data[r++]=e.data[a++],t.data[r++]=e.data[a++],t.data[r++]=e.data[a++],t.data[r++]=e.data[a++]}};for(let s=0;s<r.numFrames;s++){const n=this.drawingContext.createImageData(e,t);i(r.frames[s].image,n),r.frames[s].image=n}}r.getContext("2d").drawImage(this.canvas,0,0,this.canvas.width,this.canvas.height,0,0,r.width,r.height),this.canvas.width=this.width=e,this.canvas.height=this.height=t,this.drawingContext.drawImage(r,0,0,e,t,0,0,e,t),this.pixels.length>0&&this.loadPixels(),this.setModified(!0)}copy(...e){let t,r,i,s,n,a,o,h,u;if(9===e.length)t=e[0],r=e[1],i=e[2],s=e[3],n=e[4],a=e[5],o=e[6],h=e[7],u=e[8];else{if(8!==e.length)throw new Error("Signature not supported");t=this,r=e[0],i=e[1],s=e[2],n=e[3],a=e[4],o=e[5],h=e[6],u=e[7]}this._copyHelper(this,t,r,i,s,n,a,o,h,u)}_copyHelper(e,t,r,i,s,n,a,o,h,u){const l=t.canvas.width/t.width;let c=0,p=0;t._renderer&&t._renderer.isP3D&&(c=t.width/2,p=t.height/2),e._renderer&&e._renderer.isP3D?(e.push(),e.resetMatrix(),e.noLights(),e.blendMode(e.BLEND),e.imageMode(e.CORNER),e._renderer.image(t,r+c,i+p,s,n,a,o,h,u),e.pop()):e.drawingContext.drawImage(t.canvas,l*(r+c),l*(i+p),l*s,l*n,a,o,h,u)}mask(e){void 0===e&&(e=this);const t=this.drawingContext.globalCompositeOperation;let r=this._pixelDensity,i=1;e instanceof _s&&(i=e._pInst._renderer._pixelDensity);const s=[e,0,0,i*e.width,i*e.height,0,0,r*this.width,r*this.height];if(this.drawingContext.globalCompositeOperation="destination-in",this.gifProperties){for(let e=0;e<this.gifProperties.frames.length;e++)this.drawingContext.putImageData(this.gifProperties.frames[e].image,0,0),this.copy(...s),this.gifProperties.frames[e].image=this.drawingContext.getImageData(0,0,r*this.width,r*this.height);this.drawingContext.putImageData(this.gifProperties.frames[this.gifProperties.displayIndex].image,0,0)}else this.copy(...s);this.drawingContext.globalCompositeOperation=t,this.setModified(!0)}filter(e,t){Ri.apply(this.canvas,Ri[e],t),this.setModified(!0)}blend(...e){const t=this.drawingContext.globalCompositeOperation,r=e[e.length-1],i=Array.prototype.slice.call(e,0,e.length-1);this.drawingContext.globalCompositeOperation=r,this.copy(...i),this.drawingContext.globalCompositeOperation=t,this.setModified(!0)}setModified(e){this._modified=e}isModified(){return this._modified}save(e,t){if(this.gifProperties)!function(e,t){const r=e.gifProperties;let i=r.loopLimit;1===i?i=null:null===i&&(i=0);const s=new Uint8Array(e.width*e.height*r.numFrames),n=[],a={};for(let t=0;t<r.numFrames;t++){const i=new Set,s=r.frames[t].image.data,o=s.length,h=new Uint32Array(e.width*e.height);for(let e=0,t=0;e<o;e+=4,t++){const r=s[e+0]<<16|s[e+1]<<8|s[e+2];i.add(r),h[t]=r}const u=[...i].sort().toString();void 0===a[u]?a[u]={freq:1,frames:[t]}:(a[u].freq+=1,a[u].frames.push(t)),n.push(h)}let o=[];const h=Object.keys(a).sort(function(e,t){return a[t].freq-a[e].freq}),u=h[0].split(",").map(e=>parseInt(e));o=o.concat(a[u].frames);const l=new Set(u);for(let e=1;e<h.length;e++){const t=h[e].split(",").map(e=>parseInt(e)).filter(e=>!l.has(e));if(u.length+t.length<=256){for(let e=0;e<t.length;e++)u.push(t[e]),l.add(t[e]);o=o.concat(a[h[e]].frames)}}o=new Set(o);const c={};for(let e=0;e<u.length;e++)c[u[e]]||(c[u[e]]=e);let p=1;for(;p<u.length;)p<<=1;u.length=p;const d={loop:i,palette:new Uint32Array(u)},f=new omggif.GifWriter(s,e.width,e.height,d);let g={};for(let t=0;t<r.numFrames;t++){const i=!o.has(t),s=i?[]:u,a=new Uint8Array(e.width*e.height),h={},l=new Set;n[t].forEach((e,r)=>{i?(void 0===h[e]&&(h[e]=s.length,s.push(e)),a[r]=h[e]):a[r]=c[e],t>0&&n[t-1][r]!==e&&l.add(e)});const p={},d=s.filter(e=>!l.has(e));if(d.length>0){const e=d[0],r=i?h[e]:c[e];if(t>0){for(let e=0;e<n[t].length;e++)n[t-1][e]===n[t][e]&&(a[e]=r);p.transparent=r,g.frameOpts.disposal=1}}if(p.delay=r.frames[t].delay/10,i){let e=1;for(;e<s.length;)e<<=1;s.length=e,p.palette=new Uint32Array(s)}t>0&&f.addFrame(0,0,e.width,e.height,g.pixelPaletteIndex,g.frameOpts),g={pixelPaletteIndex:a,frameOpts:p}}g.frameOpts.disposal=1,f.addFrame(0,0,e.width,e.height,g.pixelPaletteIndex,g.frameOpts),Gi(new Blob([s.slice(0,f.end())],{type:"image/gif"}),t,"gif")}(this,e);else{let r,i=this.canvas;switch(t=t||ji(e,t)[1]||"png"){default:r="image/png";break;case"webp":r="image/webp";break;case"jpeg":case"jpg":r="image/jpeg"}i.toBlob(r=>{Gi(r,e,t)},r)}}async toBlob(){return new Promise(e=>{this.canvas.toBlob(e)})}reset(){if(this.gifProperties){const e=this.gifProperties;e.playing=!0,e.timeSinceStart=0,e.timeDisplayed=0,e.lastChangeTime=0,e.loopCount=0,e.displayIndex=0,this.drawingContext.putImageData(e.frames[0].image,0,0)}}getCurrentFrame(){if(this.gifProperties){const e=this.gifProperties;return e.displayIndex%e.numFrames}}setFrame(e){if(this.gifProperties){const t=this.gifProperties;e<t.numFrames&&e>=0?(t.timeDisplayed=0,t.lastChangeTime=0,t.displayIndex=e,this.drawingContext.putImageData(t.frames[e].image,0,0)):console.log("Cannot set GIF to a frame number that is higher than total number of frames or below zero.")}}numFrames(){if(this.gifProperties)return this.gifProperties.numFrames}play(){this.gifProperties&&(this.gifProperties.playing=!0)}pause(){this.gifProperties&&(this.gifProperties.playing=!1)}delay(e,t){if(this.gifProperties){const r=this.gifProperties;if(t<r.numFrames&&t>=0)r.frames[t].delay=e;else for(const t of r.frames)t.delay=e}}}function Hi(e,t){e.Image=$i}void 0!==p5&&Hi(p5);const qi=function(e,t){return 0!==e&&(this.x=this.x%e),0!==t&&(this.y=this.y%t),this},Wi=function(e,t,r){return 0!==e&&(this.x=this.x%e),0!==t&&(this.y=this.y%t),0!==r&&(this.z=this.z%r),this};class Xi{constructor(...e){let t=e;"function"==typeof e[0]&&(this.isPInst=!0,this._fromRadians=e[0],this._toRadians=e[1],t=e.slice(2));let r=t.length;0===r?(this.dimensions=2,this._values=[0,0,0]):(this.dimensions=r,this._values=t)}get values(){return this._values}set values(e){let t=e.length;0===t?(this.dimensions=2,this._values=[0,0,0]):(this.dimensions=t,this._values=e.slice())}get x(){return this._values[0]||0}getValue(e){if(e<this._values.length)return this._values[e];p5._friendlyError("The index parameter is trying to set a value outside the bounds of the vector","p5.Vector.setValue")}setValue(e,t){e<this._values.length?this._values[e]=t:p5._friendlyError("The index parameter is trying to set a value outside the bounds of the vector","p5.Vector.setValue")}get y(){return this._values[1]||0}get z(){return this._values[2]||0}get w(){return this._values[3]||0}set x(e){this._values.length>1&&(this._values[0]=e)}set y(e){this._values.length>1&&(this._values[1]=e)}set z(e){this._values.length>2&&(this._values[2]=e)}set w(e){this._values.length>3&&(this._values[3]=e)}toString(){return`vector[${this._values.join(", ")}]`}set(...e){return e[0]instanceof Xi?this._values=e[0].values.slice():Array.isArray(e[0])?this._values=e[0].map(e=>e||0):this._values=e.map(e=>e||0),this.dimensions=this._values.length,this}copy(){return this.isPInst?new Xi(this._fromRadians,this._toRadians,...this._values):new Xi(...this._values)}add(...e){return e[0]instanceof Xi?e=e[0].values:Array.isArray(e[0])&&(e=e[0]),e.forEach((e,t)=>{this._values[t]=(this._values[t]||0)+(e||0)}),this}rem(e,t,r){if(e instanceof Xi){if([e.x,e.y,e.z].every(Number.isFinite)){const t=parseFloat(e.x),r=parseFloat(e.y),i=parseFloat(e.z);return Wi.call(this,t,r,i)}}else if(Array.isArray(e)){if(e.every(e=>Number.isFinite(e))){if(2===e.length)return qi.call(this,e[0],e[1]);if(3===e.length)return Wi.call(this,e[0],e[1],e[2])}}else if(1===arguments.length){if(Number.isFinite(arguments[0])&&0!==arguments[0])return this.x=this.x%arguments[0],this.y=this.y%arguments[0],this.z=this.z%arguments[0],this}else if(2===arguments.length){const e=[...arguments];if(e.every(e=>Number.isFinite(e))&&2===e.length)return qi.call(this,e[0],e[1])}else if(3===arguments.length){const e=[...arguments];if(e.every(e=>Number.isFinite(e))&&3===e.length)return Wi.call(this,e[0],e[1],e[2])}}sub(...e){return e[0]instanceof Xi?e[0].values.forEach((e,t)=>{this._values[t]-=e||0}):Array.isArray(e[0])?e[0].forEach((e,t)=>{this._values[t]-=e||0}):e.forEach((e,t)=>{this._values[t]-=e||0}),this}mult(...e){if(1===e.length&&e[0]instanceof Xi){const t=e[0],r=Math.min(this._values.length,t.values.length);for(let e=0;e<r;e++){if(!Number.isFinite(t.values[e])||"number"!=typeof t.values[e])return console.warn("p5.Vector.prototype.mult:","v contains components that are either undefined or not finite numbers"),this;this._values[e]*=t.values[e]}}else if(1===e.length&&Array.isArray(e[0])){const t=e[0],r=Math.min(this._values.length,t.length);for(let e=0;e<r;e++){if(!Number.isFinite(t[e])||"number"!=typeof t[e])return console.warn("p5.Vector.prototype.mult:","arr contains elements that are either undefined or not finite numbers"),this;this._values[e]*=t[e]}}else if(1===e.length&&"number"==typeof e[0]&&Number.isFinite(e[0]))for(let t=0;t<this._values.length;t++)this._values[t]*=e[0];return this}div(...e){if(0===e.length)return this;if(1===e.length&&e[0]instanceof Xi){const t=e[0];if(t._values.every(e=>Number.isFinite(e)&&"number"==typeof e)){if(t._values.some(e=>0===e))return console.warn("p5.Vector.prototype.div:","divide by 0"),this;this._values=this._values.map((e,r)=>e/t._values[r])}else console.warn("p5.Vector.prototype.div:","vector contains components that are either undefined or not finite numbers");return this}if(1===e.length&&Array.isArray(e[0])){const t=e[0];if(t.every(e=>Number.isFinite(e)&&"number"==typeof e)){if(t.some(e=>0===e))return console.warn("p5.Vector.prototype.div:","divide by 0"),this;this._values=this._values.map((e,r)=>e/t[r])}else console.warn("p5.Vector.prototype.div:","array contains components that are either undefined or not finite numbers");return this}if(e.every(e=>Number.isFinite(e)&&"number"==typeof e)){if(e.some(e=>0===e))return console.warn("p5.Vector.prototype.div:","divide by 0"),this;this._values=this._values.map((t,r)=>t/e[0])}else console.warn("p5.Vector.prototype.div:","arguments contain components that are either undefined or not finite numbers");return this}mag(){return Math.sqrt(this.magSq())}magSq(){return this._values.reduce((e,t)=>e+t*t,0)}dot(...e){return e[0]instanceof Xi?this.dot(...e[0]._values):this._values.reduce((t,r,i)=>t+r*(e[i]||0),0)}cross(e){const t=this.y*e.z-this.z*e.y,r=this.z*e.x-this.x*e.z,i=this.x*e.y-this.y*e.x;return this.isPInst?new Xi(this._fromRadians,this._toRadians,t,r,i):new Xi(t,r,i)}dist(e){return e.copy().sub(this).mag()}normalize(){const e=this.mag();return 0!==e&&this.mult(1/e),this}limit(e){const t=this.magSq();return t>e*e&&this.div(Math.sqrt(t)).mult(e),this}setMag(e){return this.normalize().mult(e)}heading(){const e=Math.atan2(this.y,this.x);return this.isPInst?this._fromRadians(e):e}setHeading(e){this.isPInst&&(e=this._toRadians(e));let t=this.mag();return this.x=t*Math.cos(e),this.y=t*Math.sin(e),this}rotate(e){let t=this.heading()+e;this.isPInst&&(t=this._toRadians(t));const r=this.mag();return this.x=Math.cos(t)*r,this.y=Math.sin(t)*r,this}angleBetween(e){if(0===this.magSq()*e.magSq())return NaN;const t=this.cross(e);let r=Math.atan2(t.mag(),this.dot(e))*Math.sign(t.z||1);return this.isPInst&&(r=this._fromRadians(r)),r}lerp(e,t,r,i){return e instanceof Xi?this.lerp(e.x,e.y,e.z,t):(this.x+=(e-this.x)*i||0,this.y+=(t-this.y)*i||0,this.z+=(r-this.z)*i||0,this)}slerp(e,t){if(0===t)return this;if(1===t)return this.set(e);const r=this.mag(),i=e.mag();if(0===r*i)return this.mult(1-t).add(e.x*t,e.y*t,e.z*t),this;const s=this.cross(e),n=s.mag(),a=Math.atan2(n,this.dot(e));if(n>0)s.x/=n,s.y/=n,s.z/=n;else{if(a<.5*Math.PI)return this.mult(1-t).add(e.x*t,e.y*t,e.z*t),this;0===this.z&&0===e.z?s.set(0,0,1):0!==this.x?s.set(this.y,-this.x,0).normalize():s.set(1,0,0)}const o=s.cross(this),h=1-t+t*i/r,u=h*Math.cos(t*a),l=h*Math.sin(t*a);return this.x=this.x*u+o.x*l,this.y=this.y*u+o.y*l,this.z=this.z*u+o.z*l,this}reflect(e){const t=Xi.normalize(e);return this.sub(t.mult(2*this.dot(t)))}array(){return[this.x||0,this.y||0,this.z||0]}equals(...e){let t;t=e[0]instanceof Xi?e[0]._values:Array.isArray(e[0])?e[0]:e;for(let e=0;e<this._values.length;e++)if(this._values[e]!==(t[e]||0))return!1;return!0}clampToZero(){for(let e=0;e<this._values.length;e++)this._values[e]=this._clampToZero(this._values[e]);return this}_clampToZero(e){return Math.abs((e||0)-0)<=Number.EPSILON?0:e}static fromAngle(e,t){return void 0===t&&(t=1),new Xi(t*Math.cos(e),t*Math.sin(e))}static fromAngles(e,t,r){void 0===r&&(r=1);const i=Math.cos(t),s=Math.sin(t),n=Math.cos(e),a=Math.sin(e);return new Xi(r*a*s,-r*n,r*a*i)}static random2D(){return this.fromAngle(Math.random()*x)}static random3D(){const e=Math.random()*x,t=2*Math.random()-1,r=Math.sqrt(1-t*t),i=r*Math.cos(e),s=r*Math.sin(e);return new Xi(i,s,t)}static copy(e){return e.copy(e)}static add(e,t,r){return r?r.set(e):(r=e.copy(),3===arguments.length&&p5._friendlyError("The target parameter is undefined, it should be of type p5.Vector","p5.Vector.add")),r.add(t),r}static rem(e,t){if(e instanceof Xi&&t instanceof Xi){let r=e.copy();return r.rem(t),r}}static sub(e,t,r){return r?r.set(e):(r=e.copy(),3===arguments.length&&p5._friendlyError("The target parameter is undefined, it should be of type p5.Vector","p5.Vector.sub")),r.sub(t),r}static mult(e,t,r){return r?r.set(e):(r=e.copy(),3===arguments.length&&p5._friendlyError("The target parameter is undefined, it should be of type p5.Vector","p5.Vector.mult")),r.mult(t),r}static rotate(e,t,r){return 2===arguments.length?r=e.copy():(r instanceof Xi||p5._friendlyError("The target parameter should be of type p5.Vector","p5.Vector.rotate"),r.set(e)),r.rotate(t),r}static div(e,t,r){return r?r.set(e):(r=e.copy(),3===arguments.length&&p5._friendlyError("The target parameter is undefined, it should be of type p5.Vector","p5.Vector.div")),r.div(t),r}static dot(e,t){return e.dot(t)}static cross(e,t){return e.cross(t)}static dist(e,t){return e.dist(t)}static lerp(e,t,r,i){return i?i.set(e):(i=e.copy(),4===arguments.length&&p5._friendlyError("The target parameter is undefined, it should be of type p5.Vector","p5.Vector.lerp")),i.lerp(t,r),i}static slerp(e,t,r,i){return i?i.set(e):(i=e.copy(),4===arguments.length&&p5._friendlyError("The target parameter is undefined, it should be of type p5.Vector","p5.Vector.slerp")),i.slerp(t,r),i}static mag(e){return e.mag()}static magSq(e){return e.magSq()}static normalize(e,t){return arguments.length<2?t=e.copy():(t instanceof Xi||p5._friendlyError("The target parameter should be of type p5.Vector","p5.Vector.normalize"),t.set(e)),t.normalize()}static limit(e,t,r){return arguments.length<3?r=e.copy():(r instanceof Xi||p5._friendlyError("The target parameter should be of type p5.Vector","p5.Vector.limit"),r.set(e)),r.limit(t)}static setMag(e,t,r){return arguments.length<3?r=e.copy():(r instanceof Xi||p5._friendlyError("The target parameter should be of type p5.Vector","p5.Vector.setMag"),r.set(e)),r.setMag(t)}static heading(e){return e.heading()}static angleBetween(e,t){return e.angleBetween(t)}static reflect(e,t,r){return arguments.length<3?r=e.copy():(r instanceof Xi||p5._friendlyError("The target parameter should be of type p5.Vector","p5.Vector.reflect"),r.set(e)),r.reflect(t)}static array(e){return e.array()}static equals(e,t){let r;return e instanceof Xi?r=e:e instanceof Array?r=(new Xi).set(e):p5._friendlyError("The v1 parameter should be of type Array or p5.Vector","p5.Vector.equals"),r.equals(t)}}function Yi(e,t){e.Vector=Xi}function Ki(e){let t=0;for(let r=1;r<e.length;r++)t+=e[r-1].position.dist(e[r].position);return t}void 0!==p5&&Yi(p5);class Zi{constructor(e){for(const[t,r]of Object.entries(e))this[t]=r}}class Ji{vertices;_shape=null;_primitivesIndex=null;_contoursIndex=null;isClosing=!1;constructor(...e){if(this.constructor===Ji)throw new Error("ShapePrimitive is an abstract class: it cannot be instantiated.");if(!(e.length>0))throw new Error("At least one vertex must be passed to the constructor.");this.vertices=e}get vertexCount(){return this.vertices.length}get vertexCapacity(){throw new Error("Getter vertexCapacity must be implemented.")}get _firstInterpolatedVertex(){return this.startVertex()}get canOverrideAnchor(){return!1}accept(e){throw new Error("Method accept() must be implemented.")}addToShape(e){let t=e.at(-1);if(0===t.primitives.length)t.primitives.push(this);else{let r,i,s=e.at(-1,-1),n=s instanceof this.constructor,a=s.vertexCapacity-s.vertexCount;n&&a>0?(r=this.vertices.splice(0,a),i=this.vertices,s.vertices.push(...r),i.length>0&&t.primitives.push(this)):t.primitives.push(this)}if(this.vertices.length>0){let t=e.at(-1);this._primitivesIndex=t.primitives.length-1,this._contoursIndex=e.contours.length-1,this._shape=e}return e.at(-1,-1)}get _nextPrimitive(){return this._belongsToShape?this._shape.at(this._contoursIndex,this._primitivesIndex+1):null}get _belongsToShape(){return null!==this._shape}handlesClose(){return!1}close(e){throw new Error("Unimplemented!")}}class Qi{#i;primitives;constructor(e=8){this.#i=e,this.primitives=[]}get kind(){const e=0===this.primitives.length,t=8===this.#i;return e&&t?7:this.#i}accept(e){for(const t of this.primitives)t.accept(e)}}class es extends Ji{#s=1;get vertexCapacity(){return this.#s}accept(e){e.visitAnchor(this)}getEndVertex(){return this.vertices[0]}}class ts extends Ji{constructor(...e){if(super(...e),this.constructor===ts)throw new Error("Segment is an abstract class: it cannot be instantiated.")}get _previousPrimitive(){return this._belongsToShape?this._shape.at(this._contoursIndex,this._primitivesIndex-1):null}getStartVertex(){return this._previousPrimitive.getEndVertex()}getEndVertex(){return this.vertices.at(-1)}}class rs extends ts{#s=1;get vertexCapacity(){return this.#s}accept(e){e.visitLineSegment(this)}}let is=class extends ts{#n;#s;constructor(e,...t){super(...t);let r=Array.isArray(e)?e[0]:e;this.#n=r,this.#s=r}get order(){return this.#n}get vertexCapacity(){return this.#s}#a;hullLength(){return void 0===this.#a&&(this.#a=Ki([this.getStartVertex(),...this.vertices])),this.#a}accept(e){e.visitBezierSegment(this)}};class ss extends ts{#s=1/0;_splineProperties={ends:Re,tightness:0};get vertexCapacity(){return this.#s}accept(e){e.visitSplineSegment(this)}get _comesAfterSegment(){return this._previousPrimitive instanceof ts}get canOverrideAnchor(){return this._splineProperties.ends===Ne}get _firstInterpolatedVertex(){return this._splineProperties.ends===Ne?this._comesAfterSegment?this.vertices[1]:this.vertices[0]:this.getStartVertex()}get _chainedToSegment(){if(this._belongsToShape&&this._comesAfterSegment){let e=this._firstInterpolatedVertex.position;return this.getStartVertex().position.equals(e)}return!1}addToShape(e){const t=super.addToShape(e);if(this._splineProperties.ends=e._splineProperties.ends,this._splineProperties.tightness=e._splineProperties.tightness,this._splineProperties.ends!==Ne)return t;let r=!this._belongsToShape,i=e.at(-1,-1);if(r&&2===i.vertices.length&&i._comesAfterSegment&&!i._chainedToSegment){let e=i._firstInterpolatedVertex.position,t=i.getStartVertex().position;console.warn(`Spline does not start where previous path segment ends:\n second spline vertex at (${e.array()})\n expected to be at (${t.array()}).`)}return t}getEndVertex(){return this._splineProperties.ends===Re?super.getEndVertex():this._splineProperties.ends===Ne?this.vertices.at(-2):this.getStartVertex()}getControlPoints(){let e=[];this._comesAfterSegment&&e.push(this.getStartVertex()),e.push(this.getStartVertex());for(const t of this.vertices)e.push(t);const t=this.getStartVertex();return this._splineProperties.ends===Re?(e.unshift(t),e.push(this.vertices.at(-1))):this._splineProperties.ends===Ve&&(e.unshift(this.vertices.at(-1)),e.push(t,this.vertices.at(0))),e}handlesClose(){return!!this._belongsToShape&&2===this._shape.at(this._contoursIndex).primitives.length&&1===this._primitivesIndex}close(){this._splineProperties.ends=Ve}}class ns extends Ji{#s=1;get vertexCapacity(){return this.#s}accept(e){e.visitPoint(this)}}class as extends Ji{#s=2;get vertexCapacity(){return this.#s}accept(e){e.visitLine(this)}}class os extends Ji{#s=3;get vertexCapacity(){return this.#s}accept(e){e.visitTriangle(this)}}class hs extends Ji{#s=4;get vertexCapacity(){return this.#s}accept(e){e.visitQuad(this)}}class us extends Ji{#s=1/0;get vertexCapacity(){return this.#s}accept(e){e.visitTriangleFan(this)}}class ls extends Ji{#s=1/0;get vertexCapacity(){return this.#s}accept(e){e.visitTriangleStrip(this)}}class cs extends Ji{#s=1/0;get vertexCapacity(){return this.#s}accept(e){e.visitQuadStrip(this)}}class ps{creators;constructor(){let e=new Map;e.set("vertex-7",(...e)=>new es(...e)),e.set("vertex-8",(...e)=>new rs(...e)),e.set(`vertex-${M}`,(...e)=>new ns(...e)),e.set(`vertex-${k}`,(...e)=>new as(...e)),e.set("vertex-4",(...e)=>new os(...e)),e.set(`vertex-${I}`,(...e)=>new hs(...e)),e.set("vertex-6",(...e)=>new us(...e)),e.set("vertex-5",(...e)=>new ls(...e)),e.set(`vertex-${B}`,(...e)=>new cs(...e)),e.set("bezierVertex-7",(e,...t)=>new es(...t)),e.set("bezierVertex-8",(e,...t)=>new is(e,...t)),e.set("splineVertex-7",(...e)=>new es(...e)),e.set("splineVertex-8",(...e)=>new ss(...e)),this.creators=e}get(e,t){const r=`${e}-${t}`;return this.creators.get(r)}set(e,t,r){const i=`${e}-${t}`;this.creators.set(i,r)}clear(){this.creators.clear()}}class ds{#o;#h;#u;#l=3;kind=null;contours=[];_splineProperties={tightness:0,ends:Re};userVertexProperties=null;constructor(e,t=new ps){this.#h=e,this.#o=e,this.#u=t;for(const e in this.#o)"position"!==e&&"textureCoordinates"!==e&&(this[e]=function(t){this.#o[e]=t})}serializeToArray(e){if(null==e)return[];if(e instanceof Number)return[e];if(e instanceof Array)return e;if(e.array instanceof Function)return e.array();throw new Error(`Can't convert ${e} to array!`)}vertexToArray(e){const t=[];for(const r in this.#o){if(this.userVertexProperties&&r in this.userVertexProperties)continue;const i=e[r];t.push(...this.serializeToArray(i))}for(const r in this.userVertexProperties)r in e?t.push(...this.serializeToArray(e[r])):t.push(...new Array(this.userVertexProperties[r]).fill(0));return t}hydrateValue(e,t){if(null===t)return null;if(t instanceof Number)return e.shift();if(t instanceof Array){const r=[];for(let i=0;i<t.length;i++)r.push(e.shift());return r}if(t instanceof Xi)return new Xi(e.shift(),e.shift(),e.shift());if(t instanceof xi){const t=[e.shift(),e.shift(),e.shift(),e.shift()];return new xi(t)}}arrayToVertex(e){const t={},r=[...e];for(const e in this.#o){if(this.userVertexProperties&&e in this.userVertexProperties)continue;const i=this.#o[e];t[e]=this.hydrateValue(r,i)}for(const e in this.userVertexProperties){const i=this.#o[e];t[e]=this.hydrateValue(r,i)}return t}arrayScale(e,t){return e.map(e=>e*t)}arraySum(e,...t){return e.map((e,r)=>{let i=e;for(let e=0;e<t.length;e++)i+=t[e][r];return i})}arrayMinus(e,t){return e.map((e,r)=>e-t[r])}evaluateCubicBezier([e,t,r,i],s){return this.arraySum(this.arrayScale(e,Math.pow(1-s,3)),this.arrayScale(t,3*Math.pow(1-s,2)*s),this.arrayScale(r,3*(1-s)*Math.pow(s,2)),this.arrayScale(i,Math.pow(s,3)))}evaluateQuadraticBezier([e,t,r],i){return this.arraySum(this.arrayScale(e,Math.pow(1-i,2)),this.arrayScale(t,2*(1-i)*i),this.arrayScale(r,i*i))}catmullRomToBezier(e,t){let r=1-t,i=[];for(let t=0;t+3<e.length;t++){const[s,n,a,o]=e.slice(t,t+4),h=this.arraySum(n,this.arrayScale(this.arrayMinus(a,s),r/6)),u=this.arraySum(a,this.arrayScale(this.arrayMinus(n,o),r/6)),l=a;i.push([h,u,l])}return i}at(e,t,r){let i,s;switch(i=this.contours.at(e),arguments.length){case 1:return i;case 2:return i.primitives.at(t);case 3:return s=i.primitives.at(t),s.vertices.at(r)}}reset(){this.#o={...this.#h},this.kind=null,this.contours=[],this.userVertexProperties=null}vertexProperty(e,t){this.userVertexProperties=this.userVertexProperties||{};const r=this.vertexPropertyKey(e),i=Array.isArray(t)?t:[t];this.userVertexProperties[r]||(this.userVertexProperties[r]=i.length),this.#o[r]=i}vertexPropertyName(e){return e.replace(/Src$/,"")}vertexPropertyKey(e){return e+"Src"}bezierOrder(...e){this.#l=e}splineProperty(e,t){this._splineProperties[e]=t}splineProperties(e){if(!e)return this._splineProperties;for(const t in e)this.splineProperty(t,e[t])}#c(e,t){return this.#o.position=e,void 0!==t&&(this.#o.textureCoordinates=t),new Zi(this.#o)}#p(e,t,...r){let i=this.#u.get(e,t);return"bezierVertex"===e?i(this.#l,...r):i(...r)}#d(e,t,r){let i=e,s=this.at(-1).kind,n=this.#c(t,r);return this.#p(i,s,n).addToShape(this)}vertex(e,t,{isClosing:r=!1}={}){this.#d("vertex",e,t).isClosing=r}bezierVertex(e,t){this.#d("bezierVertex",e,t)}splineVertex(e,t){this.#d("splineVertex",e,t)}arcVertex(e,t){this.#d("arcVertex",e,t)}beginContour(e=8){7===this.at(-1)?.kind&&this.contours.pop(),this.contours.push(new Qi(e))}endContour(e=P,t=this.contours.length-1){const r=this.at(t);if(e===L){const e=8===r.kind,i=this.at(t,0,0),s=Object.hasOwn(i,"position"),n=this.at(t,-1);if(e&&s)if(n.handlesClose())n.close(i);else{const e=this.contours.splice(t+1,this.contours.length-t-1),r=this.#o;this.#o={...r};for(const e in i)["position","textureCoordinates"].includes(e)||(this.#o[e]=i[e]);this.vertex(i.position,i.textureCoordinates,{isClosing:!0}),this.#o=r,this.contours.push(...e)}}}beginShape(e=8){this.kind=e,this.beginContour(e)}endShape(e=P){e===L&&this.endContour(e,0)}accept(e){for(const t of this.contours)t.accept(e)}}class fs{constructor(){if(this.constructor===fs)throw new Error("PrimitiveVisitor is an abstract class: it cannot be instantiated.")}visitAnchor(e){throw new Error("Method visitAnchor() has not been implemented.")}visitLineSegment(e){throw new Error("Method visitLineSegment() has not been implemented.")}visitBezierSegment(e){throw new Error("Method visitBezierSegment() has not been implemented.")}visitSplineSegment(e){throw new Error("Method visitSplineSegment() has not been implemented.")}visitArcSegment(e){throw new Error("Method visitArcSegment() has not been implemented.")}visitPoint(e){throw new Error("Method visitPoint() has not been implemented.")}visitLine(e){throw new Error("Method visitLine() has not been implemented.")}visitTriangle(e){throw new Error("Method visitTriangle() has not been implemented.")}visitQuad(e){throw new Error("Method visitQuad() has not been implemented.")}visitTriangleFan(e){throw new Error("Method visitTriangleFan() has not been implemented.")}visitTriangleStrip(e){throw new Error("Method visitTriangleStrip() has not been implemented.")}visitQuadStrip(e){throw new Error("Method visitQuadStrip() has not been implemented.")}}class gs extends fs{path=new Path2D;strokeWeight;constructor({strokeWeight:e}){super(),this.strokeWeight=e}visitAnchor(e){let t=e.getEndVertex();this.path.moveTo(t.position.x,t.position.y)}visitLineSegment(e){if(e.isClosing)this.path.closePath();else{let t=e.getEndVertex();this.path.lineTo(t.position.x,t.position.y)}}visitBezierSegment(e){let[t,r,i]=e.vertices;switch(e.order){case 2:this.path.quadraticCurveTo(t.position.x,t.position.y,r.position.x,r.position.y);break;case 3:this.path.bezierCurveTo(t.position.x,t.position.y,r.position.x,r.position.y,i.position.x,i.position.y)}}visitSplineSegment(e){const t=e._shape;if(e._splineProperties.ends===Ne&&!e._comesAfterSegment){let t=e._firstInterpolatedVertex;this.path.moveTo(t.position.x,t.position.y)}const r=e.getControlPoints().map(e=>t.vertexToArray(e));let i=t.catmullRomToBezier(r,e._splineProperties.tightness).map(e=>e.map(e=>t.arrayToVertex(e)));for(const e of i){const t=e.flatMap(e=>[e.position.x,e.position.y]);this.path.bezierCurveTo(...t)}}visitPoint(e){const{x:t,y:r}=e.vertices[0].position;this.path.moveTo(t,r),this.path.lineTo(t+1e-5,r)}visitLine(e){const{x:t,y:r}=e.vertices[0].position,{x:i,y:s}=e.vertices[1].position;this.path.moveTo(t,r),this.path.lineTo(i,s)}visitTriangle(e){const[t,r,i]=e.vertices;this.path.moveTo(t.position.x,t.position.y),this.path.lineTo(r.position.x,r.position.y),this.path.lineTo(i.position.x,i.position.y),this.path.closePath()}visitQuad(e){const[t,r,i,s]=e.vertices;this.path.moveTo(t.position.x,t.position.y),this.path.lineTo(r.position.x,r.position.y),this.path.lineTo(i.position.x,i.position.y),this.path.lineTo(s.position.x,s.position.y),this.path.closePath()}visitTriangleFan(e){const[t,...r]=e.vertices;for(let e=0;e<r.length-1;e++){const i=r[e],s=r[e+1];this.path.moveTo(t.position.x,t.position.y),this.path.lineTo(i.position.x,i.position.y),this.path.lineTo(s.position.x,s.position.y),this.path.closePath()}}visitTriangleStrip(e){for(let t=0;t<e.vertices.length-2;t++){const r=e.vertices[t],i=e.vertices[t+1],s=e.vertices[t+2];this.path.moveTo(r.position.x,r.position.y),this.path.lineTo(i.position.x,i.position.y),this.path.lineTo(s.position.x,s.position.y),this.path.closePath()}}visitQuadStrip(e){for(let t=0;t<e.vertices.length-3;t+=2){const r=e.vertices[t],i=e.vertices[t+1],s=e.vertices[t+2],n=e.vertices[t+3];this.path.moveTo(r.position.x,r.position.y),this.path.lineTo(i.position.x,i.position.y),this.path.lineTo(n.position.x,n.position.y),this.path.lineTo(s.position.x,s.position.y),this.path.closePath()}}}class ms extends fs{contours=[];curveDetail;pointsToLines;constructor({curveDetail:e=1,pointsToLines:t=!0}={}){super(),this.curveDetail=e,this.pointsToLines=t}lastContour(){return this.contours[this.contours.length-1]}visitAnchor(e){this.contours.push([]);const t=e._nextPrimitive;t?.canOverrideAnchor?this.lastContour().push(t._firstInterpolatedVertex):this.lastContour().push(e.getEndVertex())}visitLineSegment(e){this.lastContour().push(e.getEndVertex())}visitBezierSegment(e){const t=this.lastContour(),r=Math.max(1,Math.ceil(e.hullLength()*this.curveDetail)),i=[e.getStartVertex(),...e.vertices].map(t=>e._shape.vertexToArray(t));for(let s=0;s<r;s++){const n=(s+1)/r;t.push(e._shape.arrayToVertex(3===e.order?e._shape.evaluateCubicBezier(i,n):e._shape.evaluateQuadraticBezier(i,n)))}}visitSplineSegment(e){const t=e._shape,r=this.lastContour(),i=e.getControlPoints().map(e=>t.vertexToArray(e));let s=t.catmullRomToBezier(i,e._splineProperties.tightness),n=t.vertexToArray(e._firstInterpolatedVertex);for(const e of s){const i=[n,...e],s=Math.max(1,Math.ceil(Ki(i.map(e=>t.arrayToVertex(e)))*this.curveDetail));for(let e=0;e<s;e++){const n=(e+1)/s;r.push(t.arrayToVertex(t.evaluateCubicBezier(i,n)))}n=e[2]}}visitPoint(e){this.pointsToLines?this.contours.push(...e.vertices.map(e=>[e,e])):this.contours.push(e.vertices.slice())}visitLine(e){this.contours.push(e.vertices.slice())}visitTriangle(e){this.contours.push(e.vertices.slice())}visitQuad(e){this.contours.push(e.vertices.slice())}visitTriangleFan(e){this.contours.push(e.vertices.slice())}visitTriangleStrip(e){this.contours.push(e.vertices.slice())}visitQuadStrip(e){this.contours.push(e.vertices.slice())}}class ys extends fs{constructor(){super()}}function xs(e,t){e.Shape=ds,e.Contour=Qi,e.ShapePrimitive=Ji,e.Vertex=Zi,e.Anchor=es,e.Segment=ts,e.LineSegment=rs,e.BezierSegment=is,e.SplineSegment=ss,e.Point=ns,e.Line=as,e.Triangle=os,e.Quad=hs,e.TriangleFan=us,e.TriangleStrip=ls,e.QuadStrip=cs,e.PrimitiveVisitor=fs,e.PrimitiveToPath2DConverter=gs,e.PrimitiveToVerticesConverter=ms,e.PointAtLengthGetter=ys,t.bezierOrder=function(e){return this._renderer.bezierOrder(e)},t.splineVertex=function(...e){let t=0,r=0,i=0,s=0,n=0;2===e.length?[t,r]=e:4===e.length?[t,r,s,n]=e:3===e.length?[t,r,i]=e:5===e.length&&([t,r,i,s,n]=e),this._renderer.splineVertex(t,r,i,s,n)},t.splineProperty=function(e,t){return this._renderer.splineProperty(e,t)},t.splineProperties=function(e){return this._renderer.splineProperties(e)},t.vertex=function(e,t){let r,i,s;r=i=s=0,3===arguments.length?r=arguments[2]:4===arguments.length?(i=arguments[2],s=arguments[3]):5===arguments.length&&(r=arguments[2],i=arguments[3],s=arguments[4]),this._renderer.vertex(e,t,r,i,s)},t.beginContour=function(e){this._renderer.beginContour(e)},t.endContour=function(e=P){this._renderer.endContour(e)}}void 0!==p5&&xs(p5,p5.prototype);class vs{#f={};constructor(e){for(const t in e)this[t]=e[t]}setValue(e,t){e in this.#f||(this.#f[e]=this[e]),this[e]=t}getDiff(){const e=this.#f;return this.#f={},e}getModified(){return this.#f}applyDiff(e){for(const e in this.#f)this[e]=this.#f[e];this.#f=e}}class bs{constructor(e={}){for(const t in e)this[t]=e[t]}clone(){return new bs(this)}}class _s{static states={strokeColor:null,strokeSet:!1,fillColor:null,fillSet:!1,tint:null,imageMode:_,rectMode:_,ellipseMode:A,strokeWeight:1,textFont:{family:"sans-serif"},textLeading:15,leadingSet:!1,textSize:12,textAlign:D,textBaseline:T,bezierOrder:3,splineProperties:new bs({ends:Re,tightness:0}),textWrap:ge,fontStyle:fe,fontStretch:fe,fontWeight:fe,lineHeight:fe,fontVariant:fe,direction:"inherit"};constructor(e,t,r,i){this._pInst=e,this._isMainCanvas=i,this.pixels=[],this._pixelDensity=Math.ceil(window.devicePixelRatio)||1,this.width=t,this.height=r,this._events={},i&&(this._isMainCanvas=!0),this.states=new vs(_s.states),this.states.strokeColor=new xi([0,0,0]),this.states.fillColor=new xi([1,1,1]),this._pushPopStack=[],this._pushPopDepth=0,this._clipping=!1,this._clipInvert=!1,this._currentShape=void 0}get currentShape(){return this._currentShape||(this._currentShape=new ds(this.getCommonVertexProperties())),this._currentShape}remove(){}pixelDensity(e){let t;return"number"==typeof e?(e!==this._pixelDensity&&(this._pixelDensity=e),t=this,this.resize(this.width,this.height)):t=this._pixelDensity,t}push(){this._pushPopDepth++,this._pushPopStack.push(this.states.getDiff())}pop(){this._pushPopDepth--;const e=this._pushPopStack.pop()||{},t=this.states.getModified();this.states.applyDiff(e),this.updateShapeVertexProperties(t),this.updateShapeProperties(t)}bezierOrder(e){if(void 0===e)return this.states.bezierOrder;this.states.setValue("bezierOrder",e),this.updateShapeProperties()}bezierVertex(e,t,r=0,i=0,s=0){const n=new Xi(e,t,r),a=this.getSupportedIndividualVertexProperties().textureCoordinates?new Xi(i,s):void 0;this.currentShape.bezierVertex(n,a)}splineProperty(e,t){if(void 0===t)return this.states.splineProperties[e];this.states.setValue("splineProperties",this.states.splineProperties.clone()),this.states.splineProperties[e]=t,this.updateShapeProperties()}splineProperties(e){if(!e)return{...this.states.splineProperties};for(const t in e)this.splineProperty(t,e[t])}splineVertex(e,t,r=0,i=0,s=0){const n=new Xi(e,t,r),a=this.getSupportedIndividualVertexProperties().textureCoordinates?new Xi(i,s):void 0;this.currentShape.splineVertex(n,a)}curveDetail(e){if(void 0===e)return this.states.curveDetail;this.states.setValue("curveDetail",e)}beginShape(...e){this.currentShape.reset(),this.updateShapeVertexProperties(),this.currentShape.beginShape(...e)}endShape(...e){this.currentShape.endShape(...e),this.drawShape(this.currentShape)}beginContour(e){this.currentShape.beginContour(e)}endContour(e){this.currentShape.endContour(e)}drawShape(e,t){throw new Error("Unimplemented")}vertex(e,t,r=0,i=0,s=0){const n=new Xi(e,t,r),a=this.getSupportedIndividualVertexProperties().textureCoordinates?new Xi(i,s):void 0;this.currentShape.vertex(n,a)}bezier(e,t,r,i,s,n,a,o){const h=this._pInst.bezierOrder();return this._pInst.bezierOrder(h),this._pInst.beginShape(),this._pInst.bezierVertex(e,t),this._pInst.bezierVertex(r,i),this._pInst.bezierVertex(s,n),this._pInst.bezierVertex(a,o),this._pInst.endShape(),this}spline(...e){if(8===e.length){const[t,r,i,s,n,a,o,h]=e;this._pInst.beginShape(),this._pInst.splineVertex(t,r),this._pInst.splineVertex(i,s),this._pInst.splineVertex(n,a),this._pInst.splineVertex(o,h),this._pInst.endShape()}else if(12===e.length){const[t,r,i,s,n,a,o,h,u,l,c,p]=e;this._pInst.beginShape(),this._pInst.splineVertex(t,r,i),this._pInst.splineVertex(s,n,a),this._pInst.splineVertex(o,h,u),this._pInst.splineVertex(l,c,p),this._pInst.endShape()}return this}beginClip(e={}){if(this._clipping)throw new Error("It looks like you're trying to clip while already in the middle of clipping. Did you forget to endClip()?");this._clipping=!0,this._clipInvert=e.invert}endClip(){if(!this._clipping)throw new Error("It looks like you've called endClip() without beginClip(). Did you forget to call beginClip() first?");this._clipping=!1}resize(e,t){this.width=e,this.height=t}get(e,t,r,i){const s=this._pixelDensity,n=this.canvas;if(void 0===e&&void 0===t)e=t=0,r=this.width,i=this.height;else if(e*=s,t*=s,void 0===r&&void 0===i)return e<0||t<0||e>=n.width||t>=n.height?[0,0,0,0]:this._getPixel(e,t);const a=new $i(r*s,i*s);return a.pixelDensity(s),a.canvas.getContext("2d").drawImage(n,e,t,r*s,i*s,0,0,r*s,i*s),a}scale(e,t){}fill(...e){this.states.setValue("fillSet",!0),this.states.setValue("fillColor",this._pInst.color(...e)),this.updateShapeVertexProperties()}noFill(){this.states.setValue("fillColor",null)}strokeWeight(e){if(void 0===e)return this.states.strokeWeight;this.states.setValue("strokeWeight",e)}stroke(...e){this.states.setValue("strokeSet",!0),this.states.setValue("strokeColor",this._pInst.color(...e)),this.updateShapeVertexProperties()}noStroke(){this.states.setValue("strokeColor",null)}getCommonVertexProperties(){return{}}getSupportedIndividualVertexProperties(){return{textureCoordinates:!1}}updateShapeProperties(e){if(!e||e.bezierOrder||e.splineProperties){const e=this.currentShape;e.bezierOrder(this.states.bezierOrder),e.splineProperty("ends",this.states.splineProperties.ends),e.splineProperty("tightness",this.states.splineProperties.tightness)}}updateShapeVertexProperties(e){const t=this.getCommonVertexProperties();if(!e||Object.keys(e).some(e=>e in t)){const e=this.currentShape;for(const r in t)e[r](t[r])}}_applyDefaults(){return this}finishDraw(){}_middleAlignOffset=function(){const{textFont:e,textSize:t}=this.states,r=e?.font,i=this.textDrawingContext().measureText("X");let s=(r?.data||{})["OS/2"]?.sCapHeight;return s?s*=t/r.data.head.unitsPerEm:s=i.fontBoundingBoxAscent,i.alphabeticBaseline+s/2}}const ws="video",Cs="audio";class Es{constructor(e,t,r,i){this.callback=e,this.time=t,this.id=r,this.val=i}}class Ds extends Pi{constructor(e,t){super(e,t);const r=this;this.elt.crossOrigin="anonymous",this._prevTime=0,this._cueIDCounter=0,this._cues=[],this.pixels=[],this._pixelsState=this,this._pixelDensity=1,this._modified=!1,this._frameOnCanvas=-1,Object.defineProperty(r,"src",{get(){const e=r.elt.children[0].src,t=r.elt.src===window.location.href?"":r.elt.src;return e===window.location.href?t:e},set(t){for(let e=0;e<r.elt.children.length;e++)r.elt.removeChild(r.elt.children[e]);const i=document.createElement("source");i.src=t,e.appendChild(i),r.elt.src=t,r._modified=!0}}),r._onended=function(){},r.elt.onended=function(){r._onended(r)}}play(){let e;return this.elt.currentTime===this.elt.duration&&(this.elt.currentTime=0),this.elt.readyState>1||this.elt.load(),e=this.elt.play(),e&&e.catch&&e.catch(e=>{"NotAllowedError"===e.name?console.error(e):console.error("Media play method encountered an unexpected error",e)}),this}stop(){return this.elt.pause(),this.elt.currentTime=0,this}pause(){return this.elt.pause(),this}loop(){return this.elt.setAttribute("loop",!0),this.play(),this}noLoop(){return this.elt.removeAttribute("loop"),this}_setupAutoplayFailDetection(){const t=setTimeout(()=>{console.error(e)},500);this.elt.addEventListener("play",()=>clearTimeout(t),{passive:!0,once:!0})}autoplay(e){const t=this.elt.getAttribute("autoplay");if(this.elt.setAttribute("autoplay",e),e&&!t){const e=()=>this._setupAutoplayFailDetection();4===this.elt.readyState?e():this.elt.addEventListener("canplay",e,{passive:!0,once:!0})}return this}volume(e){if(void 0===e)return this.elt.volume;this.elt.volume=e}speed(e){if(void 0===e)return this.presetPlaybackRate||this.elt.playbackRate;this.loadedmetadata?this.elt.playbackRate=e:this.presetPlaybackRate=e}time(e){return void 0!==e&&(this.elt.currentTime=e),this.elt.currentTime}duration(){return this.elt.duration}_ensureCanvas(){this.canvas||(this.canvas=document.createElement("canvas"),this.drawingContext=this.canvas.getContext("2d"),this.setModified(!0));const e=this._frameOnCanvas!==this._pInst.frameCount;this.loadedmetadata&&e&&(this.canvas.width!==this.elt.width&&(this.canvas.width=this.elt.width,this.canvas.height=this.elt.height,this.width=this.canvas.width,this.height=this.canvas.height),this.drawingContext.clearRect(0,0,this.canvas.width,this.canvas.height),!0===this.flipped&&(this.drawingContext.save(),this.drawingContext.scale(-1,1),this.drawingContext.translate(-this.canvas.width,0)),this.drawingContext.drawImage(this.elt,0,0,this.canvas.width,this.canvas.height),!0===this.flipped&&this.drawingContext.restore(),this.setModified(!0),this._frameOnCanvas=this._pInst.frameCount)}loadPixels(...e){return this._ensureCanvas(),p5.Renderer2D.prototype.loadPixels.apply(this,e)}updatePixels(e,t,r,i){return this.loadedmetadata&&(this._ensureCanvas(),p5.Renderer2D.prototype.updatePixels.call(this,e,t,r,i)),this.setModified(!0),this}get(...e){return this._ensureCanvas(),p5.Renderer2D.prototype.get.apply(this,e)}_getPixel(...e){return this.loadPixels(),p5.Renderer2D.prototype._getPixel.apply(this,e)}set(e,t,r){this.loadedmetadata&&(this._ensureCanvas(),p5.Renderer2D.prototype.set.call(this,e,t,r),this.setModified(!0))}copy(...e){this._ensureCanvas(),p5.prototype.copy.apply(this,e)}mask(...e){this.loadPixels(),this.setModified(!0),p5.Image.prototype.mask.apply(this,e)}isModified(){return this._modified}setModified(e){this._modified=e}onended(e){return this._onended=e,this}_getAudioContext(){}_getSoundOut(){}connect(e){let t,r;if(this._getAudioContext()&&this._getSoundOut())t=this._getAudioContext(),r=this._getSoundOut().input;else try{t=e.context,r=t.destination}catch(e){throw"connect() is meant to be used with Web Audio API or p5.sound.js"}this.audioSourceNode||(this.audioSourceNode=t.createMediaElementSource(this.elt),this.audioSourceNode.connect(r)),e?e.input?this.audioSourceNode.connect(e.input):this.audioSourceNode.connect(e):this.audioSourceNode.connect(r)}disconnect(){if(!this.audioSourceNode)throw"nothing to disconnect";this.audioSourceNode.disconnect()}showControls(){this.elt.style["text-align"]="inherit",this.elt.controls=!0}hideControls(){this.elt.controls=!1}addCue(e,t,r){const i=this._cueIDCounter++,s=new Es(t,e,i,r);return this._cues.push(s),this.elt.ontimeupdate||(this.elt.ontimeupdate=this._onTimeUpdate.bind(this)),i}removeCue(e){for(let t=0;t<this._cues.length;t++)this._cues[t].id===e&&(console.log(e),this._cues.splice(t,1));0===this._cues.length&&(this.elt.ontimeupdate=null)}clearCues(){this._cues=[],this.elt.ontimeupdate=null}_onTimeUpdate(){const e=this.time();for(let t=0;t<this._cues.length;t++){const r=this._cues[t].time,i=this._cues[t].val;this._prevTime<r&&r<=e&&this._cues[t].callback(i)}this._prevTime=e}}function As(e,t){function r(e,t,r){(t._userNode?t._userNode:document.body).appendChild(e);const i=r?new Ds(e,t):new Pi(e,t);return t._elements.push(i),i}function i(e,t,i,s){const n=document.createElement(t);"string"==typeof(i=i||"")&&(i=[i]);for(const e of i){const t=document.createElement("source");t.setAttribute("src",e),n.appendChild(t)}const a=r(n,e,!0);if(a.loadedmetadata=!1,n.addEventListener("loadedmetadata",()=>{a.width=n.videoWidth,a.height=n.videoHeight,0===a.elt.width&&(a.elt.width=n.videoWidth),0===a.elt.height&&(a.elt.height=n.videoHeight),a.presetPlaybackRate&&(a.elt.playbackRate=a.presetPlaybackRate,delete a.presetPlaybackRate),a.loadedmetadata=!0}),"function"==typeof s){const e=()=>{s(a),n.removeEventListener("canplaythrough",e)};n.addEventListener("canplaythrough",e)}return a}t.createVideo=function(e,t){return i(this,ws,e,t)},t.createAudio=function(e,t){return i(this,Cs,e,t)},t.VIDEO=ws,t.AUDIO=Cs,void 0===navigator.mediaDevices&&(navigator.mediaDevices={}),void 0===navigator.mediaDevices.getUserMedia&&(navigator.mediaDevices.getUserMedia=function(e){const t=navigator.webkitGetUserMedia||navigator.mozGetUserMedia;return t?new Promise(function(r,i){t.call(navigator,e,r,i)}):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}),t.createCapture=function(...i){if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new DOMException("getUserMedia not supported in this browser");let s,n,a=!0,o=!0,h=!1;for(const e of i)e===t.VIDEO?o=!1:e===t.AUDIO?a=!1:"object"==typeof e?(void 0!==e.flipped&&(h=e.flipped,delete e.flipped),s=Object.assign({},s,e)):"function"==typeof e&&(n=e);const u={video:a,audio:o};s=Object.assign({},u,s);const l=document.createElement(ws);l.setAttribute("playsinline",""),navigator.mediaDevices.getUserMedia(s).then(function(e){try{"srcObject"in l?l.srcObject=e:l.src=window.URL.createObjectURL(e)}catch(t){l.src=e}}).catch(t=>{"NotFoundError"===t.name&&e._friendlyError("No webcam found on this device","createCapture"),"NotAllowedError"===t.name&&e._friendlyError("Access to the camera was denied","createCapture"),console.error(t)});const c=r(l,this,!0);return c.loadedmetadata=!1,l.addEventListener("loadedmetadata",function(){l.play(),l.width?(c.width=l.width,c.height=l.height,h&&(c.elt.style.transform="scaleX(-1)")):(c.width=c.elt.width=l.videoWidth,c.height=c.elt.height=l.videoHeight),c.loadedmetadata=!0,n&&n(l.srcObject)}),c.flipped=h,c},e.MediaElement=Ds,Ds.prototype._getSoundOut=function(){return e.soundOut},Ds.prototype._getAudioContext=function(){return"function"==typeof t.getAudioContext?t.getAudioContext():void 0}}void 0!==p5&&As(p5,p5.prototype);var Ss=function(e,t,r,i,s){let n;return s===_?n={x:e,y:t,w:Math.abs(r),h:Math.abs(i)}:s===w?n={x:Math.min(e,r),y:Math.min(t,i),w:Math.abs(r-e),h:Math.abs(i-t)}:s===C?n={x:e-(r=Math.abs(r)),y:t-(i=Math.abs(i)),w:2*r,h:2*i}:s===A&&(n={x:e-.5*(r=Math.abs(r)),y:t-.5*(i=Math.abs(i)),w:r,h:i}),n};function Fs(e,t){t._normalizeArcAngles=(e,t,r,i,s)=>{let n;return e-=x*Math.floor(e/x),t-=x*Math.floor(t/x),n=Math.min(Math.abs(e-t),x-Math.abs(e-t)),s&&(e=e<=f?Math.atan(r/i*Math.tan(e)):e>f&&e<=3*f?Math.atan(r/i*Math.tan(e))+g:Math.atan(r/i*Math.tan(e))+x,t=t<=f?Math.atan(r/i*Math.tan(t)):t>f&&t<=3*f?Math.atan(r/i*Math.tan(t))+g:Math.atan(r/i*Math.tan(t))+x),e>t&&(t+=x),{start:e,stop:t,correspondToSamePoint:n<1e-5}},t.arc=function(e,t,r,i,s,n,a,o){if(!this._renderer.states.strokeColor&&!this._renderer.states.fillColor)return this;if(s===n)return this;s=this._toRadians(s),n=this._toRadians(n);const h=Ss(e,t,r,i,this._renderer.states.ellipseMode),u=this._normalizeArcAngles(s,n,h.w,h.h,!0);return u.correspondToSamePoint?this._renderer.ellipse([h.x,h.y,h.w,h.h,o]):(this._renderer.arc(h.x,h.y,h.w,h.h,u.start,u.stop,a,o),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput("arc",[h.x,h.y,h.w,h.h,u.start,u.stop,a])),this},t.ellipse=function(e,t,r,i,s){return this._renderEllipse(...arguments)},t.circle=function(...e){const t=e.slice(0,2);return t.push(e[2],e[2]),this._renderEllipse(...t)},t._renderEllipse=function(e,t,r,i,s){if(!this._renderer.states.strokeColor&&!this._renderer.states.fillColor)return this;void 0===i&&(i=r);const n=Ss(e,t,r,i,this._renderer.states.ellipseMode);return this._renderer.ellipse([n.x,n.y,n.w,n.h,s]),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput("ellipse",[n.x,n.y,n.w,n.h]),this},t.line=function(...e){return this._renderer.states.strokeColor&&this._renderer.line(...e),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput("line",e),this},t.point=function(...t){return this._renderer.states.strokeColor&&(1===t.length&&t[0]instanceof e.Vector?this._renderer.point.call(this._renderer,t[0].x,t[0].y,t[0].z):(this._renderer.point(...t),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput("point",t))),this},t.quad=function(...e){return(this._renderer.states.strokeColor||this._renderer.states.fillColor)&&(this._renderer.isP3D&&e.length<12?this._renderer.quad.call(this._renderer,e[0],e[1],0,e[2],e[3],0,e[4],e[5],0,e[6],e[7],0,e[8],e[9]):(this._renderer.quad(...e),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput("quadrilateral",e))),this},t.rect=function(...e){return this._renderRect(...e)},t.square=function(e,t,r,i,s,n,a){return this._renderRect.call(this,e,t,r,r,i,s,n,a)},t._renderRect=function(){if(this._renderer.states.strokeColor||this._renderer.states.fillColor){3===arguments.length&&(arguments[3]=arguments[2]);const e=Ss(arguments[0],arguments[1],arguments[2],arguments[3],this._renderer.states.rectMode);this._renderer.states.rectMode===_&&(e.w=arguments[2],e.h=arguments[3]);const t=[e.x,e.y,e.w,e.h];for(let e=4;e<arguments.length;e++)t[e]=arguments[e];this._renderer.rect(t),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput("rectangle",[e.x,e.y,e.w,e.h])}return this},t.triangle=function(...e){return(this._renderer.states.strokeColor||this._renderer.states.fillColor)&&this._renderer.triangle(e),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput("triangle",e),this}}function Ts(e,t){t.ellipseMode=function(e){return e!==_&&e!==w&&e!==C&&e!==A||this._renderer.states.setValue("ellipseMode",e),this},t.noSmooth=function(){return this._renderer.isP3D?this.setAttributes("antialias",!1):"imageSmoothingEnabled"in this.drawingContext&&(this.drawingContext.imageSmoothingEnabled=!1),this},t.rectMode=function(e){return e!==_&&e!==w&&e!==C&&e!==A||this._renderer.states.setValue("rectMode",e),this},t.smooth=function(){return this._renderer.isP3D?this.setAttributes("antialias",!0):"imageSmoothingEnabled"in this.drawingContext&&(this.drawingContext.imageSmoothingEnabled=!0),this},t.strokeCap=function(e){return e!==U&&e!==V&&e!==N||this._renderer.strokeCap(e),this},t.strokeJoin=function(e){return e!==U&&e!==z&&e!==G||this._renderer.strokeJoin(e),this},t.strokeWeight=function(e){return this._renderer.strokeWeight(e),this}}function Ms(e,t){t.bezier=function(...e){return this._renderer.states.strokeColor||this._renderer.states.fillColor?(this._renderer.bezier(...e),this):this},t.bezierPoint=function(e,t,r,i,s){const n=1-s;return Math.pow(n,3)*e+3*Math.pow(n,2)*s*t+3*n*Math.pow(s,2)*r+Math.pow(s,3)*i},t.bezierTangent=function(e,t,r,i,s){const n=1-s;return 3*i*Math.pow(s,2)-3*r*Math.pow(s,2)+6*r*n*s-6*t*n*s+3*t*Math.pow(n,2)-3*e*Math.pow(n,2)},t.spline=function(...e){return this._renderer.states.strokeColor||this._renderer.states.fillColor?(this._renderer.spline(...e),this):this},t.splinePoint=function(e,t,r,i,s){const n=this._renderer.states.splineProperties.tightness,a=s*s*s,o=s*s;return e*((n-1)/2*a+(1-n)*o+(n-1)/2*s)+t*((n+3)/2*a+(-5-n)/2*o+1)+r*((-3-n)/2*a+(n+2)*o+(1-n)/2*s)+i*((1-n)/2*a+(n-1)/2*o)},t.splineTangent=function(e,t,r,i,s){const n=this._renderer.states.splineProperties.tightness,a=s*s*3,o=2*s;return e*((n-1)/2*a+(1-n)*o+(n-1)/2)+t*((n+3)/2*a+(-5-n)/2*o)+r*((-3-n)/2*a+(n+2)*o+(1-n)/2)+i*((1-n)/2*a+(n-1)/2*o)}}function ks(e,t){t.beginShape=function(e){this._renderer.beginShape(...arguments)},t.bezierVertex=function(...e){this._renderer.bezierVertex(...e)},t.endShape=function(e,t=1){t<1&&(console.log("🌸 p5.js says: You can not have less than one instance"),t=1),this._renderer.endShape(e,t)},t.normal=function(e,t,r){return this._assert3d("normal"),this._renderer.normal(...arguments),this},t.vertexProperty=function(e,t){this._renderer.vertexProperty(e,t)}}function Is(e,t){t.beginClip=function(e={}){this._renderer.beginClip(e)},t.endClip=function(){this._renderer.endClip()},t.clip=function(e,t){this._renderer.beginClip(t),e(),this._renderer.endClip(t)},t.background=function(...e){return this._renderer.background(...e),this},t.clear=function(...e){const t=e[0]||0,r=e[1]||0,i=e[2]||0,s=e[3]||0;return this._renderer.clear(t,r,i,s),this},t.colorMode=function(e,t,r,i,s){if([bi,_i,wi,Ci,Ei,Di,Ai,Si,Fi].includes(e)){this._renderer.states.setValue("colorMode",e),this._renderer.states.setValue("colorMaxes",this._renderer.states.colorMaxes.clone());const n=this._renderer.states.colorMaxes[e];2===arguments.length?(n[0]=t,n[1]=t,n[2]=t,n[3]=t):4===arguments.length?(n[0]=t,n[1]=r,n[2]=i):5===arguments.length&&(n[0]=t,n[1]=r,n[2]=i,n[3]=s)}return this._renderer.states.colorMode},t.fill=function(...e){return this._renderer.fill(...e),this},t.noFill=function(){return this._renderer.noFill(),this},t.noStroke=function(){return this._renderer.states.setValue("strokeColor",null),this},t.stroke=function(...e){return this._renderer.stroke(...e),this},t.erase=function(e=255,t=255){return this._renderer.erase(e,t),this},t.noErase=function(){return this._renderer.noErase(),this},t.blendMode=function(e){e===fe&&(console.warn("NORMAL has been deprecated for use in blendMode. defaulting to BLEND instead."),e=$),this._renderer.blendMode(e)}}void 0!==p5&&Fs(p5,p5.prototype),void 0!==p5&&Ts(0,p5.prototype),void 0!==p5&&Ms(0,p5.prototype),void 0!==p5&&ks(0,p5.prototype),void 0!==p5&&Is(0,p5.prototype);var Bs,Ls,Ps="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Os(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Rs(e,t,r,i){for(var s=e[t++],n=1<<s,a=n+1,o=a+1,h=s+1,u=(1<<h)-1,l=0,c=0,p=0,d=e[t++],f=new Int32Array(4096),g=null;;){for(;l<16&&0!==d;)c|=e[t++]<<l,l+=8,1===d?d=e[t++]:--d;if(l<h)break;var m=c&u;if(c>>=h,l-=h,m!==n){if(m===a)break;for(var y=m<o?m:g,x=0,v=y;v>n;)v=f[v]>>8,++x;var b=v;if(p+x+(y!==m?1:0)>i)return void console.log("Warning, gif stream longer than expected.");r[p++]=b;var _=p+=x;for(y!==m&&(r[p++]=b),v=y;x--;)v=f[v],r[--_]=255&v,v>>=8;null!==g&&o<4096&&(f[o++]=g<<8|b,o>=u+1&&h<12&&(++h,u=u<<1|1)),g=m}else o=a+1,u=(1<<(h=s+1))-1,g=null}return p!==i&&console.log("Warning, gif stream shorter than expected."),r}try{Ls=function(e,t,r,i){var s=0,n=void 0===(i=void 0===i?{}:i).loop?null:i.loop,a=void 0===i.palette?null:i.palette;if(t<=0||r<=0||t>65535||r>65535)throw new Error("Width/Height invalid.");function o(e){var t=e.length;if(t<2||t>256||t&t-1)throw new Error("Invalid code/color length, must be power of 2 and 2 .. 256.");return t}e[s++]=71,e[s++]=73,e[s++]=70,e[s++]=56,e[s++]=57,e[s++]=97;var h=0,u=0;if(null!==a){for(var l=o(a);l>>=1;)++h;if(l=1<<h,--h,void 0!==i.background){if((u=i.background)>=l)throw new Error("Background index out of range.");if(0===u)throw new Error("Background index explicitly passed as 0.")}}if(e[s++]=255&t,e[s++]=t>>8&255,e[s++]=255&r,e[s++]=r>>8&255,e[s++]=(null!==a?128:0)|h,e[s++]=u,e[s++]=0,null!==a)for(var c=0,p=a.length;c<p;++c){var d=a[c];e[s++]=d>>16&255,e[s++]=d>>8&255,e[s++]=255&d}if(null!==n){if(n<0||n>65535)throw new Error("Loop count invalid.");e[s++]=33,e[s++]=255,e[s++]=11,e[s++]=78,e[s++]=69,e[s++]=84,e[s++]=83,e[s++]=67,e[s++]=65,e[s++]=80,e[s++]=69,e[s++]=50,e[s++]=46,e[s++]=48,e[s++]=3,e[s++]=1,e[s++]=255&n,e[s++]=n>>8&255,e[s++]=0}var f=!1;this.addFrame=function(t,r,i,n,h,u){if(!0===f&&(--s,f=!1),u=void 0===u?{}:u,t<0||r<0||t>65535||r>65535)throw new Error("x/y invalid.");if(i<=0||n<=0||i>65535||n>65535)throw new Error("Width/Height invalid.");if(h.length<i*n)throw new Error("Not enough pixels for the frame size.");var l=!0,c=u.palette;if(null==c&&(l=!1,c=a),null==c)throw new Error("Must supply either a local or global palette.");for(var p=o(c),d=0;p>>=1;)++d;p=1<<d;var g=void 0===u.delay?0:u.delay,m=void 0===u.disposal?0:u.disposal;if(m<0||m>3)throw new Error("Disposal out of range.");var y=!1,x=0;if(void 0!==u.transparent&&null!==u.transparent&&(y=!0,(x=u.transparent)<0||x>=p))throw new Error("Transparent color index.");if((0!==m||y||0!==g)&&(e[s++]=33,e[s++]=249,e[s++]=4,e[s++]=m<<2|(!0===y?1:0),e[s++]=255&g,e[s++]=g>>8&255,e[s++]=x,e[s++]=0),e[s++]=44,e[s++]=255&t,e[s++]=t>>8&255,e[s++]=255&r,e[s++]=r>>8&255,e[s++]=255&i,e[s++]=i>>8&255,e[s++]=255&n,e[s++]=n>>8&255,e[s++]=!0===l?128|d-1:0,!0===l)for(var v=0,b=c.length;v<b;++v){var _=c[v];e[s++]=_>>16&255,e[s++]=_>>8&255,e[s++]=255&_}return s=function(e,t,r,i){e[t++]=r;var s=t++,n=1<<r,a=n-1,o=n+1,h=o+1,u=r+1,l=0,c=0;function p(r){for(;l>=r;)e[t++]=255&c,c>>=8,l-=8,t===s+256&&(e[s]=255,s=t++)}function d(e){c|=e<<l,l+=u,p(8)}var f=i[0]&a,g={};d(n);for(var m=1,y=i.length;m<y;++m){var x=i[m]&a,v=f<<8|x,b=g[v];if(void 0===b){for(c|=f<<l,l+=u;l>=8;)e[t++]=255&c,c>>=8,l-=8,t===s+256&&(e[s]=255,s=t++);4096===h?(d(n),h=o+1,u=r+1,g={}):(h>=1<<u&&++u,g[v]=h++),f=x}else f=b}return d(f),d(o),p(1),s+1===t?e[s]=0:(e[s]=t-s-1,e[t++]=0),t}(e,s,d<2?2:d,h),s},this.end=function(){return!1===f&&(e[s++]=59,f=!0),s},this.getOutputBuffer=function(){return e},this.setOutputBuffer=function(t){e=t},this.getOutputBufferPosition=function(){return s},this.setOutputBufferPosition=function(e){s=e}},Bs=function(e){var t=0;if(71!==e[t++]||73!==e[t++]||70!==e[t++]||56!==e[t++]||56!=(e[t++]+1&253)||97!==e[t++])throw new Error("Invalid GIF 87a/89a header.");var r=e[t++]|e[t++]<<8,i=e[t++]|e[t++]<<8,s=e[t++],n=s>>7,a=1<<1+(7&s);e[t++],e[t++];var o=null,h=null;n&&(o=t,h=a,t+=3*a);var u=!0,l=[],c=0,p=null,d=0,f=null;for(this.width=r,this.height=i;u&&t<e.length;)switch(e[t++]){case 33:switch(e[t++]){case 255:if(11!==e[t]||78==e[t+1]&&69==e[t+2]&&84==e[t+3]&&83==e[t+4]&&67==e[t+5]&&65==e[t+6]&&80==e[t+7]&&69==e[t+8]&&50==e[t+9]&&46==e[t+10]&&48==e[t+11]&&3==e[t+12]&&1==e[t+13]&&0==e[t+16])t+=14,f=e[t++]|e[t++]<<8,t++;else for(t+=12;;){if(!((S=e[t++])>=0))throw Error("Invalid block size");if(0===S)break;t+=S}break;case 249:if(4!==e[t++]||0!==e[t+4])throw new Error("Invalid graphics extension block.");var g=e[t++];c=e[t++]|e[t++]<<8,p=e[t++],1&g||(p=null),d=g>>2&7,t++;break;case 254:for(;;){if(!((S=e[t++])>=0))throw Error("Invalid block size");if(0===S)break;t+=S}break;default:throw new Error("Unknown graphic control label: 0x"+e[t-1].toString(16))}break;case 44:var m=e[t++]|e[t++]<<8,y=e[t++]|e[t++]<<8,x=e[t++]|e[t++]<<8,v=e[t++]|e[t++]<<8,b=e[t++],_=b>>6&1,w=1<<1+(7&b),C=o,E=h,D=!1;b>>7&&(D=!0,C=t,E=w,t+=3*w);var A=t;for(t++;;){var S;if(!((S=e[t++])>=0))throw Error("Invalid block size");if(0===S)break;t+=S}l.push({x:m,y,width:x,height:v,has_local_palette:D,palette_offset:C,palette_size:E,data_offset:A,data_length:t-A,transparent_index:p,interlaced:!!_,delay:c,disposal:d});break;case 59:u=!1;break;default:throw new Error("Unknown gif block: 0x"+e[t-1].toString(16))}this.numFrames=function(){return l.length},this.loopCount=function(){return f},this.frameInfo=function(e){if(e<0||e>=l.length)throw new Error("Frame index out of range.");return l[e]},this.decodeAndBlitFrameBGRA=function(t,i){var s=this.frameInfo(t),n=s.width*s.height,a=new Uint8Array(n);Rs(e,s.data_offset,a,n);var o=s.palette_offset,h=s.transparent_index;null===h&&(h=256);var u=s.width,l=r-u,c=u,p=4*(s.y*r+s.x),d=4*((s.y+s.height)*r+s.x),f=p,g=4*l;!0===s.interlaced&&(g+=4*r*7);for(var m=8,y=0,x=a.length;y<x;++y){var v=a[y];if(0===c&&(c=u,(f+=g)>=d&&(g=4*l+4*r*(m-1),f=p+(u+l)*(m<<1),m>>=1)),v===h)f+=4;else{var b=e[o+3*v],_=e[o+3*v+1],w=e[o+3*v+2];i[f++]=w,i[f++]=_,i[f++]=b,i[f++]=255}--c}},this.decodeAndBlitFrameRGBA=function(t,i){var s=this.frameInfo(t),n=s.width*s.height,a=new Uint8Array(n);Rs(e,s.data_offset,a,n);var o=s.palette_offset,h=s.transparent_index;null===h&&(h=256);var u=s.width,l=r-u,c=u,p=4*(s.y*r+s.x),d=4*((s.y+s.height)*r+s.x),f=p,g=4*l;!0===s.interlaced&&(g+=4*r*7);for(var m=8,y=0,x=a.length;y<x;++y){var v=a[y];if(0===c&&(c=u,(f+=g)>=d&&(g=4*l+4*r*(m-1),f=p+(u+l)*(m<<1),m>>=1)),v===h)f+=4;else{var b=e[o+3*v],_=e[o+3*v+1],w=e[o+3*v+2];i[f++]=b,i[f++]=_,i[f++]=w,i[f++]=255}--c}}}}catch(e){}function Ns(e,t){t.createImage=function(t,r){return new e.Image(t,r)},t.saveCanvas=function(...e){let r,i,s,n,a;if(e[0]instanceof HTMLCanvasElement)r=e[0],e.shift();else if(e[0]instanceof Pi)r=e[0].elt,e.shift();else if(e[0]instanceof ma){const t=e[0];n=this.createGraphics(t.width,t.height),n.pixelDensity(t.pixelDensity()),t.loadPixels(),n.loadPixels(),n.pixels.set(t.pixels),n.updatePixels(),r=n._renderer.canvas,e.shift()}else r=this._curElement&&this._curElement.elt;switch(e.length>=1&&(i=e[0]),e.length>=2&&(s=e[1]),s=s||t._checkFileExtension(i,s)[1]||"png",s){default:a="image/png";break;case"webp":a="image/webp";break;case"jpeg":case"jpg":a="image/jpeg"}r.toBlob(e=>{t.downloadFile(e,i,s),n&&n.remove()},a)},t.encodeAndDownloadGif=function(e,r){const i=e.gifProperties;let s=i.loopLimit;1===s?s=null:null===s&&(s=0);const n=new Uint8Array(e.width*e.height*i.numFrames),a=[],o={};for(let t=0;t<i.numFrames;t++){const r=new Set,s=i.frames[t].image.data,n=s.length,h=new Uint32Array(e.width*e.height);for(let e=0,t=0;e<n;e+=4,t++){const i=s[e+0]<<16|s[e+1]<<8|s[e+2];r.add(i),h[t]=i}const u=[...r].sort().toString();void 0===o[u]?o[u]={freq:1,frames:[t]}:(o[u].freq+=1,o[u].frames.push(t)),a.push(h)}let h=[];const u=Object.keys(o).sort(function(e,t){return o[t].freq-o[e].freq}),l=u[0].split(",").map(e=>parseInt(e));h=h.concat(o[l].frames);const c=new Set(l);for(let e=1;e<u.length;e++){const t=u[e].split(",").map(e=>parseInt(e)).filter(e=>!c.has(e));if(l.length+t.length<=256){for(let e=0;e<t.length;e++)l.push(t[e]),c.add(t[e]);h=h.concat(o[u[e]].frames)}}h=new Set(h);const p={};for(let e=0;e<l.length;e++)p[l[e]]||(p[l[e]]=e);let d=1;for(;d<l.length;)d<<=1;l.length=d;const f={loop:s,palette:new Uint32Array(l)},g=new Ls(n,e.width,e.height,f);let m={};for(let t=0;t<i.numFrames;t++){const r=!h.has(t),s=r?[]:l,n=new Uint8Array(e.width*e.height),o={},u=new Set;a[t].forEach((e,i)=>{r?(void 0===o[e]&&(o[e]=s.length,s.push(e)),n[i]=o[e]):n[i]=p[e],t>0&&a[t-1][i]!==e&&u.add(e)});const c={},d=s.filter(e=>!u.has(e));if(d.length>0){const e=d[0],i=r?o[e]:p[e];if(t>0){for(let e=0;e<a[t].length;e++)a[t-1][e]===a[t][e]&&(n[e]=i);c.transparent=i,m.frameOpts.disposal=1}}if(c.delay=i.frames[t].delay/10,r){let e=1;for(;e<s.length;)e<<=1;s.length=e,c.palette=new Uint32Array(s)}t>0&&g.addFrame(0,0,e.width,e.height,m.pixelPaletteIndex,m.frameOpts),m={pixelPaletteIndex:n,frameOpts:c}}m.frameOpts.disposal=1,g.addFrame(0,0,e.width,e.height,m.pixelPaletteIndex,m.frameOpts);const y=new Blob([n.slice(0,g.end())],{type:"image/gif"});t.downloadFile(y,r,"gif")},t.saveFrames=function(e,r,i,s,n){let a=i||3;a=Math.max(Math.min(a,15),0),a*=1e3;let o=s||15;o=Math.max(Math.min(o,22),0);let h=0;const u=t._makeFrame,l=this._curElement.elt;let c=[];const p=setInterval(()=>{c.push(u(e+h,r,l)),h++},1e3/o);setTimeout(()=>{if(clearInterval(p),n)n(c);else for(const e of c)t.downloadFile(e.imageData,e.filename,e.ext);c=[]},a+.01)},t._makeFrame=function(e,t,r){let i,s;if(i=this?this._curElement.elt:r,t)switch(t.toLowerCase()){case"png":default:s="image/png";break;case"jpeg":case"jpg":s="image/jpeg"}else t="png",s="image/png";let n=i.toDataURL(s);n=n.replace(s,"image/octet-stream");const a={};return a.imageData=n,a.filename=e,a.ext=t,a}}function Vs(e){const t=e.options.typed?function(e){switch(!0){case"true"===e:case"false"===e:return"true"===e;case/.\./.test(e):return parseFloat(e);case isFinite(e):return parseInt(e);default:return e}}(e.value):e.value;e.entry.push(e.reviver(t,e.row,e.col)),e.value="",e.col++}function Us(e){e.output.push(e.entry),e.entry=[],e.row++,e.col=1}function zs(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}void 0!==p5&&Ns(p5,p5.prototype);class Gs extends Error{status;response;ok}async function js(e,t){try{const r=await fetch(e);if(r.ok){let e;switch(t){case"json":e=await r.json();break;case"text":e=await r.text();break;case"arrayBuffer":e=await r.arrayBuffer();break;case"blob":e=await r.blob();break;case"bytes":if(r.bytes)e=await r.bytes();else{const t=await r.arrayBuffer();e=new Uint8Array(t)}break;default:throw new Error("Unsupported response type")}return{data:e,headers:r.headers}}{const e=new Gs(r.statusText);throw e.status=r.status,e.response=r,e.ok=!1,e}}catch(e){throw e instanceof TypeError?console.log("You may have encountered a CORS error"):e instanceof Gs?console.log("You have encountered a HTTP error"):e instanceof SyntaxError&&console.log("There is an error parsing the response to requested data structure"),e}}function $s(e,t){function r(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}t.loadJSON=async function(t,r,i){try{const{data:e}=await js(t,"json");return r?r(e):e}catch(r){if(e._friendlyFileLoadError(5,t),i)return i(r);throw r}},t.loadStrings=async function(t,r,i){try{let{data:e}=await js(t,"text");return e=e.split(/\r?\n/),r?r(e):e}catch(r){if(e._friendlyFileLoadError(3,t),i)return i(r);throw r}},t.loadTable=async function(t,r,i,s,n){"function"==typeof arguments[arguments.length-1]&&("function"==typeof arguments[arguments.length-2]?(s=arguments[arguments.length-2],n=arguments[arguments.length-1]):s=arguments[arguments.length-1]),"string"!=typeof r&&(r=","),"function"==typeof i&&(i=!1);try{let{data:n}=await js(t,"text"),a=new e.Table;return n=function(e,t,r=e=>e){const i=Object.create(null);if(i.options=t||{},i.reviver=r,i.value="",i.entry=[],i.output=[],i.col=1,i.row=1,i.options.delimiter=void 0===i.options.delimiter?'"':t.delimiter,i.options.delimiter.length>1||0===i.options.delimiter.length)throw Error(`CSVError: delimiter must be one character [${i.options.separator}]`);if(i.options.separator=void 0===i.options.separator?",":t.separator,i.options.separator.length>1||0===i.options.separator.length)throw Error(`CSVError: separator must be one character [${i.options.separator}]`);const s=new RegExp(`${zs(i.options.delimiter)}|${zs(i.options.separator)}|\r\n|\n|\r|[^${zs(i.options.delimiter)}${zs(i.options.separator)}\r\n]+`,"y"),n=/^(\r\n|\n|\r)$/;let a=[],o="",h=0;for(;null!==(a=s.exec(e));)switch(o=a[0],h){case 0:switch(!0){case o===i.options.delimiter:h=3;break;case o===i.options.separator:h=0,Vs(i);break;case n.test(o):h=0,Vs(i),Us(i);break;default:i.value+=o,h=2}break;case 2:switch(!0){case o===i.options.separator:h=0,Vs(i);break;case n.test(o):h=0,Vs(i),Us(i);break;default:throw h=4,Error(`CSVError: Illegal state [row:${i.row}, col:${i.col}]`)}break;case 3:1==(o===i.options.delimiter)?h=4:(h=3,i.value+=o);break;case 4:switch(!0){case o===i.options.delimiter:h=3,i.value+=o;break;case o===i.options.separator:h=0,Vs(i);break;case n.test(o):h=0,Vs(i),Us(i);break;default:throw Error(`CSVError: Illegal state [row:${i.row}, col:${i.col}]`)}}return 0!==i.entry.length&&(Vs(i),Us(i)),i.output}(n,{separator:r}),a.columns=i?n.shift():Array(n[0].length).fill(null),n.forEach(t=>{const r=new e.TableRow(t);a.addRow(r)}),s?s(a):a}catch(r){if(e._friendlyFileLoadError(2,t),n)return n(r);throw r}},t.loadXML=async function(t,r,i){try{const i=new DOMParser;let{data:s}=await js(t,"text");const n=i.parseFromString(s,"application/xml");return s=new e.XML(n),r?r(s):s}catch(r){if(e._friendlyFileLoadError(1,t),i)return i(r);throw r}},t.loadBytes=async function(t,r,i){try{let{data:e}=await js(t,"arrayBuffer");return e=new Uint8Array(e),r?r(e):e}catch(r){if(e._friendlyFileLoadError(6,t),i)return i(r);throw r}},t.loadBlob=async function(e,t,r){try{const{data:r}=await js(e,"blob");return t?t(r):r}catch(e){if(r)return r(e);throw e}},t.httpGet=async function(e,t="text",r,i){return"function"==typeof t&&(i=r,r=t,t="text"),this.httpDo(e,"GET",t,r,i)},t.httpPost=async function(t,r,i="text",s,n){"function"==typeof r?(s=r,n=i,r=void 0,i="text"):"function"==typeof i&&(n=s,s=i,i="text");let a=r,o="text/plain";r instanceof e.XML?(a=r.serialize(),o="application/xml"):r instanceof e.Image?(a=await r.toBlob(),o="image/png"):"object"==typeof r&&(a=JSON.stringify(r),o="application/json");const h={method:"POST",body:a,headers:{"Content-Type":o}};a&&(h.body=a);const u=new Request(t,h);return this.httpDo(u,"POST",i,s,n)},t.httpDo=async function(e,t,r,i,s){if("function"==typeof r&&(s=i,i=r,r=void 0),!r)switch("string"==typeof e?e.split(".").pop():e.url.split(".").pop()){case"json":r="json";break;case"jpg":case"jpeg":case"png":case"webp":case"gif":r="blob";break;default:r="text"}const n=new Request(e,{method:t});try{const{data:e}=await js(n,r);return i?i(e):e}catch(e){if(s)return s(e);throw e}},t._pWriters=[],t.createWriter=function(r,i){let s;for(const n in t._pWriters)if(t._pWriters[n].name===r)return s=new e.PrintWriter(r+this.millis(),i),t._pWriters.push(s),s;return s=new e.PrintWriter(r,i),t._pWriters.push(s),s},e.PrintWriter=function(e,r){let i=this;this.name=e,this.content="",this.write=function(e){this.content+=e},this.print=function(e){this.content+=`${e}\n`},this.clear=function(){this.content=""},this.close=function(){const s=[];s.push(this.content),t.writeFile(s,e,r);for(const e in t._pWriters)t._pWriters[e].name===this.name&&t._pWriters.splice(e,1);i.clear(),i={}}},t.save=function(r,i,s){const n=arguments,a=this._curElement?this._curElement.elt:this.elt;if(0!==n.length)if(n[0]instanceof _s||n[0]instanceof ea)t.saveCanvas(n[0].canvas,n[1],n[2]);else if(1===n.length&&"string"==typeof n[0])t.saveCanvas(a,n[0]);else switch(ji(n[1],n[2])[1]){case"json":return void t.saveJSON(n[0],n[1],n[2]);case"txt":return void t.saveStrings(n[0],n[1],n[2]);default:n[0]instanceof Array?t.saveStrings(n[0],n[1],n[2]):n[0]instanceof e.Table?t.saveTable(n[0],n[1],n[2]):n[0]instanceof e.Image?t.saveCanvas(n[0].canvas,n[1]):n[0]instanceof e.SoundFile&&t.saveSound(n[0],n[1],n[2],n[3])}else t.saveCanvas(a)},t.saveJSON=function(e,t,r){let i;i=r?JSON.stringify(e):JSON.stringify(e,void 0,2),this.saveStrings(i.split("\n"),t,"json")},t.saveStrings=function(t,r,i,s){const n=i||"txt",a=new e.PrintWriter(r,n);for(let e of t)s?a.write(e+"\r\n"):a.write(e+"\n");a.close(),a.clear()},t.saveTable=function(e,t,i){let s;void 0===i?(s=t.substring(t.lastIndexOf(".")+1,t.length),s===t&&(s="csv")):s=i;const n=this.createWriter(t,s),a=e.columns;let o=",";if("tsv"===s&&(o="\t"),"html"!==s){const t=e.toString(o);n.write(t)}else{n.print("<html>"),n.print("<head>");let t=' <meta http-equiv="content-type" content';if(t+='="text/html;charset=utf-8" />',n.print(t),n.print("</head>"),n.print("<body>"),n.print(" <table>"),"0"!==a[0]){n.print(" <tr>");for(let e=0;e<a.length;e++){const t=r(a[e]);n.print(` <td>${t}`),n.print(" </td>")}n.print(" </tr>")}for(let t=0;t<e.rows.length;t++){n.print(" <tr>");for(let i=0;i<e.columns.length;i++){const s=r(e.rows[t].getString(i));n.print(` <td>${s}`),n.print(" </td>")}n.print(" </tr>")}n.print(" </table>"),n.print("</body>"),n.print("</html>")}n.close(),n.clear()},t.writeFile=function(e,r,i){let s="application/octet-stream";t._isSafari()&&(s="text/plain");const n=new Blob(e,{type:s});t.downloadFile(n,r,i)},t.downloadFile=Gi,t._checkFileExtension=ji,t._isSafari=function(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}}function Hs(e=256){let t=0,r=new Uint8Array(e);return{get buffer(){return r.buffer},reset(){t=0},bytesView:()=>r.subarray(0,t),bytes:()=>r.slice(0,t),writeByte(e){i(t+1),r[t]=e,t++},writeBytes(e,s=0,n=e.length){i(t+n);for(let i=0;i<n;i++)r[t++]=e[i+s]},writeBytesView(e,s=0,n=e.byteLength){i(t+n),r.set(e.subarray(s,s+n),t),t+=n}};function i(e){var i=r.length;if(i>=e)return;e=Math.max(e,i*(i<1048576?2:1.125)>>>0),0!=i&&(e=Math.max(e,256));let s=r;r=new Uint8Array(e),t>0&&r.set(s.subarray(0,t),0)}}void 0!==p5&&$s(p5,p5.prototype);var qs=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];function Ws(e,t,r){return e<<8&63488|t<<2&992|r>>3}function Xs(e,t,r,i){return e>>4|240&t|(240&r)<<4|(240&i)<<8}function Ys(e,t,r){return e>>4<<8|240&t|r>>4}function Ks(e,t,r){return e<t?t:e>r?r:e}function Zs(e){return e*e}function Js(e,t,r){var i=0,s=1e100;let n=e[t],a=n.cnt,o=n.rc,h=n.gc,u=n.bc;for(var l=n.fw;0!=l;l=e[l].fw){let t=e[l],r=t.cnt,n=a*r/(a+r);if(!(n>=s)){var c=0;!((c+=n*Zs(t.rc-o))>=s)&&!((c+=n*Zs(t.gc-h))>=s)&&!((c+=n*Zs(t.bc-u))>=s)&&(s=c,i=l)}}n.err=s,n.nn=i}function Qs(e,t){for(let r=0;r<e.length;r++){let i=e[r],s=i[0]===t[0]&&i[1]===t[1]&&i[2]===t[2],n=!(i.length>=4&&t.length>=4)||i[3]===t[3];if(s&&n)return!0}return!1}function en(e,t){var r,i=0;for(r=0;r<e.length;r++){let s=e[r]-t[r];i+=s*s}return i}function tn(e,t,r=en){let i=1/0,s=-1;for(let n=0;n<e.length;n++){let a=r(t,e[n]);a<i&&(i=a,s=n)}return s}function rn(e,t){let r=1<<an(t.length);for(let i=0;i<r;i++){let r=[0,0,0];i<t.length&&(r=t[i]),e.writeByte(r[0]),e.writeByte(r[1]),e.writeByte(r[2])}}function sn(e,t){e.writeByte(255&t),e.writeByte(t>>8&255)}function nn(e,t){for(var r=0;r<t.length;r++)e.writeByte(t.charCodeAt(r))}function an(e){return Math.max(Math.ceil(Math.log2(e)),1)}function on(e,t){function r(e,t,r){const i=parseInt(r/2),s=4*t,n=new Uint8Array(4*t);for(let t=0;t<i;++t){const i=t*s,a=(r-t-1)*s;n.set(e.subarray(i,i+s)),e.copyWithin(i,a,a+s),e.set(n,a)}return e}function i(e,t,r,i,s,n,a,o,h,u,l){if(e===Ie){const{x:e,y:i,w:s,h:c}=function(e,t,r,i,s,n,a,o){const h=Math.max(r/a,i/o),[u,l]=[r/h,i/h];let c=s,p=n;return e===A?c+=(a-u)/2:e===E&&(c+=a-u),t===A?p+=(o-l)/2:t===F&&(p+=o-l),{x:c,y:p,w:u,h:l}}(t,r,n,a,o,h,u,l);o=e,h=i,u=s,l=c}if(e===ke){const{x:e,y:o,w:h,h:c}=function(e,t,r,i,s,n,a,o){const h=Math.max(a/s,o/n),[u,l]=[a/h,o/h];let c=r,p=i;return e===A?c+=(s-u)/2:e===E&&(c+=s-u),t===A?p+=(n-l)/2:t===F&&(p+=n-l),{x:c,y:p,w:u,h:l}}(t,r,i,s,n,a,u,l);i=e,s=o,n=h,a=c}return{sx:o,sy:h,sw:u,sh:l,dx:i,dy:s,dw:n,dh:a}}function s(e,t){return e>0&&e<t?e:t}t.loadImage=async function(t,r,i){try{let i=new e.Image(1,1,this);const s=new Request(t,{method:"GET",mode:"cors"}),{data:n,headers:a}=await js(s,"bytes"),o=a.get("content-type");if(null===o&&console.warn("The image you loaded does not have a Content-Type header. If you are using the online editor consider reuploading the asset."),o&&o.includes("image/gif"))await async function(t,r){const i=new Bs(t);r.width=r.canvas.width=i.width,r.height=r.canvas.height=i.height;const s=[],n=i.numFrames();let a=new Uint8ClampedArray(r.width*r.height*4);const o=(t,i)=>{try{i.decodeAndBlitFrameRGBA(t,a)}catch(t){throw e._friendlyFileLoadError(8,r.src),t}};for(let e=0;e<n;e++){const t=i.frameInfo(e),n=r.drawingContext.getImageData(0,0,r.width,r.height);a=n.data.slice(),o(e,i);const h=new ImageData(a,r.width,r.height);r.drawingContext.putImageData(h,0,0);let u=t.delay;0===u&&(u=10),s.push({image:r.drawingContext.getImageData(0,0,r.width,r.height),delay:10*u}),2===t.disposal?r.drawingContext.clearRect(t.x,t.y,t.width,t.height):3===t.disposal&&r.drawingContext.putImageData(n,0,0,t.x,t.y,t.width,t.height)}let h=i.loopCount();return null===h?h=1:0===h&&(h=null),r.drawingContext.putImageData(s[0].image,0,0),s.length>1&&(r.gifProperties={displayIndex:0,loopLimit:h,loopCount:0,frames:s,numFrames:n,playing:!0,timeDisplayed:0,lastChangeTime:0}),r}(n,i);else{const e=new Blob([n]),t=await createImageBitmap(e);i.width=i.canvas.width=t.width,i.height=i.canvas.height=t.height,i.drawingContext.drawImage(t,0,0)}return i.modified=!0,r?r(i):i}catch(r){if(e._friendlyFileLoadError(0,t),"function"==typeof i)return i(r);throw r}},t.saveGif=async function(i,s,n={delay:0,units:"seconds",silent:!1,notificationDuration:0,notificationID:"progressBar",reset:!0}){if("string"!=typeof i)throw TypeError("fileName parameter must be a string");if("number"!=typeof s)throw TypeError("Duration parameter must be a number");const a=n&&n.delay||0,o=n&&n.units||"seconds",h=n&&n.silent||!1,u=n&&n.notificationDuration||0,l=n&&n.notificationID||"progressBar",c=!n||void 0===n.reset||n.reset;if("number"!=typeof a)throw TypeError("Delay parameter must be a number");if("seconds"!==o&&"frames"!==o)throw TypeError('Units parameter must be either "frames" or "seconds"');if("boolean"!=typeof h)throw TypeError("Silent parameter must be a boolean");if("number"!=typeof u)throw TypeError("Notification duration parameter must be a number");if("string"!=typeof l)throw TypeError("Notification ID parameter must be a string");this._recording=!0;let p=this._targetFrameRate;p!==1/0&&void 0!==p&&0!==p||(p=60);let d=1/p*1e3;d=d<20?20:d;const f="seconds"===o?s*p:s,g="seconds"===o?a*p:a;let m,y;c?(m=g,this.frameCount=m,y=f+g):(m=this.frameCount+g,y=m+f);const x=this._renderer._pixelDensity;this.pixelDensity(1);let v,b,_,w=[];for(null!==document.getElementById(l)&&document.getElementById(l).remove(),h||(v=this.createP(""),v.id(l),v.style("font-size","16px"),v.style("font-family","Montserrat"),v.style("background-color","#ffffffa0"),v.style("padding","8px"),v.style("border-radius","10px"),v.position(0,0)),this._renderer instanceof e.RendererGL&&(_=this.drawingContext,b=new Uint8Array(_.drawingBufferWidth*_.drawingBufferHeight*4)),this.noLoop(),await new Promise(requestAnimationFrame);m<y;){let t;this.redraw(),await new Promise(requestAnimationFrame),this._renderer instanceof e.RendererGL?(b=new Uint8Array(_.drawingBufferWidth*_.drawingBufferHeight*4),_.readPixels(0,0,_.drawingBufferWidth,_.drawingBufferHeight,_.RGBA,_.UNSIGNED_BYTE,b),t=r(b,this.width,this.height)):t=this.drawingContext.getImageData(0,0,this.width,this.height).data,w.push(t),m++,h||v.html("Saved frame <b>"+w.length.toString()+"</b> out of "+f.toString()),await new Promise(e=>setTimeout(e,0))}h||v.html("Frames processed, generating color palette..."),this.loop(),this.pixelDensity(x);const C=function(e={}){let{initialCapacity:t=4096,auto:r=!0}=e,i=Hs(t),s=new Uint8Array(256),n=new Int32Array(5003),a=new Int32Array(5003),o=!1;return{reset(){i.reset(),o=!1},finish(){i.writeByte(59)},bytes:()=>i.bytes(),bytesView:()=>i.bytesView(),get buffer(){return i.buffer},get stream(){return i},writeHeader:h,writeFrame(e,t,u,l={}){let{transparent:c=!1,transparentIndex:p=0,delay:d=0,palette:f=null,repeat:g=0,colorDepth:m=8,dispose:y=-1}=l,x=!1;if(r?o||(x=!0,h(),o=!0):x=Boolean(l.first),t=Math.max(0,Math.floor(t)),u=Math.max(0,Math.floor(u)),x){if(!f)throw new Error("First frame must include a { palette } option");(function(e,t,r,i,s=8){let n=128|s-1<<4|an(i.length)-1;sn(e,t),sn(e,r),e.writeBytes([n,0,0])})(i,t,u,f,m),rn(i,f),g>=0&&function(e,t){e.writeByte(33),e.writeByte(255),e.writeByte(11),nn(e,"NETSCAPE2.0"),e.writeByte(3),e.writeByte(1),sn(e,t),e.writeByte(0)}(i,g)}let v=Math.round(d/10);!function(e,t,r,i,s){var n,a;e.writeByte(33),e.writeByte(249),e.writeByte(4),s<0&&(s=0,i=!1),i?(n=1,a=2):(n=0,a=0),t>=0&&(a=7&t),a<<=2,e.writeByte(0|a|n),sn(e,r),e.writeByte(s||0),e.writeByte(0)}(i,y,v,c,p);let b=Boolean(f)&&!x;(function(e,t,r,i){if(e.writeByte(44),sn(e,0),sn(e,0),sn(e,t),sn(e,r),i){let t=0,r=0,s=an(i.length)-1;e.writeByte(128|t|r|s)}else e.writeByte(0)})(i,t,u,b?f:null),b&&rn(i,f),function(e,t,r,i,s=8,n,a,o){!function(e,t,r,i,s=Hs(512),n=new Uint8Array(256),a=new Int32Array(5003),o=new Int32Array(5003)){let h=a.length,u=Math.max(2,i);n.fill(0),o.fill(0),a.fill(-1);let l=0,c=0,p=u+1,d=p,f=!1,g=d,m=(1<<g)-1,y=1<<p-1,x=y+1,v=y+2,b=0,_=r[0],w=0;for(let e=h;e<65536;e*=2)++w;w=8-w,s.writeByte(u),E(y);let C=r.length;for(let e=1;e<C;e++)e:{let t=r[e],i=(t<<12)+_,s=t<<w^_;if(a[s]===i){_=o[s];break e}let n=0===s?1:h-s;for(;a[s]>=0;)if(s-=n,s<0&&(s+=h),a[s]===i){_=o[s];break e}E(_),_=t,v<4096?(o[s]=v++,a[s]=i):(a.fill(-1),v=y+2,f=!0,E(y))}return E(_),E(x),s.writeByte(0),s.bytesView();function E(e){for(l&=qs[c],c>0?l|=e<<c:l=e,c+=g;c>=8;)n[b++]=255&l,b>=254&&(s.writeByte(b),s.writeBytesView(n,0,b),b=0),l>>=8,c-=8;if((v>m||f)&&(f?(g=d,m=(1<<g)-1,f=!1):(++g,m=12===g?1<<g:(1<<g)-1)),e==x){for(;c>0;)n[b++]=255&l,b>=254&&(s.writeByte(b),s.writeBytesView(n,0,b),b=0),l>>=8,c-=8;b>0&&(s.writeByte(b),s.writeBytesView(n,0,b),b=0)}}}(0,0,t,s,e,n,a,o)}(i,e,0,0,m,s,n,a)}};function h(){nn(i,"GIF89a")}}(),E=function(e){let t=new Uint8Array(e.length*e[0].length);for(let r=0;r<e.length;r++)t.set(e[r],r*e[0].length);let r=function(e,t,r={}){let{format:i="rgb565",clearAlpha:s=!0,clearAlphaColor:n=0,clearAlphaThreshold:a=0,oneBitAlpha:o=!1}=r;if(!e||!e.buffer)throw new Error("quantize() expected RGBA Uint8Array data");if(!(e instanceof Uint8Array||e instanceof Uint8ClampedArray))throw new Error("quantize() expected RGBA Uint8Array data");let h=new Uint32Array(e.buffer),u=!1!==r.useSqrt,l="rgba4444"===i,c=function(e,t){let r=new Array("rgb444"===t?4096:65536),i=e.length;if("rgba4444"===t)for(let t=0;t<i;++t){let i=e[t],s=i>>24&255,n=i>>16&255,a=i>>8&255,o=255&i,h=Xs(o,a,n,s),u=h in r?r[h]:r[h]={ac:0,rc:0,gc:0,bc:0,cnt:0,nn:0,fw:0,bk:0,tm:0,mtm:0,err:0};u.rc+=o,u.gc+=a,u.bc+=n,u.ac+=s,u.cnt++}else if("rgb444"===t)for(let t=0;t<i;++t){let i=e[t],s=i>>16&255,n=i>>8&255,a=255&i,o=Ys(a,n,s),h=o in r?r[o]:r[o]={ac:0,rc:0,gc:0,bc:0,cnt:0,nn:0,fw:0,bk:0,tm:0,mtm:0,err:0};h.rc+=a,h.gc+=n,h.bc+=s,h.cnt++}else for(let t=0;t<i;++t){let i=e[t],s=i>>16&255,n=i>>8&255,a=255&i,o=Ws(a,n,s),h=o in r?r[o]:r[o]={ac:0,rc:0,gc:0,bc:0,cnt:0,nn:0,fw:0,bk:0,tm:0,mtm:0,err:0};h.rc+=a,h.gc+=n,h.bc+=s,h.cnt++}return r}(h,i),p=c.length,d=p-1,f=new Uint32Array(p+1);for(var g=0,m=0;m<p;++m){let e=c[m];if(null!=e){var y=1/e.cnt;l&&(e.ac*=y),e.rc*=y,e.gc*=y,e.bc*=y,c[g++]=e}}for(Zs(t)/g<.022&&(u=!1),m=0;m<g-1;++m)c[m].fw=m+1,c[m+1].bk=m,u&&(c[m].cnt=Math.sqrt(c[m].cnt));var x,v,b;for(u&&(c[m].cnt=Math.sqrt(c[m].cnt)),m=0;m<g;++m){Js(c,m);var _=c[m].err;for(v=++f[0];v>1&&!(c[x=f[b=v>>1]].err<=_);v=b)f[v]=x;f[v]=m}var w=g-t;for(m=0;m<w;){for(var C;;){var E=f[1];if((C=c[E]).tm>=C.mtm&&c[C.nn].mtm<=C.tm)break;for(C.mtm==d?E=f[1]=f[f[0]--]:(Js(c,E),C.tm=m),_=c[E].err,v=1;(b=v+v)<=f[0]&&(b<f[0]&&c[f[b]].err>c[f[b+1]].err&&b++,!(_<=c[x=f[b]].err));v=b)f[v]=x;f[v]=E}var D=c[C.nn],A=C.cnt,S=D.cnt;y=1/(A+S),l&&(C.ac=y*(A*C.ac+S*D.ac)),C.rc=y*(A*C.rc+S*D.rc),C.gc=y*(A*C.gc+S*D.gc),C.bc=y*(A*C.bc+S*D.bc),C.cnt+=D.cnt,C.mtm=++m,c[D.bk].fw=D.fw,c[D.fw].bk=D.bk,D.mtm=d}let F=[];var T=0;for(m=0;;++T){let e=Ks(Math.round(c[m].rc),0,255),t=Ks(Math.round(c[m].gc),0,255),r=Ks(Math.round(c[m].bc),0,255),i=255;l&&(i=Ks(Math.round(c[m].ac),0,255),o&&(i=i<=("number"==typeof o?o:127)?0:255),s&&i<=a&&(e=t=r=n,i=0));let h=l?[e,t,r,i]:[e,t,r];if(Qs(F,h)||F.push(h),0==(m=c[m].fw))break}return F}(t,256,{format:"rgba4444",oneBitAlpha:!0});return 256===r.length?r[r.length-1]=[255*Math.random(),255*Math.random(),255*Math.random(),0]:r.push([255*Math.random(),255*Math.random(),255*Math.random(),0]),r}(w),D={},A=e=>{const t=e.length/4,r=new Uint8Array(t);for(let i=0;i<t;i++){const t=e[4*i]<<24|e[4*i+1]<<16|e[4*i+2]<<8|e[4*i+3];void 0===D[t]&&(D[t]=tn(E,e.slice(4*i,4*(i+1)))),r[i]=D[t]}return r},S=E.length-1;let F=[];for(let e=0;e<w.length;e++){const t=A(w[e]),r=t.slice();if(0===e)C.writeFrame(t,this.width,this.height,{palette:E,delay:d,dispose:1});else{for(let e=0;e<t.length;e++)t[e]===F[e]&&(t[e]=S);C.writeFrame(t,this.width,this.height,{delay:d,transparent:!0,transparentIndex:S,dispose:1})}F=r,h||v.html("Rendered frame <b>"+e.toString()+"</b> out of "+f.toString()),await new Promise(e=>setTimeout(e,0))}C.finish();const T=C.bytesView(),M=new Blob([T],{type:"image/gif"});w=[],this._recording=!1,this.loop(),h||(v.html("Done. Downloading your gif!🌸"),u>0&&setTimeout(()=>v.remove(),1e3*u)),t.downloadFile(M,i,"gif")},t.image=function(e,t,r,n,a,o,h,u,l,c,p,d){let f=e.width,g=e.height;d=d||A,p=p||A,e.elt&&(f=void 0!==f?f:e.elt.width,g=void 0!==g?g:e.elt.height),e.elt&&e.elt.videoWidth&&!e.canvas&&(f=void 0!==f?f:e.elt.videoWidth,g=void 0!==g?g:e.elt.videoHeight);let m=t,y=r,x=n||f,v=a||g,b=o||0,_=h||0,w=void 0!==u?u:f,C=void 0!==l?l:g;w=s(w,f),C=s(C,g);let E=1;e.elt&&!e.canvas&&e.elt.style.width&&(E=e.elt.videoWidth&&!n?e.elt.videoWidth:e.elt.width,E/=parseInt(e.elt.style.width,10)),b*=E,_*=E,C*=E,w*=E;let D=Ss(m,y,x,v,this._renderer.states.imageMode);D=i(c,p,d,D.x,D.y,D.w,D.h,b,_,w,C),this._renderer.image(e,D.sx,D.sy,D.sw,D.sh,D.dx,D.dy,D.dw,D.dh)},t.tint=function(...e){const t=this.color(...e);this._renderer.states.setValue("tint",t._getRGBA([255,255,255,255]))},t.noTint=function(){this._renderer.states.setValue("tint",null)},t.imageMode=function(e){e!==_&&e!==w&&e!==A||this._renderer.states.setValue("imageMode",e)}}function hn(e,t){t.blend=function(...t){this._renderer?this._renderer.blend(...t):e.Renderer2D.prototype.blend.apply(this,t)},t.copy=function(...e){let r,i,s,n,a,o,h,u,l;if(9===e.length)r=e[0],i=e[1],s=e[2],n=e[3],a=e[4],o=e[5],h=e[6],u=e[7],l=e[8];else{if(8!==e.length)throw new Error("Signature not supported");r=this,i=e[0],s=e[1],n=e[2],a=e[3],o=e[4],h=e[5],u=e[6],l=e[7]}t._copyHelper(this,r,i,s,n,a,o,h,u,l)},t._copyHelper=(e,t,r,i,s,n,a,o,h,u)=>{const l=t.canvas.width/t.width;let c=0,p=0;t._renderer&&t._renderer.isP3D&&(c=t.width/2,p=t.height/2),e._renderer&&e._renderer.isP3D?(e.push(),e.resetMatrix(),e.noLights(),e.blendMode(e.BLEND),e.imageMode(e.CORNER),e._renderer.image(t,r+c,i+p,s,n,a,o,h,u),e.pop()):e.drawingContext.drawImage(t.canvas,l*(r+c),l*(i+p),l*s,l*n,a,o,h,u)},t.getFilterGraphicsLayer=function(){return this._renderer.getFilterGraphicsLayer()},t.filter=function(...t){let{shader:r,operation:i,value:s,useWebGL:n}=function(...t){let r={shader:void 0,operation:void 0,value:void 0,useWebGL:!0};return t[0]instanceof e.Shader?(r.shader=t[0],r):(r.operation=t[0],t.length>1&&"number"==typeof t[1]&&(r.value=t[1]),!1===t[t.length-1]&&(r.useWebGL=!1),r)}(...t);this._renderer.isP3D&&r?this._renderer.filter(r):n||this._renderer.isP3D?(!n&&this._renderer.isP3D&&console.warn("filter() with useWebGL=false is not supported in WEBGL"),this._renderer.isP3D?this._renderer.filter(i,s):(r?this._renderer.filterRenderer.setOperation(i,s,r):this._renderer.filterRenderer.setOperation(i,s),this._renderer.filterRenderer.applyFilter())):void 0!==this.canvas?Ri.apply(this.canvas,Ri[i],s):Ri.apply(this.elt,Ri[i],s)},t.get=function(e,t,r,i){return this._renderer.get(...arguments)},t.loadPixels=function(...e){return this._renderer.loadPixels()},t.set=function(e,t,r){this._renderer.set(e,t,r)},t.updatePixels=function(e,t,r,i){0!==this.pixels.length&&this._renderer.updatePixels(e,t,r,i)}}void 0!==p5&&on(p5,p5.prototype),void 0!==p5&&hn(p5,p5.prototype);class un{#g=null;constructor(...e){if(this.constructor===un)throw new Error("Class is of abstract type and can't be instantiated")}}const ln=e=>{if(Math.sqrt(e.length)%1!=0)throw new Error("Array length must be a perfect square.");return!0};let cn=Array,pn=e=>Array.isArray(e);"undefined"!=typeof Float32Array&&(cn=Float32Array,pn=e=>Array.isArray(e)||e instanceof Float32Array);class dn extends un{matrix;#m;constructor(...e){if(super(...e),pn(e[0])&&ln(e[0])){const t=Math.sqrt(e[0].length);this.#m=t,this.matrix=cn.from(e[0])}else"number"==typeof e[0]&&(this.#m=Number(e[0]),this.matrix=this.#y(e[0]));return this}get mat3(){return 3===this.#m?this.matrix:void 0}get mat4(){return 4===this.#m?this.matrix:void 0}add(e){if(this.matrix.length!==e.matrix.length)throw new Error("Matrices must be of the same dimension to add.");for(let t=0;t<this.matrix.length;t++)this.matrix[t]+=e.matrix[t];return this}setElement(e,t){return e>=0&&e<this.matrix.length&&(this.matrix[e]=t),this}reset(){return this.matrix=this.#y(this.#m),this}set(e){let t=cn.from([...arguments]);return e instanceof dn?t=cn.from(e.matrix):pn(e)&&(t=cn.from(e)),t.length!==this.matrix.length?(p5._friendlyError(`Expected same dimensions values but received different ${t.length}.`,"p5.Matrix.set"),this):(this.matrix=t,this)}get(){return new dn(this.matrix)}copy(){return new dn(this.matrix)}clone(){return this.copy()}diagonal(){const e=[];for(let t=0;t<this.#m;t++)e.push(this.matrix[t*(this.#m+1)]);return e}row(e){const t=[];for(let r=0;r<this.#m;r++)t.push(this.matrix[r*this.#m+e]);return new Xi(...t)}column(e){const t=[];for(let r=0;r<this.#m;r++)t.push(this.matrix[e*this.#m+r]);return new Xi(...t)}transpose(e){return 4===this.#m?this.#x(e):3===this.#m?this.#v(e):this.#b(e)}mult(e){let t;return e===this||e===this.matrix?t=this.copy().matrix:e instanceof dn?t=e.matrix:pn(e)&&ln(e)?t=e:ln(Array.from(arguments))&&(t=Array.from(arguments)),4===this.#m&&16===t.length?this.#_(t):3===this.#m&&9===t.length?this.#w(t):this.#C(t)}multiplyVec(e,t){void 0===t&&(t=e.copy());for(let r=0;r<this.#m;r++)t.values[r]=this.row(r).dot(e);return t}invert(e){if(4===this.#m)return this.#E(e);if(3===this.#m)return this.#D(e);throw new Error("Invert is not implemented for N>4 at the moment, we are working on it")}createSubMatrix3x3(){if(4===this.#m){const e=new dn(3);return e.mat3[0]=this.matrix[0],e.mat3[1]=this.matrix[1],e.mat3[2]=this.matrix[2],e.mat3[3]=this.matrix[4],e.mat3[4]=this.matrix[5],e.mat3[5]=this.matrix[6],e.mat3[6]=this.matrix[8],e.mat3[7]=this.matrix[9],e.mat3[8]=this.matrix[10],e}throw new Error("Matrix dimension must be 4 to create a 3x3 submatrix.")}inverseTranspose4x4({mat4:e}){if(3!==this.#m)throw new Error("This function only works with 3×3 matrices.");this.matrix[0]=e[0],this.matrix[1]=e[1],this.matrix[2]=e[2],this.matrix[3]=e[4],this.matrix[4]=e[5],this.matrix[5]=e[6],this.matrix[6]=e[8],this.matrix[7]=e[9],this.matrix[8]=e[10];const t=this.invert();if(t)t.transpose(this.matrix);else for(let e=0;e<9;e++)this.matrix[e]=0;return this}apply(e){let t;if(e===this||e===this.matrix)t=this.copy().matrix;else if(e instanceof dn)t=e.matrix;else if(pn(e))t=e;else{if(16!==arguments.length)return;t=arguments}const r=this.matrix,i=r[0],s=r[4],n=r[8],a=r[12];r[0]=t[0]*i+t[1]*s+t[2]*n+t[3]*a,r[4]=t[4]*i+t[5]*s+t[6]*n+t[7]*a,r[8]=t[8]*i+t[9]*s+t[10]*n+t[11]*a,r[12]=t[12]*i+t[13]*s+t[14]*n+t[15]*a;const o=r[1],h=r[5],u=r[9],l=r[13];r[1]=t[0]*o+t[1]*h+t[2]*u+t[3]*l,r[5]=t[4]*o+t[5]*h+t[6]*u+t[7]*l,r[9]=t[8]*o+t[9]*h+t[10]*u+t[11]*l,r[13]=t[12]*o+t[13]*h+t[14]*u+t[15]*l;const c=r[2],p=r[6],d=r[10],f=r[14];r[2]=t[0]*c+t[1]*p+t[2]*d+t[3]*f,r[6]=t[4]*c+t[5]*p+t[6]*d+t[7]*f,r[10]=t[8]*c+t[9]*p+t[10]*d+t[11]*f,r[14]=t[12]*c+t[13]*p+t[14]*d+t[15]*f;const g=r[3],m=r[7],y=r[11],x=r[15];return r[3]=t[0]*g+t[1]*m+t[2]*y+t[3]*x,r[7]=t[4]*g+t[5]*m+t[6]*y+t[7]*x,r[11]=t[8]*g+t[9]*m+t[10]*y+t[11]*x,r[15]=t[12]*g+t[13]*m+t[14]*y+t[15]*x,this}scale(e,t,r){return e instanceof Xi?(t=e.y,r=e.z,e=e.x):e instanceof Array&&(t=e[1],r=e[2],e=e[0]),this.matrix[0]*=e,this.matrix[1]*=e,this.matrix[2]*=e,this.matrix[3]*=e,this.matrix[4]*=t,this.matrix[5]*=t,this.matrix[6]*=t,this.matrix[7]*=t,this.matrix[8]*=r,this.matrix[9]*=r,this.matrix[10]*=r,this.matrix[11]*=r,this}rotate4x4(e,t,r,i){t instanceof Xi?(r=t.y,i=t.z,t=t.x):t instanceof Array&&(r=t[1],i=t[2],t=t[0]);const s=Math.sqrt(t*t+r*r+i*i);t*=1/s,r*=1/s,i*=1/s;const n=this.matrix[0],a=this.matrix[1],o=this.matrix[2],h=this.matrix[3],u=this.matrix[4],l=this.matrix[5],c=this.matrix[6],p=this.matrix[7],d=this.matrix[8],f=this.matrix[9],g=this.matrix[10],m=this.matrix[11],y=Math.sin(e),x=Math.cos(e),v=1-x,b=t*t*v+x,_=r*t*v+i*y,w=i*t*v-r*y,C=t*r*v-i*y,E=r*r*v+x,D=i*r*v+t*y,A=t*i*v+r*y,S=r*i*v-t*y,F=i*i*v+x;return this.matrix[0]=n*b+u*_+d*w,this.matrix[1]=a*b+l*_+f*w,this.matrix[2]=o*b+c*_+g*w,this.matrix[3]=h*b+p*_+m*w,this.matrix[4]=n*C+u*E+d*D,this.matrix[5]=a*C+l*E+f*D,this.matrix[6]=o*C+c*E+g*D,this.matrix[7]=h*C+p*E+m*D,this.matrix[8]=n*A+u*S+d*F,this.matrix[9]=a*A+l*S+f*F,this.matrix[10]=o*A+c*S+g*F,this.matrix[11]=h*A+p*S+m*F,this}translate(e){const t=e[0],r=e[1],i=e[2]||0;return this.matrix[12]+=this.matrix[0]*t+this.matrix[4]*r+this.matrix[8]*i,this.matrix[13]+=this.matrix[1]*t+this.matrix[5]*r+this.matrix[9]*i,this.matrix[14]+=this.matrix[2]*t+this.matrix[6]*r+this.matrix[10]*i,this.matrix[15]+=this.matrix[3]*t+this.matrix[7]*r+this.matrix[11]*i,this}rotateX(e){this.rotate4x4(e,1,0,0)}rotateY(e){this.rotate4x4(e,0,1,0)}rotateZ(e){this.rotate4x4(e,0,0,1)}perspective(e,t,r,i){const s=1/Math.tan(e/2),n=1/(r-i);return this.matrix[0]=s/t,this.matrix[1]=0,this.matrix[2]=0,this.matrix[3]=0,this.matrix[4]=0,this.matrix[5]=s,this.matrix[6]=0,this.matrix[7]=0,this.matrix[8]=0,this.matrix[9]=0,this.matrix[10]=(i+r)*n,this.matrix[11]=-1,this.matrix[12]=0,this.matrix[13]=0,this.matrix[14]=2*i*r*n,this.matrix[15]=0,this}ortho(e,t,r,i,s,n){const a=1/(e-t),o=1/(r-i),h=1/(s-n);return this.matrix[0]=-2*a,this.matrix[1]=0,this.matrix[2]=0,this.matrix[3]=0,this.matrix[4]=0,this.matrix[5]=-2*o,this.matrix[6]=0,this.matrix[7]=0,this.matrix[8]=0,this.matrix[9]=0,this.matrix[10]=2*h,this.matrix[11]=0,this.matrix[12]=(e+t)*a,this.matrix[13]=(i+r)*o,this.matrix[14]=(n+s)*h,this.matrix[15]=1,this}multiplyVec4(e,t,r,i){const s=new Array(4),n=this.matrix;return s[0]=n[0]*e+n[4]*t+n[8]*r+n[12]*i,s[1]=n[1]*e+n[5]*t+n[9]*r+n[13]*i,s[2]=n[2]*e+n[6]*t+n[10]*r+n[14]*i,s[3]=n[3]*e+n[7]*t+n[11]*r+n[15]*i,s}multiplyPoint({x:e,y:t,z:r}){const i=this.multiplyVec4(e,t,r,1);return new Xi(i[0],i[1],i[2])}multiplyAndNormalizePoint({x:e,y:t,z:r}){const i=this.multiplyVec4(e,t,r,1);return i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],new Xi(i[0],i[1],i[2])}multiplyDirection({x:e,y:t,z:r}){const i=this.multiplyVec4(e,t,r,0);return new Xi(i[0],i[1],i[2])}multiplyVec3(e,t){return void 0===t&&(t=e.copy()),t.x=this.row(0).dot(e),t.y=this.row(1).dot(e),t.z=this.row(2).dot(e),t}#y(e){if(3===e)return new cn([1,0,0,0,1,0,0,0,1]);if(4===e)return new cn([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);const t=new cn(e*e).fill(0);for(let r=0;r<e;r++)t[r*e+r]=1;return t}#_(e){let t=this.matrix[0],r=this.matrix[1],i=this.matrix[2],s=this.matrix[3];return this.matrix[0]=t*e[0]+r*e[4]+i*e[8]+s*e[12],this.matrix[1]=t*e[1]+r*e[5]+i*e[9]+s*e[13],this.matrix[2]=t*e[2]+r*e[6]+i*e[10]+s*e[14],this.matrix[3]=t*e[3]+r*e[7]+i*e[11]+s*e[15],t=this.matrix[4],r=this.matrix[5],i=this.matrix[6],s=this.matrix[7],this.matrix[4]=t*e[0]+r*e[4]+i*e[8]+s*e[12],this.matrix[5]=t*e[1]+r*e[5]+i*e[9]+s*e[13],this.matrix[6]=t*e[2]+r*e[6]+i*e[10]+s*e[14],this.matrix[7]=t*e[3]+r*e[7]+i*e[11]+s*e[15],t=this.matrix[8],r=this.matrix[9],i=this.matrix[10],s=this.matrix[11],this.matrix[8]=t*e[0]+r*e[4]+i*e[8]+s*e[12],this.matrix[9]=t*e[1]+r*e[5]+i*e[9]+s*e[13],this.matrix[10]=t*e[2]+r*e[6]+i*e[10]+s*e[14],this.matrix[11]=t*e[3]+r*e[7]+i*e[11]+s*e[15],t=this.matrix[12],r=this.matrix[13],i=this.matrix[14],s=this.matrix[15],this.matrix[12]=t*e[0]+r*e[4]+i*e[8]+s*e[12],this.matrix[13]=t*e[1]+r*e[5]+i*e[9]+s*e[13],this.matrix[14]=t*e[2]+r*e[6]+i*e[10]+s*e[14],this.matrix[15]=t*e[3]+r*e[7]+i*e[11]+s*e[15],this}#C(e){if(e.length!==this.matrix.length)throw new Error("Matrices must be of the same dimension to multiply.");const t=new cn(this.matrix.length).fill(0);for(let r=0;r<this.#m;r++)for(let i=0;i<this.#m;i++)for(let s=0;s<this.#m;s++)t[r*this.#m+i]+=this.matrix[r*this.#m+s]*e[s*this.#m+i];return this.matrix=t,this}#w(e){let t=this.mat3[0],r=this.mat3[1],i=this.mat3[2];return this.mat3[0]=t*e[0]+r*e[3]+i*e[6],this.mat3[1]=t*e[1]+r*e[4]+i*e[7],this.mat3[2]=t*e[2]+r*e[5]+i*e[8],t=this.mat3[3],r=this.mat3[4],i=this.mat3[5],this.mat3[3]=t*e[0]+r*e[3]+i*e[6],this.mat3[4]=t*e[1]+r*e[4]+i*e[7],this.mat3[5]=t*e[2]+r*e[5]+i*e[8],t=this.mat3[6],r=this.mat3[7],i=this.mat3[8],this.mat3[6]=t*e[0]+r*e[3]+i*e[6],this.mat3[7]=t*e[1]+r*e[4]+i*e[7],this.mat3[8]=t*e[2]+r*e[5]+i*e[8],this}#b(){const e=this.#m;for(let t=0;t<e;t++)for(let r=0;r<e;r++)this.matrix[t*e+r]=this.matrix[r*e+t];return this}#x(e){let t,r,i,s,n,a;return console.log("====> 4x4"),e instanceof dn?(t=e.matrix[1],r=e.matrix[2],i=e.matrix[3],s=e.matrix[6],n=e.matrix[7],a=e.matrix[11],this.matrix[0]=e.matrix[0],this.matrix[1]=e.matrix[4],this.matrix[2]=e.matrix[8],this.matrix[3]=e.matrix[12],this.matrix[4]=t,this.matrix[5]=e.matrix[5],this.matrix[6]=e.matrix[9],this.matrix[7]=e.matrix[13],this.matrix[8]=r,this.matrix[9]=s,this.matrix[10]=e.matrix[10],this.matrix[11]=e.matrix[14],this.matrix[12]=i,this.matrix[13]=n,this.matrix[14]=a,this.matrix[15]=e.matrix[15]):pn(e)&&(t=e[1],r=e[2],i=e[3],s=e[6],n=e[7],a=e[11],this.matrix[0]=e[0],this.matrix[1]=e[4],this.matrix[2]=e[8],this.matrix[3]=e[12],this.matrix[4]=t,this.matrix[5]=e[5],this.matrix[6]=e[9],this.matrix[7]=e[13],this.matrix[8]=r,this.matrix[9]=s,this.matrix[10]=e[10],this.matrix[11]=e[14],this.matrix[12]=i,this.matrix[13]=n,this.matrix[14]=a,this.matrix[15]=e[15]),this}#v(e){void 0===e&&(e=this.mat3);const t=e[1],r=e[2],i=e[5];return this.mat3[0]=e[0],this.mat3[1]=e[3],this.mat3[2]=e[6],this.mat3[3]=t,this.mat3[4]=e[4],this.mat3[5]=e[7],this.mat3[6]=r,this.mat3[7]=i,this.mat3[8]=e[8],this}#E(e){let t,r,i,s,n,a,o,h,u,l,c,p,d,f,g,m;e instanceof dn?(t=e.matrix[0],r=e.matrix[1],i=e.matrix[2],s=e.matrix[3],n=e.matrix[4],a=e.matrix[5],o=e.matrix[6],h=e.matrix[7],u=e.matrix[8],l=e.matrix[9],c=e.matrix[10],p=e.matrix[11],d=e.matrix[12],f=e.matrix[13],g=e.matrix[14],m=e.matrix[15]):pn(e)&&(t=e[0],r=e[1],i=e[2],s=e[3],n=e[4],a=e[5],o=e[6],h=e[7],u=e[8],l=e[9],c=e[10],p=e[11],d=e[12],f=e[13],g=e[14],m=e[15]);const y=t*a-r*n,x=t*o-i*n,v=t*h-s*n,b=r*o-i*a,_=r*h-s*a,w=i*h-s*o,C=u*f-l*d,E=u*g-c*d,D=u*m-p*d,A=l*g-c*f,S=l*m-p*f,F=c*m-p*g;let T=y*F-x*S+v*A+b*D-_*E+w*C;return T?(T=1/T,this.matrix[0]=(a*F-o*S+h*A)*T,this.matrix[1]=(i*S-r*F-s*A)*T,this.matrix[2]=(f*w-g*_+m*b)*T,this.matrix[3]=(c*_-l*w-p*b)*T,this.matrix[4]=(o*D-n*F-h*E)*T,this.matrix[5]=(t*F-i*D+s*E)*T,this.matrix[6]=(g*v-d*w-m*x)*T,this.matrix[7]=(u*w-c*v+p*x)*T,this.matrix[8]=(n*S-a*D+h*C)*T,this.matrix[9]=(r*D-t*S-s*C)*T,this.matrix[10]=(d*_-f*v+m*y)*T,this.matrix[11]=(l*v-u*_-p*y)*T,this.matrix[12]=(a*E-n*A-o*C)*T,this.matrix[13]=(t*A-r*E+i*C)*T,this.matrix[14]=(f*x-d*b-g*y)*T,this.matrix[15]=(u*b-l*x+c*y)*T,this):null}#D(){const e=this.mat3[0],t=this.mat3[1],r=this.mat3[2],i=this.mat3[3],s=this.mat3[4],n=this.mat3[5],a=this.mat3[6],o=this.mat3[7],h=this.mat3[8],u=h*s-n*o,l=-h*i+n*a,c=o*i-s*a;let p=e*u+t*l+r*c;return p?(p=1/p,this.mat3[0]=u*p,this.mat3[1]=(-h*t+r*o)*p,this.mat3[2]=(n*t-r*s)*p,this.mat3[3]=l*p,this.mat3[4]=(h*e-r*a)*p,this.mat3[5]=(-n*e+r*i)*p,this.mat3[6]=c*p,this.mat3[7]=(-o*e+t*a)*p,this.mat3[8]=(s*e-t*i)*p,this):null}#A(){if(4!==this.#m)throw new Error("Determinant is only implemented for 4x4 matrices. We are working on it.");const e=this.matrix[0]*this.matrix[5]-this.matrix[1]*this.matrix[4],t=this.matrix[0]*this.matrix[6]-this.matrix[2]*this.matrix[4],r=this.matrix[0]*this.matrix[7]-this.matrix[3]*this.matrix[4],i=this.matrix[1]*this.matrix[6]-this.matrix[2]*this.matrix[5],s=this.matrix[1]*this.matrix[7]-this.matrix[3]*this.matrix[5],n=this.matrix[2]*this.matrix[7]-this.matrix[3]*this.matrix[6],a=this.matrix[8]*this.matrix[13]-this.matrix[9]*this.matrix[12],o=this.matrix[8]*this.matrix[14]-this.matrix[10]*this.matrix[12],h=this.matrix[8]*this.matrix[15]-this.matrix[11]*this.matrix[12],u=this.matrix[9]*this.matrix[14]-this.matrix[10]*this.matrix[13],l=this.matrix[9]*this.matrix[15]-this.matrix[11]*this.matrix[13];return e*(this.matrix[10]*this.matrix[15]-this.matrix[11]*this.matrix[14])-t*l+r*u+i*h-s*o+n*a}}function gn(e,t){e.Matrix=dn}void 0!==p5&&gn(p5);class mn{constructor(e=128){this.length=0,this.data=new Float32Array(e),this.initialLength=e}dataArray(){return this.subArray(0,this.length)}clear(){this.length=0}rescale(){if(this.length<this.data.length/2){const e=1<<Math.ceil(Math.log2(this.length)),t=new Float32Array(e);t.set(this.data.subarray(0,this.length),0),this.data=t}}reset(){this.clear(),this.data=new Float32Array(this.initialLength)}push(...e){this.ensureLength(this.length+e.length),this.data.set(e,this.length),this.length+=e.length}slice(e,t){return this.data.slice(e,Math.min(t,this.length))}subArray(e,t){return this.data.subarray(e,Math.min(t,this.length))}ensureLength(e){for(;this.data.length<e;){const e=new Float32Array(2*this.data.length);e.set(this.data,0),this.data=e}}}function yn(e,t){e.DataArray=mn}void 0!==p5&&yn(p5);class xn{constructor(e,t,r,i){this.renderer=i,this.vertices=[],this.boundingBoxCache=null,this.lineVertices=new mn,this.lineTangentsIn=new mn,this.lineTangentsOut=new mn,this.lineSides=new mn,this.vertexNormals=[],this.faces=[],this.uvs=[],this.edges=[],this.vertexColors=[],this.vertexStrokeColors=[],this.userVertexProperties={},this.lineVertexColors=new mn,this.detailX=void 0!==e?e:1,this.detailY=void 0!==t?t:1,this.dirtyFlags={},this._hasFillTransparency=void 0,this._hasStrokeTransparency=void 0,this.gid=`_p5_Geometry_${xn.nextId}`,xn.nextId++,r instanceof Function&&r.call(this)}calculateBoundingBox(){if(this.boundingBoxCache)return this.boundingBoxCache;let e=new Xi(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),t=new Xi(Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE);for(let r=0;r<this.vertices.length;r++){let i=this.vertices[r];e.x=Math.min(e.x,i.x),e.y=Math.min(e.y,i.y),e.z=Math.min(e.z,i.z),t.x=Math.max(t.x,i.x),t.y=Math.max(t.y,i.y),t.z=Math.max(t.z,i.z)}let r=new Xi(t.x-e.x,t.y-e.y,t.z-e.z),i=new Xi((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2);return this.boundingBoxCache={min:e,max:t,size:r,offset:i},this.boundingBoxCache}reset(){this.renderer?.onReset?.(this),this._hasFillTransparency=void 0,this._hasStrokeTransparency=void 0,this.lineVertices.clear(),this.lineTangentsIn.clear(),this.lineTangentsOut.clear(),this.lineSides.clear(),this.vertices.length=0,this.edges.length=0,this.vertexColors.length=0,this.vertexStrokeColors.length=0,this.lineVertexColors.clear(),this.vertexNormals.length=0,this.uvs.length=0;for(const e in this.userVertexProperties)this.userVertexProperties[e].delete();this.userVertexProperties={},this.dirtyFlags={}}hasFillTransparency(){if(void 0===this._hasFillTransparency){this._hasFillTransparency=!1;for(let e=0;e<this.vertexColors.length;e+=4)if(this.vertexColors[e+3]<1){this._hasFillTransparency=!0;break}}return this._hasFillTransparency}hasStrokeTransparency(){if(void 0===this._hasStrokeTransparency){this._hasStrokeTransparency=!1;for(let e=0;e<this.lineVertexColors.length;e+=4)if(this.lineVertexColors[e+3]<1){this._hasStrokeTransparency=!0;break}}return this._hasStrokeTransparency}clearColors(){return this.vertexColors=[],this}saveObj(e="model.obj"){let t="";if(this.vertices.forEach(e=>{t+=`v ${e.x} ${e.y} ${e.z}\n`}),this.uvs&&this.uvs.length>0)for(let e=0;e<this.uvs.length;e+=2)t+=`vt ${this.uvs[e]} ${this.uvs[e+1]}\n`;this.vertexNormals&&this.vertexNormals.length>0&&this.vertexNormals.forEach(e=>{t+=`vn ${e.x} ${e.y} ${e.z}\n`}),this.faces.forEach(e=>{let r="f";e.forEach(e=>{r+=" ",r+=e+1,(this.vertexNormals.length>0||this.uvs.length>0)&&(r+="/",this.uvs.length>0&&(r+=e+1),r+="/",this.vertexNormals.length>0&&(r+=e+1))}),t+=r+"\n"}),Gi(new Blob([t],{type:"text/plain"}),e,"obj")}saveStl(e="model.stl",{binary:t=!1}={}){let r,i=e.substring(0,e.lastIndexOf(".")),s=[];for(let e of this.faces){const t=Xi.sub(this.vertices[e[1]],this.vertices[e[0]]),r=Xi.sub(this.vertices[e[2]],this.vertices[e[0]]),i=t.y*r.z-t.z*r.y,n=t.z*r.x-t.x*r.z,a=t.x*r.y-t.y*r.x;s.push(new Xi(i,n,a).normalize())}if(t){let e=80;const t=2*this.faces.length+3*this.faces.length*4*4+80+4,i=new ArrayBuffer(t);r=new DataView(i),r.setUint32(e,this.faces.length,!0),e+=4;for(const[t,i]of Object.entries(this.faces)){const n=s[t];r.setFloat32(e,n.x,!0),e+=4,r.setFloat32(e,n.y,!0),e+=4,r.setFloat32(e,n.z,!0),e+=4;for(let t of i){const i=this.vertices[t];r.setFloat32(e,i.x,!0),e+=4,r.setFloat32(e,i.y,!0),e+=4,r.setFloat32(e,i.z,!0),e+=4}r.setUint16(e,0,!0),e+=2}}else{r="solid "+i+"\n";for(const[e,t]of Object.entries(this.faces)){const i=s[e];r+=" facet norm "+i.x+" "+i.y+" "+i.z+"\n",r+=" outer loop\n";for(let e of t){const t=this.vertices[e];r+=" vertex "+t.x+" "+t.y+" "+t.z+"\n"}r+=" endloop\n",r+=" endfacet\n"}r+="endsolid "+i+"\n"}Gi(new Blob([r],{type:"text/plain"}),e,"stl")}flipU(){this.uvs=this.uvs.flat().map((e,t)=>t%2==0?1-e:e)}flipV(){this.uvs=this.uvs.flat().map((e,t)=>t%2==0?e:1-e)}computeFaces(){this.faces.length=0;const e=this.detailX+1;let t,r,i,s;for(let n=0;n<this.detailY;n++)for(let a=0;a<this.detailX;a++)t=n*e+a,r=n*e+a+1,i=(n+1)*e+a+1,s=(n+1)*e+a,this.faces.push([t,r,s]),this.faces.push([s,r,i]);return this}_getFaceNormal(e){const t=this.faces[e],r=this.vertices[t[0]],i=this.vertices[t[1]],s=this.vertices[t[2]],n=Xi.sub(i,r),a=Xi.sub(s,r),o=Xi.cross(n,a),h=Xi.mag(o);let u=h/(Xi.mag(n)*Xi.mag(a));return 0===u||isNaN(u)?(console.warn("p5.Geometry.prototype._getFaceNormal:","face has colinear sides or a repeated vertex"),o):(u>1&&(u=1),o.mult(Math.asin(u)/h))}computeNormals(e=De,{roundToPrecision:t=3}={}){const r=this.vertexNormals;let i=this.vertices;const s=this.faces;let n;if(e===Ae){const e={},r=[],n=Math.pow(10,t),a=e=>Math.round(e*n)/n,o=e=>`${a(e.x)},${a(e.y)},${a(e.z)}`;for(let t=0;t<i.length;t++){const s=i[t],n=o(s);void 0===e[n]&&(e[n]=r.length,r.push(s))}s.forEach(t=>{for(let r=0;r<3;++r){const s=t[r],n=i[s],a=o(n);t[r]=e[a]}}),this.edges.forEach(t=>{for(let r=0;r<2;++r){const s=t[r],n=i[s],a=o(n);t[r]=e[a]}}),this.vertices=i=r}for(r.length=0,n=0;n<i.length;++n)r.push(new Xi);for(s.forEach((e,t)=>{const i=this._getFaceNormal(t);for(let t=0;t<3;++t){const s=e[t];r[s].add(i)}}),n=0;n<i.length;++n)r[n].normalize();return this}averageNormals(){for(let e=0;e<=this.detailY;e++){const t=this.detailX+1;let r=Xi.add(this.vertexNormals[e*t],this.vertexNormals[e*t+this.detailX]);r=Xi.div(r,2),this.vertexNormals[e*t]=r,this.vertexNormals[e*t+this.detailX]=r}return this}averagePoleNormals(){let e=new Xi(0,0,0);for(let t=0;t<this.detailX;t++)e.add(this.vertexNormals[t]);e=Xi.div(e,this.detailX);for(let t=0;t<this.detailX;t++)this.vertexNormals[t]=e;e=new Xi(0,0,0);for(let t=this.vertices.length-1;t>this.vertices.length-1-this.detailX;t--)e.add(this.vertexNormals[t]);e=Xi.div(e,this.detailX);for(let t=this.vertices.length-1;t>this.vertices.length-1-this.detailX;t--)this.vertexNormals[t]=e;return this}_makeTriangleEdges(){this.edges.length=0;for(let e=0;e<this.faces.length;e++)this.edges.push([this.faces[e][0],this.faces[e][1]]),this.edges.push([this.faces[e][1],this.faces[e][2]]),this.edges.push([this.faces[e][2],this.faces[e][0]]);return this}makeEdgesFromFaces(){this._makeTriangleEdges()}_edgesToVertices(){this.lineVertices.clear(),this.lineTangentsIn.clear(),this.lineTangentsOut.clear(),this.lineSides.clear();const e=new Map,t=new Set;let r;for(let i=0;i<this.edges.length;i++){const s=this.edges[i-1],n=this.edges[i],a=n[0]===n[1],o=this.vertices[n[0]],h=this.vertices[n[1]],u=this.vertexStrokeColors.length>0&&s?this.vertexStrokeColors.slice(4*s[1],4*(s[1]+1)):[0,0,0,0],l=this.vertexStrokeColors.length>0?this.vertexStrokeColors.slice(4*n[0],4*(n[0]+1)):[0,0,0,0],c=this.vertexStrokeColors.length>0?this.vertexStrokeColors.slice(4*n[1],4*(n[1]+1)):[0,0,0,0],p=a?new Xi(0,1,0):h.copy().sub(o).normalize(),d=p.magSq()>0;if(d&&this._addSegment(o,h,l,c,p),!this.renderer?._simpleLines){if(i>0&&s[1]===n[0])t.has(n[0])||(t.add(n[0]),e.delete(n[0]),r&&d&&p.dot(r)<1-1e-8&&this._addJoin(o,r,p,l));else if(a)this._addCap(o,p.copy().mult(-1),l),this._addCap(o,p,l);else{if(d&&!t.has(n[0])){const r=e.get(n[0]);r?(this._addJoin(o,r.dir,p,l),e.delete(n[0]),t.add(n[0])):e.set(n[0],{point:o,dir:p.copy().mult(-1),color:l})}if(!a&&r&&!t.has(s[1])){const i=e.get(s[1]);i?(this._addJoin(this.vertices[s[1]],r,i.dir.copy().mult(-1),u),e.delete(s[1]),t.add(s[1])):e.set(s[1],{point:this.vertices[s[1]],dir:r,color:u}),r=void 0}}if(i===this.edges.length-1&&!t.has(n[1])){const r=e.get(n[1]);r?(this._addJoin(h,p,r.dir.copy().mult(-1),c),e.delete(n[1]),t.add(n[1])):e.set(n[1],{point:h,dir:p,color:c})}d&&(r=p)}}for(const{point:t,dir:r,color:i}of e.values())this._addCap(t,r,i);return this}_addSegment(e,t,r,i,s){const n=e.array(),a=t.array(),o=s.array();this.lineSides.push(1,1,-1,1,-1,-1);for(const e of[this.lineTangentsIn,this.lineTangentsOut])for(let t=0;t<6;t++)e.push(...o);return this.lineVertices.push(...n,...a,...n,...a,...a,...n),this.renderer?._simpleLines||this.lineVertexColors.push(...r,...i,...r,...i,...i,...r),this}_addCap(e,t,r){const i=e.array(),s=t.array(),n=[0,0,0];for(let e=0;e<6;e++)this.lineVertices.push(...i),this.lineTangentsIn.push(...s),this.lineTangentsOut.push(...n),this.lineVertexColors.push(...r);return this.lineSides.push(-1,2,-2,1,2,-1),this}_addJoin(e,t,r,i){const s=e.array(),n=t.array(),a=r.array();for(let e=0;e<12;e++)this.lineVertices.push(...s),this.lineTangentsIn.push(...n),this.lineTangentsOut.push(...a),this.lineVertexColors.push(...i);return this.lineSides.push(-1,-3,-2,-1,0,-3),this.lineSides.push(3,1,2,3,0,1),this}normalize(){if(this.vertices.length>0){const e=this.vertices[0].copy(),t=this.vertices[0].copy();for(let r=0;r<this.vertices.length;r++)e.x=Math.max(e.x,this.vertices[r].x),t.x=Math.min(t.x,this.vertices[r].x),e.y=Math.max(e.y,this.vertices[r].y),t.y=Math.min(t.y,this.vertices[r].y),e.z=Math.max(e.z,this.vertices[r].z),t.z=Math.min(t.z,this.vertices[r].z);const r=Xi.lerp(e,t,.5),i=Xi.sub(e,t),s=200/Math.max(Math.max(i.x,i.y),i.z);for(let e=0;e<this.vertices.length;e++)this.vertices[e].sub(r),this.vertices[e].mult(s)}return this}vertexProperty(e,t,r){let i;this.userVertexProperties[e]||(i=this.userVertexProperties[e]=this._userVertexPropertyHelper(e,t,r)),i=this.userVertexProperties[e],r?i.pushDirect(t):(i.setCurrentData(t),i.pushCurrentData())}_userVertexPropertyHelper(e,t,r){const i=this.userVertexProperties[e]={name:e,dataSize:r||(t.length?t.length:1),geometry:this,getName(){return this.name},getCurrentData(){return void 0===this.currentData&&(this.currentData=new Array(this.getDataSize()).fill(0)),this.currentData},getDataSize(){return this.dataSize},getSrcName(){return this.name.concat("Src")},getDstName(){return this.name.concat("Buffer")},getSrcArray(){const e=this.getSrcName();return this.geometry[e]},setCurrentData(e){this.currentData=e},pushCurrentData(){const e=this.getCurrentData();this.pushDirect(e)},pushDirect(e){e.length?this.getSrcArray().push(...e):this.getSrcArray().push(e)},resetSrcArray(){this.geometry[this.getSrcName()]=[]},delete(){const e=this.getSrcName();delete this.geometry[e]}};return this[i.getSrcName()]=[],this.userVertexProperties[e]}}function vn(e,t){e.Geometry=xn}xn.nextId=0,void 0!==p5&&vn(p5);class bn{constructor(e){this.renderer=e,e._pInst.push(),this.identityMatrix=new dn(4),e.states.setValue("uModelMatrix",new dn(4)),this.geometry=new xn(void 0,void 0,void 0,this.renderer),this.geometry.gid=`_p5_GeometryBuilder_${bn.nextGeometryId}`,bn.nextGeometryId++,this.hasTransform=!1}transformVertices(e){return this.hasTransform?e.map(e=>this.renderer.states.uModelMatrix.multiplyPoint(e)):e}transformNormals(e){return this.hasTransform?e.map(e=>this.renderer.scratchMat3.multiplyVec(e)):e}addGeometry(e){this.hasTransform=!this.renderer.states.uModelMatrix.mat4.every((e,t)=>e===this.identityMatrix.mat4[t]),this.hasTransform&&this.renderer.scratchMat3.inverseTranspose4x4(this.renderer.states.uModelMatrix);let t=this.geometry.vertices.length;this.geometry.vertices.push(...this.transformVertices(e.vertices)),this.geometry.vertexNormals.push(...this.transformNormals(e.vertexNormals)),this.geometry.uvs.push(...e.uvs);const r=e.userVertexProperties,i=this.geometry.userVertexProperties,s=this.geometry.vertices.length-e.vertices.length;for(const t in i){if(t in r)continue;const s=i[t],n=s.getDataSize()*e.vertices.length,a=Array(n).fill(0);s.pushDirect(a)}for(const e in r){const t=r[e],n=t.getSrcArray(),a=t.getDataSize();if(s>0&&!(e in i)){const t=Array(a*s).fill(0);this.geometry.vertexProperty(e,t,a)}this.geometry.vertexProperty(e,n,a)}this.renderer.states.fillColor&&this.geometry.faces.push(...e.faces.map(e=>e.map(e=>e+t))),this.renderer.states.strokeColor&&this.geometry.edges.push(...e.edges.map(e=>e.map(e=>e+t)));const n=[...e.vertexColors];for(;n.length<4*e.vertices.length;)n.push(...this.renderer.states.curFillColor);this.geometry.vertexColors.push(...n)}addImmediate(e,t,{validateFaces:r=!1}={}){const i=[];if(this.renderer.states.fillColor)if(5===t||t===B)for(let t=2;t<e.vertices.length;t++)t%2==0?i.push([t,t-1,t-2]):i.push([t,t-2,t-1]);else if(6===t)for(let t=2;t<e.vertices.length;t++)i.push([0,t-1,t]);else if(4===t)for(let t=0;t<e.vertices.length;t+=3)(!r||e.vertices[t].copy().sub(e.vertices[t+1]).cross(e.vertices[t].copy().sub(e.vertices[t+2])).magSq()>0)&&i.push([t,t+1,t+2]);this.addGeometry(Object.assign({},e,{faces:i}))}addRetained(e){this.addGeometry(e)}finish(){return this.renderer._pInst.pop(),this.geometry}}bn.nextGeometryId=0;class _n{constructor(e,t,r,i){this.w=e,this.vec=new Xi(t,r,i)}static fromAxisAngle(e,t,r,i){const s=Math.cos(e/2),n=new Xi(t,r,i).normalize().mult(Math.sin(e/2));return new _n(s,n.x,n.y,n.z)}conjugate(){return new _n(this.w,-this.vec.x,-this.vec.y,-this.vec.z)}multiply(e){return new _n(this.w*e.w-this.vec.x*e.vec.x-this.vec.y*e.vec.y-this.vec.z-e.vec.z,this.w*e.vec.x+this.vec.x*e.w+this.vec.y*e.vec.z-this.vec.z*e.vec.y,this.w*e.vec.y-this.vec.x*e.vec.z+this.vec.y*e.w+this.vec.z*e.vec.x,this.w*e.vec.z+this.vec.x*e.vec.y-this.vec.y*e.vec.x+this.vec.z*e.w)}rotateVector(e){return Xi.mult(e,this.w*this.w-this.vec.dot(this.vec)).add(Xi.mult(this.vec,2*e.dot(this.vec))).add(Xi.mult(this.vec,2*this.w).cross(e)).clampToZero()}rotateBy(e){return e.multiply(this).multiply(e.conjugate()).vec.clampToZero()}}function wn(e,t){e.Quat=_n}void 0!==p5&&wn(p5);class Cn{constructor(e){this._renderer=e,this.cameraType="default",this.useLinePerspective=!0,this.cameraMatrix=new dn(4),this.projMatrix=new dn(4),this.yScale=1}perspective(e,t,r,i){const s=this._renderer.zClipRange();this.cameraType=arguments.length>0?"custom":"default",void 0===e?(e=this.defaultCameraFOV,this.cameraFOV=e):this.cameraFOV=this._renderer._pInst._toRadians(e),void 0===t&&(t=this.defaultAspectRatio),void 0===r&&(r=this.defaultCameraNear),void 0===i&&(i=this.defaultCameraFar),r<=1e-4&&(r=.01,console.log("Avoid perspective near plane values close to or below 0. Setting value to 0.01.")),i<r&&console.log("Perspective far plane value is less than near plane value. Nothing will be shown."),this.aspectRatio=t,this.cameraNear=r,this.cameraFar=i,this.projMatrix=new dn(4);const n=1/Math.tan(this.cameraFOV/2),a=1/(this.cameraNear-this.cameraFar);let o,h;0===s[0]?(o=i/(r-i),h=i*r/(r-i)):(o=(i+r)*a,h=2*i*r*a),this.projMatrix.set(n/t,0,0,0,0,-n*this.yScale,0,0,0,0,o,-1,0,0,h,0),this._isActive()&&(this._renderer.states.setValue("uPMatrix",this._renderer.states.uPMatrix.clone()),this._renderer.states.uPMatrix.set(this.projMatrix))}ortho(e,t,r,i,s,n){const a=this.fbo||this._renderer;void 0===e&&(e=-a.width/2),void 0===t&&(t=+a.width/2),void 0===r&&(r=-a.height/2),void 0===i&&(i=+a.height/2),void 0===s&&(s=0),void 0===n&&(n=Math.max(a.width,a.height)+800),this.cameraNear=s,this.cameraFar=n;const o=t-e,h=i-r,u=n-s,l=2/o,c=2/h*this.yScale,p=-2/u,d=-(t+e)/o,f=-(i+r)/h,g=-(n+s)/u;this.projMatrix=new dn(4),this.projMatrix.set(l,0,0,0,0,-c,0,0,0,0,p,0,d,f,g,1),this._isActive()&&(this._renderer.states.setValue("uPMatrix",this._renderer.states.uPMatrix.clone()),this._renderer.states.uPMatrix.set(this.projMatrix)),this.cameraType="custom"}frustum(e,t,r,i,s,n){void 0===e&&(e=.05*-this._renderer.width),void 0===t&&(t=.05*+this._renderer.width),void 0===r&&(r=.05*+this._renderer.height),void 0===i&&(i=.05*-this._renderer.height),void 0===s&&(s=this.defaultCameraNear),void 0===n&&(n=this.defaultCameraFar),this.cameraNear=s,this.cameraFar=n;const a=t-e,o=i-r,h=n-s,u=2*s/a,l=2*s/o*this.yScale,c=-2*n*s/h,p=(t+e)/a,d=(i+r)/o,f=-(n+s)/h;this.projMatrix=new dn(4),this.projMatrix.set(u,0,0,0,0,-l,0,0,p,d,f,-1,0,0,c,0),this._isActive()&&(this._renderer.states.setValue("uPMatrix",this._renderer.states.uPMatrix.clone()),this._renderer.states.uPMatrix.set(this.projMatrix)),this.cameraType="custom"}_rotateView(e,t,r,i){let s=this.centerX,n=this.centerY,a=this.centerZ;s-=this.eyeX,n-=this.eyeY,a-=this.eyeZ;const o=new dn(4);o.rotate4x4(this._renderer._pInst._toRadians(e),t,r,i);const h=[s*o.mat4[0]+n*o.mat4[4]+a*o.mat4[8],s*o.mat4[1]+n*o.mat4[5]+a*o.mat4[9],s*o.mat4[2]+n*o.mat4[6]+a*o.mat4[10]];h[0]+=this.eyeX,h[1]+=this.eyeY,h[2]+=this.eyeZ,this.camera(this.eyeX,this.eyeY,this.eyeZ,h[0],h[1],h[2],this.upX,this.upY,this.upZ)}roll(e){const t=this._getLocalAxes(),r=_n.fromAxisAngle(this._renderer._pInst._toRadians(e),t.z[0],t.z[1],t.z[2]).rotateVector(new Xi(this.upX,this.upY,this.upZ));this.camera(this.eyeX,this.eyeY,this.eyeZ,this.centerX,this.centerY,this.centerZ,r.x,r.y,r.z)}pan(e){const t=this._getLocalAxes();this._rotateView(e,t.y[0],t.y[1],t.y[2])}tilt(e){const t=this._getLocalAxes();this._rotateView(e,t.x[0],t.x[1],t.x[2])}lookAt(e,t,r){this.camera(this.eyeX,this.eyeY,this.eyeZ,e,t,r,this.upX,this.upY,this.upZ)}camera(e,t,r,i,s,n,a,o,h){void 0===e&&(e=this.defaultEyeX,t=this.defaultEyeY,r=this.defaultEyeZ,i=e,s=t,n=0,a=0,o=1,h=0),this.eyeX=e,this.eyeY=t,this.eyeZ=r,void 0!==i&&(this.centerX=i,this.centerY=s,this.centerZ=n),void 0!==a&&(this.upX=a,this.upY=o,this.upZ=h);const u=this._getLocalAxes();this.cameraMatrix.set(u.x[0],u.y[0],u.z[0],0,u.x[1],u.y[1],u.z[1],0,u.x[2],u.y[2],u.z[2],0,0,0,0,1);const l=-e,c=-t,p=-r;return this.cameraMatrix.translate([l,c,p]),this._isActive()&&(this._renderer.states.setValue("uViewMatrix",this._renderer.states.uViewMatrix.clone()),this._renderer.states.uViewMatrix.set(this.cameraMatrix)),this}move(e,t,r){const i=this._getLocalAxes(),s=[i.x[0]*e,i.x[1]*e,i.x[2]*e],n=[i.y[0]*t,i.y[1]*t,i.y[2]*t],a=[i.z[0]*r,i.z[1]*r,i.z[2]*r];this.camera(this.eyeX+s[0]+n[0]+a[0],this.eyeY+s[1]+n[1]+a[1],this.eyeZ+s[2]+n[2]+a[2],this.centerX+s[0]+n[0]+a[0],this.centerY+s[1]+n[1]+a[1],this.centerZ+s[2]+n[2]+a[2],this.upX,this.upY,this.upZ)}setPosition(e,t,r){const i=e-this.eyeX,s=t-this.eyeY,n=r-this.eyeZ;this.camera(e,t,r,this.centerX+i,this.centerY+s,this.centerZ+n,this.upX,this.upY,this.upZ)}set(e){const t=["eyeX","eyeY","eyeZ","centerX","centerY","centerZ","upX","upY","upZ","cameraFOV","aspectRatio","cameraNear","cameraFar","cameraType","yScale","useLinePerspective"];for(const r of t)this[r]=e[r];this.cameraMatrix=e.cameraMatrix.copy(),this.projMatrix=e.projMatrix.copy(),this._isActive()&&(this._renderer.states.setValue("uModelMatrix",this._renderer.states.uModelMatrix.clone()),this._renderer.states.setValue("uViewMatrix",this._renderer.states.uViewMatrix.clone()),this._renderer.states.setValue("uPMatrix",this._renderer.states.uPMatrix.clone()),this._renderer.states.uModelMatrix.reset(),this._renderer.states.uViewMatrix.set(this.cameraMatrix),this._renderer.states.uPMatrix.set(this.projMatrix))}slerp(e,t,r){if(0===r)return void this.set(e);if(1===r)return void this.set(t);0!==this.projMatrix.mat4[15]&&(this.projMatrix.setElement(0,e.projMatrix.mat4[0]*Math.pow(t.projMatrix.mat4[0]/e.projMatrix.mat4[0],r)),this.projMatrix.setElement(5,e.projMatrix.mat4[5]*Math.pow(t.projMatrix.mat4[5]/e.projMatrix.mat4[5],r)),this._isActive()&&this._renderer.states.setValue("uPMatrix",this.projMatrix.clone()));const i=new Xi(e.eyeX,e.eyeY,e.eyeZ),s=new Xi(t.eyeX,t.eyeY,t.eyeZ),n=new Xi(e.centerX,e.centerY,e.centerZ),a=new Xi(t.centerX,t.centerY,t.centerZ),o=Xi.dist(i,n),h=Xi.dist(s,a),u=o*Math.pow(h/o,r),l=Xi.sub(i,s),c=i.copy().sub(s).sub(n).add(a),p=c.magSq();let d=1;p>1e-6&&(d=Xi.dot(l,c)/p,d=Math.max(0,Math.min(d,1)));const f=Xi.lerp(Xi.lerp(i,n,d),Xi.lerp(s,a,d),r),g=e.cameraMatrix.createSubMatrix3x3(),m=t.cameraMatrix.createSubMatrix3x3(),y=g.row(2),x=m.row(2),v=g.row(1),b=m.row(1),_=new Xi,w=new Xi,C=new Xi,E=new Xi,D=m.mult(g.copy().transpose()),A=D.diagonal();let S,F,T,M,k=.5*(A[0]+A[1]+A[2]-1);if(1-k<1e-7)return _.set(Xi.lerp(y,x,r)).normalize(),C.set(_).mult(d*u).add(f),E.set(_).mult((d-1)*u).add(f),w.set(Xi.lerp(v,b,r)).normalize(),void this.camera(C.x,C.y,C.z,E.x,E.y,E.z,w.x,w.y,w.z);let I=1/(1-k);const B=Math.max(A[0],A[1],A[2]),L=D.mat3[1]+D.mat3[3],P=D.mat3[2]+D.mat3[6],O=D.mat3[5]+D.mat3[7];B===A[0]?(S=Math.sqrt((A[0]-k)*I),I/=S,F=.5*L*I,T=.5*P*I,M=.5*(D.mat3[7]-D.mat3[5])/S):B===A[1]?(F=Math.sqrt((A[1]-k)*I),I/=F,T=.5*O*I,S=.5*L*I,M=.5*(D.mat3[2]-D.mat3[6])/F):(T=Math.sqrt((A[2]-k)*I),I/=T,S=.5*P*I,F=.5*O*I,M=.5*(D.mat3[3]-D.mat3[1])/T);const R=r*Math.atan2(M,k),N=Math.cos(R),V=Math.sin(R),U=1-N,z=S*F,G=F*T,j=T*S,$=new dn([N+U*S*S,U*z+V*T,U*j-V*F,U*z-V*T,N+U*F*F,U*G+V*S,U*j+V*F,U*G-V*S,N+U*T*T]);$.multiplyVec(y,_),C.set(_).mult(d*u).add(f),E.set(_).mult((d-1)*u).add(f),$.multiplyVec(v,w),this.camera(C.x,C.y,C.z,E.x,E.y,E.z,w.x,w.y,w.z)}_computeCameraDefaultSettings(){this.defaultAspectRatio=this._renderer.width/this._renderer.height,this.defaultEyeX=0,this.defaultEyeY=0,this.defaultEyeZ=800,this.defaultCameraFOV=2*Math.atan(this._renderer.height/2/this.defaultEyeZ),this.defaultCenterX=0,this.defaultCenterY=0,this.defaultCenterZ=0,this.defaultCameraNear=this.defaultEyeZ*this._renderer.defaultNearScale(),this.defaultCameraFar=this.defaultEyeZ*this._renderer.defaultFarScale()}_setDefaultCamera(){this.cameraFOV=this.defaultCameraFOV,this.aspectRatio=this.defaultAspectRatio,this.eyeX=this.defaultEyeX,this.eyeY=this.defaultEyeY,this.eyeZ=this.defaultEyeZ,this.centerX=this.defaultCenterX,this.centerY=this.defaultCenterY,this.centerZ=this.defaultCenterZ,this.upX=0,this.upY=1,this.upZ=0,this.cameraNear=this.defaultCameraNear,this.cameraFar=this.defaultCameraFar,this.perspective(),this.camera(),this.cameraType="default"}_resize(){"default"===this.cameraType&&(this._computeCameraDefaultSettings(),this.cameraFOV=this.defaultCameraFOV,this.aspectRatio=this.defaultAspectRatio,this.perspective())}copy(){const e=new Cn(this._renderer);return e.cameraFOV=this.cameraFOV,e.aspectRatio=this.aspectRatio,e.eyeX=this.eyeX,e.eyeY=this.eyeY,e.eyeZ=this.eyeZ,e.centerX=this.centerX,e.centerY=this.centerY,e.centerZ=this.centerZ,e.upX=this.upX,e.upY=this.upY,e.upZ=this.upZ,e.cameraNear=this.cameraNear,e.cameraFar=this.cameraFar,e.cameraType=this.cameraType,e.useLinePerspective=this.useLinePerspective,e.cameraMatrix=this.cameraMatrix.copy(),e.projMatrix=this.projMatrix.copy(),e.yScale=this.yScale,e.cameraType=this.cameraType,e}clone(){return this.copy()}_getLocalAxes(){let e=this.eyeX-this.centerX,t=this.eyeY-this.centerY,r=this.eyeZ-this.centerZ;const i=Math.sqrt(e*e+t*t+r*r);0!==i&&(e/=i,t/=i,r/=i);let s=this.upX,n=this.upY,a=this.upZ,o=n*r-a*t,h=-s*r+a*e,u=s*t-n*e;s=t*u-r*h,n=-e*u+r*o,a=e*h-t*o;const l=Math.sqrt(o*o+h*h+u*u);0!==l&&(o/=l,h/=l,u/=l);const c=Math.sqrt(s*s+n*n+a*a);return 0!==c&&(s/=c,n/=c,a/=c),{x:[o,h,u],y:[s,n,a],z:[e,t,r]}}_orbit(e,t,r){const i=this.eyeX-this.centerX,s=this.eyeY-this.centerY,n=this.eyeZ-this.centerZ;let a=Math.hypot(i,s,n);const o=new Xi(i,s,n).normalize(),h=new Xi(this.upX,this.upY,this.upZ).normalize(),u=Xi.cross(h,o).normalize(),l=Xi.cross(u,h);a*=Math.pow(10,r),a<this.cameraNear&&(a=this.cameraNear),a>this.cameraFar&&(a=this.cameraFar);const c=Math.acos(Math.max(-1,Math.min(1,Xi.dot(o,h))))+t,p=e;(c<=0||c>=Math.PI)&&(this.upX*=-1,this.upY*=-1,this.upZ*=-1),h.mult(Math.cos(c)),l.mult(Math.cos(p)*Math.sin(c)),u.mult(Math.sin(p)*Math.sin(c)),o.set(h).add(l).add(u),this.eyeX=a*o.x+this.centerX,this.eyeY=a*o.y+this.centerY,this.eyeZ=a*o.z+this.centerZ,this.camera(this.eyeX,this.eyeY,this.eyeZ,this.centerX,this.centerY,this.centerZ,this.upX,this.upY,this.upZ)}_orbitFree(e,t,r){const i=this.eyeX-this.centerX,s=this.eyeY-this.centerY,n=this.eyeZ-this.centerZ;let a=Math.hypot(i,s,n);const o=new Xi(i,s,n).normalize(),h=new Xi(this.upX,this.upY,this.upZ),u=Xi.cross(h,o).normalize(),l=Xi.cross(o,u),c=Math.atan2(t,e);l.mult(Math.sin(c)),u.mult(Math.cos(c)).add(l);const p=Math.sqrt(e*e+t*t),d=Xi.cross(o,u);a*=Math.pow(10,r),a<this.cameraNear&&(a=this.cameraNear),a>this.cameraFar&&(a=this.cameraFar);const f=Math.cos(p),g=Math.sin(p),m=h.dot(o),y=h.dot(u),x=m*f+y*g,v=-m*g+y*f,b=h.dot(d);h.x=x*o.x+v*u.x+b*d.x,h.y=x*o.y+v*u.y+b*d.y,h.z=x*o.z+v*u.z+b*d.z,u.mult(-g),o.mult(f).add(u).mult(a),this.camera(o.x+this.centerX,o.y+this.centerY,o.z+this.centerZ,this.centerX,this.centerY,this.centerZ,h.x,h.y,h.z)}_isActive(){return this===this._renderer.states.curCamera}}function En(e,t){t.camera=function(...e){return this._assert3d("camera"),this._renderer.camera(...e),this},t.perspective=function(...e){return this._assert3d("perspective"),this._renderer.perspective(...e),this},t.linePerspective=function(e){if(!(this._renderer instanceof jn))throw new Error("linePerspective() must be called in WebGL mode.");return this._renderer.linePerspective(e)},t.ortho=function(...e){return this._assert3d("ortho"),this._renderer.ortho(...e),this},t.frustum=function(...e){return this._assert3d("frustum"),this._renderer.frustum(...e),this},t.createCamera=function(){return this._assert3d("createCamera"),this._renderer.createCamera()},t.setCamera=function(e){this._renderer.setCamera(e)},e.Camera=Cn,jn.prototype.camera=function(...e){this.states.setValue("curCamera",this.states.curCamera.clone()),this.states.curCamera.camera(...e)},jn.prototype.perspective=function(...e){this.states.setValue("curCamera",this.states.curCamera.clone()),this.states.curCamera.perspective(...e)},jn.prototype.linePerspective=function(e){if(void 0===e)return this.states.curCamera.useLinePerspective;this.states.setValue("curCamera",this.states.curCamera.clone()),this.states.curCamera.useLinePerspective=e},jn.prototype.ortho=function(...e){this.states.setValue("curCamera",this.states.curCamera.clone()),this.states.curCamera.ortho(...e)},jn.prototype.frustum=function(...e){this.states.setValue("curCamera",this.states.curCamera.clone()),this.states.curCamera.frustum(...e)},jn.prototype.createCamera=function(){const e=new Cn(this);return e._computeCameraDefaultSettings(),e._setDefaultCamera(),e},jn.prototype.setCamera=function(e){this.states.setValue("curCamera",e),this.states.setValue("uPMatrix",this.states.uPMatrix.clone()),this.states.uPMatrix.set(e.projMatrix),this.states.setValue("uViewMatrix",this.states.uViewMatrix.clone()),this.states.uViewMatrix.set(e.cameraMatrix)}}void 0!==p5&&En(p5,p5.prototype);var Dn={exports:{}};!function(e){var t;function r(e,t){return e.b===t.b&&e.a===t.a}function i(e,t){return e.b<t.b||e.b===t.b&&e.a<=t.a}function s(e,t,r){var i=t.b-e.b,s=r.b-t.b;return 0<i+s?i<s?t.a-e.a+i/(i+s)*(e.a-r.a):t.a-r.a+s/(i+s)*(r.a-e.a):0}function n(e,t,r){var i=t.b-e.b,s=r.b-t.b;return 0<i+s?(t.a-r.a)*i+(t.a-e.a)*s:0}function a(e,t){return e.a<t.a||e.a===t.a&&e.b<=t.b}function o(e,t,r){var i=t.a-e.a,s=r.a-t.a;return 0<i+s?i<s?t.b-e.b+i/(i+s)*(e.b-r.b):t.b-r.b+s/(i+s)*(r.b-e.b):0}function h(e,t,r){var i=t.a-e.a,s=r.a-t.a;return 0<i+s?(t.b-r.b)*i+(t.b-e.b)*s:0}function u(e){return i(e.b.a,e.a)}function l(e){return i(e.a,e.b.a)}function c(e,t,r,i){return(e=0>e?0:e)<=(r=0>r?0:r)?0===r?(t+i)/2:t+e/(e+r)*(i-t):i+r/(e+r)*(t-i)}function p(e){var t=y(e.b);return v(t,e.c),v(t.b,e.c),b(t,e.a),t}function d(e,t){var r=!1,i=!1;e!==t&&(t.a!==e.a&&(i=!0,w(t.a,e.a)),t.d!==e.d&&(r=!0,C(t.d,e.d)),x(t,e),i||(v(t,e.a),e.a.c=e),r||(b(t,e.d),e.d.a=e))}function f(e){var t=e.b,r=!1;e.d!==e.b.d&&(r=!0,C(e.d,e.b.d)),e.c===e?w(e.a,null):(e.b.d.a=Q(e),e.a.c=e.c,x(e,Q(e)),r||b(e,e.d)),t.c===t?(w(t.a,null),C(t.d,null)):(e.d.a=Q(t),t.a.c=t.c,x(t,Q(t))),_(e)}function g(e){var t=y(e),r=t.b;return x(t,e.e),t.a=e.b.a,v(r,t.a),t.d=r.d=e.d,t=t.b,x(e.b,Q(e.b)),x(e.b,t),e.b.a=t.a,t.b.a.c=t.b,t.b.d=e.b.d,t.f=e.f,t.b.f=e.b.f,t}function m(e,t){var r=!1,i=y(e),s=i.b;return t.d!==e.d&&(r=!0,C(t.d,e.d)),x(i,e.e),x(s,t),i.a=e.b.a,s.a=t.a,i.d=s.d=e.d,e.d.a=s,r||b(i,e.d),i}function y(e){var t=new J,r=new J,i=e.b.h;return r.h=i,i.b.h=t,t.h=e,e.b.h=r,t.b=r,t.c=t,t.e=r,r.b=t,r.c=r,r.e=t}function x(e,t){var r=e.c,i=t.c;r.b.e=t,i.b.e=e,e.c=i,t.c=r}function v(e,t){var r=t.f,i=new te(t,r);r.e=i,t.f=i,r=i.c=e;do{r.a=i,r=r.c}while(r!==e)}function b(e,t){var r=t.d,i=new Z(t,r);r.b=i,t.d=i,i.a=e,i.c=t.c,r=e;do{r.d=i,r=r.e}while(r!==e)}function _(e){var t=e.h;e=e.b.h,t.b.h=e,e.b.h=t}function w(e,t){var r=e.c,i=r;do{i.a=t,i=i.c}while(i!==r);r=e.f,(i=e.e).f=r,r.e=i}function C(e,t){var r=e.a,i=r;do{i.d=t,i=i.e}while(i!==r);r=e.d,(i=e.b).d=r,r.b=i}function E(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t}var D=4e150;function A(e,t){e.f+=t.f,e.b.f+=t.b.f}function S(e,t,r){return e=e.a,t=t.a,r=r.a,t.b.a===e?r.b.a===e?i(t.a,r.a)?0>=n(r.b.a,t.a,r.a):0<=n(t.b.a,r.a,t.a):0>=n(r.b.a,e,r.a):r.b.a===e?0<=n(t.b.a,e,t.a):(t=s(t.b.a,e,t.a))>=(e=s(r.b.a,e,r.a))}function F(e){e.a.i=null;var t=e.e;t.a.c=t.c,t.c.a=t.a,e.e=null}function T(e,t){f(e.a),e.c=!1,e.a=t,t.i=e}function M(e){var t=e.a.a;do{e=de(e)}while(e.a.a===t);return e.c&&(T(e,t=m(pe(e).a.b,e.a.e)),e=de(e)),e}function k(e,t,r){var i=new ce;return i.a=r,i.e=H(e.f,t.e,i),r.i=i}function I(e,t){switch(e.s){case 100130:return!!(1&t);case 100131:return 0!==t;case 100132:return 0<t;case 100133:return 0>t;case 100134:return 2<=t||-2>=t}return!1}function B(e){var t=e.a,r=t.d;r.c=e.d,r.a=t,F(e)}function L(e,t,r){for(e=t,t=t.a;e!==r;){e.c=!1;var i=pe(e),s=i.a;if(s.a!==t.a){if(!i.c){B(e);break}T(i,s=m(t.c.b,s.b))}t.c!==s&&(d(Q(s),s),d(t,s)),B(e),t=i.a,e=i}return t}function P(e,t,r,i,s,n){var a=!0;do{k(e,t,r.b),r=r.c}while(r!==i);for(null===s&&(s=pe(t).a.b.c);(r=(i=pe(t)).a.b).a===s.a;)r.c!==s&&(d(Q(r),r),d(Q(s),r)),i.f=t.f-r.f,i.d=I(e,i.f),t.b=!0,!a&&V(e,t)&&(A(r,s),F(t),f(s)),a=!1,t=i,s=r;t.b=!0,n&&z(e,t)}function O(e,t,r,i,s){var n=[t.g[0],t.g[1],t.g[2]];t.d=null,t.d=e.o&&e.o(n,r,i,e.c)||null,null===t.d&&(s?e.n||(K(e,100156),e.n=!0):t.d=r[0])}function R(e,t,r){var i=[null,null,null,null];i[0]=t.a.d,i[1]=r.a.d,O(e,t.a,i,[.5,.5,0,0],!1),d(t,r)}function N(e,t,r,i,s){var n=Math.abs(t.b-e.b)+Math.abs(t.a-e.a),a=Math.abs(r.b-e.b)+Math.abs(r.a-e.a),o=s+1;i[s]=.5*a/(n+a),i[o]=.5*n/(n+a),e.g[0]+=i[s]*t.g[0]+i[o]*r.g[0],e.g[1]+=i[s]*t.g[1]+i[o]*r.g[1],e.g[2]+=i[s]*t.g[2]+i[o]*r.g[2]}function V(e,t){var s=pe(t),a=t.a,o=s.a;if(i(a.a,o.a)){if(0<n(o.b.a,a.a,o.a))return!1;if(r(a.a,o.a)){if(a.a!==o.a){s=e.e;var h=a.a.h;if(0<=h){var u=(s=s.b).d,l=s.e,c=s.c,p=c[h];u[p]=u[s.a],c[u[p]]=p,p<=--s.a&&(1>=p||i(l[u[p>>1]],l[u[p]])?ue(s,p):le(s,p)),l[h]=null,c[h]=s.b,s.b=h}else for(s.c[-(h+1)]=null;0<s.a&&null===s.c[s.d[s.a-1]];)--s.a;R(e,Q(o),a)}}else g(o.b),d(a,Q(o)),t.b=s.b=!0}else{if(0>n(a.b.a,o.a,a.a))return!1;de(t).b=t.b=!0,g(a.b),d(Q(o),a)}return!0}function U(e,t){var u=pe(t),l=t.a,p=u.a,f=l.a,m=p.a,y=l.b.a,x=p.b.a,v=new te;if(f===m||Math.min(f.a,y.a)>Math.max(m.a,x.a))return!1;if(i(f,m)){if(0<n(x,f,m))return!1}else if(0>n(y,m,f))return!1;var b,_,w=y,C=f,E=x,D=m;if(i(w,C)||(b=w,w=C,C=b),i(E,D)||(b=E,E=D,D=b),i(w,E)||(b=w,w=E,E=b,b=C,C=D,D=b),i(E,C)?i(C,D)?(0>(b=s(w,E,C))+(_=s(E,C,D))&&(b=-b,_=-_),v.b=c(b,E.b,_,C.b)):(0>(b=n(w,E,C))+(_=-n(w,D,C))&&(b=-b,_=-_),v.b=c(b,E.b,_,D.b)):v.b=(E.b+C.b)/2,a(w,C)||(b=w,w=C,C=b),a(E,D)||(b=E,E=D,D=b),a(w,E)||(b=w,w=E,E=b,b=C,C=D,D=b),a(E,C)?a(C,D)?(0>(b=o(w,E,C))+(_=o(E,C,D))&&(b=-b,_=-_),v.a=c(b,E.a,_,C.a)):(0>(b=h(w,E,C))+(_=-h(w,D,C))&&(b=-b,_=-_),v.a=c(b,E.a,_,D.a)):v.a=(E.a+C.a)/2,i(v,e.a)&&(v.b=e.a.b,v.a=e.a.a),w=i(f,m)?f:m,i(w,v)&&(v.b=w.b,v.a=w.a),r(v,f)||r(v,m))return V(e,t),!1;if(!r(y,e.a)&&0<=n(y,e.a,v)||!r(x,e.a)&&0>=n(x,e.a,v)){if(x===e.a)return g(l.b),d(p.b,l),l=pe(t=M(t)).a,L(e,pe(t),u),P(e,t,Q(l),l,l,!0),!0;if(y===e.a){g(p.b),d(l.e,Q(p)),m=(f=u=t).a.b.a;do{f=de(f)}while(f.a.b.a===m);return f=pe(t=f).a.b.c,u.a=Q(p),P(e,t,(p=L(e,u,null)).c,l.b.c,f,!0),!0}return 0<=n(y,e.a,v)&&(de(t).b=t.b=!0,g(l.b),l.a.b=e.a.b,l.a.a=e.a.a),0>=n(x,e.a,v)&&(t.b=u.b=!0,g(p.b),p.a.b=e.a.b,p.a.a=e.a.a),!1}return g(l.b),g(p.b),d(Q(p),l),l.a.b=v.b,l.a.a=v.a,l.a.h=ie(e.e,l.a),l=l.a,p=[0,0,0,0],v=[f.d,y.d,m.d,x.d],l.g[0]=l.g[1]=l.g[2]=0,N(l,f,y,p,0),N(l,m,x,p,2),O(e,l,v,p,!0),de(t).b=t.b=u.b=!0,!1}function z(e,t){for(var r=pe(t);;){for(;r.b;)t=r,r=pe(r);if(!t.b&&(r=t,null===(t=de(t))||!t.b))break;t.b=!1;var s,a=t.a,o=r.a;if(s=a.b.a!==o.b.a)e:{var h=pe(s=t),u=s.a,l=h.a,c=void 0;if(i(u.b.a,l.b.a)){if(0>n(u.b.a,l.b.a,u.a)){s=!1;break e}de(s).b=s.b=!0,c=g(u),d(l.b,c),c.d.c=s.d}else{if(0<n(l.b.a,u.b.a,l.a)){s=!1;break e}s.b=h.b=!0,c=g(l),d(u.e,l.b),c.b.d.c=s.d}s=!0}if(s&&(r.c?(F(r),f(o),o=(r=pe(t)).a):t.c&&(F(t),f(a),a=(t=de(r)).a)),a.a!==o.a)if(a.b.a===o.b.a||t.c||r.c||a.b.a!==e.a&&o.b.a!==e.a)V(e,t);else if(U(e,t))break;a.a===o.a&&a.b.a===o.b.a&&(A(o,a),F(t),f(a),t=de(r))}}function G(e,t){e.a=t;for(var s=t.c;null===s.i;)if((s=s.c)===t.c){s=e;var a=t;(u=new ce).a=a.c.b;var o=(c=s.f).a;do{o=o.a}while(null!==o.b&&!c.c(c.b,u,o.b));var h=pe(c=o.b),u=c.a;if(o=h.a,0===n(u.b.a,a,u.a))r((u=c.a).a,a)||r(u.b.a,a)||(g(u.b),c.c&&(f(u.c),c.c=!1),d(a.c,u),G(s,a));else{var l=i(o.b.a,u.b.a)?c:h;h=void 0,c.d||l.c?(h=l===c?m(a.c.b,u.e):m(o.b.c.b,a.c).b,l.c?T(l,h):(u=s,(c=k(s,c,h)).f=de(c).f+c.a.f,c.d=I(u,c.f)),G(s,a)):P(s,c,a.c,a.c,null,!0)}return}if(c=(u=pe(s=M(s.i))).a,(u=L(e,u,null)).c===c){u=(c=u).c,o=pe(s),h=s.a,l=o.a;var c,p=!1;h.b.a!==l.b.a&&U(e,s),r(h.a,e.a)&&(d(Q(u),h),u=pe(s=M(s)).a,L(e,pe(s),o),p=!0),r(l.a,e.a)&&(d(c,Q(l)),c=L(e,o,null),p=!0),p?P(e,s,c.c,u,u,!0):(a=i(l.a,h.a)?Q(l):h,P(e,s,a=m(c.c.b,a),a.c,a.c,!1),a.b.i.c=!0,z(e,s))}else P(e,s,u.c,c,c,!0)}function j(e,t){var r=new ce,i=p(e.b);i.a.b=D,i.a.a=t,i.b.a.b=-D,i.b.a.a=t,e.a=i.b.a,r.a=i,r.f=0,r.d=!1,r.c=!1,r.h=!0,r.b=!1,i=H(i=e.f,i.a,r),r.e=i}function $(e){this.a=new q,this.b=e,this.c=S}function H(e,t,r){do{t=t.c}while(null!==t.b&&!e.c(e.b,t.b,r));return e=new q(r,t.a,t),t.a.c=e,t.a=e}function q(e,t,r){this.b=e||null,this.a=t||this,this.c=r||this}function W(){this.d=X,this.p=this.b=this.q=null,this.j=[0,0,0],this.s=100130,this.n=!1,this.o=this.a=this.e=this.f=null,this.m=!1,this.c=this.r=this.i=this.k=this.l=this.h=null}var X=0;function Y(e,t){if(e.d!==t)for(;e.d!==t;)if(e.d<t)switch(e.d){case X:K(e,100151),e.u(null);break;case 1:K(e,100152),e.t()}else switch(e.d){case 2:K(e,100154),e.v();break;case 1:K(e,100153),e.w()}}function K(e,t){e.p&&e.p(t,e.c)}function Z(e,t){this.b=e||this,this.d=t||this,this.a=null,this.c=!1}function J(){this.h=this,this.i=this.d=this.a=this.e=this.c=this.b=null,this.f=0}function Q(e){return e.b.e}function ee(){this.c=new te,this.a=new Z,this.b=new J,this.d=new J,this.b.b=this.d,this.d.b=this.b}function te(e,t){this.e=e||this,this.f=t||this,this.d=this.c=null,this.g=[0,0,0],this.h=this.a=this.b=0}function re(){this.c=[],this.d=null,this.a=0,this.e=!1,this.b=new ne}function ie(e,t){if(e.e){var r,i=e.b,s=++i.a;return 2*s>i.f&&(i.f*=2,i.c=ae(i.c,i.f+1)),0===i.b?r=s:(r=i.b,i.b=i.c[i.b]),i.e[r]=t,i.c[r]=s,i.d[s]=r,i.h&&le(i,s),r}return i=e.a++,e.c[i]=t,-(i+1)}function se(e){if(0===e.a)return he(e.b);var t=e.c[e.d[e.a-1]];if(0!==e.b.a&&i(oe(e.b),t))return he(e.b);do{--e.a}while(0<e.a&&null===e.c[e.d[e.a-1]]);return t}function ne(){this.d=ae([0],33),this.e=[null,null],this.c=[0,0],this.a=0,this.f=32,this.b=0,this.h=!1,this.d[1]=1}function ae(e,t){for(var r=Array(t),i=0;i<e.length;i++)r[i]=e[i];for(;i<t;i++)r[i]=0;return r}function oe(e){return e.e[e.d[1]]}function he(e){var t=e.d,r=e.e,i=e.c,s=t[1],n=r[s];return 0<e.a&&(t[1]=t[e.a],i[t[1]]=1,r[s]=null,i[s]=e.b,e.b=s,0<--e.a&&ue(e,1)),n}function ue(e,t){for(var r=e.d,s=e.e,n=e.c,a=t,o=r[a];;){var h=a<<1;h<e.a&&i(s[r[h+1]],s[r[h]])&&(h+=1);var u=r[h];if(h>e.a||i(s[o],s[u])){r[a]=o,n[o]=a;break}r[a]=u,n[u]=a,a=h}}function le(e,t){for(var r=e.d,s=e.e,n=e.c,a=t,o=r[a];;){var h=a>>1,u=r[h];if(0===h||i(s[u],s[o])){r[a]=o,n[o]=a;break}r[a]=u,n[u]=a,a=h}}function ce(){this.e=this.a=null,this.f=0,this.c=this.b=this.h=this.d=!1}function pe(e){return e.e.c.b}function de(e){return e.e.a.b}(t=W.prototype).x=function(){Y(this,X)},t.B=function(e,t){switch(e){case 100142:return;case 100140:switch(t){case 100130:case 100131:case 100132:case 100133:case 100134:return void(this.s=t)}break;case 100141:return void(this.m=!!t);default:return void K(this,100900)}K(this,100901)},t.y=function(e){switch(e){case 100142:return 0;case 100140:return this.s;case 100141:return this.m;default:K(this,100900)}return!1},t.A=function(e,t,r){this.j[0]=e,this.j[1]=t,this.j[2]=r},t.z=function(e,t){var r=t||null;switch(e){case 100100:case 100106:this.h=r;break;case 100104:case 100110:this.l=r;break;case 100101:case 100107:this.k=r;break;case 100102:case 100108:this.i=r;break;case 100103:case 100109:this.p=r;break;case 100105:case 100111:this.o=r;break;case 100112:this.r=r;break;default:K(this,100900)}},t.C=function(e,t){var r=!1,i=[0,0,0];Y(this,2);for(var s=0;3>s;++s){var n=e[s];-1e150>n&&(n=-1e150,r=!0),1e150<n&&(n=1e150,r=!0),i[s]=n}r&&K(this,100155),null===(r=this.q)?d(r=p(this.b),r.b):(g(r),r=r.e),r.a.d=t,r.a.g[0]=i[0],r.a.g[1]=i[1],r.a.g[2]=i[2],r.f=1,r.b.f=-1,this.q=r},t.u=function(e){Y(this,X),this.d=1,this.b=new ee,this.c=e},t.t=function(){Y(this,1),this.d=2,this.q=null},t.v=function(){Y(this,2),this.d=1},t.w=function(){Y(this,1),this.d=X;var e=!1,t=[c=this.j[0],s=this.j[1],o=this.j[2]];if(0===c&&0===s&&0===o){for(var s=[-2e150,-2e150,-2e150],a=[2e150,2e150,2e150],o=[],h=[],c=(e=this.b.c).e;c!==e;c=c.e)for(var p=0;3>p;++p){var d=c.g[p];d<a[p]&&(a[p]=d,h[p]=c),d>s[p]&&(s[p]=d,o[p]=c)}if(c=0,s[1]-a[1]>s[0]-a[0]&&(c=1),s[2]-a[2]>s[c]-a[c]&&(c=2),a[c]>=s[c])t[0]=0,t[1]=0,t[2]=1;else{for(s=0,a=h[c],o=o[c],h=[0,0,0],a=[a.g[0]-o.g[0],a.g[1]-o.g[1],a.g[2]-o.g[2]],p=[0,0,0],c=e.e;c!==e;c=c.e)p[0]=c.g[0]-o.g[0],p[1]=c.g[1]-o.g[1],p[2]=c.g[2]-o.g[2],h[0]=a[1]*p[2]-a[2]*p[1],h[1]=a[2]*p[0]-a[0]*p[2],h[2]=a[0]*p[1]-a[1]*p[0],(d=h[0]*h[0]+h[1]*h[1]+h[2]*h[2])>s&&(s=d,t[0]=h[0],t[1]=h[1],t[2]=h[2]);0>=s&&(t[0]=t[1]=t[2]=0,t[E(a)]=1)}e=!0}for(h=E(t),c=this.b.c,s=(h+1)%3,o=(h+2)%3,h=0<t[h]?1:-1,t=c.e;t!==c;t=t.e)t.b=t.g[s],t.a=h*t.g[o];if(e){for(t=0,c=(e=this.b.a).b;c!==e;c=c.b)if(!(0>=(s=c.a).f))do{t+=(s.a.b-s.b.a.b)*(s.a.a+s.b.a.a),s=s.e}while(s!==c.a);if(0>t)for(e=(t=this.b.c).e;e!==t;e=e.e)e.a=-e.a}for(this.n=!1,c=(t=this.b.b).h;c!==t;c=e)e=c.h,s=c.e,r(c.a,c.b.a)&&c.e.e!==c&&(R(this,s,c),f(c),s=(c=s).e),s.e===c&&(s!==c&&(s!==e&&s!==e.b||(e=e.h),f(s)),c!==e&&c!==e.b||(e=e.h),f(c));for(this.e=t=new re,c=(e=this.b.c).e;c!==e;c=c.e)c.h=ie(t,c);for(function(e){e.d=[];for(var t=0;t<e.a;t++)e.d[t]=t;e.d.sort(function(e){return function(t,r){return i(e[t],e[r])?1:-1}}(e.c)),e.e=!0,function(e){for(var t=e.a;1<=t;--t)ue(e,t);e.h=!0}(e.b)}(t),this.f=new $(this),j(this,-D),j(this,D);null!==(t=se(this.e));){for(;;){e:if(c=this.e,0===c.a)e=oe(c.b);else if(e=c.c[c.d[c.a-1]],0!==c.b.a&&(c=oe(c.b),i(c,e))){e=c;break e}if(null===e||!r(e,t))break;e=se(this.e),R(this,t.c,e.c)}G(this,t)}for(this.a=this.f.a.a.b.a.a,t=0;null!==(e=this.f.a.a.b);)e.h||++t,F(e);for(this.f=null,(t=this.e).b=null,t.d=null,this.e=t.c=null,c=(t=this.b).a.b;c!==t.a;c=e)e=c.b,(c=c.a).e.e===c&&(A(c.c,c),f(c));if(!this.n){if(t=this.b,this.m)for(c=t.b.h;c!==t.b;c=e)e=c.h,c.b.d.c!==c.d.c?c.f=c.d.c?1:-1:f(c);else for(c=t.a.b;c!==t.a;c=e)if(e=c.b,c.c){for(c=c.a;i(c.b.a,c.a);c=c.c.b);for(;i(c.a,c.b.a);c=c.e);for(s=c.c.b,o=void 0;c.e!==s;)if(i(c.b.a,s.a)){for(;s.e!==c&&(u(s.e)||0>=n(s.a,s.b.a,s.e.b.a));)s=(o=m(s.e,s)).b;s=s.c.b}else{for(;s.e!==c&&(l(c.c.b)||0<=n(c.b.a,c.a,c.c.b.a));)c=(o=m(c,c.c.b)).b;c=c.e}for(;s.e.e!==c;)s=(o=m(s.e,s)).b}if(this.h||this.i||this.k||this.l)if(this.m){for(e=(t=this.b).a.b;e!==t.a;e=e.b)if(e.c){this.h&&this.h(2,this.c),c=e.a;do{this.k&&this.k(c.a.d,this.c),c=c.e}while(c!==e.a);this.i&&this.i(this.c)}}else{for(t=this.b,e=!!this.l,c=!1,s=-1,o=t.a.d;o!==t.a;o=o.d)if(o.c){c||(this.h&&this.h(4,this.c),c=!0),h=o.a;do{e&&s!==(a=h.b.d.c?0:1)&&(s=a,this.l&&this.l(!!s,this.c)),this.k&&this.k(h.a.d,this.c),h=h.e}while(h!==o.a)}c&&this.i&&this.i(this.c)}if(this.r){for(c=(t=this.b).a.b;c!==t.a;c=e)if(e=c.b,!c.c){o=(s=c.a).e,h=void 0;do{o=(h=o).e,h.d=null,null===h.b.d&&(h.c===h?w(h.a,null):(h.a.c=h.c,x(h,Q(h))),(a=h.b).c===a?w(a.a,null):(a.a.c=a.c,x(a,Q(a))),_(h))}while(h!==s);s=c.d,(c=c.b).d=s,s.b=c}return this.r(this.b),void(this.c=this.b=null)}}this.b=this.c=null},Ps.libtess={GluTesselator:W,windingRule:{GLU_TESS_WINDING_ODD:100130,GLU_TESS_WINDING_NONZERO:100131,GLU_TESS_WINDING_POSITIVE:100132,GLU_TESS_WINDING_NEGATIVE:100133,GLU_TESS_WINDING_ABS_GEQ_TWO:100134},primitiveType:{GL_LINE_LOOP:2,GL_TRIANGLES:4,GL_TRIANGLE_STRIP:5,GL_TRIANGLE_FAN:6},errorType:{GLU_TESS_MISSING_BEGIN_POLYGON:100151,GLU_TESS_MISSING_END_POLYGON:100153,GLU_TESS_MISSING_BEGIN_CONTOUR:100152,GLU_TESS_MISSING_END_CONTOUR:100154,GLU_TESS_COORD_TOO_LARGE:100155,GLU_TESS_NEED_COMBINE_CALLBACK:100156},gluEnum:{GLU_TESS_MESH:100112,GLU_TESS_TOLERANCE:100142,GLU_TESS_WINDING_RULE:100140,GLU_TESS_BOUNDARY_ONLY:100141,GLU_INVALID_ENUM:100900,GLU_INVALID_VALUE:100901,GLU_TESS_BEGIN:100100,GLU_TESS_VERTEX:100101,GLU_TESS_END:100102,GLU_TESS_ERROR:100103,GLU_TESS_EDGE_FLAG:100104,GLU_TESS_COMBINE:100105,GLU_TESS_BEGIN_DATA:100106,GLU_TESS_VERTEX_DATA:100107,GLU_TESS_END_DATA:100108,GLU_TESS_ERROR_DATA:100109,GLU_TESS_EDGE_FLAG_DATA:100110,GLU_TESS_COMBINE_DATA:100111}},W.prototype.gluDeleteTess=W.prototype.x,W.prototype.gluTessProperty=W.prototype.B,W.prototype.gluGetTessProperty=W.prototype.y,W.prototype.gluTessNormal=W.prototype.A,W.prototype.gluTessCallback=W.prototype.z,W.prototype.gluTessVertex=W.prototype.C,W.prototype.gluTessBeginPolygon=W.prototype.u,W.prototype.gluTessBeginContour=W.prototype.t,W.prototype.gluTessEndContour=W.prototype.v,W.prototype.gluTessEndPolygon=W.prototype.w,e.exports=Ps.libtess}(Dn);var An=Os(Dn.exports);class Sn{constructor(e,t,r,i,s,n){this.size=e,this.src=t,this.dst=r,this.attr=i,this._renderer=s,this.map=n}default(e){return this.default=e,this}_prepareBuffer(e,t){this._renderer._prepareBuffer(this,e,t)}}function Fn(e,t){e.RenderBuffer=Sn}void 0!==p5&&Fn(p5);const Tn={vertices:1,vertexNormals:1,vertexColors:4,vertexStrokeColors:4,uvs:2},Mn=Object.values(Tn).reduce((e,t)=>e+t);class kn{constructor(e){this.renderer=e,this.shapeMode=8,this.geometry=new xn(void 0,void 0,void 0,this.renderer),this.geometry.gid="__IMMEDIATE_MODE_GEOMETRY__",this.contourIndices=[],this._useUserVertexProperties=void 0,this._bezierVertex=[],this._quadraticVertex=[],this._curveVertex=[],this.isProcessingVertices=!1,this._tessy=this._initTessy(),this.tessyVertexSize=Mn,this.bufferStrides={...Tn}}constructFromContours(e,t){this._useUserVertexProperties&&this._resetUserVertexProperties(),this.geometry.reset(),this.contourIndices=[],this.shapeMode=e.contours[0].kind;const r=!!this.renderer.states.strokeColor,i={};if(e.userVertexProperties){this._useUserVertexProperties=!0;for(const t in e.userVertexProperties){const r=e.vertexPropertyName(t),s=this.geometry._userVertexPropertyHelper(r,[],e.userVertexProperties[t]);i[t]=s,this.tessyVertexSize+=s.getDataSize(),this.bufferStrides[s.getSrcName()]=s.getDataSize(),this.renderer.buffers.user.push(new Sn(s.getDataSize(),s.getSrcName(),s.getDstName(),r,this.renderer))}}else this._useUserVertexProperties=!1;for(const e of t){this.contourIndices.push(this.geometry.vertices.length);for(const t of e){if(this.shapeMode===I&&this.geometry.vertices.length%6==3)for(const e in this.bufferStrides){const t=this.bufferStrides[e],r=this.geometry[e];r.push(...r.slice(r.length-3*t,r.length-2*t),...r.slice(r.length-t,r.length))}this.geometry.vertices.push(t.position),this.geometry.vertexNormals.push(t.normal||new Xi(0,0,0)),this.geometry.uvs.push(t.textureCoordinates.x,t.textureCoordinates.y),this.renderer.states.fillColor?this.geometry.vertexColors.push(...t.fill.array()):this.geometry.vertexColors.push(0,0,0,0),this.renderer.states.strokeColor?this.geometry.vertexStrokeColors.push(...t.stroke.array()):this.geometry.vertexStrokeColors.push(0,0,0,0);for(const e in i){const r=i[e];e in t&&r.setCurrentData(t[e]),r.pushCurrentData()}}}r&&(this.geometry.edges=this._calculateEdges(this.shapeMode,this.geometry.vertices)),r&&!this.renderer.geometryBuilder&&this.geometry._edgesToVertices(),8===this.shapeMode?(this.isProcessingVertices=!0,this._tesselateShape(),this.isProcessingVertices=!1):this.shapeMode===B?this.shapeMode=5:this.shapeMode===I&&(this.shapeMode=4),this.renderer.states.textureMode===ve&&null!==this.renderer.states._tex&&this.renderer.states._tex.width>0&&this.renderer.states._tex.height>0&&(this.geometry.uvs=this.geometry.uvs.map((e,t)=>t%2==0?e/this.renderer.states._tex.width:e/this.renderer.states._tex.height))}_resetUserVertexProperties(){const e=this.geometry.userVertexProperties;for(const t in e){const r=e[t];delete this.bufferStrides[t],r.delete()}this._useUserVertexProperties=!1,this.tessyVertexSize=Mn,this.geometry.userVertexProperties={}}_calculateEdges(e,t){const r=[];let i=0;const s=this.contourIndices.slice();let n=-1;switch(e){case 5:for(i=0;i<t.length-2;i++)r.push([i,i+1]),r.push([i,i+2]);r.push([i,i+1]);break;case 6:for(i=1;i<t.length-1;i++)r.push([0,i]),r.push([i,i+1]);r.push([0,t.length-1]);break;case 4:for(i=0;i<t.length-2;i+=3)r.push([i,i+1]),r.push([i+1,i+2]),r.push([i+2,i]);break;case k:for(i=0;i<t.length-1;i+=2)r.push([i,i+1]);break;case I:for(i=0;i<t.length-5;i+=6)r.push([i,i+1]),r.push([i+1,i+2]),r.push([i+2,i+5]),r.push([i+5,i]);break;case B:for(i=0;i<t.length-2;i+=2)r.push([i,i+1]),r.push([i+1,i+3]),r.push([i,i+2]);r.push([i,i+1]);break;default:for(i=0;i<t.length;i++)i===s[0]?n=s.shift():t[n]&&t[i].equals(t[n])?r.push([i-1,n]):r.push([i-1,i])}return r}_tesselateShape(){const e=[];for(let t=0;t<this.geometry.vertices.length;t++){this.contourIndices.length>0&&this.contourIndices[0]===t&&(this.contourIndices.shift(),e.push([])),e[e.length-1].push(this.geometry.vertices[t].x,this.geometry.vertices[t].y,this.geometry.vertices[t].z,this.geometry.uvs[2*t],this.geometry.uvs[2*t+1],this.geometry.vertexColors[4*t],this.geometry.vertexColors[4*t+1],this.geometry.vertexColors[4*t+2],this.geometry.vertexColors[4*t+3],this.geometry.vertexNormals[t].x,this.geometry.vertexNormals[t].y,this.geometry.vertexNormals[t].z);for(const r in this.geometry.userVertexProperties){const i=this.geometry.userVertexProperties[r],s=t*i.getDataSize(),n=s+i.getDataSize(),a=i.getSrcArray().slice(s,n);e[e.length-1].push(...a)}}const t=1e-6;for(const r of e){const e=this.tessyVertexSize;for(let i=e;i<r.length;i+=e){const s=r[i-e],n=r[i-e+1],a=r[i],o=r[i+1];Math.abs(a-s)<t&&(r[i]=s),Math.abs(o-n)<t&&(r[i+1]=n)}}const r=this._triangulate(e);if(0===r.length)return;this.shapeMode=4;const i=this.geometry.vertices;this.geometry.vertices=[],this.geometry.vertexNormals=[],this.geometry.uvs=[];for(const e in this.geometry.userVertexProperties)this.geometry.userVertexProperties[e].resetSrcArray();const s=[];for(let e=0,t=r.length;e<t;e+=this.tessyVertexSize){s.push(...r.slice(e+5,e+9)),this.geometry.vertexNormals.push(new Xi(...r.slice(e+9,e+12)));{let t=12;for(const i in this.geometry.userVertexProperties){const s=this.geometry.userVertexProperties[i],n=s.getDataSize(),a=e+t,o=a+n;s.setCurrentData(r.slice(a,o)),s.pushCurrentData(),t+=n}}this.geometry.vertices.push(new Xi(...r.slice(e,e+3))),this.geometry.uvs.push(...r.slice(e+3,e+5))}if(this.renderer.geometryBuilder){const e=new Map;this.geometry.edges=this.geometry.edges.map(t=>t.map(t=>{if(!e.has(t)){const r=i[t];let s=this.geometry.vertices.findIndex(e=>r.x===e.x&&r.y===e.y&&r.z===e.z);if(-1===s){let e=1/0,t=0;for(let i=0;i<this.geometry.vertices.length;i++){const s=this.geometry.vertices[i],n=r.x-s.x,a=r.y-s.y,o=r.z-s.z,h=n*n+a*a+o*o;h<e&&(e=h,t=i)}s=t}e.set(t,s)}return e.get(t)}))}this.geometry.vertexColors=s}_initTessy(){const e=new An.GluTesselator;return e.gluTessCallback(An.gluEnum.GLU_TESS_VERTEX_DATA,function(e,t){for(const r of e)t.push(r)}),e.gluTessCallback(An.gluEnum.GLU_TESS_BEGIN,function(e){e!==An.primitiveType.GL_TRIANGLES&&console.log(`expected TRIANGLES but got type: ${e}`)}),e.gluTessCallback(An.gluEnum.GLU_TESS_ERROR,function(e){console.log("error callback"),console.log(`error number: ${e}`)}),e.gluTessCallback(An.gluEnum.GLU_TESS_COMBINE,(e,t,r)=>{const i=new Array(this.tessyVertexSize).fill(0);for(let e=0;e<r.length;e++)for(let s=0;s<i.length;s++)0!==r[e]&&t[e]&&(i[s]+=t[e][s]*r[e]);return i}),e.gluTessCallback(An.gluEnum.GLU_TESS_EDGE_FLAG,function(e){}),e.gluTessProperty(An.gluEnum.GLU_TESS_WINDING_RULE,An.windingRule.GLU_TESS_WINDING_NONZERO),e}_triangulate(e){const t=e[0]?e[0][2]:void 0;let r=!0;for(const i of e)for(let e=0;e<i.length;e+=this.tessyVertexSize)if(i[e+2]!==t){r=!1;break}r?this._tessy.gluTessNormal(0,0,1):this._tessy.gluTessNormal(0,0,0);const i=[];this._tessy.gluTessBeginPolygon(i);for(const t of e){this._tessy.gluTessBeginContour();for(let e=0;e<t.length;e+=this.tessyVertexSize){const r=t.slice(e,e+this.tessyVertexSize);this._tessy.gluTessVertex(r,r)}this._tessy.gluTessEndContour()}return this._tessy.gluTessEndPolygon(),i}}class In{constructor(e){this.renderer=e,this.cache={}}numCached(){return Object.keys(this.cache).length}isCached(e){return void 0!==this.cache[e]}getGeometryByID(e){return this.cache[e]?.geometry}getCached(e){return this.getCachedID(e.gid)}getCachedID(e){return this.cache[e]}ensureCached(e){const t=e.gid;if(!t)throw new Error("The p5.Geometry you passed in has no gid property!");if(this.isCached(t))return this.getCached(e);if(this.freeBuffers(t),Object.keys(this.cache).length>1e3){const e=Object.keys(this.cache)[0];this.freeBuffers(e)}const r={geometry:e};this.cache[t]=r;const i=e.faces.length?e.faces.flat():null;let s=null;return i&&(s=i.some(e=>e>65535)?Uint32Array:Uint16Array),this.renderer._ensureGeometryBuffers(r,i,s),r}freeBuffers(e){const t=this.cache[e];t&&(delete this.cache[e],this.renderer._freeBuffers(t))}}const Bn={[de]:3,[le]:4,[ae]:.5},Ln="middle",Pn="_fontBoundsSingle",On="start",Rn="end";function Nn(e,t){const r=/\r?\n/g,i=/,\s+/,s=/^".*"$/,n=/[^\x00-\x7F]/,a=/\t/g,o=new RegExp(`(?:${["wght","wdth","ital","slnt","opsz"].join("|")})`);["text","textAlign","textAscent","textDescent","textLeading","textMode","textFont","textSize","textStyle","textWidth","textWrap","textBounds","textDirection","textProperty","textProperties","fontBounds","fontWidth","fontAscent","fontDescent","textWeight"].forEach(r=>{t[r]=function(...e){if(!(r in _s.prototype))throw Error(`Renderer2D.prototype.${r} is not defined.`);return this._renderer[r](...e)},e.Graphics.prototype[r]=function(...e){return this._renderer[r](...e)}});const h={textAlign:{default:t.LEFT,type:"Context2d"},textBaseline:{default:t.BASELINE,type:"Context2d"},textFont:{default:{family:"sans-serif"}},textLeading:{default:15},textSize:{default:12},textWrap:{default:t.WORD},fontStretch:{default:t.NORMAL,isShorthand:!0},fontWeight:{default:t.NORMAL,isShorthand:!0},lineHeight:{default:t.NORMAL,isShorthand:!0},fontVariant:{default:t.NORMAL,isShorthand:!0},fontStyle:{default:t.NORMAL,isShorthand:!0},direction:{default:"inherit"}},u=["font","direction","fontKerning","fontStretch","fontVariantCaps","letterSpacing","textAlign","textBaseline","textRendering","wordSpacing"],l=Object.keys(h).filter(e=>h[e].isShorthand),c=["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded"];let p,d;_s.prototype.text=function(e,t,r,i,s){let n=this.textDrawingContext().textBaseline;({x:t,y:r,width:i,height:s}=this._handleRectMode(t,r,i,s));let a=this._processLines(e,i,s);a=this._positionLines(t,r,i,s,a),a.forEach(e=>this._renderText(e.text,e.x,e.y)),this.textDrawingContext().textBaseline=n},_s.prototype.textBounds=function(e,t,r,i,s){return this._computeBounds("_textBoundsSingle",e,t,r,i,s).bounds},_s.prototype.fontBounds=function(e,t,r,i,s){return this._computeBounds(Pn,e,t,r,i,s).bounds},_s.prototype.textWidth=function(e){let t=this._processLines(e);return Math.max(...t.map(e=>this._textWidthSingle(e)))},_s.prototype.fontWidth=function(e){let t=this._processLines(e);return Math.max(...t.map(e=>this._fontWidthSingle(e)))},_s.prototype.textAscent=function(e=""){return e.length?this.textDrawingContext().measureText(e).actualBoundingBoxAscent:this.fontAscent()},_s.prototype.fontAscent=function(){return this.textDrawingContext().measureText("_").fontBoundingBoxAscent},_s.prototype.textDescent=function(e=""){return e.length?this.textDrawingContext().measureText(e).actualBoundingBoxDescent:this.fontDescent()},_s.prototype.fontDescent=function(){return this.textDrawingContext().measureText("_").fontBoundingBoxDescent},_s.prototype.textAlign=function(e,r){return void 0!==e?(this.states.setValue("textAlign",e),void 0!==r&&(r===t.CENTER&&(r=Ln),this.states.setValue("textBaseline",r)),this._applyTextProperties()):{horizontal:this.states.textAlign,vertical:this.states.textBaseline}},_s.prototype._currentTextFont=function(){return this.states.textFont.font||this.states.textFont.family},_s.prototype.textFont=function(t,r,i){if(0===arguments.length)return this._currentTextFont();let s=t;if(t instanceof e.Font?s=t.face.family:t.data instanceof Uint8Array?(s=t.name.fontFamily,t.name?.fontSubfamily&&(s+="-"+t.name.fontSubfamily)):"string"==typeof t&&void 0===r&&/[.0-9]+(%|em|p[xt])/.test(s)&&({family:s,size:r}=this._directSetFontString(s)),"string"!=typeof s)throw Error("null font in textFont()");return 2===arguments.length&&"object"==typeof r&&(i=r,r=void 0),this.states.setValue("textFont",{font:t,family:s,size:r}),void 0!==r&&this._setTextSize(r),"object"==typeof i&&this.textProperties(i),this._applyTextProperties()},_s.prototype._directSetFontString=function(e,t=0){t&&console.log('_directSetFontString"'+e+'"');let r=l.reduce((e,t)=>(e[t]=h[t].default,e),{}),i=this._cachedDiv(r);i.style.font=e;let s=getComputedStyle(i);return l.forEach(e=>{this.states[e]=s[e],t&&console.log(" this.states."+e+'="'+s[e]+'"')}),{family:s.fontFamily,size:s.fontSize}},_s.prototype.textLeading=function(e){return"number"==typeof e?(this.states.setValue("leadingSet",!0),this.states.setValue("textLeading",e),this._applyTextProperties()):this.states.textLeading},_s.prototype.textWeight=function(t){return"number"==typeof t?(this.states.setValue("fontWeight",t),this._applyTextProperties(),void(e.prototype._isSafari()||this._setCanvasStyleProperty("font-variation-settings",`"wght" ${t}`))):this.states.fontWeight},_s.prototype.textSize=function(e){return void 0!==e?(this._setTextSize(e),this._applyTextProperties()):this.states.textSize},_s.prototype.textStyle=function(e){return void 0!==e?(this.states.setValue("fontStyle",e),this._applyTextProperties()):this.states.fontStyle},_s.prototype.textWrap=function(e){return e===t.WORD||e===t.CHAR?(this.states.setValue("textWrap",e),this._pInst):this.states.textWrap},_s.prototype.textDirection=function(e){return void 0!==e?(this.states.setValue("direction",e),this._applyTextProperties()):this.states.direction},_s.prototype.textProperty=function(e,t,r){let i=!1,s=r?.debug||!1;if(void 0===t){let t=this.textProperties();if(e in t)return t[e];throw Error('Unknown text option "'+e+'"')}return e in this.states&&this.states[e]!==t?(this.states[e]=t,i=!0,s&&console.log("this.states."+e+'="'+options[e]+'"')):e in this.textDrawingContext()?(this._setContextProperty(e,t,s),i=!0):e in this.textCanvas().style?(this._setCanvasStyleProperty(e,t,s),i=!0):console.warn('Ignoring unknown text option: "'+e+'"\n'),i?this._applyTextProperties():this._pInst},_s.prototype.textProperties=function(e){if(void 0!==e)return Object.keys(e).forEach(t=>{this.textProperty(t,e[t])}),this._pInst;let t=this.textDrawingContext();return e=u.reduce((e,r)=>(e[r]=t[r],e),{}),Object.keys(h).forEach(r=>{if("Context2d"===h[r]?.type)e[r]=t[r];else if("textFont"===r){let t=this._currentTextFont();"object"==typeof t&&"_pInst"in t&&(t=Object.assign({},t),delete t._pInst),e[r]=t}else e[r]=this.states[r]}),e},_s.prototype.textMode=function(){},_s.prototype._currentTextFont=function(){return this.states.textFont.font||this.states.textFont.family},_s.prototype._computeBounds=function(t,r,i,s,n,a,o){let h=this.textDrawingContext(),u=h.textBaseline,{textLeading:l,textAlign:c}=this.states;({width:n,height:a}=this._rectModeAdjust(i,s,n,a));let p=this._processLines(r,n,a),d=p.map((e,r)=>this[t].bind(this)(e,i,s+r*l));p.length>1&&void 0!==n&&d.forEach(t=>t.x+=e.Renderer2D.prototype._xAlignOffset.call(this,c,n)),e.Renderer2D.prototype._yAlignOffset.call(this,d,a||0);let f=d[0];return p.length>1&&(f=this._aggregateBounds(d),o?.ignoreRectMode||this._rectModeAlign(f,n||0,a||0)),h.textBaseline=u,{bounds:f,lines:p}},_s.prototype._rectModeAdjust=function(e,r,i,s){if(void 0!==i)switch(this.states.rectMode){case t.CENTER:break;case t.CORNERS:i-=e,s-=r;break;case t.RADIUS:i*=2,s*=2}return{x:e,y:r,width:i,height:s}},_s.prototype._setCanvasStyleProperty=function(e,t,r){let i=t.toString();r&&console.log("canvas.style."+e+'="'+i+'"'),"fontVariationSettings"===e&&this._handleFontVariationSettings(i),this.textCanvas().style[e]=i,this.textCanvas().style[e]},_s.prototype._handleFontVariationSettings=function(e,t=!1){"object"==typeof e&&(e=Object.keys(e).map(t=>t+" "+e[t]).join(", ")),e.split(i).forEach(e=>{e=e.replace(/["']/g,"");let r=o.exec(e);if(r&&r.length){let i=r[0],s=parseFloat(parseFloat(e.replace(i,"").trim()).toFixed(3));switch(i){case"wght":return t&&console.log("setting font-weight="+s),this.states.fontWeight!==s&&this.textWeight(s),s;case"wdth":break;case"ital":t&&console.log("setting font-style="+(s?"italic":"normal"));break;case"slnt":t&&console.log("setting font-style="+(s?"oblique":"normal"));break;case"opsz":t&&console.log("setting font-optical-size="+s)}}})},_s.prototype._setContextProperty=function(e,t,r=!1){if(this.textDrawingContext()[e]===t)return this._pInst;(p??=[]).push([e,t]),r&&console.log("queued context2d."+e+'="'+t+'"')},_s.prototype._handleRectMode=function(e,r,i,s){let n=this.states.rectMode;if(void 0!==i)switch(n){case t.RADIUS:e-=(i*=2)/2,void 0!==s&&(r-=(s*=2)/2);break;case t.CENTER:e-=i/2,void 0!==s&&(r-=s/2);break;case t.CORNERS:i-=e,void 0!==s&&(s-=r)}return{x:e,y:r,width:i,height:s}},_s.prototype._fontSizePx=function(e,{family:t}=this.states.textFont){if(r=e,!isNaN(r)&&""!==r.trim())return parseFloat(e);var r;let i=this._cachedDiv({fontSize:e});i.style.fontSize=e,i.style.fontFamily=t;let s=getComputedStyle(i).fontSize,n=parseFloat(s);if("number"!=typeof n)throw Error("textSize: invalid font-size");return n},_s.prototype._cachedDiv=function(e){if(void 0===d){let t=document.createElement("div");t.ariaHidden="true",t.style.display="none",Object.entries(e).forEach(([e,r])=>{t.style[e]=r}),this.textCanvas().appendChild(t),d=t}return d},_s.prototype._aggregateBounds=function(e){let t=Math.min(...e.map(e=>e.x)),r=Math.min(...e.map(e=>e.y)),i=Math.max(...e.map(e=>e.y+e.h));return{x:t,y:r,w:Math.max(...e.map(e=>e.x+e.w))-t,h:i-r}},_s.prototype._processLines=function(e,r,i){void 0!==r&&this.textDrawingContext().textBaseline===t.BASELINE&&(this.drawingContext.textBaseline=t.TOP);let s=this._splitOnBreaks(e.toString()),n=s.length>1,a=void 0!==r,o=a&&s.some(e=>this._textWidthSingle(e)>r),{textLeading:h,textWrap:u}=this.states;if((n||o)&&a&&(s=this._lineate(u,s,r)),a&&void 0!==i){if(void 0===h)throw Error("leading is required if height is specified");for(let e=0;e<s.length;e++)if(h*(e+1)>i){s=s.slice(0,e);break}}return s},_s.prototype._xAlignOffset=function(e,r){switch(e){case t.LEFT:return 0;case t.CENTER:return r/2;case t.RIGHT:return r;case On:return 0;case Rn:throw new Error("textBounds: END not yet supported for textAlign");default:return 0}},_s.prototype._rectModeAlign=function(e,r,i){if(void 0!==r){switch(this.states.rectMode){case t.CENTER:e.x-=(r-e.w)/2,e.y-=(i-e.h)/2;break;case t.CORNERS:e.w+=e.x,e.h+=e.y;break;case t.RADIUS:e.x-=(r-e.w)/2,e.y-=(i-e.h)/2,e.w/=2,e.h/=2}return e}},_s.prototype._rectModeAlignRevert=function(e,r,i){if(void 0!==r){switch(this.states.rectMode){case t.CENTER:e.x+=(r-e.w)/2,e.y+=(i-e.h)/2;break;case t.CORNERS:e.w-=e.x,e.h-=e.y;break;case t.RADIUS:e.x+=(r-e.w)/2,e.y+=(i-e.h)/2,e.w*=2,e.h*=2}return e}},_s.prototype._textWidthSingle=function(e){let t=this.textDrawingContext().measureText(e),r=t.actualBoundingBoxLeft;return t.actualBoundingBoxRight+r},_s.prototype._fontWidthSingle=function(e){return this.textDrawingContext().measureText(e).width},_s.prototype._textBoundsSingle=function(e,t=0,r=0){let i=this.textDrawingContext().measureText(e),s=i.actualBoundingBoxAscent,n=i.actualBoundingBoxDescent,a=i.actualBoundingBoxLeft;return{x:t-a,y:r-s,w:i.actualBoundingBoxRight+a,h:s+n}},_s.prototype._fontBoundsSingle=function(e,t=0,r=0){let i=this.textDrawingContext().measureText(e),s=i.fontBoundingBoxAscent,n=i.fontBoundingBoxDescent;return{x:t-=this._xAlignOffset(this.states.textAlign,i.width),y:r-s,w:i.width,h:s+n}},_s.prototype._setTextSize=function(e){if("string"==typeof e&&(e=this._fontSizePx(e)),"number"==typeof e){if(this.states.textSize!==e)return this.states.setValue("textSize",e),this.states.leadingSet||this.states.setValue("textLeading",1.275*this.states.textSize),!0}else console.warn("textSize: invalid size: "+e);return!1},_s.prototype._lineate=function(e,r,i=1/0,s={}){let n,a,o,h,u=s.splitChar??(e===t.WORD?" ":""),l=[];for(let e=0;e<r.length;e++){n="",h=r[e].split(u);for(let e=0;e<h.length;e++)a=`${n+h[e]}`+u,o=this._textWidthSingle(a),n.length>0&&o>i?(l.push(n.trim()),n=`${h[e]}`+u):n=a;l.push(n.trim())}return l},_s.prototype._splitOnBreaks=function(e){return e&&0!==e.length?e.replace(a," ").split(r):[""]},_s.prototype._parseFontFamily=function(e){return e.split(i).map(e=>(((e=e.trim()).indexOf(" ")>-1||n.test(e))&&!s.test(e)&&(e=`"${e}"`),e)).join(", ")},_s.prototype._applyFontString=function(){let{textFont:e,textSize:r,lineHeight:i,fontStyle:s,fontWeight:n,fontVariant:a}=this.states,o=this.textDrawingContext(),h=this._parseFontFamily(e.family),u=s!==t.NORMAL?`${s} `:"",l=n!==t.NORMAL?`${n} `:"",c=`${u}${a!==t.NORMAL?`${a} `:""}${l}${`${r}px`+(i!==t.NORMAL?`/${i} `:" ")}${h}`.trim();return o.font=c,o.font===c||c===o.font},_s.prototype._applyTextProperties=function(e=!1){this._applyFontString();let t=this.textDrawingContext();t.direction=this.states.direction,t.textAlign=this.states.textAlign,t.textBaseline=this.states.textBaseline;let r=this.states.fontStretch;for(c.includes(r)&&t.fontStretch!==r&&(t.fontStretch=r);p?.length;){let[r,i]=p.shift();e&&console.log('apply context property "'+r+'" = "'+i+'"'),t[r]=i,t[r]!==i&&(console.warn(`Unable to set '${r}' property on context2d. It may not be supported.`),console.log('Expected "'+i+'" but got: "'+t[r]+'"'))}return this._pInst}}function Vn(e,t,r){switch(t){case oe:return e.baseFilterShader().modify(({p5:e})=>{e.getColor((t,r)=>{const i=e.getTexture(r,t.texCoord),s=e.dot(i.rgb,e.vec3(.2126,.7152,.0722));return e.vec4(s,s,s,i.a)})},{p5:r});case ue:return e.baseFilterShader().modify(({p5:e})=>{e.getColor((t,r)=>{const i=e.getTexture(r,t.texCoord),s=e.vec3(1)-i.rgb;return e.vec4(s,i.a)})},{p5:r});case ae:return e.baseFilterShader().modify(({p5:e})=>{const t=e.uniformFloat("filterParameter");e.getColor((r,i)=>{const s=e.getTexture(i,r.texCoord),n=e.dot(s.rgb,e.vec3(.2126,.7152,.0722)),a=e.floor(255*t)/255,o=e.step(a,n);return e.vec4(e.vec3(o),s.a)})},{p5:r});case le:return e.baseFilterShader().modify(({p5:e})=>{const t=e.uniformFloat("filterParameter");e.getColor((r,i)=>{const s=e.getTexture(i,r.texCoord),n=((t,r)=>(t*=r,(t=e.floor(t))/(r-1)))(s.rgb,t);return e.vec4(n,s.a)})},{p5:r});case de:return e.baseFilterShader().modify(({p5:e})=>{const t=e.uniformFloat("radius"),r=e.uniformVec2("direction"),i=(t,r)=>e.pow(r-e.abs(t),2);e.getColor((s,n)=>{const a=s.texCoord;let o=e.floor(7*t);0==e.mod(o,2)&&o++;let h=e.vec4(0),u=0,l=1;o>64&&(l=o/64,o=64);const c=(l-1)*e.mix(-.5,.5,(t=>{let r=e.fract(.1031*t.xyx);return r+=e.dot(r,r.yzx+33.33),e.fract((r.x+r.y)*r.z)})(a*s.canvasSize));for(let t=0;t<o;t++){const p=t*l-.5*(o-1)*l+c,d=a+e.vec2(p,p)/s.canvasSize*r,f=i(p,.5*(o-1)*l),g=e.getTexture(n,d);h+=f*g*e.vec4(g.a,g.a,g.a,1),u+=f}const p=h/u;return e.vec4(p.r/p.a,p.g/p.a,p.b/p.a,p.a)})},{p5:r});case pe:return e.baseFilterShader().modify(({p5:e})=>{const t=t=>e.dot(t.rgb,e.vec3(.2126,.7152,.0722));e.getColor((r,i)=>{const s=r.texCoord;let n=e.getTexture(i,s),a=t(n);for(let o=-1;o<=1;o++)for(let h=-1;h<=1;h++)if(0!=o||0!=h){const u=e.vec2(o,h)*r.texelSize,l=e.getTexture(i,s+u),c=t(l);c<a&&(a=c,n=l)}return n})},{p5:r});case ce:return e.baseFilterShader().modify(({p5:e})=>{const t=t=>e.dot(t.rgb,e.vec3(.2126,.7152,.0722));e.getColor((r,i)=>{const s=r.texCoord;let n=e.getTexture(i,s),a=t(n);for(let o=-1;o<=1;o++)for(let h=-1;h<=1;h++)if(0!=o||0!=h){const u=e.vec2(o,h)*r.texelSize,l=e.getTexture(i,s+u),c=t(l);c>a&&(a=c,n=l)}return n})},{p5:r});case he:return e.baseFilterShader().modify(({p5:e})=>{e.getColor((t,r)=>{const i=e.getTexture(r,t.texCoord);return e.vec4(i.rgb,1)})},{p5:r});default:throw new Error(`Unknown filter: ${t}`)}}function Un(e){const t={},r={};let i="";const s=function(r,s){i+=e(`STROKE_CAP_${r}`,`${s}`,"u32"),t[Ue[r]]=s},n=function(t,s){i+=e(`STROKE_JOIN_${t}`,`${s}`,"u32"),r[Ue[t]]=s};return s("ROUND",0),s("PROJECT",1),s("SQUARE",2),n("ROUND",0),n("MITER",1),n("BEVEL",2),{STROKE_CAP_ENUM:t,STROKE_JOIN_ENUM:r,lineDefs:i}}void 0!==p5&&Nn(p5,p5.prototype);const{STROKE_CAP_ENUM:zn,STROKE_JOIN_ENUM:Gn}=Un(()=>"");class jn extends _s{constructor(e,t,r,i,s){super(e,t,r,i),this.canvas=this.elt=s||document.createElement("canvas"),this.contextReady=this.setupContext(),this._isMainCanvas?(this._pInst._curElement=this,this._pInst.canvas=this.canvas):this.canvas.style.display="none",this.elt.id="defaultCanvas0",this.elt.classList.add("p5Canvas"),this.wrappedElt=new Pi(this.elt,this._pInst);for(const e of Object.getOwnPropertyNames(Pi.prototype))"constructor"!==e&&"_"!==e[0]&&Object.defineProperty(this,e,{get(){return this.wrappedElt[e]}});const n=this._adjustDimensions(t,r);if(t=n.adjustedWidth,r=n.adjustedHeight,this.width=t,this.height=r,this.elt.width=t*this._pixelDensity,this.elt.height=r*this._pixelDensity,this.elt.style.width=`${t}px`,this.elt.style.height=`${r}px`,this._updateViewport(),this._pInst._userNode)this._pInst._userNode.appendChild(this.elt);else{if(0===document.getElementsByTagName("main").length){let e=document.createElement("main");document.body.appendChild(e)}document.getElementsByTagName("main")[0].appendChild(this.elt)}this.isP3D=!0,this.geometryBuilder=void 0,this.states.uModelMatrix=new dn(4),this.states.uViewMatrix=new dn(4),this.states.uPMatrix=new dn(4),this.mainCamera=new Cn(this),this.states.curCamera||(this.states.curCamera=this.mainCamera),this.states.uPMatrix.set(this.states.curCamera.projMatrix),this.states.uViewMatrix.set(this.states.curCamera.cameraMatrix),this.states.enableLighting=!1,this.states.ambientLightColors=[],this.states.specularColors=[1,1,1],this.states.directionalLightDirections=[],this.states.directionalLightDiffuseColors=[],this.states.directionalLightSpecularColors=[],this.states.pointLightPositions=[],this.states.pointLightDiffuseColors=[],this.states.pointLightSpecularColors=[],this.states.spotLightPositions=[],this.states.spotLightDirections=[],this.states.spotLightDiffuseColors=[],this.states.spotLightSpecularColors=[],this.states.spotLightAngle=[],this.states.spotLightConc=[],this.states.activeImageLight=null,this.states.curFillColor=[1,1,1,1],this.states.curAmbientColor=[1,1,1,1],this.states.curSpecularColor=[0,0,0,0],this.states.curEmissiveColor=[0,0,0,0],this.states.curStrokeColor=[0,0,0,1],this.states.curBlendMode=$,this.states._hasSetAmbient=!1,this.states._useSpecularMaterial=!1,this.states._useEmissiveMaterial=!1,this.states._useNormalMaterial=!1,this.states._useShininess=1,this.states._useMetalness=0,this.states.tint=[255,255,255,255],this.states.constantAttenuation=1,this.states.linearAttenuation=0,this.states.quadraticAttenuation=0,this.states._currentNormal=new Xi(0,0,1),this.states.drawMode=ye,this.states._tex=null,this.states.textureMode=ve,this.states.textureWrapX=Ce,this.states.textureWrapY=Ce,this._isErasing=!1,this._simpleLines=!1,this._clipDepths=[],this._isClipApplied=!1,this._stencilTestOn=!1,this.mixedAmbientLight=[],this.mixedSpecularColor=[],this.diffusedTextures=new Map,this.specularTextures=new Map,this.preEraseBlend=void 0,this._cachedFillStyle=[1,1,1,1],this._cachedStrokeStyle=[0,0,0,1],this._isBlending=!1,this._useLineColor=!1,this._useVertexColor=!1,this.registerEnabled=new Set,this.mainCamera._computeCameraDefaultSettings(),this.mainCamera._setDefaultCamera(),this.filterCamera=new Cn(this),this.filterCamera._computeCameraDefaultSettings(),this.filterCamera._setDefaultCamera(),this.prevTouches=[],this.zoomVelocity=0,this.rotateVelocity=new Xi(0,0),this.moveVelocity=new Xi(0,0),this.executeZoom=!1,this.executeRotateAndMove=!1,this._drawingFilter=!1,this._drawingImage=!1,this.specularShader=void 0,this.sphereMapping=void 0,this.diffusedShader=void 0,this._baseFilterShader=void 0,this._defaultLightShader=void 0,this._defaultImmediateModeShader=void 0,this._defaultNormalShader=void 0,this._defaultColorShader=void 0,this.states.userFillShader=void 0,this.states.userStrokeShader=void 0,this.states.userImageShader=void 0,this.states.curveDetail=1/4,this.shapeBuilder=new kn(this),this.geometryBufferCache=new In(this),this.curStrokeCap=U,this.curStrokeJoin=U,this.textures=new Map,this.framebuffers=new Set,this.activeFramebuffers=[],this.states.filterShader=void 0,this.filterLayer=void 0,this.filterLayerTemp=void 0,this.defaultFilterShaders={},this.fontInfos={},this._curShader=void 0,this.drawShapeCount=1,this.scratchMat3=new dn(3),this._validateFaces=!1,this.buffers={fill:[new Sn(3,"vertices","vertexBuffer","aPosition",this,this._vToNArray),new Sn(3,"vertexNormals","normalBuffer","aNormal",this,this._vToNArray),new Sn(4,"vertexColors","colorBuffer","aVertexColor",this).default(e=>e.vertices.flatMap(()=>[-1,-1,-1,-1])),new Sn(3,"vertexAmbients","ambientBuffer","aAmbientColor",this),new Sn(2,"uvs","uvBuffer","aTexCoord",this,e=>e.flat())],stroke:[new Sn(4,"lineVertexColors","lineColorBuffer","aVertexColor",this).default(e=>e.lineVertices.flatMap(()=>[-1,-1,-1,-1])),new Sn(3,"lineVertices","lineVerticesBuffer","aPosition",this),new Sn(3,"lineTangentsIn","lineTangentsInBuffer","aTangentIn",this),new Sn(3,"lineTangentsOut","lineTangentsOutBuffer","aTangentOut",this),new Sn(1,"lineSides","lineSidesBuffer","aSide",this)],text:[new Sn(3,"vertices","vertexBuffer","aPosition",this,this._vToNArray),new Sn(2,"uvs","uvBuffer","aTexCoord",this,e=>e.flat())],user:[]}}async _resetContext(e,t,r=jn){const i=this.width,s=this.height,n=this.canvas.id,a=this._pInst instanceof ea,o={position:this.canvas.style.position,top:this.canvas.style.top,left:this.canvas.style.left};if(a){const e=this._pInst;e.canvas.parentNode.removeChild(e.canvas),e.canvas=document.createElement("canvas"),(e._pInst._userNode||document.body).appendChild(e.canvas),Pi.call(e,e.canvas,e._pInst),e.width=i,e.height=s}else{let e=this.canvas;e&&e.parentNode.removeChild(e),e=document.createElement("canvas"),e.id=n,this._pInst._userNode?this._pInst._userNode.appendChild(e):document.body.appendChild(e),this._pInst.canvas=e,this.canvas=e,this.canvas.style.position=o.position,this.canvas.style.top=o.top,this.canvas.style.left=o.left}const h=new r(this._pInst,i,s,!a,this._pInst.canvas);this._pInst._renderer=h,h._applyDefaults(),h.contextReady&&await h.contextReady,"function"==typeof t&&setTimeout(()=>{t.apply(window._renderer,e)},0)}remove(){this.wrappedElt.remove(),this.wrappedElt=null,this.canvas=null,this.elt=null}beginGeometry(){if(this.geometryBuilder)throw new Error("It looks like `beginGeometry()` is being called while another p5.Geometry is already being build.");this.geometryBuilder=new bn(this),this.geometryBuilder.prevFillColor=this.states.fillColor,this.fill(new xi([-1,-1,-1,-1]))}endGeometry(){if(!this.geometryBuilder)throw new Error("Make sure you call beginGeometry() before endGeometry()!");const e=this.geometryBuilder.finish();return this.geometryBuilder.prevFillColor?this.fill(this.geometryBuilder.prevFillColor):this.noFill(),this.geometryBuilder=void 0,e}buildGeometry(e){return this.beginGeometry(),e(),this.endGeometry()}beginShape(...e){super.beginShape(...e)}curveDetail(e){if(void 0===e)return this.states.curveDetail;this.states.setValue("curveDetail",e)}drawShape(e){const t=new ms({curveDetail:this.states.curveDetail});e.accept(t),this.shapeBuilder.constructFromContours(e,t.contours),this.geometryBuilder?this.geometryBuilder.addImmediate(this.shapeBuilder.geometry,this.shapeBuilder.shapeMode,{validateFaces:this._validateFaces}):(this.states.fillColor||this.states.strokeColor)&&this._drawGeometry(this.shapeBuilder.geometry,{mode:this.shapeBuilder.shapeMode,count:this.drawShapeCount}),this.drawShapeCount=1}endShape(e,t){this.drawShapeCount=t,super.endShape(e,t)}vertexProperty(...e){this.currentShape.vertexProperty(...e)}normal(e,t,r){e instanceof Xi?this.states.setValue("_currentNormal",e):this.states.setValue("_currentNormal",new Xi(e,t,r)),this.updateShapeVertexProperties()}model(e,t=1){e.vertices.length>0&&(this.geometryBuilder?this.geometryBuilder.addRetained(e):(this.geometryInHash(e.gid)||(e._edgesToVertices(),this._getOrMakeCachedBuffers(e)),this._drawGeometry(e,{count:t})))}_getOrMakeCachedBuffers(e){return this.geometryBufferCache.ensureCached(e)}_drawGeometry(e,{mode:t=4,count:r=1}={}){for(const t in e.userVertexProperties){const r=e.userVertexProperties[t];this.buffers.user.push(new Sn(r.getDataSize(),r.getSrcName(),r.getDstName(),r.getName(),this))}this.states.fillColor&&e.vertices.length>=3&&![k,M].includes(t)&&this._drawFills(e,{mode:t,count:r}),this.states.strokeColor&&e.lineVertices.length>=1&&this._drawStrokes(e,{count:r}),this.buffers.user=[]}_drawFills(e,{count:t,mode:r}={}){this._useVertexColor=e.vertexColors.length>0&&!e.vertexColors.isDefault;const i=!this._drawingFilter&&this.states.userFillShader?this.states.userFillShader:this._getFillShader();i.bindShader("fill"),this._setGlobalUniforms(i),this._setFillUniforms(i),i.bindTextures();for(const t of this.buffers.fill)t._prepareBuffer(e,i);this._prepareUserAttributes(e,i),this._disableRemainingAttributes(i),this._applyColorBlend(this.states.curFillColor,e.hasFillTransparency()),this._drawBuffers(e,{mode:r,count:t}),i.unbindShader()}_drawStrokes(e,{count:t}={}){this._useLineColor=e.vertexStrokeColors.length>0;const r=this._getStrokeShader();r.bindShader("stroke"),this._setGlobalUniforms(r),this._setStrokeUniforms(r),r.bindTextures();for(const t of this.buffers.stroke)t._prepareBuffer(e,r);this._prepareUserAttributes(e,r),this._disableRemainingAttributes(r),this._applyColorBlend(this.states.curStrokeColor,e.hasStrokeTransparency()),this._drawBuffers(e,{count:t}),r.unbindShader()}_prepareUserAttributes(e,t){for(const r of this.buffers.user){if(!this._pInst.constructor.disableFriendleErrors){const t=e.userVertexProperties[r.attr];if(t){const r=t.getSrcArray().length/t.getDataSize();r>e.vertices.length?this._pInst.constructor._friendlyError(`One of the geometries has a custom vertex property '${t.getName()}' with more values than vertices. This is probably caused by directly using the Geometry.vertexProperty() method.`,"vertexProperty()"):r<e.vertices.length&&this._pInst.constructor._friendlyError(`One of the geometries has a custom vertex property '${t.getName()}' with fewer values than vertices. This is probably caused by directly using the Geometry.vertexProperty() method.`,"vertexProperty()")}}r._prepareBuffer(e,t)}}_drawGeometryScaled(e,t,r,i){let s=this.states.uModelMatrix;this.states.setValue("uModelMatrix",this.states.uModelMatrix.clone());try{this.states.uModelMatrix.scale(t,r,i),this.geometryBuilder?this.geometryBuilder.addRetained(e):this._drawGeometry(e)}finally{this.states.setValue("uModelMatrix",s)}}_update(){this.states.setValue("uModelMatrix",this.states.uModelMatrix.clone()),this.states.uModelMatrix.reset(),this.states.setValue("uViewMatrix",this.states.uViewMatrix.clone()),this.states.uViewMatrix.set(this.states.curCamera.cameraMatrix),this.states.setValue("ambientLightColors",[]),this.states.setValue("specularColors",[1,1,1]),this.states.setValue("directionalLightDirections",[]),this.states.setValue("directionalLightDiffuseColors",[]),this.states.setValue("directionalLightSpecularColors",[]),this.states.setValue("pointLightPositions",[]),this.states.setValue("pointLightDiffuseColors",[]),this.states.setValue("pointLightSpecularColors",[]),this.states.setValue("spotLightPositions",[]),this.states.setValue("spotLightDirections",[]),this.states.setValue("spotLightDiffuseColors",[]),this.states.setValue("spotLightSpecularColors",[]),this.states.setValue("spotLightAngle",[]),this.states.setValue("spotLightConc",[]),this.states.setValue("enableLighting",!1),this.states.setValue("tint",[255,255,255,255]),this._resetBuffersBeforeDraw()}background(...e){const t=e[0];if(null!=t&&"object"==typeof t&&"number"==typeof t.width&&"number"==typeof t.height&&(null!=t.canvas||null!=t.elt))return this._pInst.clear(),this._pInst.push(),this._pInst.resetMatrix(),this._pInst.imageMode(A),this._pInst.image(t,0,0,this._pInst.width,this._pInst.height),void this._pInst.pop();const r=this._pInst.color(...e);this.clear(...r._getRGBA())}get uModelMatrix(){return this.states.uModelMatrix}get uViewMatrix(){return this.states.uViewMatrix}get uPMatrix(){return this.states.uPMatrix}get uMVMatrix(){const e=this.uModelMatrix.copy();return e.mult(this.uViewMatrix),e}getWorldToScreenMatrix(){const e=this.states.uModelMatrix,t=this.states.uViewMatrix,r=this.states.uPMatrix,i=new dn(4);return i.scale(this.width,this.height,1),i.translate([.5,.5,.5]),i.scale(.5,-.5,.5),e.copy().mult(t).mult(r).mult(i)}fill(...e){super.fill(...e);const t=this.states.fillColor;this.states.setValue("curFillColor",t._array),this.states.setValue("drawMode",ye),this.states.setValue("_useNormalMaterial",!1),this.states.setValue("_tex",null)}stroke(...e){super.stroke(...e),this.states.setValue("curStrokeColor",this.states.strokeColor._array)}getCommonVertexProperties(){return{...super.getCommonVertexProperties(),stroke:this.states.strokeColor,fill:this.states.fillColor,normal:this.states._currentNormal}}getSupportedIndividualVertexProperties(){return{textureCoordinates:!0}}strokeCap(e){this.curStrokeCap=e}strokeJoin(e){this.curStrokeJoin=e}getFilterLayer(){return this.filterLayer||(this.filterLayer=new ma(this)),this.filterLayer}getFilterLayerTemp(){return this.filterLayerTemp||(this.filterLayerTemp=new ma(this)),this.filterLayerTemp}matchSize(e,t){e.width===t.width&&e.height===t.height||e.resize(t.width,t.height),e.pixelDensity()!==t.pixelDensity()&&e.pixelDensity(t.pixelDensity())}filter(...e){let t,r,i=this.getFilterLayer();if("string"==typeof e[0]){r=e[0];let s=r in Bn&&void 0===e[1];t=s?Bn[r]:e[1],r in this.defaultFilterShaders||(this.defaultFilterShaders[r]=this._makeFilterShader(i.renderer,r)),this.states.setValue("filterShader",this.defaultFilterShaders[r])}else this.states.setValue("filterShader",e[0]);const s=this.activeFramebuffer()||this;this.matchSize(i,s),i.draw(()=>this.clear());let n=[1/(s.width*s.pixelDensity()),1/(s.height*s.pixelDensity())];if(r===de){const e=this.getFilterLayerTemp();this.matchSize(e,s),this.push(),this.states.setValue("strokeColor",null),this.blendMode($),this.shader(this.states.filterShader),this.states.filterShader.setUniform("texelSize",n),this.states.filterShader.setUniform("canvasSize",[s.width,s.height]),this.states.filterShader.setUniform("radius",Math.max(1,t)),e.draw(()=>{this.states.filterShader.setUniform("direction",[1,0]),this.states.filterShader.setUniform("tex0",s),this.clear(),this.shader(this.states.filterShader),this.noLights(),this.plane(s.width,s.height)}),i.draw(()=>{this.states.filterShader.setUniform("direction",[0,1]),this.states.filterShader.setUniform("tex0",e),this.clear(),this.shader(this.states.filterShader),this.noLights(),this.plane(s.width,s.height)}),this.pop()}else i.draw(()=>{this.states.setValue("strokeColor",null),this.blendMode($),this.shader(this.states.filterShader),this.states.filterShader.setUniform("tex0",s),this.states.filterShader.setUniform("texelSize",n),this.states.filterShader.setUniform("canvasSize",[s.width,s.height]),this.states.filterShader.setUniform("filterParameter",t),this.noLights(),this.plane(s.width,s.height)});this.push(),this.states.setValue("strokeColor",null),this.clear(),this.push(),this.states.setValue("imageMode",_),this.blendMode($),s.filterCamera._resize(),this.setCamera(s.filterCamera),this.resetMatrix(),this._drawingFilter=!0,this.image(i,0,0,i.width,i.height,-s.width/2,-s.height/2,s.width,s.height),this._drawingFilter=!1,this.clearDepth(),this.pop(),this.pop()}pixelDensity(e){return e?this._pInst.pixelDensity(e):this._pInst.pixelDensity()}blendMode(e){e===W||e===X||e===q||e===$||e===K||e===Q||e===Z||e===ee||e===J||e===H?this.states.setValue("curBlendMode",e):e!==ne&&e!==te&&e!==re&&e!==ie&&e!==se||console.warn("BURN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, and DODGE only work for blendMode in 2D mode.")}erase(e,t){this._isErasing||(this.preEraseBlend=this.states.curBlendMode,this._isErasing=!0,this.blendMode(H),this._cachedFillStyle=this.states.curFillColor.slice(),this.states.setValue("curFillColor",[1,1,1,e/255]),this._cachedStrokeStyle=this.states.curStrokeColor.slice(),this.states.setValue("curStrokeColor",[1,1,1,t/255]))}noErase(){this._isErasing&&(this.states.setValue("curFillColor",this._cachedFillStyle.slice()),this.states.setValue("curStrokeColor",this._cachedStrokeStyle.slice()),this.states.setValue("curBlendMode",this.preEraseBlend),this.blendMode(this.preEraseBlend),this._isErasing=!1,this._applyBlendMode())}_applyBlendMode(){}drawTarget(){return this.activeFramebuffers[this.activeFramebuffers.length-1]||this}beginClip(e={}){super.beginClip(e),this.drawTarget()._isClipApplied=!0,this._applyClip(),this.push(),this.resetShader(),this.states.fillColor&&this.fill(0,0),this.states.strokeColor&&this.stroke(0,0)}endClip(){this.pop(),this._unapplyClip(),this._clipDepths.push(this._pushPopDepth),super.endClip()}_clearClip(){this._clearClipBuffer(),this._clipDepths.length>0&&this._clipDepths.pop(),this.drawTarget()._isClipApplied=!1}_getTempFramebuffer(){return this._tempFramebuffer||(this._tempFramebuffer=new ma(this,{format:Be,useDepth:this._pInst._glAttributes.depth,depthFormat:Le,antialias:this._pInst._glAttributes.antialias})),this._tempFramebuffer}geometryInHash(e){return this.geometryBufferCache.isCached(e)}resize(e,t){super.resize(e,t);const r={};for(const e in this.drawingContext){const t=this.drawingContext[e];"object"!=typeof t&&"function"!=typeof t&&(r[e]=t)}const i=this._adjustDimensions(e,t);e=i.adjustedWidth,t=i.adjustedHeight,this.width=e,this.height=t,this.canvas.width=e*this._pixelDensity,this.canvas.height=t*this._pixelDensity,this.canvas.style.width=`${e}px`,this.canvas.style.height=`${t}px`,this._updateViewport(),this._updateSize(),this.mainCamera._resize(),this.states.curCamera!==this.mainCamera&&this.states.curCamera._resize(),void 0!==this.pixels&&this._createPixelsArray();for(const e of this.framebuffers)this.flushDraw?.(),e._canvasSizeChanged();this.flushDraw?.();for(const t in r)try{this.drawingContext[t]=r[t]}catch(e){}}applyMatrix(e,t,r,i,s,n){this.states.setValue("uModelMatrix",this.states.uModelMatrix.clone()),16===arguments.length?dn.prototype.apply.apply(this.states.uModelMatrix,arguments):this.states.uModelMatrix.apply([e,t,0,0,r,i,0,0,0,0,1,0,s,n,0,1])}translate(e,t,r){return e instanceof Xi&&(r=e.z,t=e.y,e=e.x),this.states.setValue("uModelMatrix",this.states.uModelMatrix.clone()),this.states.uModelMatrix.translate([e,t,r]),this}scale(e,t,r){return this.states.setValue("uModelMatrix",this.states.uModelMatrix.clone()),this.states.uModelMatrix.scale(e,t,r),this}rotate(e,t){return void 0===t?this.rotateZ(e):(this.states.setValue("uModelMatrix",this.states.uModelMatrix.clone()),dn.prototype.rotate4x4.apply(this.states.uModelMatrix,arguments),this)}rotateX(e){return this.rotate(e,1,0,0),this}rotateY(e){return this.rotate(e,0,1,0),this}rotateZ(e){return this.rotate(e,0,0,1),this}pop(...e){this._clipDepths.length>0&&this._pushPopDepth===this._clipDepths[this._clipDepths.length-1]&&this._clearClip(),super.pop(...e),this._applyStencilTestIfClipping()}resetMatrix(){return this.states.setValue("uModelMatrix",this.states.uModelMatrix.clone()),this.states.uModelMatrix.reset(),this.states.setValue("uViewMatrix",this.states.uViewMatrix.clone()),this.states.uViewMatrix.set(this.states.curCamera.cameraMatrix),this}_getStrokeShader(){return this.states.userStrokeShader||this._getLineShader()}_getFillShader(){return this._drawingImage?this.states.userImageShader&&!this._drawingFilter?this.states.userImageShader:this._getLightShader():this.states.userFillShader?this.states.userFillShader:this.states._useNormalMaterial?this._getNormalShader():this.states.enableLighting||this.states._tex?this._getLightShader():this._getColorShader()}baseMaterialShader(){return this._getLightShader()}baseNormalShader(){return this._getNormalShader()}baseColorShader(){return this._getColorShader()}baseStrokeShader(){return this._getLineShader()}activeFramebuffer(){return this.activeFramebuffers[this.activeFramebuffers.length-1]||null}createFramebuffer(e){return new ma(this,e)}_setGlobalUniforms(e){const t=this.states.uModelMatrix,r=this.states.uViewMatrix,i=this.states.uPMatrix,s=t.copy().mult(r);if(e.setUniform("uPerspective",this.states.curCamera.useLinePerspective?1:0),e.setUniform("uViewMatrix",r.mat4),e.setUniform("uProjectionMatrix",i.mat4),e.setUniform("uModelMatrix",t.mat4),e.setUniform("uModelViewMatrix",s.mat4),e.uniforms.uModelViewProjectionMatrix){const t=s.copy();t.mult(i),e.setUniform("uModelViewProjectionMatrix",t.mat4)}e.uniforms.uNormalMatrix&&(this.scratchMat3.inverseTranspose4x4(s),e.setUniform("uNormalMatrix",this.scratchMat3.mat3)),e.uniforms.uModelNormalMatrix&&(this.scratchMat3.inverseTranspose4x4(this.states.uModelMatrix),e.setUniform("uModelNormalMatrix",this.scratchMat3.mat3)),e.uniforms.uCameraNormalMatrix&&(this.scratchMat3.inverseTranspose4x4(this.states.uViewMatrix),e.setUniform("uCameraNormalMatrix",this.scratchMat3.mat3)),e.setUniform("uViewport",this._viewport)}_setStrokeUniforms(e){e.setUniform("uSimpleLines",this._simpleLines),e.setUniform("uUseLineColor",this._useLineColor),e.setUniform("uMaterialColor",this.states.curStrokeColor),e.setUniform("uStrokeWeight",this.states.strokeWeight),e.setUniform("uStrokeCap",zn[this.curStrokeCap]),e.setUniform("uStrokeJoin",Gn[this.curStrokeJoin])}_setFillUniforms(e){this.mixedSpecularColor=[...this.states.curSpecularColor];const t=this._getEmptyTexture();this.states._useMetalness>0&&(this.mixedSpecularColor=this.mixedSpecularColor.map((e,t)=>this.states.curFillColor[t]*this.states._useMetalness+e*(1-this.states._useMetalness))),e.setUniform("uUseVertexColor",this._useVertexColor),e.setUniform("uMaterialColor",this.states.curFillColor),e.setUniform("isTexture",!!this.states._tex),e.setUniform("uSampler",this.states._tex||t),e.setUniform("uTint",this.states.tint),e.setUniform("uHasSetAmbient",this.states._hasSetAmbient),e.setUniform("uAmbientMatColor",this.states.curAmbientColor),e.setUniform("uSpecularMatColor",this.mixedSpecularColor),e.setUniform("uEmissiveMatColor",this.states.curEmissiveColor),e.setUniform("uSpecular",this.states._useSpecularMaterial),e.setUniform("uEmissive",this.states._useEmissiveMaterial),e.setUniform("uShininess",this.states._useShininess),e.setUniform("uMetallic",this.states._useMetalness),this._setImageLightUniforms(e),e.setUniform("uUseLighting",this.states.enableLighting);const r=this.states.pointLightDiffuseColors.length/3;e.setUniform("uPointLightCount",r),e.setUniform("uPointLightLocation",this.states.pointLightPositions),e.setUniform("uPointLightDiffuseColors",this.states.pointLightDiffuseColors),e.setUniform("uPointLightSpecularColors",this.states.pointLightSpecularColors);const i=this.states.directionalLightDiffuseColors.length/3;e.setUniform("uDirectionalLightCount",i),e.setUniform("uLightingDirection",this.states.directionalLightDirections),e.setUniform("uDirectionalDiffuseColors",this.states.directionalLightDiffuseColors),e.setUniform("uDirectionalSpecularColors",this.states.directionalLightSpecularColors);let s=[0,0,0];for(let e=0;e<this.states.ambientLightColors.length;e+=3)for(let t=0;t<3;t++)this.states._useMetalness>0?s[t]+=Math.max(0,this.states.ambientLightColors[e+t]-this.states._useMetalness):s[t]+=this.states.ambientLightColors[e+t];e.setUniform("uAmbientColor",s);const n=this.states.spotLightDiffuseColors.length/3;e.setUniform("uSpotLightCount",n),e.setUniform("uSpotLightAngle",this.states.spotLightAngle),e.setUniform("uSpotLightConc",this.states.spotLightConc),e.setUniform("uSpotLightDiffuseColors",this.states.spotLightDiffuseColors),e.setUniform("uSpotLightSpecularColors",this.states.spotLightSpecularColors),e.setUniform("uSpotLightLocation",this.states.spotLightPositions),e.setUniform("uSpotLightDirection",this.states.spotLightDirections),e.setUniform("uConstantAttenuation",this.states.constantAttenuation),e.setUniform("uLinearAttenuation",this.states.linearAttenuation),e.setUniform("uQuadraticAttenuation",this.states.quadraticAttenuation)}_setImageLightUniforms(e){if(e.setUniform("uUseImageLight",null!=this.states.activeImageLight),this.states.activeImageLight){let t=this.getDiffusedTexture(this.states.activeImageLight);e.setUniform("environmentMapDiffused",t);let r=this.getSpecularTexture(this.states.activeImageLight);e.setUniform("environmentMapSpecular",r)}else e.setUniform("environmentMapDiffused",this._getEmptyTexture()),e.setUniform("environmentMapSpecular",this._getEmptyTexture())}_getEmptyTexture(){if(!this._emptyTexture){const e=new $i(1,1);e.set(0,0,255),this._emptyTexture=new ta(this,e)}return this._emptyTexture}getTexture(e){let t=e;t instanceof ma&&(t=t.color);const r=this.textures.get(t);if(r)return r;const i=new ta(this,t);return this.textures.set(t,i),i}_normalizeBufferData(e,t=Float32Array){return e?e instanceof mn?e.dataArray():e instanceof t?e:new t(e):null}_arraysEqual(e,t){return e.length===t.length&&e.every((e,r)=>e===t[r])}_isTypedArray(e){return[Float32Array,Float64Array,Int16Array,Uint16Array,Uint32Array].some(t=>e instanceof t)}_vToNArray(e){return e.flatMap(e=>[e.x,e.y,e.z])}_beforeDrawText(){}_afterDrawText(){}textCanvas(){return this._textCanvas||(this._textCanvas=document.createElement("canvas"),this._textCanvas.width=1,this._textCanvas.height=1,this._textCanvas.style.display="none",this.canvas.parentElement.insertBefore(this._textCanvas,this.canvas)),this._textCanvas}textDrawingContext(){if(!this._textDrawingContext){const e=this.textCanvas();this._textDrawingContext=e.getContext("2d")}return this._textDrawingContext}_positionLines(e,t,r,i,s){let{textLeading:n,textAlign:a}=this.states;const o=s.map(e=>this._fontWidthSingle(e));let h,u=new Array(s.length),l=void 0===r?Math.max(0,...o):r,c=void 0===i?0:i;for(let i=0;i<s.length;i++){switch(a){case On:throw new Error("textBounds: START not yet supported for textAlign");case D:h=e;break;case A:h=e+(l-o[i])/2-l/2+(r||0)/2;break;case E:h=e+l-o[i]-l+(r||0);break;case Rn:throw new Error("textBounds: END not yet supported for textAlign");default:h=e}u[i]={text:s[i],x:h,y:t+i*n}}return this._yAlignOffset(u,c)}_verticalAlignFont=function(){const e=this.textDrawingContext().measureText("X");return-e.alphabeticBaseline||-e.fontBoundingBoxAscent+e.fontBoundingBoxDescent};_yAlignOffset(e,t){if(void 0===t)throw Error("_yAlignOffset: height is required");let{textLeading:r,textBaseline:i,textSize:s}=this.states,n=0,a=e.length,o=s*a+(r-s)*(a-1);switch(i){case S:n=this._verticalAlignFont();break;case T:break;case Ln:n=(-o+s+(t||0))/2+this._verticalAlignFont()+this._middleAlignOffset();break;case F:n=-(o-s)+(t||0);break;default:console.warn(`${i} is not supported in WebGL mode.`)}return e.forEach(e=>e.y+=n),e}_makeFilterShader(e,t){return Vn(this,t,this._pInst)}makeDiffusedTexture(e){if(null!=this.diffusedTextures.get(e))return this.diffusedTextures.get(e);let t,r=Math.floor(e.height/e.width*200);return t=new ma(this,{width:200,height:r,density:1}),this.diffusedShader||(this.diffusedShader=this._createImageLightShader("diffused")),t.draw(()=>{this.shader(this.diffusedShader),this._setImageLightShaderUniforms(this.diffusedShader,e),this.states.setValue("strokeColor",null),this.noLights(),this.plane(200,r)}),this.diffusedTextures.set(e,t),t}getDiffusedTexture(e){return this.diffusedTextures.get(e)}makeSpecularTexture(e){if(null!=this.specularTextures.get(e))return this.specularTextures.get(e);const t=512;let r,i=Math.floor(Math.log2(t))+1;this.specularShader||(this.specularShader=this._createImageLightShader("specular"));const s=this._prepareMipmapData(t,i),n=new ma(this,{width:t,height:t,density:1});let a=0;for(let r=t;r>=1;r/=2){n.resize(r,r);let t=1-Math.log(r)/Math.log(2)/i;n.draw(()=>{this.shader(this.specularShader),this.clear(),this._setImageLightShaderUniforms(this.specularShader,e,t),this.states.setValue("strokeColor",null),this.noLights(),this.plane(r,r)}),this._accumulateMipLevel(n,s,a,r,r),a++}return n.remove(),r=this._finalizeMipmapTexture(s),this.specularTextures.set(e,r),r}getSpecularTexture(e){return this.specularTextures.get(e)}_getSphereMapping(e){if(!this.sphereMapping){const e=this._pInst;this.sphereMapping=this.baseFilterShader().modify(({p5:e})=>{const t=e.uniformTexture("uEnvMap"),r=e.uniformFloat("uFovY"),i=e.uniformFloat("uAspect"),s=e.uniformVec3("uN1"),n=e.uniformVec3("uN2"),a=e.uniformVec3("uN3");e.getColor(o=>{const h=r*i,u=e.mix(r/2,-r/2,o.texCoord.y),l=e.mix(h/2,-h/2,o.texCoord.x);let c=e.normalize([l,u,1]);c=[e.dot(c,s),e.dot(c,n),e.dot(c,a)];const p=c.z;c.z=c.x,c.x=-p;const d=[e.atan(c.z,c.x)/(2*e.PI)+.5,.5+.5*-c.y];return e.getTexture(t,d)})},{p5:e})}this.scratchMat3.inverseTranspose4x4(this.states.uViewMatrix),this.scratchMat3.invert(this.scratchMat3),this.sphereMapping.setUniform("uFovY",this.states.curCamera.cameraFOV),this.sphereMapping.setUniform("uAspect",this.states.curCamera.aspectRatio);const t=this.scratchMat3.mat3;return this.sphereMapping.setUniform("uN1",[t[0],t[3],t[6]]),this.sphereMapping.setUniform("uN2",[t[1],t[4],t[7]]),this.sphereMapping.setUniform("uN3",[t[2],t[5],t[8]]),this.sphereMapping.setUniform("uEnvMap",e),this.sphereMapping}_createImageLightShader(e){throw new Error("_createImageLightShader must be implemented by the renderer")}_setImageLightShaderUniforms(e,t,r){e.setUniform("environmentMap",t),void 0!==r&&e.setUniform("roughness",r)}_createMipmapTexture(e){throw new Error("_createMipmapTexture must be implemented by the renderer")}_prepareMipmapData(e,t){throw new Error("_prepareMipmapData must be implemented by the renderer")}_accumulateMipLevel(e,t,r,i,s){throw new Error("_accumulateMipLevel must be implemented by the renderer")}_finalizeMipmapTexture(e){throw new Error("_finalizeMipmapTexture must be implemented by the renderer")}remove(){this._textCanvas&&this._textCanvas.parentElement.removeChild(this._textCanvas),super.remove()}}function $n(e,t){e.Renderer3D=jn}function Hn(e,t){t.strokeMode=function(e){if(void 0===e)return this._renderer._simpleLines?o:h;if(e===o)this._renderer._simpleLines=!0;else{if(e!==h)throw Error("no such parameter");this._renderer._simpleLines=!1}},t.buildGeometry=function(e){return this._renderer.buildGeometry(e)},t.freeGeometry=function(e){this._renderer.geometryBufferCache.freeBuffers(e.gid)},t.plane=function(e=50,t=e,r=1,i=1){return this._assert3d("plane"),this._renderer.plane(e,t,r,i),this},t.box=function(e,t,r,i,s){return this._assert3d("box"),this._renderer.box(e,t,r,i,s),this},t.sphere=function(e=50,t=24,r=16){return this._assert3d("sphere"),this._renderer.sphere(e,t,r),this},t.cylinder=function(e=50,t=e,r=24,i=1,s=!0,n=!0){return this._assert3d("cylinder"),this._renderer.cylinder(e,t,r,i,s,n),this},t.cone=function(e=50,t=e,r=24,i=1,s=!0){return this._assert3d("cone"),this._renderer.cone(e,t,r,i,s),this},t.ellipsoid=function(e=50,t=e,r=e,i=24,s=16){return this._assert3d("ellipsoid"),this._renderer.ellipsoid(e,t,r,i,s),this},t.torus=function(e,t,r,i){return this._assert3d("torus"),this._renderer.torus(e,t,r,i),this},jn.prototype.point=function(e,t,r=0){return this.beginShape(M),this.vertex(e,t,r),this.endShape(),this},jn.prototype.triangle=function(e){const t=e[0],r=e[1],i=e[2],s=e[3],n=e[4],a=e[5],o="tri";if(!this.geometryInHash(o)){const e=new xn(1,1,function(){const e=[];e.push(new Xi(0,0,0)),e.push(new Xi(1,0,0)),e.push(new Xi(0,1,0)),this.edges=[[0,1],[1,2],[2,0]],this.vertices=e,this.faces=[[0,1,2]],this.uvs=[0,0,1,0,1,1]},this);e._edgesToVertices(),e.computeNormals(),e.gid=o,this.geometryBufferCache.ensureCached(e)}const h=this.states.uModelMatrix.copy();try{const e=Math.sign(t*s-i*r+i*a-n*s+n*r-t*a),h=new dn([i-t,s-r,0,0,n-t,a-r,0,0,0,0,e,0,t,r,0,1]).mult(this.states.uModelMatrix);this.states.setValue("uModelMatrix",h),this.model(this.geometryBufferCache.getGeometryByID(o))}finally{this.states.setValue("uModelMatrix",h)}return this},jn.prototype.ellipse=function(e){this.arc(e[0],e[1],e[2],e[3],0,x,P,e[4])},jn.prototype.arc=function(...e){const t=e[0],r=e[1],i=e[2],s=e[3],n=e[4],a=e[5],o=e[6],h=e[7]||25;let u,l;if(Math.abs(a-n)>=x?(u="ellipse",l=`${u}|${h}|`):(u="arc",l=`${u}|${n}|${a}|${o}|${h}|`),!this.geometryInHash(l)){const e=function(){if(n.toFixed(10)!==a.toFixed(10)){o!==R&&void 0!==o||(this.vertices.push(new Xi(.5,.5,0)),this.uvs.push([.5,.5]));for(let e=0;e<=h;e++){const t=e/h*(a-n)+n,r=.5+Math.cos(t)/2,i=.5+Math.sin(t)/2;this.vertices.push(new Xi(r,i,0)),this.uvs.push([r,i]),e<h-1&&(this.faces.push([0,e+1,e+2]),this.edges.push([e+1,e+2]))}switch(o){case R:this.faces.push([0,this.vertices.length-2,this.vertices.length-1]),this.edges.push([0,1]),this.edges.push([this.vertices.length-2,this.vertices.length-1]),this.edges.push([0,this.vertices.length-1]);break;case O:this.edges.push([0,1]),this.edges.push([0,this.vertices.length-1]);break;case P:this.edges.push([0,1]);break;default:this.faces.push([0,this.vertices.length-2,this.vertices.length-1]),this.edges.push([this.vertices.length-2,this.vertices.length-1])}}},t=new xn(h,1,e,this);t.computeNormals(),h<=50?t._edgesToVertices(t):this.states.strokeColor&&console.log(`Cannot apply a stroke to an ${u} with more than 50 detail`),t.gid=l,this.geometryBufferCache.ensureCached(t)}const c=this.states.uModelMatrix;this.states.setValue("uModelMatrix",this.states.uModelMatrix.clone());try{this.states.uModelMatrix.translate([t,r,0]),this.states.uModelMatrix.scale(i,s,1),this.model(this.geometryBufferCache.getGeometryByID(l))}finally{this.states.setValue("uModelMatrix",c)}return this},jn.prototype.rect=function(e){const t=e[0],r=e[1],i=e[2],s=e[3];if(void 0===e[4]){const n=this._pInst._glAttributes?.perPixelLighting??!0,a=e[4]||(n?1:24),o=e[5]||(n?1:16),h=`rect|${a}|${o}`;if(!this.geometryInHash(h)){const e=function(){for(let e=0;e<=this.detailY;e++){const t=e/this.detailY;for(let e=0;e<=this.detailX;e++){const r=e/this.detailX,i=new Xi(r,t,0);this.vertices.push(i),this.uvs.push(r,t)}}a>0&&o>0&&(this.edges=[[0,a],[a,(a+1)*(o+1)-1],[(a+1)*(o+1)-1,(a+1)*o],[(a+1)*o,0]])},t=new xn(a,o,e,this);t.computeFaces().computeNormals()._edgesToVertices(),t.gid=h,this.geometryBufferCache.ensureCached(t)}const u=this.states.uModelMatrix;this.states.setValue("uModelMatrix",this.states.uModelMatrix.copy());try{this.states.uModelMatrix.translate([t,r,0]),this.states.uModelMatrix.scale(i,s,1),this.model(this.geometryBufferCache.getGeometryByID(h))}finally{this.states.setValue("uModelMatrix",u)}}else{let n=e[4],a=void 0===e[5]?n:e[5],o=void 0===e[6]?a:e[6],h=void 0===e[7]?o:e[7],u=t,l=r,c=i,p=s;if(c+=u,p+=l,u>c){const e=u;u=c,c=e}if(l>p){const e=l;l=p,p=e}const d=Math.min((c-u)/2,(p-l)/2);n>d&&(n=d),a>d&&(a=d),o>d&&(o=d),h>d&&(h=d);let f=u,g=l,m=c,y=p;const x=this.states.textureMode;this.states.setValue("textureMode",fe);const v=this.bezierOrder();this.bezierOrder(2),this.beginShape();const b=(e,t)=>[e,t,0,(e-f)/i,(t-g)/s];0!==a?(this.vertex(...b(m-a,g)),this.bezierVertex(...b(m,g)),this.bezierVertex(...b(m,g+a))):this.vertex(...b(m,g)),0!==o?(this.vertex(...b(m,y-o)),this.bezierVertex(...b(m,y)),this.bezierVertex(...b(m-o,y))):this.vertex(...b(m,y)),0!==h?(this.vertex(...b(f+h,y)),this.bezierVertex(...b(f,y)),this.bezierVertex(...b(f,y-h))):this.vertex(...b(f,y)),0!==n?(this.vertex(...b(f,g+n)),this.bezierVertex(...b(f,g)),this.bezierVertex(...b(f+n,g))):this.vertex(...b(f,g)),this.endShape(L),this.states.setValue("textureMode",x),this.bezierOrder(v)}return this},jn.prototype.quad=function(e,t,r,i,s,n,a,o,h,u,l,c,p=2,d=2){const f=`quad|${e}|${t}|${r}|${i}|${s}|${n}|${a}|${o}|${h}|${u}|${l}|${c}|${p}|${d}`;if(!this.geometryInHash(f)){const g=new xn(p,d,function(){let p=1/(this.detailX-1),d=1/(this.detailY-1);for(let f=0;f<this.detailY;f++)for(let g=0;g<this.detailX;g++){let m=g*p,y=f*d,x=(1-m)*((1-y)*e+y*u)+m*((1-y)*i+y*a),v=(1-m)*((1-y)*t+y*l)+m*((1-y)*s+y*o),b=(1-m)*((1-y)*r+y*c)+m*((1-y)*n+y*h);this.vertices.push(new Xi(x,v,b)),this.uvs.push([m,y])}},this);g.faces=[];for(let e=0;e<d-1;e++)for(let t=0;t<p-1;t++){let r=t+e*p,i=t+1+e*p,s=t+1+(e+1)*p,n=t+(e+1)*p;g.faces.push([r,i,s]),g.faces.push([r,s,n])}g.computeNormals(),g.edges.length=0;const m=[0,2,3,1];for(let e=0;e<m.length;e++){const t=m[e],r=m[(e+1)%m.length];g.edges.push([t,r])}g._edgesToVertices(),g.gid=f,this.geometryBufferCache.ensureCached(g)}return this.model(this.geometryBufferCache.getGeometryByID(f)),this},jn.prototype.bezier=function(e,t,r,i,s,n,a,o,h,u,l,c){8===arguments.length&&(l=o,u=a,o=n,a=s,s=i,i=r,r=n=h=c=0),this.bezierOrder(),this.bezierOrder(3),this.beginShape(),this.vertex(e,t,r),this.bezierVertex(i,s,n),this.bezierVertex(a,o,h),this.bezierVertex(u,l,c),this.endShape()},jn.prototype.curve=function(e,t,r,i,s,n,a,o,h,u,l,c){8===arguments.length&&(u=a,l=o,a=s,o=i,s=i=r,r=n=h=c=0),this.beginShape(),this.splineVertex(e,t,r),this.splineVertex(i,s,n),this.splineVertex(a,o,h),this.splineVertex(u,l,c),this.endShape()},jn.prototype.line=function(...e){return 6===e.length?(this.beginShape(k),this.vertex(e[0],e[1],e[2]),this.vertex(e[3],e[4],e[5]),this.endShape()):4===e.length&&(this.beginShape(k),this.vertex(e[0],e[1],0),this.vertex(e[2],e[3],0),this.endShape()),this},jn.prototype.image=function(e,t,r,i,s,n,a,o,h){this._isErasing&&this.blendMode(this._cachedBlendMode),this.push(),this.noLights(),this.states.setValue("strokeColor",null),this.texture(e),this.states.setValue("textureMode",fe);let u=0;t<=e.width&&(u=t/e.width);let l=1;t+i<=e.width&&(l=(t+i)/e.width);let c=0;r<=e.height&&(c=r/e.height);let p=1;r+s<=e.height&&(p=(r+s)/e.height),this._drawingImage=!0,this.beginShape(),this.vertex(n,a,0,u,c),this.vertex(n+o,a,0,l,c),this.vertex(n+o,a+h,0,l,p),this.vertex(n,a+h,0,u,p),this.endShape(L),this._drawingImage=!1,this.pop(),this._isErasing&&this.blendMode(H)};const r=function(e,t,r,i,s,n,a){e=e<=0?1:e,t=t<0?0:t,r=r<=0?e:r,i=i<3?3:i;const o=(n=void 0===n||n)?-2:0,h=(s=s<1?1:s)+((a=void 0===a?0!==t:a)?2:0),u=Math.atan2(e-t,r),l=Math.sin(u),c=Math.cos(u);let p,d,f;for(p=o;p<=h;++p){let n,a=p/s,o=r*a;for(p<0?(o=0,a=0,n=e):p>s?(o=r,a=1,n=t):n=e+(t-e)*a,-2!==p&&p!==s+2||(n=0),o-=r/2,d=0;d<i;++d){const e=d/(i-1),r=2*Math.PI*e,h=Math.sin(r),u=Math.cos(r);let f;this.vertices.push(new Xi(h*n,o,u*n)),f=p<0?new Xi(0,-1,0):p>s&&t?new Xi(0,1,0):new Xi(h*c,l,u*c),this.vertexNormals.push(f),this.uvs.push(e,a)}}let g=0;if(n){for(f=0;f<i;++f){const e=(f+1)%i;this.faces.push([g+f,g+i+e,g+i+f])}g+=2*i}for(p=0;p<s;++p){for(d=0;d<i;++d){const e=(d+1)%i;this.faces.push([g+d,g+e,g+i+e]),this.faces.push([g+d,g+i+e,g+i+d])}g+=i}if(a)for(g+=i,d=0;d<i;++d)this.faces.push([g+d,g+(d+1)%i,g+i])};jn.prototype.plane=function(e=50,t=e,r=1,i=1){const s=`plane|${r}|${i}`;if(!this.geometryInHash(s)){const e=function(){let e,t,r;for(let i=0;i<=this.detailY;i++){t=i/this.detailY;for(let i=0;i<=this.detailX;i++)e=i/this.detailX,r=new Xi(e-.5,t-.5,0),this.vertices.push(r),this.uvs.push(e,t)}},t=new xn(r,i,e,this);t.computeFaces().computeNormals(),r<=1&&i<=1?t._makeTriangleEdges()._edgesToVertices():this.states.strokeColor&&console.log("Cannot draw stroke on plane objects with more than 1 detailX or 1 detailY"),t.gid=s,this.geometryBufferCache.ensureCached(t)}this._drawGeometryScaled(this.geometryBufferCache.getGeometryByID(s),e,t,1)},jn.prototype.box=function(e=50,t=e,r=t,i,s){const n=this.attributes&&this.attributes.perPixelLighting;void 0===i&&(i=n?1:4),void 0===s&&(s=n?1:4);const a=`box|${i}|${s}`;if(!this.geometryInHash(a)){const e=function(){this.edges=[[0,1],[1,3],[3,2],[6,7],[8,9],[9,11],[14,15],[16,17],[17,19],[18,19],[20,21],[22,23]],[[0,4,2,6],[1,3,5,7],[0,1,4,5],[2,6,3,7],[0,2,1,3],[4,5,6,7]].forEach((e,t)=>{const r=4*t;for(let t=0;t<4;t++){const r=e[t],i=new Xi((2*(1&r)-1)/2,((2&r)-1)/2,((4&r)/2-1)/2);this.vertices.push(i),this.uvs.push(1&t,(2&t)/2)}this.faces.push([r,r+1,r+2]),this.faces.push([r+2,r+1,r+3])})},t=new xn(i,s,e,this);t.computeNormals(),i<=4&&s<=4?t._edgesToVertices():this.states.strokeColor&&console.log("Cannot draw stroke on box objects with more than 4 detailX or 4 detailY"),t.gid=a,this.geometryBufferCache.ensureCached(t)}this._drawGeometryScaled(this.geometryBufferCache.getGeometryByID(a),e,t,r)},jn.prototype.sphere=function(e=50,t=24,r=16){this.ellipsoid(e,e,e,t,r)},jn.prototype.ellipsoid=function(t=50,r=t,i=t,s=24,n=16){const a=`ellipsoid|${s}|${n}`;if(!this.geometryInHash(a)){const t=function(){for(let t=0;t<=this.detailY;t++){const r=t/this.detailY,i=Math.PI*r-Math.PI/2,s=Math.cos(i),n=Math.sin(i);for(let t=0;t<=this.detailX;t++){const i=t/this.detailX,a=2*Math.PI*i,o=Math.cos(a),h=Math.sin(a),u=new e.Vector(s*h,n,s*o);this.vertices.push(u),this.vertexNormals.push(u),this.uvs.push(i,r)}}},r=new xn(s,n,t,this);r.computeFaces(),s<=24&&n<=24?r._makeTriangleEdges()._edgesToVertices():this.states.strokeColor&&console.log("Cannot draw stroke on ellipsoids with more than 24 detailX or 24 detailY"),r.gid=a,this.geometryBufferCache.ensureCached(r)}this._drawGeometryScaled(this.geometryBufferCache.getGeometryByID(a),t,r,i)},jn.prototype.cylinder=function(t=50,i=t,s=24,n=1,a=!0,o=!0){const h=`cylinder|${s}|${n}|${a}|${o}`;if(!this.geometryInHash(h)){const t=new e.Geometry(s,n,function(){r.call(this,1,1,1,s,n,a,o)},this);s<=24&&n<=16?t._makeTriangleEdges()._edgesToVertices():this.states.strokeColor&&console.log("Cannot draw stroke on cylinder objects with more than 24 detailX or 16 detailY"),t.gid=h,this.geometryBufferCache.ensureCached(t)}this._drawGeometryScaled(this.geometryBufferCache.getGeometryByID(h),t,i,t)},jn.prototype.cone=function(e=50,t=e,i=24,s=1,n=!0){const a=`cone|${i}|${s}|${n}`;if(!this.geometryInHash(a)){const e=new xn(i,s,function(){r.call(this,1,0,1,i,s,n,!1)},this);i<=24&&s<=16?e._makeTriangleEdges()._edgesToVertices():this.states.strokeColor&&console.log("Cannot draw stroke on cone objects with more than 24 detailX or 16 detailY"),e.gid=a,this.geometryBufferCache.ensureCached(e)}this._drawGeometryScaled(this.geometryBufferCache.getGeometryByID(a),e,t,e)},jn.prototype.torus=function(e=50,t=10,r=24,i=16){if(0===e)return;if(0===t)return;const s=(t/e).toPrecision(4),n=`torus|${s}|${r}|${i}`;if(!this.geometryInHash(n)){const e=function(){for(let e=0;e<=this.detailY;e++){const t=e/this.detailY,r=2*Math.PI*t,i=Math.cos(r),n=Math.sin(r),a=1+s*i;for(let e=0;e<=this.detailX;e++){const r=e/this.detailX,o=2*Math.PI*r,h=Math.cos(o),u=Math.sin(o),l=new Xi(a*h,a*u,s*n),c=new Xi(i*h,i*u,n);this.vertices.push(l),this.vertexNormals.push(c),this.uvs.push(r,t)}}},t=new xn(r,i,e,this);t.computeFaces(),r<=24&&i<=16?t._makeTriangleEdges()._edgesToVertices():this.states.strokeColor&&console.log("Cannot draw strokes on torus object with more than 24 detailX or 16 detailY"),t.gid=n,this.geometryBufferCache.ensureCached(t)}this._drawGeometryScaled(this.geometryBufferCache.getGeometryByID(n),e,e,e)},t.curveDetail=function(e){if(!(this._renderer instanceof jn))throw new Error("curveDetail() only works in WebGL mode. Did you mean to call createCanvas(width, height, WEBGL)?");return this._renderer.curveDetail(e)}}function qn(e,t){t.ambientLight=function(e,t,r,i){return this._assert3d("ambientLight"),this._renderer.ambientLight(...arguments),this},t.specularColor=function(e,t,r){return this._assert3d("specularColor"),this._renderer.specularColor(...arguments),this},t.directionalLight=function(e,t,r,i,s,n){return this._assert3d("directionalLight"),this._renderer.directionalLight(...arguments),this},t.pointLight=function(e,t,r,i,s,n){return this._assert3d("pointLight"),this._renderer.pointLight(...arguments),this},t.imageLight=function(e){this._renderer.imageLight(e)},t.panorama=function(e){this.filter(this._renderer._getSphereMapping(e))},t.lights=function(){return this._assert3d("lights"),this._renderer.lights(),this},t.lightFalloff=function(e,t,r){return this._assert3d("lightFalloff"),this._renderer.lightFalloff(e,t,r),this},t.spotLight=function(e,t,r,i,s,n,a,o,h,u,l){return this._assert3d("spotLight"),this._renderer.spotLight(...arguments),this},t.noLights=function(...e){return this._assert3d("noLights"),this._renderer.noLights(),this},jn.prototype.ambientLight=function(e,t,r,i){const s=this._pInst.color(...arguments);this.states.setValue("ambientLightColors",[...this.states.ambientLightColors]),this.states.ambientLightColors.push(s._array[0],s._array[1],s._array[2]),this.states.setValue("enableLighting",!0)},jn.prototype.specularColor=function(e,t,r){const i=this._pInst.color(...arguments);this.states.setValue("specularColors",[i._array[0],i._array[1],i._array[2]])},jn.prototype.directionalLight=function(e,t,r,i,s,n){let a,o,h,u;a=e instanceof xi?e:this._pInst.color(e,t,r);const l=arguments[arguments.length-1];"number"==typeof l?(o=arguments[arguments.length-3],h=arguments[arguments.length-2],u=arguments[arguments.length-1]):(o=l.x,h=l.y,u=l.z);const c=Math.sqrt(o*o+h*h+u*u);this.states.setValue("directionalLightDirections",[...this.states.directionalLightDirections]),this.states.directionalLightDirections.push(o/c,h/c,u/c),this.states.setValue("directionalLightDiffuseColors",[...this.states.directionalLightDiffuseColors]),this.states.directionalLightDiffuseColors.push(a._array[0],a._array[1],a._array[2]),this.states.setValue("directionalLightSpecularColors",[...this.states.directionalLightSpecularColors]),Array.prototype.push.apply(this.states.directionalLightSpecularColors,this.states.specularColors),this.states.setValue("enableLighting",!0)},jn.prototype.pointLight=function(e,t,r,i,s,n){let a,o,h,u;a=e instanceof xi?e:this._pInst.color(e,t,r);const l=arguments[arguments.length-1];"number"==typeof l?(o=arguments[arguments.length-3],h=arguments[arguments.length-2],u=arguments[arguments.length-1]):(o=l.x,h=l.y,u=l.z),this.states.setValue("pointLightPositions",[...this.states.pointLightPositions]),this.states.pointLightPositions.push(o,h,u),this.states.setValue("pointLightDiffuseColors",[...this.states.pointLightDiffuseColors]),this.states.pointLightDiffuseColors.push(a._array[0],a._array[1],a._array[2]),this.states.setValue("pointLightSpecularColors",[...this.states.pointLightSpecularColors]),Array.prototype.push.apply(this.states.pointLightSpecularColors,this.states.specularColors),this.states.setValue("enableLighting",!0)},jn.prototype.imageLight=function(e){this.states.setValue("activeImageLight",e),this.states.setValue("enableLighting",!0),this.makeDiffusedTexture(e),this.makeSpecularTexture(e)},jn.prototype.lights=function(){const e=this._pInst.color("rgb(128,128,128)");this.ambientLight(e),this.directionalLight(e,0,0,-1)},jn.prototype.lightFalloff=function(e,t,r){e<0&&(e=0,console.warn("Value of constant argument in lightFalloff() should be never be negative. Set to 0.")),t<0&&(t=0,console.warn("Value of linear argument in lightFalloff() should be never be negative. Set to 0.")),r<0&&(r=0,console.warn("Value of quadratic argument in lightFalloff() should be never be negative. Set to 0.")),0===e&&0===t&&0===r&&(e=1,console.warn("Either one of the three arguments in lightFalloff() should be greater than zero. Set constant argument to 1.")),this.states.setValue("constantAttenuation",e),this.states.setValue("linearAttenuation",t),this.states.setValue("quadraticAttenuation",r)},jn.prototype.spotLight=function(e,t,r,i,s,n,a,o,h,u,l){if(this.states.spotLightDiffuseColors.length/3>=4)return;let c,p,d;const f=arguments.length;switch(f){case 11:case 10:c=this._pInst.color(e,t,r),p=new Xi(i,s,n),d=new Xi(a,o,h);break;case 9:e instanceof xi?(c=e,p=new Xi(t,r,i),d=new Xi(s,n,a),u=o,l=h):i instanceof Xi?(c=this._pInst.color(e,t,r),p=i,d=new Xi(s,n,a),u=o,l=h):a instanceof Xi?(c=this._pInst.color(e,t,r),p=new Xi(i,s,n),d=a,u=o,l=h):(c=this._pInst.color(e,t,r),p=new Xi(i,s,n),d=new Xi(a,o,h));break;case 8:e instanceof xi?(c=e,p=new Xi(t,r,i),d=new Xi(s,n,a),u=o):i instanceof Xi?(c=this._pInst.color(e,t,r),p=i,d=new Xi(s,n,a),u=o):(c=this._pInst.color(e,t,r),p=new Xi(i,s,n),d=a,u=o);break;case 7:e instanceof xi&&t instanceof Xi?(c=e,p=t,d=new Xi(r,i,s),u=n,l=a):e instanceof xi&&s instanceof Xi?(c=e,p=new Xi(t,r,i),d=s,u=n,l=a):i instanceof Xi&&s instanceof Xi?(c=this._pInst.color(e,t,r),p=i,d=s,u=n,l=a):e instanceof xi?(c=e,p=new Xi(t,r,i),d=new Xi(s,n,a)):i instanceof Xi?(c=this._pInst.color(e,t,r),p=i,d=new Xi(s,n,a)):(c=this._pInst.color(e,t,r),p=new Xi(i,s,n),d=a);break;case 6:i instanceof Xi&&s instanceof Xi?(c=this._pInst.color(e,t,r),p=i,d=s,u=n):e instanceof xi&&s instanceof Xi?(c=e,p=new Xi(t,r,i),d=s,u=n):e instanceof xi&&t instanceof Xi&&(c=e,p=t,d=new Xi(r,i,s),u=n);break;case 5:e instanceof xi&&t instanceof Xi&&r instanceof Xi?(c=e,p=t,d=r,u=i,l=s):i instanceof Xi&&s instanceof Xi?(c=this._pInst.color(e,t,r),p=i,d=s):e instanceof xi&&s instanceof Xi?(c=e,p=new Xi(t,r,i),d=s):e instanceof xi&&t instanceof Xi&&(c=e,p=t,d=new Xi(r,i,s));break;case 4:c=e,p=t,d=r,u=i;break;case 3:c=e,p=t,d=r;break;default:return void console.warn(`Sorry, input for spotlight() is not in prescribed format. Too ${f<3?"few":"many"} arguments were provided`)}this.states.setValue("spotLightDiffuseColors",[...this.states.spotLightDiffuseColors,c._array[0],c._array[1],c._array[2]]),this.states.setValue("spotLightSpecularColors",[...this.states.spotLightSpecularColors,...this.states.specularColors]),this.states.setValue("spotLightPositions",[...this.states.spotLightPositions,p.x,p.y,p.z]),d.normalize(),this.states.setValue("spotLightDirections",[...this.states.spotLightDirections,d.x,d.y,d.z]),void 0===u&&(u=Math.PI/3),void 0!==l&&l<1?(l=1,console.warn("Value of concentration needs to be greater than 1. Setting it to 1")):void 0===l&&(l=100),u=this._pInst._toRadians(u),this.states.setValue("spotLightAngle",[...this.states.spotLightAngle,Math.cos(u)]),this.states.setValue("spotLightConc",[...this.states.spotLightConc,l]),this.states.setValue("enableLighting",!0)},jn.prototype.noLights=function(){this.states.setValue("activeImageLight",null),this.states.setValue("enableLighting",!1),this.states.setValue("ambientLightColors",[]),this.states.setValue("specularColors",[1,1,1]),this.states.setValue("directionalLightDirections",[]),this.states.setValue("directionalLightDiffuseColors",[]),this.states.setValue("directionalLightSpecularColors",[]),this.states.setValue("pointLightPositions",[]),this.states.setValue("pointLightDiffuseColors",[]),this.states.setValue("pointLightSpecularColors",[]),this.states.setValue("spotLightPositions",[]),this.states.setValue("spotLightDirections",[]),this.states.setValue("spotLightDiffuseColors",[]),this.states.setValue("spotLightSpecularColors",[]),this.states.setValue("spotLightAngle",[]),this.states.setValue("spotLightConc",[]),this.states.setValue("constantAttenuation",1),this.states.setValue("linearAttenuation",0),this.states.setValue("quadraticAttenuation",0),this.states.setValue("_useShininess",1),this.states.setValue("_useMetalness",0)}}void 0!==p5&&$n(p5),void 0!==p5&&Hn(p5,p5.prototype),void 0!==p5&&qn(0,p5.prototype);const Wn=Object.getPrototypeOf(Uint8Array);class Xn{constructor(e,t,r,i={}){this._renderer=e,this._vertSrc=t,this._fragSrc=r,this._vertShader=-1,this._fragShader=-1,this._glProgram=0,this._loadedAttributes=!1,this.attributes={},this._loadedUniforms=!1,this.uniforms={},this._bound=!1,this.samplers=[],this.hooks={uniforms:i.uniforms||{},declarations:i.declarations,varyingVariables:i.varyingVariables||[],helpers:i.helpers||{},vertex:i.vertex||{},fragment:i.fragment||{},hookAliases:i.hookAliases||{},modified:{vertex:i.modified&&i.modified.vertex||{},fragment:i.modified&&i.modified.fragment||{}}}}hookTypes(e){return this._renderer.getShaderHookTypes(this,e)}shaderSrc(e,t){return this._renderer.populateHooks(this,e,t)}version(){const e=/#version (.+)$/.exec(this.vertSrc());return e?e[1]:"100 es"}vertSrc(){return this.shaderSrc(this._vertSrc,"vertex")}fragSrc(){return this.shaderSrc(this._fragSrc,"fragment")}inspectHooks(){console.log("==== Vertex shader hooks: ====");for(const e in this.hooks.vertex)console.log((this.hooks.modified.vertex[e]?"[MODIFIED] ":"")+e+this.hooks.vertex[e]);console.log(""),console.log("==== Fragment shader hooks: ====");for(const e in this.hooks.fragment)console.log((this.hooks.modified.fragment[e]?"[MODIFIED] ":"")+e+this.hooks.fragment[e]);console.log(""),console.log("==== Helper functions: ====");for(const e in this.hooks.helpers)console.log(e+this.hooks.helpers[e])}modify(e){const t={vertex:{},fragment:{},helpers:{}};for(const r in e)"declarations"!==r&&"uniforms"!==r&&"varyingVariables"!==r&&("vertexDeclarations"===r?t.vertex.declarations=(t.vertex.declarations||"")+"\n"+e[r]:"fragmentDeclarations"===r?t.fragment.declarations=(t.fragment.declarations||"")+"\n"+e[r]:this.hooks.vertex[r]?t.vertex[r]=e[r]:this.hooks.fragment[r]?t.fragment[r]=e[r]:t.helpers[r]=e[r]);const r=Object.assign({},this.hooks.modified.vertex),i=Object.assign({},this.hooks.modified.fragment);for(const e in t.vertex||{})"declarations"!==e&&(r[e]=!0);for(const e in t.fragment||{})"declarations"!==e&&(i[e]=!0);return new Xn(this._renderer,this._vertSrc,this._fragSrc,{declarations:(this.hooks.declarations||"")+"\n"+(e.declarations||""),uniforms:Object.assign({},this.hooks.uniforms,e.uniforms||{}),varyingVariables:(e.varyingVariables||[]).concat(this.hooks.varyingVariables||[]),fragment:Object.assign({},this.hooks.fragment,t.fragment||{}),vertex:Object.assign({},this.hooks.vertex,t.vertex||{}),helpers:Object.assign({},this.hooks.helpers,t.helpers||{}),hookAliases:Object.assign({},this.hooks.hookAliases,t.hookAliases||{}),modified:{vertex:r,fragment:i}})}init(){if(!this._initialized){try{this._renderer._initShader(this)}catch(e){throw new Error(`Whoops! Something went wrong initializing the shader:\n${e.message||e}`)}this._loadAttributes(),this._loadUniforms(),this._renderer._finalizeShader(this),this._initialized=!0}return this}setDefaultUniforms(){for(const e in this.hooks.uniforms){const t=this._renderer.uniformNameFromHookKey(e),r=this.hooks.uniforms[e];let i;i=r instanceof Function?r():r,null!=i&&this.setUniform(t,i)}}copyToContext(e){const t=new Xn(e._renderer,this._vertSrc,this._fragSrc);return t.ensureCompiledOnContext(e._renderer),t}ensureCompiledOnContext(e){if(0!==this._glProgram&&this._renderer!==e)throw new Error("The shader being run is attached to a different context. Do you need to copy it to this context first with .copyToContext()?");0===this._glProgram&&(this._renderer=e?._renderer?.filterRenderer?._renderer||e,this.init())}_loadAttributes(){this._loadedAttributes||(this.attributes=this._renderer._getShaderAttributes(this),this._loadedAttributes=!0)}_loadUniforms(){if(this._loadedUniforms)return;this.uniforms={},this.samplers=[];const e=this._renderer.getUniformMetadata(this);for(const t of e){const e={...t,_cachedData:void 0};e.isSampler&&this.samplers.push(e),this.uniforms[e.name]=e}this._loadedUniforms=!0}bindShader(e,t){if(this.shaderType&&this.shaderType!==e)throw new Error(`You've already used this shader as a ${this.shaderType} shader, but are now using it as a ${e}.`);this.shaderType=e,this.init(),this._bound||(this.useProgram(t),this._bound=!0)}unbindShader(){return this._bound&&(this.unbindTextures(),this._bound=!1),this}bindTextures(){const e=this._renderer._getEmptyTexture();for(const t of this.samplers){if(t.noData)continue;let r=t.texture;(void 0===r||r.isFramebufferTexture&&!r.src.framebuffer.antialias&&r.src.framebuffer===this._renderer.activeFramebuffer())&&(t.texture=r=e),this._renderer._updateTexture(t,r)}}unbindTextures(){for(const e of this.samplers)e.texture?.isFramebufferTexture&&this._renderer._unbindFramebufferTexture(e)}useProgram(e){return this._renderer._curShader!==this&&(this._renderer._useShader(this),this._renderer._curShader=this),this}setUniform(e,t){this.init();const r=this.uniforms[e];if(r){if(r.isArray){if(r._cachedData&&this._renderer._arraysEqual(r._cachedData,t))return;r._cachedData=t.slice(0)}else{if(r._cachedData&&r._cachedData===t)return;if(Array.isArray(t)||t instanceof Wn){if(r._cachedData&&this._renderer._arraysEqual(r._cachedData,t))return;r._cachedData=t.slice(0)}else{if(r._cachedData===t)return;r._cachedData=t}}this._renderer.updateUniformValue(this,r,t)}}enableAttrib(e,t,r,i,s,n){return e&&-1!==e.location&&this._renderer._enableAttrib(this,e,t,r,i,s,n),this}}function Yn(e,t){e.Shader=Xn}async function Kn(e){const t=await fetch(e).then(e=>e.text());return new Function(t)}function Zn(e,t){const r=e._runStrandsInGlobalMode;e._runStrandsInGlobalMode=!0;try{return t()}finally{e._runStrandsInGlobalMode=r}}function Jn(e,t){t.loadShader=async function(e,t,r,i){const s=new Xn;try{return s._vertSrc=(await js(e,"text")).data,s._fragSrc=(await js(t,"text")).data,r&&r(s)||s}catch(e){if(i)return i(e);throw e}},t.createShader=function(e,t,r){return new Xn(this._renderer,e,t,r)},t.loadFilterShader=async function(e,t,r){try{const r=await this.loadStrings(e),i=await r.join("\n");let s;return s=/void\s+main/.exec(i)?this.createFilterShader(i,!0):Zn(this,()=>this.baseFilterShader().modify(new Function(i))),t&&(s=t(s)||s),s}catch(e){r?r(e):console.error(e)}},t.buildFilterShader=function(e){return this.baseFilterShader().modify(e)},t.createFilterShader=function(e,t=!1){let r=e.includes("#version 300 es")?"#version 300 es\n uniform mat4 uModelViewMatrix;\n uniform mat4 uProjectionMatrix;\n\n in vec3 aPosition;\n in vec2 aTexCoord;\n out vec2 vTexCoord;\n\n void main() {\n // transferring texcoords for the frag shader\n vTexCoord = aTexCoord;\n\n // copy position with a fourth coordinate for projection (1.0 is normal)\n vec4 positionVec4 = vec4(aPosition, 1.0);\n\n // project to 3D space\n gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n }\n ":"\n uniform mat4 uModelViewMatrix;\n uniform mat4 uProjectionMatrix;\n\n attribute vec3 aPosition;\n // texcoords only come from p5 to vertex shader\n // so pass texcoords on to the fragment shader in a varying variable\n attribute vec2 aTexCoord;\n varying vec2 vTexCoord;\n\n void main() {\n // transferring texcoords for the frag shader\n vTexCoord = aTexCoord;\n\n // copy position with a fourth coordinate for projection (1.0 is normal)\n vec4 positionVec4 = vec4(aPosition, 1.0);\n\n // project to 3D space\n gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n }\n ";const i=new Xn(this._renderer,r,e);return t||(this._renderer.GL?i.ensureCompiledOnContext(this._renderer):i.ensureCompiledOnContext(this)),i},t.shader=function(e){return this._assert3d("shader"),this._renderer.shader(e),this},t.strokeShader=function(e){return this._assert3d("strokeShader"),this._renderer.strokeShader(e),this},t.imageShader=function(e){return this._assert3d("imageShader"),this._renderer.imageShader(e),this},t.buildMaterialShader=function(e){return this.baseMaterialShader().modify(e)},t.loadMaterialShader=async function(e,t,r){try{const r=await Kn(e);let i=Zn(this,()=>this.buildMaterialShader(r));return t&&(i=t(i)||i),i}catch(e){console.error(e),r&&r(e)}},t.baseMaterialShader=function(){return this._assert3d("baseMaterialShader"),this._renderer.baseMaterialShader()},t.baseFilterShader=function(){return(this._renderer.filterRenderer||this._renderer).baseFilterShader()},t.buildNormalShader=function(e){return this.baseNormalShader().modify(e)},t.loadNormalShader=async function(e,t,r){try{const r=await Kn(e);let i=this.withGlobalStrands(this,()=>this.buildNormalShader(r));return t&&(i=t(i)||i),i}catch(e){console.error(e),r&&r(e)}},t.baseNormalShader=function(){return this._assert3d("baseNormalShader"),this._renderer.baseNormalShader()},t.buildColorShader=function(e){return this.baseColorShader().modify(e)},t.loadColorShader=async function(e,t,r){try{const r=await Kn(e);let i=Zn(this,()=>this.buildColorShader(r));return t&&(i=t(i)||i),i}catch(e){console.error(e),r&&r(e)}},t.baseColorShader=function(){return this._assert3d("baseColorShader"),this._renderer.baseColorShader()},t.buildStrokeShader=function(e){return this.baseStrokeShader().modify(e)},t.loadStrokeShader=async function(e,t,r){try{const r=await Kn(e);let i=Zn(this,()=>this.buildStrokeShader(r));return t&&(i=t(i)||i),i}catch(e){console.error(e),r&&r(e)}},t.baseStrokeShader=function(){return this._assert3d("baseStrokeShader"),this._renderer.baseStrokeShader()},t.resetShader=function(){return this._renderer.resetShader(),this},t.texture=function(e){return this._assert3d("texture"),e.gifProperties&&e._animateGif(this),this._renderer.texture(e),this},t.textureMode=function(e){e!==ve&&e!==fe?console.warn(`You tried to set ${e} textureMode only supports IMAGE & NORMAL `):this._renderer.states.setValue("textureMode",e)},t.textureWrap=function(e,t=e){this._renderer.states.setValue("textureWrapX",e),this._renderer.states.setValue("textureWrapY",t);for(const r of this._renderer.textures.values())r.setWrapMode(e,t)},t.normalMaterial=function(...e){return this._assert3d("normalMaterial"),this._renderer.normalMaterial(...e),this},t.ambientMaterial=function(e,r,i){this._assert3d("ambientMaterial");const s=t.color.apply(this,arguments);return this._renderer.states.setValue("_hasSetAmbient",!0),this._renderer.states.setValue("curAmbientColor",s._array),this._renderer.states.setValue("_useNormalMaterial",!1),this._renderer.states.setValue("enableLighting",!0),this._renderer.states.fillColor||this._renderer.states.setValue("fillColor",new xi([1,1,1])),this},t.emissiveMaterial=function(e,r,i,s){this._assert3d("emissiveMaterial");const n=t.color.apply(this,arguments);return this._renderer.states.setValue("curEmissiveColor",n._array),this._renderer.states.setValue("_useEmissiveMaterial",!0),this._renderer.states.setValue("_useNormalMaterial",!1),this._renderer.states.setValue("enableLighting",!0),this},t.specularMaterial=function(e,r,i,s){this._assert3d("specularMaterial");const n=t.color.apply(this,arguments);return this._renderer.states.setValue("curSpecularColor",n._array),this._renderer.states.setValue("_useSpecularMaterial",!0),this._renderer.states.setValue("_useNormalMaterial",!1),this._renderer.states.setValue("enableLighting",!0),this},t.shininess=function(e){return this._assert3d("shininess"),this._renderer.shininess(e),this},t.metalness=function(e){return this._assert3d("metalness"),this._renderer.metalness(e),this},jn.prototype.shader=function(e){this.states.setValue("userFillShader",e),this.states.setValue("_useNormalMaterial",!1),e.ensureCompiledOnContext(this),e.setDefaultUniforms()},jn.prototype.strokeShader=function(e){this.states.setValue("userStrokeShader",e),e.ensureCompiledOnContext(this),e.setDefaultUniforms()},jn.prototype.imageShader=function(e){this.states.setValue("userImageShader",e),e.ensureCompiledOnContext(this),e.setDefaultUniforms()},jn.prototype.resetShader=function(){this.states.setValue("userFillShader",null),this.states.setValue("userStrokeShader",null),this.states.setValue("userImageShader",null)},jn.prototype.texture=function(e){this.states.setValue("drawMode",xe),this.states.setValue("_useNormalMaterial",!1),this.states.setValue("_tex",e),this.states.setValue("fillColor",new xi([1,1,1]))},jn.prototype.normalMaterial=function(...e){this.states.setValue("drawMode",ye),this.states.setValue("_useSpecularMaterial",!1),this.states.setValue("_useEmissiveMaterial",!1),this.states.setValue("_useNormalMaterial",!0),this.states.setValue("curFillColor",[1,1,1,1]),this.states.setValue("fillColor",new xi([1,1,1])),this.states.setValue("strokeColor",null)},jn.prototype.shininess=function(e){e<1&&(e=1),this.states.setValue("_useShininess",e)},jn.prototype.metalness=function(e){const t=1-Math.exp(-e/100);this.states.setValue("_useMetalness",t)}}function Qn(e,t){const r=t.DEGREES="degrees",i=t.RADIANS="radians";t._angleMode=i,t.acos=function(e){return this._fromRadians(Math.acos(e))},t.asin=function(e){return this._fromRadians(Math.asin(e))},t.atan=function(e){return this._fromRadians(Math.atan(e))},t.atan2=function(e,t){return this._fromRadians(Math.atan2(e,t))},t.cos=function(e){return Math.cos(this._toRadians(e))},t.sin=function(e){return Math.sin(this._toRadians(e))},t.tan=function(e){return Math.tan(this._toRadians(e))},t.degrees=e=>e*b,t.radians=e=>e*v,t.angleMode=function(e){if(void 0===e)return this._angleMode;if(e===r||e===i){if(e===this._angleMode)return;e===i?(this.pRotationX=this.pRotationX*v,this.pRotationY=this.pRotationY*v,this.pRotationZ=this.pRotationZ*v):(this.pRotationX=this.pRotationX*b,this.pRotationY=this.pRotationY*b,this.pRotationZ=this.pRotationZ*b),this._angleMode=e}},t._toRadians=function(e){return this._angleMode===r?e*v:e},t._toDegrees=function(e){return this._angleMode===i?e*b:e},t._fromRadians=function(e){return this._angleMode===r?e*b:e},t._fromDegrees=function(e){return this._angleMode===i?e*v:e}}void 0!==p5&&Yn(p5),void 0!==p5&&loading(p5,p5.prototype),void 0!==p5&&Qn(0,p5.prototype);class ea{constructor(e,t,r,s,n){const a=r||i;return this._pInst=s,this._renderer=new ga[a](this,e,t,!1,n),this._initializeInstanceVariables(this),this._renderer._applyDefaults(),this}get elt(){return this.canvas}get deltaTime(){return this._pInst.deltaTime}get canvas(){return this._renderer?.canvas}get drawingContext(){return this._renderer.drawingContext}get width(){return this._renderer?.width}get height(){return this._renderer?.height}get pixels(){return this._renderer?.pixels}pixelDensity(e){let t;return"number"==typeof e?(e!==this._renderer._pixelDensity&&(this._renderer._pixelDensity=e),t=this,this.resizeCanvas(this.width,this.height,!0)):t=this._renderer._pixelDensity,t}resizeCanvas(e,t){this._renderer.resize(e,t)}reset(){this._renderer.resetMatrix(),this._renderer.isP3D&&this._renderer._update()}remove(){this._renderer.remove(),this._renderer=void 0}createFramebuffer(e){return new ma(this._renderer,e)}_assert3d(e){if(!this._renderer.isP3D)throw new Error(`${e}() is only supported in WEBGL mode. If you'd like to use 3D graphics and WebGL, see https://p5js.org/examples/form-3d-primitives.html for more information.`)}_initializeInstanceVariables(){this._accessibleOutputs={text:!1,grid:!1,textLabel:!1,gridLabel:!1},this._styles=[],this._downKeys={}}}class ta{constructor(e,t,r={}){this._renderer=e,this.src=t,this.format=r.format||"rgba8unorm",this.minFilter=r.minFilter||me,this.magFilter=r.magFilter||me,this.wrapS=r.wrapS||e.states.textureWrapX,this.wrapT=r.wrapT||e.states.textureWrapY,this.dataType=r.dataType||"uint8",this.textureHandle=null,this._detectSourceType();const i=this._getTextureDataFromSource();this.width=i.width,this.height=i.height,this.init(i)}_detectSourceType(){const e=this.src;this.isFramebufferTexture=e instanceof fa,this.isSrcP5Image=e instanceof $i,this.isSrcP5Graphics=e instanceof ea,this.isSrcP5Renderer=e instanceof _s,this.isImageData="undefined"!=typeof ImageData&&e instanceof ImageData,this.isSrcMediaElement=void 0!==Ds&&e instanceof Ds,this.isSrcHTMLElement=void 0!==Pi&&e instanceof Pi&&!this.isSrcMediaElement&&!this.isSrcP5Graphics&&!this.isSrcP5Renderer}remove(){this.textureHandle&&(this._renderer.deleteTexture(this.textureHandle),this.textureHandle=null)}_getTextureDataFromSource(){let e;return this.isFramebufferTexture?e=this.src.rawTexture():this.isSrcP5Image?e=this.src.canvas:this.isSrcMediaElement||this.isSrcHTMLElement?(this.src._ensureCanvas&&this.src._ensureCanvas(),e=this.src.elt):this.isSrcP5Graphics||this.isSrcP5Renderer?e=this.src.canvas:this.isImageData&&(e=this.src),e}init(e){this.isFramebufferTexture?this.textureHandle=this._renderer.createFramebufferTextureHandle(this.src):this.textureHandle=this._renderer.createTexture({format:this.format,dataType:this.dataType,width:e.width,height:e.height}),this._renderer.setTextureParams(this,{minFilter:this.minFilter,magFilter:this.magFilter,wrapS:this.wrapS,wrapT:this.wrapT}),this.bindTexture(),this._shouldDeferUpload()?this._renderer.uploadTextureFromData(this.textureHandle,new Uint8Array(1,1,1,1),1,1):this.isFramebufferTexture||this._renderer.uploadTextureFromSource(this.textureHandle,e),this.unbindTexture()}_shouldDeferUpload(){return 0===this.width||0===this.height||this.isSrcMediaElement&&!this.src.loadedmetadata}update(){const e=this._getTextureDataFromSource();if(!e)return!1;let t=!1;return this._shouldUpdate(e)&&(this.bindTexture(),this._renderer.uploadTextureFromSource(this.textureHandle,e),t=!0),t}_shouldUpdate(e){const t=this.src;if(0===t.width||0===t.height)return!1;if(this.isFramebufferTexture)return this.src.update(),!1;let r=!1;return e.width!==this.width||e.height!==this.height?(r=!0,this.width=e.width||t.width,this.height=e.height||t.height,this.isSrcP5Image?t.setModified(!1):(this.isSrcMediaElement||this.isSrcHTMLElement)&&t.setModified&&t.setModified(!0)):this.isSrcP5Image?(t.gifProperties&&t._animateGif(this._renderer._pInst),t.isModified()&&(r=!0,t.setModified(!1))):this.isSrcMediaElement?t.isModified()?(r=!0,t.setModified(!1)):t.loadedmetadata&&this._videoPrevUpdateTime!==t.time()&&(this._videoPrevUpdateTime=t.time(),r=!0):this.isImageData?t._dirty&&(t._dirty=!1,r=!0):r=!0,r}bindTexture(){return this._renderer.bindTexture(this),this}unbindTexture(){this._renderer.unbindTexture()}getTexture(){return this.isFramebufferTexture?this.src.rawTexture():this.textureHandle}getSampler(){return this._renderer.getSampler(this)}setInterpolation(e,t){this.minFilter=e,this.magFilter=t,this._renderer.setTextureParams(this)}setWrapMode(e,t){this.wrapS=e,this.wrapT=t,this._renderer.setTextureParams(this)}}class ra extends ta{constructor(e,t,r={}){super(e,t,{minFilter:me,magFilter:me,...r}),this.levels=t}_getTextureDataFromSource(){return this.src}init(e){if(Array.isArray(e)){const t=e[0];this.width=t.width,this.height=t.height,this.textureHandle=this._renderer.createMipmapTextureHandle({levels:e,format:this.format,dataType:this.dataType,width:this.width,height:this.height})}else this.width=e.size,this.height=e.size,this.textureHandle=this._renderer.createMipmapTextureHandle({gpuTexture:e.gpuTexture,format:e.format,dataType:"uint8",width:this.width,height:this.height});this._renderer.setTextureParams(this,{minFilter:this.minFilter,magFilter:this.magFilter,wrapS:this.wrapS,wrapT:this.wrapT})}update(){}}function ia(e,t){e.Texture=ta,e.MipmapTexture=ra}function sa(e,t,r,i,s,n,a,o,h,u){const l=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,r);const c=o===t.RGBA?4:3,p=n*a*c,d=h===t.UNSIGNED_BYTE?Uint8Array:Float32Array;if(e instanceof d&&e.length===p||(e=new d(p)),t.readPixels(i,u?u-s-a:s,n,a,o,h,e),t.bindFramebuffer(t.FRAMEBUFFER,l),u){const t=Math.floor(a/2),r=new d(n*c);for(let i=0;i<t;i++){const t=i*n*4,s=(a-i-1)*n*4;r.set(e.subarray(t,t+4*n)),e.copyWithin(t,s,s+4*n),e.set(r,s)}}return e}function na(e,t,r,i,s,n,a){const o=e.getParameter(e.FRAMEBUFFER_BINDING);e.bindFramebuffer(e.FRAMEBUFFER,t);const h=s===e.RGBA?4:3,u=new(n===e.UNSIGNED_BYTE?Uint8Array:Float32Array)(h);return e.readPixels(r,a?a-i-1:i,1,1,s,n,u),e.bindFramebuffer(e.FRAMEBUFFER,o),Array.from(u)}function aa(e,t,r){e.bindTexture();const i=e.minFilter===_e?t.NEAREST:e.minFilter===be?t.LINEAR_MIPMAP_LINEAR:t.LINEAR,s=e.magFilter===_e?t.NEAREST:t.LINEAR,a=e=>!(e&e-1),o=e._getTextureDataFromSource();let h,u;o.naturalWidth&&o.naturalHeight?(h=o.naturalWidth,u=o.naturalHeight):(h=e.width,u=e.height);const l=a(h),c=a(u);let p,d;e.wrapS===we?r===n||l&&c?p=t.REPEAT:(console.warn("You tried to set the wrap mode to REPEAT but the texture size is not a power of two. Setting to CLAMP instead"),p=t.CLAMP_TO_EDGE):e.wrapS===Ee?r===n||l&&c?p=t.MIRRORED_REPEAT:(console.warn("You tried to set the wrap mode to MIRROR but the texture size is not a power of two. Setting to CLAMP instead"),p=t.CLAMP_TO_EDGE):p=t.CLAMP_TO_EDGE,e.wrapT===we?r===n||l&&c?d=t.REPEAT:(console.warn("You tried to set the wrap mode to REPEAT but the texture size is not a power of two. Setting to CLAMP instead"),d=t.CLAMP_TO_EDGE):e.wrapT===Ee?r===n||l&&c?d=t.MIRRORED_REPEAT:(console.warn("You tried to set the wrap mode to MIRROR but the texture size is not a power of two. Setting to CLAMP instead"),d=t.CLAMP_TO_EDGE):d=t.CLAMP_TO_EDGE,t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,s),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,p),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,d),e.unbindTexture()}function oa(e,t,r,i,s){const n=t.location;switch(e.useProgram(),t.type){case s.BOOL:!0===r?s.uniform1i(n,1):s.uniform1i(n,0);break;case s.INT:t.size>1?r.length&&s.uniform1iv(n,r):s.uniform1i(n,r);break;case s.FLOAT:t.size>1?r.length&&s.uniform1fv(n,r):s.uniform1f(n,r);break;case s.FLOAT_MAT3:s.uniformMatrix3fv(n,!1,r);break;case s.FLOAT_MAT4:s.uniformMatrix4fv(n,!1,r);break;case s.FLOAT_VEC2:t.size>1?r.length&&s.uniform2fv(n,r):s.uniform2f(n,r[0],r[1]);break;case s.FLOAT_VEC3:t.size>1?r.length&&s.uniform3fv(n,r):s.uniform3f(n,r[0],r[1],r[2]);break;case s.FLOAT_VEC4:t.size>1?r.length&&s.uniform4fv(n,r):s.uniform4f(n,r[0],r[1],r[2],r[3]);break;case s.INT_VEC2:t.size>1?r.length&&s.uniform2iv(n,r):s.uniform2i(n,r[0],r[1]);break;case s.INT_VEC3:t.size>1?r.length&&s.uniform3iv(n,r):s.uniform3i(n,r[0],r[1],r[2]);break;case s.INT_VEC4:t.size>1?r.length&&s.uniform4iv(n,r):s.uniform4i(n,r[0],r[1],r[2],r[3]);break;case s.SAMPLER_2D:if("number"==typeof r){if(r<s.TEXTURE0||r>s.TEXTURE31||r!==Math.ceil(r))return void console.log("🌸 p5.js says: You're trying to use a number as the data for a texture.Please use a texture.");s.activeTexture(r),s.uniform1i(n,r)}else s.activeTexture(s.TEXTURE0+t.samplerIndex),t.texture=r instanceof ta?r:i(r),s.uniform1i(n,t.samplerIndex);break;case s.SAMPLER_CUBE:case s.SAMPLER_3D:case s.SAMPLER_2D_SHADOW:case s.SAMPLER_2D_ARRAY:case s.SAMPLER_2D_ARRAY_SHADOW:case s.SAMPLER_CUBE_SHADOW:case s.INT_SAMPLER_2D:case s.INT_SAMPLER_3D:case s.INT_SAMPLER_CUBE:case s.INT_SAMPLER_2D_ARRAY:case s.UNSIGNED_INT_SAMPLER_2D:case s.UNSIGNED_INT_SAMPLER_3D:case s.UNSIGNED_INT_SAMPLER_CUBE:case s.UNSIGNED_INT_SAMPLER_2D_ARRAY:if("number"!=typeof r)break;if(r<s.TEXTURE0||r>s.TEXTURE31||r!==Math.ceil(r)){console.log("🌸 p5.js says: You're trying to use a number as the data for a texture.Please use a texture.");break}s.activeTexture(r),s.uniform1i(n,r)}}function ha(e,t){const r=e._glProgram,i=t.getProgramParameter(r,t.ACTIVE_UNIFORMS),s=[];let n=0;for(let e=0;e<i;++e){const i=t.getActiveUniform(r,e),a={};a.location=t.getUniformLocation(r,i.name),a.size=i.size;let o=i.name;i.size>1&&(o=o.substring(0,o.indexOf("[0]"))),a.name=o,a.type=i.type,a._cachedData=void 0,a.type===t.SAMPLER_2D&&(a.isSampler=!0,a.samplerIndex=n,n++),a.isArray=i.size>1||a.type===t.FLOAT_MAT3||a.type===t.FLOAT_MAT4||a.type===t.FLOAT_VEC2||a.type===t.FLOAT_VEC3||a.type===t.FLOAT_VEC4||a.type===t.INT_VEC2||a.type===t.INT_VEC4||a.type===t.INT_VEC3,s.push(a)}return s}function ua(e,t){const r={},i=t.getProgramParameter(e._glProgram,t.ACTIVE_ATTRIBUTES);for(let s=0;s<i;++s){const i=t.getActiveAttrib(e._glProgram,s),n=i.name,a=t.getAttribLocation(e._glProgram,n),o={};o.name=n,o.location=a,o.index=s,o.type=i.type,o.size=i.size,r[n]=o}return r}function la(e,t,r){const i="void main";if(!t.includes(i))return t;let[s,n]=t.split(i),a="",o="";for(const t in e.hooks.uniforms)a+=`uniform ${t};\n`;if(e.hooks.declarations&&(a+=e.hooks.declarations+"\n"),e.hooks[r].declarations&&(a+=e.hooks[r].declarations+"\n"),e.hooks.varyingVariables&&e.hooks.varyingVariables.length>0)for(const t of e.hooks.varyingVariables)"vertex"===r?a+=`OUT ${t};\n`:"fragment"===r&&(a+=`IN ${t};\n`);for(const t in e.hooks.helpers)a+=`${t}${e.hooks.helpers[t]}\n`;for(const t in e.hooks[r]){if("declarations"===t)continue;const[i,s]=t.split(" ");(e.hooks.modified.vertex[t]||e.hooks.modified.fragment[t])&&(o+="#define AUGMENTED_HOOK_"+s+"\n"),a+=i+" HOOK_"+s+e.hooks[r][t]+"\n"}return-1!==s.indexOf("#define HOOK_DEFINES")&&(s=s.replace("#define HOOK_DEFINES","\n"+o+"\n"),o=""),s+"\n"+o+a+i+n}function ca({GL:e,webglVersion:t}){const r=e,i=t===n?r.getExtension("EXT_color_buffer_float")&&r.getExtension("EXT_float_blend"):r.getExtension("OES_texture_float"),s=i&&r.getExtension("OES_texture_float_linear"),a=t===n?r.getExtension("EXT_color_buffer_float"):r.getExtension("OES_texture_half_float");return{float:i,floatLinear:s,halfFloat:a,halfFloatLinear:a&&r.getExtension("OES_texture_half_float_linear")}}void 0!==p5&&ia(p5);const pa=(e,t,r)=>Math.max(Math.min(e,r),t);class da extends Cn{constructor(e){super(e.renderer),this.fbo=e,this.yScale=e.renderer.framebufferYScale()}_computeCameraDefaultSettings(){super._computeCameraDefaultSettings(),this.defaultAspectRatio=this.fbo.width/this.fbo.height,this.defaultCameraFOV=2*Math.atan(this.fbo.height/2/this.defaultEyeZ)}copy(){const e=super.copy();return e.fbo=this.fbo,e}}class fa{constructor(e,t){this.framebuffer=e,this.property=t}get width(){return this.framebuffer.width*this.framebuffer.density}get height(){return this.framebuffer.height*this.framebuffer.density}update(){this.framebuffer._update(this.property)}rawTexture(){return{texture:this.framebuffer[this.property]}}}let ga,ma=class{constructor(e,t={}){if(this.renderer=e,this.renderer.framebuffers.add(this),this._isClipApplied=!1,this._useCanvasFormat=t._useCanvasFormat||!1,this.dirty={colorTexture:!1,depthTexture:!1},this.pixels=[],this.format=t.format||Be,this.channels=t.channels||(this.renderer.defaultFramebufferAlpha()?Ti:bi),this.useDepth=void 0===t.depth||t.depth,this.depthFormat=t.depthFormat||Pe,this.textureFiltering=t.textureFiltering||me,void 0===t.antialias?this.antialiasSamples=this.renderer.defaultFramebufferAntialias()?2:0:"number"==typeof t.antialias?this.antialiasSamples=t.antialias:this.antialiasSamples=t.antialias?2:0,this.antialias=this.antialiasSamples>0,this.antialias&&!this.renderer.supportsFramebufferAntialias()&&(console.warn("Framebuffer antialiasing is unsupported in this context"),this.antialias=!1),this.density=t.density||this.renderer._pixelDensity,t.width&&t.height){const e=this.renderer._adjustDimensions(t.width,t.height);this.width=e.adjustedWidth,this.height=e.adjustedHeight,this._autoSized=!1}else void 0===t.width!=(void 0===t.height)&&console.warn("Please supply both width and height for a framebuffer to give it a size. Only one was given, so the framebuffer will match the size of its canvas."),this.width=this.renderer.width,this.height=this.renderer.height,this._autoSized=!0;this.renderer.validateFramebufferFormats(this),t.stencil&&!this.useDepth&&console.warn("A stencil buffer can only be used if also using depth. Since the framebuffer has no depth buffer, the stencil buffer will be ignored."),this.useStencil=this.useDepth&&(void 0===t.stencil||t.stencil),this.renderer.createFramebufferResources(this),this._recreateTextures(),this.defaultCamera=this.createCamera(),this.filterCamera=this.createCamera(),this.draw(()=>this.renderer.clear())}resize(e,t){this._autoSized=!1;const r=this.renderer._adjustDimensions(e,t);e=r.adjustedWidth,t=r.adjustedHeight,this.width=e,this.height=t,this._handleResize()}pixelDensity(e){if(!e)return this.density;this._autoSized=!1,this.density=e,this._handleResize()}autoSized(e){if(void 0===e)return this._autoSized;this._autoSized=e,this._handleResize()}_checkIfFormatsAvailable(){const e=this.gl;this.useDepth&&this.renderer.webglVersion===s&&!e.getExtension("WEBGL_depth_texture")&&(console.warn("Unable to create depth textures in this environment. Falling back to a framebuffer without depth."),this.useDepth=!1),this.useDepth&&this.renderer.webglVersion===s&&this.depthFormat===Pe&&(console.warn("FLOAT depth format is unavailable in WebGL 1. Defaulting to UNSIGNED_INT."),this.depthFormat=Le),[Be,Pe,Oe].includes(this.format)||(console.warn("Unknown Framebuffer format. Please use UNSIGNED_BYTE, FLOAT, or HALF_FLOAT. Defaulting to UNSIGNED_BYTE."),this.format=Be),this.useDepth&&![Le,Pe].includes(this.depthFormat)&&(console.warn("Unknown Framebuffer depth format. Please use UNSIGNED_INT or FLOAT. Defaulting to FLOAT."),this.depthFormat=Pe);const t=ca(this.renderer);t.float||this.format!==Pe||(console.warn("This environment does not support FLOAT textures. Falling back to UNSIGNED_BYTE."),this.format=Be),this.useDepth&&!t.float&&this.depthFormat===Pe&&(console.warn("This environment does not support FLOAT depth textures. Falling back to UNSIGNED_INT."),this.depthFormat=Le),t.halfFloat||this.format!==Oe||(console.warn("This environment does not support HALF_FLOAT textures. Falling back to UNSIGNED_BYTE."),this.format=Be),this.channels===bi&&[Pe,Oe].includes(this.format)&&(console.warn("FLOAT and HALF_FLOAT formats do not work cross-platform with only RGB channels. Falling back to RGBA."),this.channels=Ti)}_deleteTextures(){this.renderer.deleteFramebufferTextures(this)}_recreateTextures(){if(this._updateSize(),this.renderer.recreateFramebufferTextures(this),this.useDepth){this.depth=new fa(this,"depthTexture");const e=_e;this.depthP5Texture=new ta(this.renderer,this.depth,{minFilter:e,magFilter:e}),this.renderer.textures.set(this.depth,this.depthP5Texture)}this.color=new fa(this,"colorTexture");const e=this.textureFiltering===me?me:_e;this.colorP5Texture=new ta(this.renderer,this.color,{minFilter:e,magFilter:e}),this.renderer.textures.set(this.color,this.colorP5Texture)}_updateSize(){this._autoSized&&(this.width=this.renderer.width,this.height=this.renderer.height,this.density=this.renderer._pixelDensity)}_canvasSizeChanged(){this._autoSized&&this._handleResize()}_handleResize(){this._deleteTextures(),this._recreateTextures(),this.defaultCamera._resize()}createCamera(){const e=new da(this);return e._computeCameraDefaultSettings(),e._setDefaultCamera(),e}remove(){this._deleteTextures(),this.renderer.deleteFramebufferResources(this),this.renderer.framebuffers.delete(this)}begin(){this.prevFramebuffer=this.renderer.activeFramebuffer(),this.prevFramebuffer&&this.prevFramebuffer._beforeEnd(),this.renderer.activeFramebuffers.push(this),this._beforeBegin(),this.renderer.push(),this.renderer.states.setValue("curCamera",this.defaultCamera),this.renderer.states.setValue("uPMatrix",this.renderer.states.uPMatrix.clone()),this.renderer.states.uPMatrix.set(this.defaultCamera.projMatrix),this.renderer.states.setValue("uViewMatrix",this.renderer.states.uViewMatrix.clone()),this.renderer.states.uViewMatrix.set(this.defaultCamera.cameraMatrix),this.renderer.resetMatrix(),this.renderer.states.uViewMatrix.set(this.renderer.states.curCamera.cameraMatrix),this.renderer.states.uModelMatrix.reset(),this.renderer._applyStencilTestIfClipping()}_framebufferToBind(){return this.renderer.getFramebufferToBind(this)}_update(e){this.dirty[e]&&(this.renderer.updateFramebufferTexture(this,e),this.dirty[e]=!1)}_beforeBegin(){this.renderer.bindFramebuffer(this),this.renderer.viewport(this.width*this.density,this.height*this.density),this.renderer.flushDraw&&this.renderer.flushDraw()}_beforeEnd(){this.antialias&&(this.dirty={colorTexture:!0,depthTexture:!0}),this.renderer.flushDraw&&this.renderer.flushDraw()}end(){if(this.renderer.pop(),this.renderer.activeFramebuffers.pop()!==this)throw new Error("It looks like you've called end() while another Framebuffer is active.");this._beforeEnd(),this.prevFramebuffer?this.prevFramebuffer._beforeBegin():(this.renderer.bindFramebuffer(null),this.renderer.viewport(this.renderer._origViewport.width,this.renderer._origViewport.height)),this.renderer._applyStencilTestIfClipping()}draw(e){this.begin(),e(),this.end()}loadPixels(){this._update("colorTexture");const e=this.renderer.readFramebufferPixels(this);return e&&"function"==typeof e.then?e.then(e=>(this.pixels=e,e)):(this.pixels=e,e)}get(e,t,r,i){if(this._update("colorTexture"),void 0===e&&void 0===t)e=0,t=0,r=this.width,i=this.height;else if(void 0===r&&void 0===i)return(e<0||t<0||e>=this.width||t>=this.height)&&(console.warn("The x and y values passed to p5.Framebuffer.get are outside of its range and will be clamped."),e=pa(e,0,this.width-1),t=pa(t,0,this.height-1)),this.renderer.readFramebufferPixel(this,e*this.density,t*this.density);return e=pa(e,0,this.width-1),t=pa(t,0,this.height-1),r=pa(r,1,this.width-e),i=pa(i,1,this.height-t),this.renderer.readFramebufferRegion(this,e,t,r,i)}updatePixels(){this.renderer.updateFramebufferPixels(this)}};function ya(e,t){e.FramebufferCamera=da,e.FramebufferTexture=fa,e.Framebuffer=ma}function xa(e,t){e.renderers||(e.renderers={}),ga=e.renderers,t.createCanvas=function(e,t,r,...s){let n=i;return Reflect.ownKeys(ga).includes(r)?n=r:s.unshift(r),this._renderer&&this._renderer.remove(),this._renderer=new ga[n](this,e,t,!0,...s),this._defaultGraphicsCreated=!0,this._elements.push(this._renderer),this._renderer._applyDefaults(),Object.hasOwn(this,"pixels")||Object.defineProperty(this,"pixels",{get(){return this._renderer?.pixels}}),this._renderer.contextReady?this._renderer.contextReady.then(()=>this._renderer):this._renderer},t.resizeCanvas=function(e,t,r){this._renderer&&(this._renderer.resize(e,t),r||this.redraw()),this._addAccsOutput()&&this._updateAccsOutput()},t.noCanvas=function(){this.canvas&&this.canvas.parentNode.removeChild(this.canvas)},t.createGraphics=function(t,r,...s){return s[0]instanceof HTMLCanvasElement&&(s[1]=s[0],s[0]=i),new e.Graphics(t,r,s[0],this,s[1])},t.createFramebuffer=function(e){return new ma(this._renderer,e)},t.clearDepth=function(e){this._assert3d("clearDepth"),this._renderer.clearDepth(e)}}void 0!==p5&&ya(p5),void 0!==p5&&xa(p5,p5.prototype);var va="precision highp float;\n\nuniform sampler2D tex0;\nuniform vec2 canvasSize;\nuniform vec2 texelSize;\n\nIN vec2 vTexCoord;\n\nstruct FilterInputs {\n vec2 texCoord;\n vec2 canvasSize;\n vec2 texelSize;\n};\n\nvoid main(void) {\n FilterInputs inputs;\n inputs.texCoord = vTexCoord;\n inputs.canvasSize = canvasSize;\n inputs.texelSize = texelSize;\n OUT_COLOR = HOOK_getColor(inputs, tex0);\n OUT_COLOR.rgb *= outColor.a;\n}\n",ba="precision highp int;\n\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nIN vec3 aPosition;\nIN vec2 aTexCoord;\nOUT vec2 vTexCoord;\n\nvoid main() {\n // transferring texcoords for the frag shader\n vTexCoord = aTexCoord;\n\n // copy position with a fourth coordinate for projection (1.0 is normal)\n vec4 positionVec4 = vec4(aPosition, 1.0);\n\n // project to 3D space\n gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n}\n",_a="#ifdef WEBGL2\n\n#define IN in\n#define OUT out\n\n#ifdef FRAGMENT_SHADER\nout vec4 outColor;\n#define OUT_COLOR outColor\n#endif\n#define TEXTURE texture\n\n#else\n\n#ifdef FRAGMENT_SHADER\n#define IN varying\n#else\n#define IN attribute\n#endif\n#define OUT varying\n#define TEXTURE texture2D\n\n#ifdef FRAGMENT_SHADER\n#define OUT_COLOR gl_FragColor\n#endif\n\n#endif\n\nvec4 getTexture(in sampler2D content, vec2 coord) {\n vec4 color = TEXTURE(content, coord);\n if (color.a > 0.) color.rgb /= color.a;\n return color;\n}\n";const wa={OPERATION:"operation",LITERAL:"literal",VARIABLE:"variable",CONSTANT:"constant",STRUCT:"struct",PHI:"phi",STATEMENT:"statement",ASSIGNMENT:"assignment"},Ca=Object.fromEntries(Object.entries(wa).map(([e,t])=>[t,e])),Ea={[wa.OPERATION]:["opCode","dependsOn","dimension","baseType"],[wa.LITERAL]:["value","dimension","baseType"],[wa.VARIABLE]:["identifier","dimension","baseType"],[wa.CONSTANT]:["value","dimension","baseType"],[wa.STRUCT]:[""],[wa.PHI]:["dependsOn","phiBlocks","dimension","baseType"],[wa.STATEMENT]:["statementType"],[wa.ASSIGNMENT]:["dependsOn"]},Da="discard",Aa="break",Sa="early_return",Fa="expression",Ta="empty",Ma="float",ka="int",Ia="bool",Ba="mat",La="defer",Pa="sampler2D",Oa="sampler",Ra={[Ma]:3,[ka]:2,[Ia]:1,[Ba]:0,[La]:-1,[Pa]:-10,[Oa]:-11},Na={float1:{fnName:"float",baseType:Ma,dimension:1,priority:3},float2:{fnName:"vec2",baseType:Ma,dimension:2,priority:3},float3:{fnName:"vec3",baseType:Ma,dimension:3,priority:3},float4:{fnName:"vec4",baseType:Ma,dimension:4,priority:3},int1:{fnName:"int",baseType:ka,dimension:1,priority:2},int2:{fnName:"ivec2",baseType:ka,dimension:2,priority:2},int3:{fnName:"ivec3",baseType:ka,dimension:3,priority:2},int4:{fnName:"ivec4",baseType:ka,dimension:4,priority:2},bool1:{fnName:"bool",baseType:Ia,dimension:1,priority:1},bool2:{fnName:"bvec2",baseType:Ia,dimension:2,priority:1},bool3:{fnName:"bvec3",baseType:Ia,dimension:3,priority:1},bool4:{fnName:"bvec4",baseType:Ia,dimension:4,priority:1},mat2:{fnName:"mat2x2",baseType:Ba,dimension:2,priority:0},mat3:{fnName:"mat3x3",baseType:Ba,dimension:3,priority:0},mat4:{fnName:"mat4x4",baseType:Ba,dimension:4,priority:0},defer:{fnName:null,baseType:La,dimension:null,priority:-1},sampler2D:{fnName:"sampler2D",baseType:Pa,dimension:1,priority:-10},sampler:{fnName:"sampler",baseType:Oa,dimension:1,priority:-11}},Va=function(e){let t=void 0===e.type?e:e.type;const r={name:e.name,properties:[],typeName:t.typeName};for(const e of t.properties){const t=e.type.dataType;r.properties.push({name:e.name,dataType:t})}return r};function Ua(e){return!(!e||!e.properties)}const za={baseType:Ma,dimension:null,priority:3},Ga={baseType:ka,dimension:null,priority:2},ja={baseType:Ia,dimension:null,priority:1},$a=Object.fromEntries(Object.values(Na).filter(e=>null!==e.fnName).map(e=>[e.fnName,e])),Ha=201,qa=[{arity:"unary",name:"not",symbol:"!",opCode:100},{arity:"unary",name:"neg",symbol:"-",opCode:101},{arity:"unary",name:"plus",symbol:"+",opCode:102},{arity:"binary",name:"add",symbol:"+",opCode:0},{arity:"binary",name:"sub",symbol:"-",opCode:1},{arity:"binary",name:"mult",symbol:"*",opCode:2},{arity:"binary",name:"div",symbol:"/",opCode:3},{arity:"binary",name:"mod",symbol:"%",opCode:4},{arity:"binary",name:"equalTo",symbol:"==",opCode:5},{arity:"binary",name:"notEqual",symbol:"!=",opCode:6},{arity:"binary",name:"greaterThan",symbol:">",opCode:7},{arity:"binary",name:"greaterEqual",symbol:">=",opCode:8},{arity:"binary",name:"lessThan",symbol:"<",opCode:9},{arity:"binary",name:"lessEqual",symbol:"<=",opCode:10},{arity:"binary",name:"and",symbol:"&&",opCode:11},{arity:"binary",name:"or",symbol:"||",opCode:12}],Wa={},Xa={};for(const{symbol:e,opCode:t,name:r,arity:i}of qa)Wa[t]=e,"unary"===i&&(Xa[e]=r);const Ya={GLOBAL:"global",FUNCTION:"function",BRANCH:"branch",IF_COND:"if_cond",IF_BODY:"if_body",ELSE_COND:"else_cond",SCOPE_START:"scope_start",SCOPE_END:"scope_end",FOR:"for",MERGE:"merge",DEFAULT:"default"};function Ka(e){throw new Error(`[p5.strands internal error]: ${e}`)}function Za(e,t){throw new Error(`[p5.strands ${e}]: ${t}`)}function Ja(){return{nextID:0,cache:new Map,nodeTypes:[],baseTypes:[],dimensions:[],opCodes:[],values:[],identifiers:[],phiBlocks:[],dependsOn:[],usedBy:[],statementTypes:[],swizzles:[]}}function Qa(e,t){const r=function(e,t){const r=e.nextID++;e.nodeTypes[r]=t.nodeType,e.opCodes[r]=t.opCode,e.values[r]=t.value,e.identifiers[r]=t.identifier,e.dependsOn[r]=t.dependsOn.slice(),e.usedBy[r]=t.usedBy,e.phiBlocks[r]=t.phiBlocks.slice(),e.baseTypes[r]=t.baseType,e.dimensions[r]=t.dimension,e.statementTypes[r]=t.statementType,e.swizzles[r]=t.swizzle;for(const i of t.dependsOn)Array.isArray(e.usedBy[i])||(e.usedBy[i]=[]),e.usedBy[i].push(r);return r}(e,t);return r}function eo(e={}){const t={nodeType:e.nodeType??null,baseType:e.baseType??null,dimension:e.dimension??null,opCode:e.opCode??null,value:e.value??null,identifier:e.identifier??null,statementType:e.statementType??null,swizzle:e.swizzle??null,dependsOn:Array.isArray(e.dependsOn)?e.dependsOn:[],usedBy:Array.isArray(e.usedBy)?e.usedBy:[],phiBlocks:Array.isArray(e.phiBlocks)?e.phiBlocks:[]};return function(e){const t=e.nodeType,r=Ea[t];2===r.length&&Ka(`Required fields for node type '${Ca[t]}' not defined. Please add them to the utils.js file in p5.strands!`);const i=[];for(const t of r)null===e[t]&&i.push(t);if(e.dependsOn?.some(e=>void 0===e))throw new Error("Undefined dependency!");i.length>0&&Ka(`Missing fields ${i.join(", ")} for a node type '${Ca[t]}'.`)}(t),t}function to(e,t){return{id:t,nodeType:e.nodeTypes[t],opCode:e.opCodes[t],value:e.values[t],identifier:e.identifiers[t],dependsOn:e.dependsOn[t],usedBy:e.usedBy[t],phiBlocks:e.phiBlocks[t],dimension:e.dimensions[t],baseType:e.baseTypes[t],statementType:e.statementTypes[t],swizzle:e.swizzles[t]}}function ro(e,t){return{baseType:e.baseTypes[t],dimension:e.dimensions[t],priority:Ra[e.baseTypes[t]]}}function io(e,t){e.blockStack.push(t),e.blockOrder.push(t),e.currentBlock=t}function so(e){e.blockStack.pop();const t=e.blockStack.length;e.currentBlock=e.blockStack[t-1]}function no(e,t){e.blockStack.push(t),e.currentBlock=t}function ao(e,t){const r=e.nextID++;return e.blockTypes[r]=t,e.incomingEdges[r]=[],e.outgoingEdges[r]=[],e.blockInstructions[r]=[],r}function oo(e,t,r){e.outgoingEdges[t].push(r),e.incomingEdges[r].push(t)}function ho(e,t,r){void 0===r&&Ka("undefined nodeID in `recordInBasicBlock()`"),void 0===t&&Ka("undefined blockID in `recordInBasicBlock()"),e.blockInstructions[t]=e.blockInstructions[t]||[],e.blockInstructions[t].push(r)}function uo(e,t){const r=new Set,i=[];return function t(s){if(!r.has(s)){r.add(s);for(let r of e[s].sort((e,t)=>t-e)||[])t(r);i.push(s)}}(t),i.reverse()}Object.fromEntries(Object.entries(Ya).map(([e,t])=>[t,e]));class lo{constructor(e,t,r){this.id=e,this.strandsContext=r,this.dimension=t,this.structProperties=null,this.isStrandsNode=!0;const i=to(this.strandsContext.dag,this.id);i&&i.identifier&&(this._originalIdentifier=i.identifier),i&&(this._originalBaseType=i.baseType,this._originalDimension=i.dimension)}withStructProperties(e){return this.structProperties=e,this}copy(){return co(this.id,this.dimension,this.strandsContext)}typeInfo(){return{baseType:this._originalBaseType||Ma,dimension:this.dimension}}bridge(e){const{dag:t,cfg:r}=this.strandsContext,i=to(t,this.id),s=i?.baseType??Ma;let n;if(n=e instanceof lo?e.id:_o(this.strandsContext,{baseType:s,dimension:this.dimension},e).id,this._originalIdentifier){const{id:e}=go(this.strandsContext,{baseType:this._originalBaseType,dimension:this._originalDimension},this._originalIdentifier),i=Qa(t,eo({nodeType:wa.ASSIGNMENT,dependsOn:[e,n],phiBlocks:[]}));ho(r,r.currentBlock,i),this.strandsContext.globalAssignments.push(i);const s=Qa(t,eo({nodeType:wa.VARIABLE,baseType:this._originalBaseType,dimension:this._originalDimension,identifier:this._originalIdentifier}));this.id=s}else this.id=n;return this}bridgeSwizzle(e,t){const{dag:r,cfg:i}=this.strandsContext,s=to(r,this.id),n=s?.baseType??Ma;let a;if(a=t instanceof lo?t.id:_o(this.strandsContext,{baseType:n,dimension:this.dimension},t).id,this._originalIdentifier){const{id:t}=go(this.strandsContext,{baseType:this._originalBaseType,dimension:this._originalDimension},this._originalIdentifier),s=Qa(r,eo({nodeType:wa.OPERATION,opCode:103,baseType:this._originalBaseType,dimension:e.length,swizzle:e,dependsOn:[t]})),n=Qa(r,eo({nodeType:wa.ASSIGNMENT,dependsOn:[s,a],phiBlocks:[]}));ho(i,i.currentBlock,n),this.strandsContext.globalAssignments.push(n);const o=Qa(r,eo({nodeType:wa.VARIABLE,baseType:this._originalBaseType,dimension:this._originalDimension,identifier:this._originalIdentifier}));this.id=o}else this.id=a;return this}getValue(){if(this._originalIdentifier){const{id:e,dimension:t}=go(this.strandsContext,{baseType:this._originalBaseType,dimension:this._originalDimension},this._originalIdentifier);return co(e,t,this.strandsContext)}return this}}function co(e,t,r,i){return new Proxy(new lo(e,t,r),function(e,t,r,i){const s=[["x","y","z","w"],["r","g","b","a"],["s","t","p","q"]].map(e=>e.slice(0,t)),n={get(e,t,i){if(t in e)return Reflect.get(...arguments);for(const i of s)if([...t.toString()].every(e=>i.includes(e))){const n=[...t].map(e=>{const t=i.indexOf(e);return s[0][t]}).join(""),a=Do(r,e,n);return co(a.id,a.dimension,r)}},set(e,t,n,a){for(const a of s){const s=[...t];if(!(s.every(e=>a.includes(e))&&new Set(s).size===s.length&&e.dimension>=s.length))continue;const o=e.dimension,h=new Array(o);for(let t=0;t<o;t++){const{id:i,dimension:s}=Do(r,e,"xyzw"[t]);h[t]=co(i,s,r)}let u=[];if(n instanceof lo)if(1===n.dimension)u=Array(s.length).fill(n);else if(n.dimension===s.length)for(let e=0;e<s.length;e++){const{id:t,dimension:i}=Do(r,n,"xyzw"[e]);u.push(co(t,i,r))}else Za("type error",`Swizzle assignment: RHS vector does not match LHS vector (need ${s.length}, got ${n.dimension}).`);else if(Array.isArray(n)){const e=n.flat(1/0);1===e.length?u=Array(s.length).fill(e[0]):e.length===s.length?u=e:Za("type error",`Swizzle assignment: RHS length ${e.length} does not match ${s.length}.`)}else"number"==typeof n?u=Array(s.length).fill(n):Za("type error",`Unsupported RHS for swizzle assignment: ${n}`);for(let e=0;e<s.length;e++)h[a.indexOf(s[e])]=u[e];const l=to(r.dag,e.id),c=l?.baseType??Ma,{id:p}=_o(r,{baseType:c,dimension:o},h);return e.id=p,"function"==typeof i&&i(p),!0}return Reflect.set(...arguments)}};return n}(0,t,r,i))}const po={acos:[{params:[za],returnType:za,isp5Function:!0}],acosh:[{params:[za],returnType:za,isp5Function:!1}],asin:[{params:[za],returnType:za,isp5Function:!0}],asinh:[{params:[za],returnType:za,isp5Function:!1}],atan:[{params:[za],returnType:za,isp5Function:!0},{params:[za,za],returnType:za,isp5Function:!0}],atanh:[{params:[za],returnType:za,isp5Function:!1}],cos:[{params:[za],returnType:za,isp5Function:!0}],cosh:[{params:[za],returnType:za,isp5Function:!1}],degrees:[{params:[za],returnType:za,isp5Function:!0}],radians:[{params:[za],returnType:za,isp5Function:!0}],sin:[{params:[za],returnType:za,isp5Function:!0}],sinh:[{params:[za],returnType:za,isp5Function:!1}],tan:[{params:[za],returnType:za,isp5Function:!0}],tanh:[{params:[za],returnType:za,isp5Function:!1}],abs:[{params:[za],returnType:za,isp5Function:!0},{params:[za],returnType:Ga,isp5Function:!0}],ceil:[{params:[za],returnType:za,isp5Function:!0}],clamp:[{params:[za,za,za],returnType:za,isp5Function:!1},{params:[za,Na.float1,Na.float1],returnType:za,isp5Function:!1},{params:[Ga,Ga,Ga],returnType:Ga,isp5Function:!1},{params:[Ga,Na.int1,Na.int1],returnType:Ga,isp5Function:!1}],dFdx:[{params:[za],returnType:za,isp5Function:!1}],dFdy:[{params:[za],returnType:za,isp5Function:!1}],exp:[{params:[za],returnType:za,isp5Function:!0}],exp2:[{params:[za],returnType:za,isp5Function:!1}],floor:[{params:[za],returnType:za,isp5Function:!0}],fma:[{params:[za,za,za],returnType:za,isp5Function:!1}],fract:[{params:[za],returnType:za,isp5Function:!0}],fwidth:[{params:[za],returnType:za,isp5Function:!1}],inversesqrt:[{params:[za],returnType:za,isp5Function:!0}],log:[{params:[za],returnType:za,isp5Function:!0}],log2:[{params:[za],returnType:za,isp5Function:!1}],max:[{params:[za,za],returnType:za,isp5Function:!0},{params:[za,Na.float1],returnType:za,isp5Function:!0},{params:[Ga,Ga],returnType:Ga,isp5Function:!0},{params:[Ga,Na.int1],returnType:Ga,isp5Function:!0}],min:[{params:[za,za],returnType:za,isp5Function:!0},{params:[za,Na.float1],returnType:za,isp5Function:!0},{params:[Ga,Ga],returnType:Ga,isp5Function:!0},{params:[Ga,Na.int1],returnType:Ga,isp5Function:!0}],mix:[{params:[za,za,za],returnType:za,isp5Function:!1},{params:[za,za,Na.float1],returnType:za,isp5Function:!1},{params:[za,za,ja],returnType:za,isp5Function:!1}],mod:[{params:[za,za],returnType:za,isp5Function:!0},{params:[za,Na.float1],returnType:za,isp5Function:!0}],pow:[{params:[za,za],returnType:za,isp5Function:!0}],round:[{params:[za],returnType:za,isp5Function:!0}],roundEven:[{params:[za],returnType:za,isp5Function:!1}],sign:[{params:[za],returnType:za,isp5Function:!1},{params:[Ga],returnType:Ga,isp5Function:!1}],smoothstep:[{params:[za,za,za],returnType:za,isp5Function:!1},{params:[Na.float1,Na.float1,za],returnType:za,isp5Function:!1}],sqrt:[{params:[za],returnType:za,isp5Function:!0}],step:[{params:[za,za],returnType:za,isp5Function:!1}],trunc:[{params:[za],returnType:za,isp5Function:!1}],cross:[{params:[Na.float3,Na.float3],returnType:Na.float3,isp5Function:!0}],distance:[{params:[za,za],returnType:Na.float1,isp5Function:!0}],dot:[{params:[za,za],returnType:Na.float1,isp5Function:!0}],equal:[{params:[za,za],returnType:ja,isp5Function:!1},{params:[Ga,Ga],returnType:ja,isp5Function:!1},{params:[ja,ja],returnType:ja,isp5Function:!1}],faceforward:[{params:[za,za,za],returnType:za,isp5Function:!1}],length:[{params:[za],returnType:Na.float1,isp5Function:!1}],normalize:[{params:[za],returnType:za,isp5Function:!0}],notEqual:[{params:[za,za],returnType:ja,isp5Function:!1},{params:[Ga,Ga],returnType:ja,isp5Function:!1},{params:[ja,ja],returnType:ja,isp5Function:!1}],reflect:[{params:[za,za],returnType:za,isp5Function:!1}],refract:[{params:[za,za,Na.float1],returnType:za,isp5Function:!1}]};function fo(e,t,r){const{cfg:i,dag:s}=e;let{dimension:n,baseType:a}=t;1!==n&&Ka("Created a scalar literal node with dimension > 1.");const o=Qa(s,eo({nodeType:wa.LITERAL,dimension:n,baseType:a,value:r}));return ho(i,i.currentBlock,o),{id:o,dimension:n}}function go(e,t,r){const{cfg:i,dag:s}=e,{dimension:n,baseType:a}=t,o=Qa(s,eo({nodeType:wa.VARIABLE,dimension:n,baseType:a,identifier:r}));return ho(i,i.currentBlock,o),{id:o,dimension:n}}function mo(e,t,r){const{dag:i,cfg:s}=e;let n,a;if(t instanceof lo)a=t;else{const{id:r,dimension:i}=_o(e,{baseType:Ma,dimension:null},t);a=co(r,i,e)}n=[a.id];const o=Qa(i,eo({nodeType:wa.OPERATION,opCode:r,dependsOn:n,baseType:i.baseTypes[a.id],dimension:a.dimension}));return ho(s,s.currentBlock,o),{id:o,dimension:a.dimension}}function yo(e,t,r,i){const{dag:s,cfg:n}=e;let a;if(r[0]instanceof lo&&1===r.length)a=r[0];else{const{id:t,dimension:i}=_o(e,{baseType:Ma,dimension:null},r);a=co(t,i,e)}let o=t.id,h=a.id;const u=ro(s,t.id),l=ro(s,a.id),c={node:null,toType:u};if(u.baseType===l.baseType&&u.baseType===La){c.toType.baseType=Ma,u.dimension===l.dimension?c.toType.dimension=u.dimension:1===u.dimension&&l.dimension>1?c.toType.dimension=l.dimension:1===l.dimension&&u.dimension>1?c.toType.dimension=u.dimension:Za("type error",`You have tried to perform a binary operation:\n${u.baseType+u.dimension} ${Wa[i]} ${l.baseType+l.dimension}\nIt's only possible to operate on two nodes with the same dimension, or a scalar value and a vector.`);const r=_o(e,c.toType,t),s=_o(e,c.toType,a);o=r.id,h=s.id}else if(u.baseType!==l.baseType||u.dimension!==l.dimension){1===u.dimension&&l.dimension>1?(c.node=t,c.toType=l):1===l.dimension&&u.dimension>1||u.priority>l.priority?(c.node=a,c.toType=u):l.priority>u.priority?(c.node=t,c.toType=l):Za("type error",`A vector of length ${u.dimension} operated with a vector of length ${l.dimension} is not allowed.`);const r=_o(e,c.toType,c.node);c.node===t?o=(t=co(r.id,r.dimension,e)).id:(a=co(r.id,r.dimension,e),h=a.id)}const p=eo({nodeType:wa.OPERATION,opCode:i,dependsOn:[o,h],baseType:c.toType.baseType,dimension:c.toType.dimension}),d=Qa(s,p);return ho(n,n.currentBlock,d),{id:d,dimension:p.dimension}}function xo(e,t,r,i){const{cfg:s,dag:n}=e;if(0===i.length)for(const e of t.properties){const t=e.dataType,a=Qa(n,eo({nodeType:wa.VARIABLE,baseType:t.baseType,dimension:t.dimension,identifier:`${r}.${e.name}`}));ho(s,s.currentBlock,a),i.push(a)}const a=Qa(n,eo({nodeType:wa.VARIABLE,dimension:t.properties.length,baseType:t.typeName,identifier:r,dependsOn:i}));return ho(s,s.currentBlock,a),{id:a,dimension:0,components:i}}function vo(e,t,r){const i=Array.isArray(r)?r:[r],s=[];let{dimension:n,baseType:a}=t;const o=e.dag;let h=0,u=null;for(const t of i.flat(1/0))if(t&&t.isStrandsNode){const e=to(o,t.id);if(u=t.id,a=e.baseType,e.opCode===Ha)for(const t of e.dependsOn)s.push(t);else s.push(t.id);h+=e.dimension}else if("number"!=typeof t)Za("type error",`You've tried to construct a scalar or vector type with a non-numeric value: ${t}`);else{const{id:r,dimension:i}=fo(e,{dimension:1,baseType:a},t);s.push(r),h+=i}return null===n?n=h:n>h&&1===h?h=n:1!==h&&h!==n&&Za("type error",`You've tried to construct a ${a+n} with ${h} components`),{originalNodeID:u,mappedDependencies:s,inferredTypeInfo:{dimension:n,baseType:a,priority:Ra[a]}}}function bo(e,t,r){const i=eo({nodeType:wa.OPERATION,opCode:Ha,dimension:t.dimension,baseType:t.baseType,dependsOn:r});return Qa(e.dag,i)}function _o(e,t,r){const i=e.cfg,{mappedDependencies:s,inferredTypeInfo:n}=vo(e,t,r),a={baseType:t.baseType,dimension:n.dimension},o=bo(e,a,s);return t.baseType!==La&&ho(i,i.currentBlock,o),{id:o,dimension:a.dimension,components:s}}function wo(e,t,r){const{cfg:i,dag:s}=e,{properties:n}=t;r.length!==n.length&&Za("type error",`You've tried to construct a ${t.typeName} struct with ${r.length} properties, but it expects ${n.length} properties.\nThe properties it expects are:\n${n.map(e=>e.name+" "+e.DataType.baseType+e.DataType.dimension)}`);const a=[];for(let t=0;t<n.length;t++){const i=n[t],{originalNodeID:s,mappedDependencies:o}=vo(e,i.dataType,r[t]);s?a.push(s):a.push(bo(e,i.dataType,o))}const o=Qa(s,eo({nodeType:wa.OPERATION,opCode:Ha,dimension:n.length,baseType:t.typeName,dependsOn:a}));return ho(i,i.currentBlock,o),{id:o,dimension:n.length,components:t.components}}function Co(e,t,r,{overloads:i}={}){const{cfg:s,dag:n}=e,a=i||po[t],o=r.map(t=>vo(e,Na.defer,t)),h=a.filter(e=>e.params.length===o.length);if(0===h.length){const e=new Set,r=[];a.forEach(t=>e.add(t.params.length)),e.forEach(e=>r.push(`${e}`));const i=r.join(", or ");Za("parameter validation error",`Function '${t}' has ${a.length} variants which expect ${i} arguments, but ${o.length} arguments were provided.`)}const u=e=>null===e.dimension;let l=null,c=0,p=null,d=null;for(const e of h){let t=!0,r=0;for(let i=0;i<o.length;i++){const s=o[i].inferredTypeInfo,n=e.params[i];let a=n.dimension;u(n)?(null!==d&&1!==d||(d=s.dimension),d===s.dimension||1===s.dimension&&d>=1||(t=!1),a=d):s.dimension>a&&(t=!1),s.baseType===n.baseType?r+=2:n.priority>s.priority&&(r+=1)}t&&(!l||r>c)&&(l=e,c=r,p={...e.returnType},u(p)&&(p.dimension=d))}null===l&&Za("parameter validation",`No matching overload for ${t} was found!`);let f=[];for(let t=0;t<l.params.length;t++){const r=o[t],i={...l.params[t]};if(u(i)&&(i.dimension=d),r.originalNodeID&&(m=i,(g=r.inferredTypeInfo).dimension===m.dimension&&g.baseType===m.baseType))f.push(r.originalNodeID);else{const t=bo(e,i,r.mappedDependencies);ho(s,s.currentBlock,t),f.push(t)}}var g,m;const y=Qa(n,eo({nodeType:wa.OPERATION,opCode:200,identifier:t,dependsOn:f,baseType:p.baseType,dimension:p.dimension}));return ho(s,s.currentBlock,y),{id:y,dimension:p.dimension}}function Eo(e,t){const{dag:r,cfg:i}=e,s=Qa(r,eo({nodeType:wa.STATEMENT,statementType:t}));return ho(i,i.currentBlock,s),s}function Do(e,t,r){const{dag:i,cfg:s}=e,n=i.baseTypes[t.id],a=Qa(i,eo({nodeType:wa.OPERATION,baseType:n,dimension:r.length,opCode:103,dependsOn:[t.id],swizzle:r}));return ho(s,s.currentBlock,a),{id:a,dimension:r.length}}function Ao(e,t){return e.nodeTypes[t]===wa.OPERATION&&e.baseTypes[t]!==Pa&&(e.usedBy[t]||[]).length>1}const So={float1:"float",float2:"vec2",float3:"vec3",float4:"vec4",int1:"int",int2:"ivec2",int3:"ivec3",int4:"ivec4",bool1:"bool",bool2:"bvec2",bool3:"bvec3",bool4:"bvec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},Fo={[Ya.DEFAULT]:(e,t,r)=>{const{dag:i,cfg:s}=t,n=s.blockInstructions[e]||[];for(const e of n){const t=i.nodeTypes[e];if(Ao(i,e)){const t=To.generateDeclaration(r,i,e);r.write(t)}t===wa.STATEMENT&&To.generateStatement(r,i,e),t===wa.ASSIGNMENT&&(To.generateAssignment(r,i,e),r.visitedNodes.add(e))}},[Ya.BRANCH](e,t,r){const{dag:i,cfg:s}=t,n=s.blockInstructions[e]||[];for(const e of n){const t=to(i,e);if(t.nodeType===wa.PHI){const s=t.dependsOn||[];if(s.length>0){const t=s[0],i=r.tempNames[t];if(i){r.tempNames[e]=i;continue}}const n="T"+r.nextTempID++;r.tempNames[e]=n;const a=ro(i,e),o=To.getTypeName(a.baseType,a.dimension);r.write(`${o} ${n};`)}}this[Ya.DEFAULT](e,t,r)},[Ya.IF_COND](e,t,r){const{dag:i,cfg:s}=t,n=s.blockConditions[e],a=To.generateExpression(r,i,n);r.write(`if (${a})`),this[Ya.DEFAULT](e,t,r)},[Ya.ELSE_COND](e,t,r){r.write("else"),this[Ya.DEFAULT](e,t,r)},[Ya.IF_BODY](e,t,r){this[Ya.DEFAULT](e,t,r),this.assignPhiNodeValues(e,t,r)},[Ya.SCOPE_START](e,t,r){r.write("{"),r.indent++},[Ya.SCOPE_END](e,t,r){r.indent--,r.write("}")},[Ya.MERGE](e,t,r){this[Ya.DEFAULT](e,t,r)},[Ya.FUNCTION](e,t,r){this[Ya.DEFAULT](e,t,r)},[Ya.FOR](e,t,r){const{dag:i,cfg:s}=t,n=s.blockInstructions[e]||[];r.write("for (");const a=r.suppressSemicolon;for(let e=0;e<n.length;e++){const t=n[e],s=to(i,t),a=e===n.length-1;if(r.suppressSemicolon=a,Ao(i,t)){const e=To.generateDeclaration(r,i,t);r.write(e)}s.nodeType===wa.STATEMENT&&To.generateStatement(r,i,t),s.nodeType===wa.ASSIGNMENT&&(To.generateAssignment(r,i,t),r.visitedNodes.add(t))}r.suppressSemicolon=a,r.write(")")},assignPhiNodeValues(e,t,r){const{dag:i,cfg:s}=t,n=s.outgoingEdges[e]||[];for(const t of n){const n=s.blockInstructions[t]||[];for(const t of n){const s=to(i,t);if(s.nodeType===wa.PHI){const n=s.phiBlocks?.indexOf(e);if(-1!==n&&n<s.dependsOn.length){const e=s.dependsOn[n],a=r.tempNames[t];if(a&&null!==e){const t=To.generateExpression(r,i,e);r.write(`${a} = ${t};`)}}}}}}},To={hookEntry:e=>`(${e.parameters.flatMap(e=>`${e.qualifiers?.length?e.qualifiers.join(" "):""}${e.type.typeName} ${e.name}`).join(", ")}) {`,getTypeName:(e,t)=>So[e+t]||e,generateHookUniformKey(e,t){return`${this.getTypeName(t.baseType,t.dimension)} ${e}`},generateVaryingVariable:(e,t)=>`${t.fnName} ${e}`,generateLocalDeclaration:(e,t)=>`${t.fnName} ${e};`,generateStatement(e,t,r){const i=to(t,r),s=e.suppressSemicolon?"":";";if(i.statementType===Da)e.write(`discard${s}`);else if(i.statementType===Aa)e.write(`break${s}`);else if(i.statementType===Fa){const r=i.dependsOn[0],n=this.generateExpression(e,t,r);e.write(`${n}${s}`)}else if(i.statementType===Ta)e.write(s);else if(i.statementType===Sa){const r=i.dependsOn[0],n=this.generateExpression(e,t,r);e.write(`return ${n}${s}`)}},generateAssignment(e,t,r){const i=to(t,r),s=i.dependsOn[0],n=i.dependsOn[1],a=this.generateExpression(e,t,s),o=this.generateExpression(e,t,n),h=e.suppressSemicolon?"":";";a&&o&&a!==o&&e.write(`${a} = ${o}${h}`)},generateDeclaration(e,t,r){const i=this.generateExpression(e,t,r),s="T"+e.nextTempID++;e.tempNames[r]=s;const n=ro(t,r);return`${this.getTypeName(n.baseType,n.dimension)} ${s} = ${i};`},generateReturnStatement(e,t,r,i){const s=e.dag,n=to(s,r);if(Ua(i)){const e=i;for(let r=0;r<e.properties.length;r++){const i=e.properties[r],a=this.generateExpression(t,s,n.dependsOn[r]);i.name!==a&&t.write(`${n.identifier}.${i.name} = ${a};`)}}t.write(`return ${this.generateExpression(t,s,r)};`)},generateExpression(e,t,r){const i=to(t,r);if(e.tempNames?.[r])return e.tempNames[r];switch(i.nodeType){case wa.LITERAL:return i.baseType===Ma?i.value.toFixed(4):i.value;case wa.VARIABLE:if(e.shaderContext&&e.strandsContext?.sharedVariables?.has(i.identifier)){const t=e.strandsContext.sharedVariables.get(i.identifier);"vertex"===e.shaderContext?t.usedInVertex=!0:"fragment"===e.shaderContext&&(t.usedInFragment=!0)}return i.identifier;case wa.OPERATION:const s=i.usedBy.length>0;if(i.opCode===Ha)return i.baseType===Pa?this.generateExpression(e,t,i.dependsOn[0]):`${this.getTypeName(i.baseType,i.dimension)}(${i.dependsOn.map(r=>this.generateExpression(e,t,r)).join(", ")})`;if(200===i.opCode){const r=i.dependsOn.map(r=>this.generateExpression(e,t,r));return`${i.identifier}(${r.join(", ")})`}if(13===i.opCode){const[r,s]=i.dependsOn;return`${this.generateExpression(e,t,r)}.${this.generateExpression(e,t,s)}`}if(103===i.opCode){const r=i.dependsOn[0];return`${this.generateExpression(e,t,r)}.${i.swizzle}`}if(2===i.dependsOn.length){const[r,n]=i.dependsOn,a=this.generateExpression(e,t,r),o=this.generateExpression(e,t,n);if(4===i.opCode){const e=to(t,r),i=to(t,n);return e.baseType===Ma||i.baseType===Ma?`mod(${a}, ${o})`:`(${a} % ${o})`}const h=Wa[i.opCode];return s?`(${a} ${h} ${o})`:`${a} ${h} ${o}`}if(100===i.opCode||101===i.opCode||102===i.opCode){const[r]=i.dependsOn,s=this.generateExpression(e,t,r);return`${Wa[i.opCode]}${s}`}case wa.PHI:if(i.identifier)return i.identifier;if(e.tempNames?.[r])return e.tempNames[r];{const r=i.dependsOn.filter(e=>null!==e);if(r.length>0)return this.generateExpression(e,t,r[0]);throw new Error("No valid inputs for node")}case wa.ASSIGNMENT:Ka("ASSIGNMENT nodes should not be used as expressions");default:Ka(`${Ca[i.nodeType]} code generation not implemented yet`)}},generateBlock(e,t,r){const i=t.cfg.blockTypes[e];(Fo[i]||Fo[Ya.DEFAULT]).call(Fo,e,t,r)},createGetTextureCall(e,t){const{id:r,dimension:i}=Co(e,"getTexture",t,{overloads:[{params:[Na.sampler2D,Na.float2],returnType:Na.float4}]});return{id:r,dimension:i}},instanceIdReference:()=>"gl_InstanceID"};function Mo(e,t){let r=e._vertSrc,i=e.hooks.vertex[t];if(i||(i=e.hooks.fragment[t],r=e._fragSrc),!i)throw new Error(`Can't find hook ${t}!`);const s=t.split(/\s+/g),n=s.pop(),a=s.pop(),o=[...s],h=/\(([^\)]*)\)/.exec(i);if(!h)throw new Error(`Couldn't find function parameters in hook body:\n${i}`);const u=e=>{const t=new RegExp(`struct\\s+${e}\\s*{([^}]*)}`).exec(r);if(!t)return;const i=[];for(const e of t[1].split(";")){const t=e.trim().split(/\s+|,/g),r=t.shift(),s=[...t],n=u(r);for(const e of s){const t=$a[r]||null;i.push({name:e,type:{typeName:r,qualifiers:[],properties:n,dataType:t}})}}return i},l=h[1].split(",").map(e=>{const t=e.trim().split(/\s+/g),r=t.pop(),i=t.pop();return{name:r,type:{typeName:i,qualifiers:[...t],properties:u(i),dataType:$a[i]||null}}}),c=$a[a]||null;return{name:n,returnType:{typeName:a,qualifiers:o,properties:u(a),dataType:c},parameters:l}}var ko="// Based on https://github.com/stegu/webgl-noise/blob/22434e04d7753f7e949e8d724ab3da2864c17a0f/src/noise3D.glsl\n// MIT licensed, adapted for p5.strands\n\nvec3 mod289(vec3 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 mod289(vec4 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x) {\n return mod289(((x*34.0)+10.0)*x);\n}\n\nvec4 taylorInvSqrt(vec4 r)\n{\n return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nfloat baseNoise(vec3 v)\n{\n const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n // First corner\n vec3 i = floor(v + dot(v, C.yyy) );\n vec3 x0 = v - i + dot(i, C.xxx) ;\n\n // Other corners\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min( g.xyz, l.zxy );\n vec3 i2 = max( g.xyz, l.zxy );\n\n // x0 = x0 - 0.0 + 0.0 * C.xxx;\n // x1 = x0 - i1 + 1.0 * C.xxx;\n // x2 = x0 - i2 + 2.0 * C.xxx;\n // x3 = x0 - 1.0 + 3.0 * C.xxx;\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y\n vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y\n\n // Permutations\n i = mod289(i);\n vec4 p = permute( permute( permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n\n // Gradients: 7x7 points over a square, mapped onto an octahedron.\n // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)\n float n_ = 0.142857142857; // 1.0/7.0\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)\n\n vec4 x = x_ *ns.x + ns.yyyy;\n vec4 y = y_ *ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4( x.xy, y.xy );\n vec4 b1 = vec4( x.zw, y.zw );\n\n //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;\n //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;\n vec4 s0 = floor(b0)*2.0 + 1.0;\n vec4 s1 = floor(b1)*2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;\n vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;\n\n vec3 p0 = vec3(a0.xy,h.x);\n vec3 p1 = vec3(a0.zw,h.y);\n vec3 p2 = vec3(a1.xy,h.z);\n vec3 p3 = vec3(a1.zw,h.w);\n\n //Normalise gradients\n vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n // Mix final noise value\n vec4 m = max(0.5 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);\n m = m * m;\n return 105.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),\n dot(p2,x2), dot(p3,x3) ) );\n}\n\nfloat noise(vec3 st, int octaves, float ampFalloff) {\n float result = 0.0;\n float amplitude = 1.0;\n float frequency = 1.0;\n\n for (int i = 0; i < 8; i++) {\n if (i >= octaves) break;\n result += amplitude * baseNoise(st * frequency);\n frequency *= 2.0;\n amplitude *= ampFalloff;\n }\n return (result + 1.0) * 0.5;\n}\n";class Io{constructor(e){this.parentRenderer=e,this.canvas=document.createElement("canvas"),this.canvas.width=e.width,this.canvas.height=e.height;let t=n;this.gl=this.canvas.getContext("webgl2"),this.gl||(t=s,this.gl=this.canvas.getContext("webgl")),this.gl?(this.textures=new Map,this._renderer={GL:this.gl,registerEnabled:new Set,_curShader:null,_emptyTexture:null,webglVersion:t,states:{textureWrapX:Ce,textureWrapY:Ce},_arraysEqual:(e,t)=>JSON.stringify(e)===JSON.stringify(t),_getEmptyTexture:()=>{if(!this._emptyTexture){const e=new $i(1,1);e.set(0,0,255),this._emptyTexture=new ta(this._renderer,e)}return this._emptyTexture},_initShader:e=>{const t=this.gl,r=t.createShader(t.VERTEX_SHADER);if(t.shaderSource(r,e.vertSrc()),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new Error(`Yikes! An error occurred compiling the vertex shader: ${t.getShaderInfoLog(r)}`);const i=t.createShader(t.FRAGMENT_SHADER);if(t.shaderSource(i,e.fragSrc()),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS))throw new Error(`Darn! An error occurred compiling the fragment shader: ${t.getShaderInfoLog(i)}`);const s=t.createProgram();if(t.attachShader(s,r),t.attachShader(s,i),t.linkProgram(s),!t.getProgramParameter(s,t.LINK_STATUS))throw new Error(`Snap! Error linking shader program: ${t.getProgramInfoLog(s)}`);e._glProgram=s,e._vertShader=r,e._fragShader=i},getTexture:e=>{let t=e;t instanceof Framebuffer&&(t=t.color);const r=this.textures.get(t);if(r)return r;const i=new ta(this._renderer,t);return this.textures.set(t,i),i},populateHooks:(e,t,r)=>la(e,t,r),_getShaderAttributes:e=>ua(e,this.gl),getUniformMetadata:e=>ha(e,this.gl),_finalizeShader:()=>{},_useShader:e=>{this.gl.useProgram(e._glProgram)},bindTexture:e=>{this.gl.bindTexture(this.gl.TEXTURE_2D,e.getTexture().texture)},unbindTexture:()=>{this.gl.bindTexture(this.gl.TEXTURE_2D,null)},_unbindFramebufferTexture:e=>{const t=this.gl,r=this._getEmptyTexture();t.activeTexture(t.TEXTURE0+e.samplerIndex),r.bindTexture(),t.uniform1i(e.location,e.samplerIndex)},createTexture:({width:e,height:t,format:r,dataType:i})=>{const s=this.gl,n=s.createTexture();return s.bindTexture(s.TEXTURE_2D,n),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,e,t,0,s.RGBA,s.UNSIGNED_BYTE,null),{texture:n,glFormat:s.RGBA,glDataType:s.UNSIGNED_BYTE}},uploadTextureFromSource:({texture:e,glFormat:t,glDataType:r},i)=>{const s=this.gl;s.bindTexture(s.TEXTURE_2D,e),s.texImage2D(s.TEXTURE_2D,0,t,t,r,i)},uploadTextureFromData:({texture:e,glFormat:t,glDataType:r},i,s,n)=>{const a=this.gl;a.bindTexture(a.TEXTURE_2D,e),a.texImage2D(a.TEXTURE_2D,0,t,s,n,0,t,r,i)},setTextureParams:e=>aa(e,this.gl,this._renderer.webglVersion),updateUniformValue:(e,t,r)=>oa(e,t,r,e=>this._renderer.getTexture(e),this.gl),_enableAttrib:(e,t,r,i,s,n,a)=>{const o=t.location,h=this.gl;this._renderer.registerEnabled.has(o)||(h.enableVertexAttribArray(o),this._renderer.registerEnabled.add(o)),h.vertexAttribPointer(o,r,i||h.FLOAT,s||!1,n||0,a||0)},_disableRemainingAttributes:e=>{for(const t of this._renderer.registerEnabled.values())Object.keys(e.attributes).some(r=>e.attributes[r].location===t)||(this.gl.disableVertexAttribArray(t),this._renderer.registerEnabled.delete(t))},_updateTexture:(e,t)=>{const r=this.gl;r.activeTexture(r.TEXTURE0+e.samplerIndex),t.bindTexture(),t.update(),r.uniform1i(e.location,e.samplerIndex)},baseFilterShader:()=>this.baseFilterShader(),strandsBackend:To,getShaderHookTypes:(e,t)=>Mo(e,t),uniformNameFromHookKey:e=>e.slice(e.indexOf(" ")+1)},this._baseFilterShader=void 0,this.filterShaders={},this.operation=null,this.filterParameter=1,this.customShader=null,this._shader=null,this.vertexBuffer=this.gl.createBuffer(),this.texcoordBuffer=this.gl.createBuffer(),this.vertices=new Float32Array([-1,-1,1,-1,-1,1,1,1]),this.texcoords=new Float32Array([0,1,1,1,0,0,1,0]),this._bindBufferData(this.vertexBuffer,this.gl.ARRAY_BUFFER,this.vertices),this._bindBufferData(this.texcoordBuffer,this.gl.ARRAY_BUFFER,this.texcoords)):console.error("WebGL not supported, cannot apply filter.")}_webGL2CompatibilityPrefix(e,t){let r="";return this._renderer.webglVersion===n&&(r+="#version 300 es\n#define WEBGL2\n"),"vert"===e?r+="#define VERTEX_SHADER\n":"frag"===e&&(r+="#define FRAGMENT_SHADER\n"),t&&(r+=`precision ${t} float;\n`),r}baseFilterShader(){return this._baseFilterShader||(this._baseFilterShader=new Xn(this._renderer,this._webGL2CompatibilityPrefix("vert","highp")+_a+ba,this._webGL2CompatibilityPrefix("frag","highp")+_a+va,{vertex:{},fragment:{"vec4 getColor":"(FilterInputs inputs, in sampler2D canvasContent) {\n return getTexture(canvasContent, inputs.texCoord);\n }"}})),this._baseFilterShader}getNoiseShaderSnippet(){return ko}setOperation(e,t,r=null){this.operation=e,this.filterParameter=t,e in Bn&&void 0===t&&(this.filterParameter=Bn[e]),this.customShader=r,this._initializeShader()}_initializeShader(){if(this.customShader)return void(this._shader=this.customShader);if(!this.operation)return void console.error("No operation set for FilterRenderer2D, cannot initialize shader.");if(this.filterShaders[this.operation])return void(this._shader=this.filterShaders[this.operation]);const e=Vn(this._renderer,this.operation,this.parentRenderer._pInst);this.filterShaders[this.operation]=e,this._shader=e}_bindBufferData(e,t,r){const i=this.gl;i.bindBuffer(t,e),i.bufferData(t,r,i.STATIC_DRAW)}get canvasTexture(){return this._canvasTexture||(this._canvasTexture=new ta(this._renderer,this.parentRenderer.wrappedElt)),this._canvasTexture}_renderPass(){const e=this.gl;this._shader.bindShader("fill");const t=this.parentRenderer.pixelDensity?this.parentRenderer.pixelDensity():1,r=[1/(this.parentRenderer.width*t),1/(this.parentRenderer.height*t)],i=this.canvasTexture;this._shader.setUniform("tex0",i),this._shader.setUniform("texelSize",r),this._shader.setUniform("canvasSize",[this.parentRenderer.width,this.parentRenderer.height]),this._shader.setUniform("radius",Math.max(1,this.filterParameter)),this._shader.setUniform("filterParameter",this.filterParameter),this._shader.setDefaultUniforms(),this.parentRenderer.states.setValue("rectMode",_),this.parentRenderer.states.setValue("imageMode",_),this.parentRenderer.blendMode($),this.parentRenderer.resetMatrix();const s=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];this._shader.setUniform("uModelViewMatrix",s),this._shader.setUniform("uProjectionMatrix",s),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),this._shader.enableAttrib(this._shader.attributes.aPosition,2),e.bindBuffer(e.ARRAY_BUFFER,this.texcoordBuffer),this._shader.enableAttrib(this._shader.attributes.aTexCoord,2),this._shader.bindTextures(),this._renderer._disableRemainingAttributes(this._shader),e.drawArrays(e.TRIANGLE_STRIP,0,4),this._shader.unbindShader()}applyFilter(){this._shader?(this.parentRenderer.push(),this.parentRenderer.resetMatrix(),this.operation!==de||this.customShader?(this._renderPass(),this.parentRenderer.clear(),this.parentRenderer.blendMode($),this.parentRenderer.drawingContext.drawImage(this.canvas,0,0,this.parentRenderer.width,this.parentRenderer.height)):(this._shader.setUniform("direction",[1,0]),this._renderPass(),this.parentRenderer.clear(),this.parentRenderer.drawingContext.drawImage(this.canvas,0,0,this.parentRenderer.width,this.parentRenderer.height),this._shader.setUniform("direction",[0,1]),this._renderPass(),this.parentRenderer.clear(),this.parentRenderer.drawingContext.drawImage(this.canvas,0,0,this.parentRenderer.width,this.parentRenderer.height)),this.parentRenderer.pop()):console.error("Cannot apply filter: shader not initialized.")}}const Bo="rgba(0,0,0,0)";class Lo extends _s{constructor(e,t,r,i,s,n={}){super(e,t,r,i),this.canvas=this.elt=s||document.createElement("canvas"),i?(this._pInst._curElement=this,this._pInst.canvas=this.canvas):this.canvas.style.display="none",this.elt.id="defaultCanvas0",this.elt.classList.add("p5Canvas");for(const e of Object.getOwnPropertyNames(Pi.prototype))"constructor"!==e&&"_"!==e[0]&&Object.defineProperty(this,e,{get(){return this.wrappedElt[e]}});if(this.elt.width=t*this._pixelDensity,this.elt.height=r*this._pixelDensity,this.elt.style.width=`${t}px`,this.elt.style.height=`${r}px`,this._pInst._userNode)this._pInst._userNode.appendChild(this.elt);else{if(0===document.getElementsByTagName("main").length){let e=document.createElement("main");document.body.appendChild(e)}document.getElementsByTagName("main")[0].appendChild(this.elt)}this.drawingContext=this.canvas.getContext("2d",n),"display-p3"===n.colorSpace&&(this.states.colorMode=_i),this.scale(this._pixelDensity,this._pixelDensity),this.wrappedElt=new Pi(this.elt,this._pInst),this.clipPath=null}get filterRenderer(){return this._filterRenderer||(this._filterRenderer=new Io(this)),this._filterRenderer}remove(){this.wrappedElt.remove(),this.wrappedElt=null,this.canvas=null,this.elt=null}getFilterGraphicsLayer(){if(!this.filterGraphicsLayer){const e=this._pInst;this.filterGraphicsLayer=new ea(this.width,this.height,s,e)}return this.filterGraphicsLayer.width===this.width&&this.filterGraphicsLayer.height===this.height||this.filterGraphicsLayer.resizeCanvas(this.width,this.height),this.filterGraphicsLayer.pixelDensity()!==this._pInst.pixelDensity()&&this.filterGraphicsLayer.pixelDensity(this._pInst.pixelDensity()),this.filterGraphicsLayer}_applyDefaults(){this.states.setValue("_cachedFillStyle",void 0),this.states.setValue("_cachedStrokeStyle",void 0),this._cachedBlendMode=$,this._setFill(Fe),this._setStroke(Se),this.drawingContext.lineCap=U,this.drawingContext.font="normal 12px sans-serif"}resize(e,t){super.resize(e,t);const r={};for(const e in this.drawingContext){const t=this.drawingContext[e];"object"!=typeof t&&"function"!=typeof t&&(r[e]=t)}this.canvas.width=e*this._pixelDensity,this.canvas.height=t*this._pixelDensity,this.canvas.style.width=`${e}px`,this.canvas.style.height=`${t}px`,this.drawingContext.scale(this._pixelDensity,this._pixelDensity);for(const t in r)try{this.drawingContext[t]=r[t]}catch(e){}}background(...e){if(this.push(),this.resetMatrix(),e[0]instanceof $i)if(e[1]>=0){const t=e[0];this.drawingContext.globalAlpha=e[1]/255,this._pInst.image(t,0,0,this.width,this.height)}else this._pInst.image(e[0],0,0,this.width,this.height);else{const t=this._pInst.color(...e);this._pInst._addAccsOutput?.()&&this._pInst._accsBackground?.(t._getRGBA([255,255,255,255]));const r=t.toString();this._setFill(r),this._isErasing&&this.blendMode(this._cachedBlendMode),this.drawingContext.fillRect(0,0,this.width,this.height),this._isErasing&&this._pInst.erase()}this.pop()}clear(){this.drawingContext.save(),this.resetMatrix(),this.drawingContext.clearRect(0,0,this.width,this.height),this.drawingContext.restore()}fill(...e){super.fill(...e);const t=this.states.fillColor;this._setFill(t.toString()),this._pInst._addAccsOutput?.()&&this._pInst._accsCanvasColors?.("fill",t._getRGBA([255,255,255,255]))}stroke(...e){super.stroke(...e);const t=this.states.strokeColor;this._setStroke(t.toString()),this._pInst._addAccsOutput?.()&&this._pInst._accsCanvasColors?.("stroke",t._getRGBA([255,255,255,255]))}erase(e,t){if(!this._isErasing){this.states.setValue("_cachedFillStyle",this.drawingContext.fillStyle);const r=this._pInst.color(255,e).toString();this.drawingContext.fillStyle=r,this.states.setValue("_cachedStrokeStyle",this.drawingContext.strokeStyle);const i=this._pInst.color(255,t).toString();this.drawingContext.strokeStyle=i;const s=this._cachedBlendMode;this.blendMode(H),this._cachedBlendMode=s,this._isErasing=!0}}noErase(){this._isErasing&&(this.drawingContext.fillStyle=this.states._cachedFillStyle,this.drawingContext.strokeStyle=this.states._cachedStrokeStyle,this.blendMode(this._cachedBlendMode),this._isErasing=!1)}drawShape(e){const t=new gs({strokeWeight:this.states.strokeWeight});if(e.accept(t),this._clipping){const e=this.drawingContext.getTransform(),r=this._clipBaseTransform.inverse().multiply(e);this.clipPath.addPath(t.path,r),this.clipPath.closePath()}else this.states.fillColor&&this.drawingContext.fill(t.path),this.states.strokeColor&&this.drawingContext.stroke(t.path)}beginClip(e={}){super.beginClip(e),this._clipBaseTransform=this.drawingContext.getTransform(),this.states.setValue("_cachedFillStyle",this.drawingContext.fillStyle);const t=this._pInst.color(255,0).toString();this.drawingContext.fillStyle=t,this.states.setValue("_cachedStrokeStyle",this.drawingContext.strokeStyle);const r=this._pInst.color(255,0).toString();this.drawingContext.strokeStyle=r;const i=this._cachedBlendMode;this.blendMode($),this._cachedBlendMode=i,this.clipPath=new Path2D,this._clipBaseTransform=this.drawingContext.getTransform(),this._clipInvert&&(this.clipPath.moveTo(-2*this.width,-2*this.height),this.clipPath.lineTo(-2*this.width,2*this.height),this.clipPath.lineTo(2*this.width,2*this.height),this.clipPath.lineTo(2*this.width,-2*this.height),this.clipPath.closePath())}endClip(){const e=this.drawingContext.getTransform();this.drawingContext.setTransform(this._clipBaseTransform),this.drawingContext.clip(this.clipPath),this.drawingContext.setTransform(e),this.clipPath=null,super.endClip(),this.drawingContext.fillStyle=this.states._cachedFillStyle,this.drawingContext.strokeStyle=this.states._cachedStrokeStyle,this.blendMode(this._cachedBlendMode)}image(e,t,r,i,s,n,a,o,h){let u;e.gifProperties&&e._animateGif(this._pInst);try{e instanceof Ds&&e._ensureCanvas(),this.states.tint&&e.canvas&&(u=this._getTintedImageCanvas(e)),u||(u=e.canvas||e.elt);let l=1;e.width&&e.width>0&&(l=u.width/e.width),this._isErasing&&this.blendMode(this._cachedBlendMode),this.drawingContext.drawImage(u,l*t,l*r,l*i,l*s,n,a,o,h),this._isErasing&&this._pInst.erase()}catch(e){if("NS_ERROR_NOT_AVAILABLE"!==e.name)throw e}}_getTintedImageCanvas(e){if(!e.canvas)return e;e.tintCanvas||(e.tintCanvas=document.createElement("canvas")),e.tintCanvas.width!==e.canvas.width&&(e.tintCanvas.width=e.canvas.width),e.tintCanvas.height!==e.canvas.height&&(e.tintCanvas.height=e.canvas.height);const t=e.tintCanvas.getContext("2d");return t.save(),t.clearRect(0,0,e.canvas.width,e.canvas.height),this.states.tint[0]<255||this.states.tint[1]<255||this.states.tint[2]<255?(t.drawImage(e.canvas,0,0),t.globalCompositeOperation="luminosity",t.drawImage(e.canvas,0,0),t.globalCompositeOperation="color",t.drawImage(e.canvas,0,0),t.globalCompositeOperation="multiply",t.fillStyle=`rgb(${this.states.tint.slice(0,3).join(", ")})`,t.fillRect(0,0,e.canvas.width,e.canvas.height),t.globalCompositeOperation="destination-in",t.globalAlpha=this.states.tint[3]/255,t.drawImage(e.canvas,0,0)):(t.globalAlpha=this.states.tint[3]/255,t.drawImage(e.canvas,0,0)),t.restore(),e.tintCanvas}blendMode(e){if(e===K)console.warn("blendMode(SUBTRACT) only works in WEBGL mode.");else{if(e!==$&&e!==H&&e!==W&&e!==X&&e!==Y&&e!==J&&e!==Z&&e!==Q&&e!==ee&&e!==te&&e!==re&&e!==ie&&e!==se&&e!==ne&&e!==q)throw new Error(`Mode ${e} not recognized.`);this._cachedBlendMode=e,this.drawingContext.globalCompositeOperation=e}}blend(...e){const t=this.drawingContext.globalCompositeOperation,r=e[e.length-1],i=Array.prototype.slice.call(e,0,e.length-1);this.drawingContext.globalCompositeOperation=r,Po.prototype.copy.apply(this,i),this.drawingContext.globalCompositeOperation=t}_getPixel(e,t){let r,i;return r=this.drawingContext.getImageData(e,t,1,1).data,i=0,[r[0],r[1],r[2],r[3]]}loadPixels(){const e=this._pixelDensity,t=this.width*e,r=this.height*e,i=this.drawingContext.getImageData(0,0,t,r);this.imageData=i,this.pixels=i.data}set(e,t,r){if(e=Math.floor(e),t=Math.floor(t),r instanceof ea||r instanceof $i){this.drawingContext.save(),this.drawingContext.setTransform(1,0,0,1,0,0),this.drawingContext.scale(this._pixelDensity,this._pixelDensity);const i=r.width,s=r.height;this.drawingContext.clearRect(e,t,i,s),this.drawingContext.drawImage(r.canvas,e,t,i,s)}else{let i=0,s=0,n=0,a=0,o=4*(t*this._pixelDensity*(this.width*this._pixelDensity)+e*this._pixelDensity);if(this.imageData||this.loadPixels(),"number"==typeof r)o<this.pixels.length&&(i=r,s=r,n=r,a=255);else if(Array.isArray(r)){if(r.length<4)throw new Error("pixel array must be of the form [R, G, B, A]");o<this.pixels.length&&(i=r[0],s=r[1],n=r[2],a=r[3])}else r instanceof Po.Color&&o<this.pixels.length&&([i,s,n,a]=r._getRGBA([255,255,255,255]));for(let r=0;r<this._pixelDensity;r++)for(let h=0;h<this._pixelDensity;h++)o=4*((t*this._pixelDensity+h)*this.width*this._pixelDensity+(e*this._pixelDensity+r)),this.pixels[o]=i,this.pixels[o+1]=s,this.pixels[o+2]=n,this.pixels[o+3]=a}}updatePixels(e,t,r,i){const s=this._pixelDensity;void 0===e&&void 0===t&&void 0===r&&void 0===i&&(e=0,t=0,r=this.width,i=this.height),e*=s,t*=s,r*=s,i*=s,this.gifProperties&&(this.gifProperties.frames[this.gifProperties.displayIndex].image=this.imageData),this.drawingContext.putImageData(this.imageData,0,0,e,t,r,i)}arc(e,t,r,i,s,n,a){const o=this.drawingContext,h=e+r/2,u=t+i/2,l=r/2,c=i/2;if(this._clipping){const e=new Path2D;e.ellipse(h,u,l,c,0,s,n);const t=this.drawingContext.getTransform(),r=this._clipBaseTransform.inverse().multiply(t);return this.clipPath.addPath(e,r),this}const p=!(a===O||a===P||(n-s)%x==0);return this.states.fillColor&&(o.beginPath(),o.ellipse(h,u,l,c,0,s,n),p&&o.lineTo(h,u),o.closePath(),o.fill()),this.states.strokeColor&&(o.beginPath(),o.ellipse(h,u,l,c,0,s,n),a===R&&p&&o.lineTo(h,u),a!==R&&a!==O||o.closePath(),o.stroke()),this}ellipse(e){const t=this.drawingContext,r=!!this.states.fillColor,i=this.states.strokeColor,s=parseFloat(e[0]),n=parseFloat(e[1]),a=parseFloat(e[2]),o=parseFloat(e[3]);if(r&&!i){if(this._getFill()===Bo)return this}else if(!r&&i&&this._getStroke()===Bo)return this;const h=s+a/2,u=n+o/2,l=a/2,c=o/2;if(this._clipping){const e=new Path2D;e.ellipse(h,u,l,c,0,0,2*Math.PI);const t=this.drawingContext.getTransform(),r=this._clipBaseTransform.inverse().multiply(t);return this.clipPath.addPath(e,r),this}return t.beginPath(),t.ellipse(h,u,l,c,0,0,2*Math.PI),t.closePath(),r&&t.fill(),i&&t.stroke(),this}line(e,t,r,i){const s=this.drawingContext;if(!this.states.strokeColor)return this;if(this._getStroke()===Bo)return this;if(this._clipping){const s=new Path2D;s.moveTo(e,t),s.lineTo(r,i);const n=this.drawingContext.getTransform(),a=this._clipBaseTransform.inverse().multiply(n);return this.clipPath.addPath(s,a),this}return s.beginPath(),s.moveTo(e,t),s.lineTo(r,i),s.stroke(),this}point(e,t){const r=this.drawingContext;if(!this.states.strokeColor)return this;if(this._getStroke()===Bo)return this;const i=this._getStroke(),s=this._getFill();if(this._clipping){const r=new Path2D,i=this.drawingContext.lineWidth;r.arc(e,t,i/2,0,x);const s=this.drawingContext.getTransform(),n=this._clipBaseTransform.inverse().multiply(s);return this.clipPath.addPath(r,n),this}return this._setFill(i),r.beginPath(),r.arc(e,t,r.lineWidth/2,0,x,!1),r.fill(),this._setFill(s),this}quad(e,t,r,i,s,n,a,o){const h=this.drawingContext,u=!!this.states.fillColor,l=this.states.strokeColor;if(u&&!l){if(this._getFill()===Bo)return this}else if(!u&&l&&this._getStroke()===Bo)return this;if(this._clipping){const h=new Path2D;h.moveTo(e,t),h.lineTo(r,i),h.lineTo(s,n),h.lineTo(a,o),h.closePath();const u=this.drawingContext.getTransform(),l=this._clipBaseTransform.inverse().multiply(u);return this.clipPath.addPath(h,l),this}return h.beginPath(),h.moveTo(e,t),h.lineTo(r,i),h.lineTo(s,n),h.lineTo(a,o),h.closePath(),u&&h.fill(),l&&h.stroke(),this}rect(e){const t=e[0],r=e[1],i=e[2],s=e[3];let n=e[4],a=e[5],o=e[6],h=e[7];const u=this.drawingContext,l=!!this.states.fillColor,c=this.states.strokeColor;if(l&&!c){if(this._getFill()===Bo)return this}else if(!l&&c&&this._getStroke()===Bo)return this;if(this._clipping){const e=new Path2D;void 0===n?e.rect(t,r,i,s):e.roundRect(t,r,i,s,[n,a,o,h]);const u=this.drawingContext.getTransform(),l=this._clipBaseTransform.inverse().multiply(u);return this.clipPath.addPath(e,l),this}if(u.beginPath(),void 0===n)u.rect(t,r,i,s);else{void 0===a&&(a=n),void 0===o&&(o=a),void 0===h&&(h=o);const e=Math.abs(i),l=Math.abs(s),c=e/2,p=l/2;e<2*n&&(n=c),l<2*n&&(n=p),e<2*a&&(a=c),l<2*a&&(a=p),e<2*o&&(o=c),l<2*o&&(o=p),e<2*h&&(h=c),l<2*h&&(h=p),u.roundRect(t,r,i,s,[n,a,o,h])}return l&&u.fill(),c&&u.stroke(),this}triangle(e){const t=this.drawingContext,r=!!this.states.fillColor,i=this.states.strokeColor,s=e[0],n=e[1],a=e[2],o=e[3],h=e[4],u=e[5];if(r&&!i){if(this._getFill()===Bo)return this}else if(!r&&i&&this._getStroke()===Bo)return this;if(this._clipping){const e=new Path2D;e.moveTo(s,n),e.lineTo(a,o),e.lineTo(h,u),e.closePath();const t=this.drawingContext.getTransform(),r=this._clipBaseTransform.inverse().multiply(t);return this.clipPath.addPath(e,r),this}return t.beginPath(),t.moveTo(s,n),t.lineTo(a,o),t.lineTo(h,u),t.closePath(),r&&t.fill(),i&&t.stroke(),this}strokeCap(e){return e!==U&&e!==V&&e!==N||(this.drawingContext.lineCap=e),this}strokeJoin(e){return e!==U&&e!==z&&e!==G||(this.drawingContext.lineJoin=e),this}strokeWeight(e){return super.strokeWeight(e),this.drawingContext.lineWidth=void 0===e||0===e?1e-4:e,this}_getFill(){return this.states._cachedFillStyle||this.states.setValue("_cachedFillStyle",this.drawingContext.fillStyle),this.states._cachedFillStyle}_setFill(e){e!==this.states._cachedFillStyle&&(this.drawingContext.fillStyle=e,this.states.setValue("_cachedFillStyle",e))}_getStroke(){return this.states._cachedStrokeStyle||this.states.setValue("_cachedStrokeStyle",this.drawingContext.strokeStyle),this.states._cachedStrokeStyle}_setStroke(e){e!==this.states._cachedStrokeStyle&&(this.drawingContext.strokeStyle=e,this.states.setValue("_cachedStrokeStyle",e))}applyMatrix(e,t,r,i,s,n){this.drawingContext.transform(e,t,r,i,s,n)}getWorldToScreenMatrix(){let e=(new DOMMatrix).scale(1/this._pixelDensity).multiply(this.drawingContext.getTransform());return new dn(e.toFloat32Array())}resetMatrix(){return this.drawingContext.setTransform(1,0,0,1,0,0),this.drawingContext.scale(this._pixelDensity,this._pixelDensity),this}rotate(e){this.drawingContext.rotate(e)}scale(e,t){return this.drawingContext.scale(e,t),this}translate(e,t){return e instanceof Po.Vector&&(t=e.y,e=e.x),this.drawingContext.translate(e,t),this}push(){return this.drawingContext.save(),super.push()}pop(e){this.drawingContext.restore(),super.pop(e)}textCanvas(){return this.canvas}textDrawingContext(){return this.drawingContext}_renderText(e,t,r,i,s){let n=this.states,a=this.textDrawingContext();r<s||r>=i||(this.push(),n.strokeColor&&n.strokeSet&&a.strokeText(e,t,r),!this._clipping&&n.fillColor&&(n.fillSet||this._setFill("#000000"),a.fillText(e,t,r)),this.pop())}_positionLines(e,t,r,i,s){let n,{textLeading:a,textAlign:o}=this.states,h=new Array(s.length),u=void 0===r?0:r,l=void 0===i?0:i;for(let r=0;r<s.length;r++){switch(o){case On:throw new Error("textBounds: START not yet supported for textAlign");case D:n=e;break;case A:n=e+u/2;break;case E:n=e+u;break;case Rn:throw new Error("textBounds: END not yet supported for textAlign")}h[r]={text:s[r],x:n,y:t+r*a}}return this._yAlignOffset(h,l)}_yAlignOffset(e,t){if(void 0===t)throw Error("_yAlignOffset: height is required");let{textLeading:r,textBaseline:i}=this.states,s=0,n=t-r*(e.length-1);switch(i){case S:case T:break;case Ln:s=n/2+this._middleAlignOffset();break;case F:s=n;break;case"ideographic":console.warn("textBounds: IDEOGRAPHIC not yet supported for textBaseline");break;case"hanging":console.warn("textBounds: HANGING not yet supported for textBaseline")}return e.forEach(e=>e.y+=s),e}}let Po=class e{static VERSION=r;static instance=null;static lifecycleHooks={presetup:[],postsetup:[],predraw:[],postdraw:[],remove:[]};static _checkForUserDefinedFunctions=()=>{};static _friendlyFileLoadError=()=>{};constructor(t,r){if(e.decorations.size>0){for(const[t,r]of e.decorations)for(const i in e.prototype)"function"==typeof e.prototype[i]&&t.some(e=>"string"==typeof e?e===i:e instanceof RegExp?e.test(i):void 0)&&(e.prototype[i]=r(e.prototype[i],{kind:"method",name:i,access:{},static:!1,private:!1,addInitializer(e){}}));e.decorations.clear()}this.hitCriticalError=!1,this._setupDone=!1,this._userNode=r,this._curElement=null,this._elements=[],this._glAttributes=null,this._webgpuAttributes=null,this._requestAnimId=0,this._isGlobal=!1,this._loop=!0,this._startListener=null,this._initializeInstanceVariables(),this._events={},this._removeAbortController=new AbortController,this._removeSignal=this._removeAbortController.signal,this._millisStart=-1,this._recording=!1,this._lcg_random_state=null,this._gaussian_previous=!1,this._updateWindowSize();const i=function(e){return function(t){if("constructor"===t)return;const r=Object.getOwnPropertyDescriptor(e,t),i=Object.getOwnPropertyDescriptor(Po.prototype,t),s=r&&r.get||i&&i.get;let n,a=!1,o=!1;if(!s){const e=Po.prototype[t];a="function"==typeof e,a||void 0===Ue[t]||(o=!0,n=e)}if(a){const r=Po.prototype[t].bind(e);Object.defineProperty(window,t,{configurable:!0,enumerable:!0,value:r})}else if(o)Object.defineProperty(window,t,{configurable:!0,enumerable:!0,value:n});else if(s||!a){let r=null,i=null,s=null;Object.defineProperty(window,t,{configurable:!0,enumerable:!0,get:()=>{const n=e[t];return null===s?(s="function"==typeof n,s?(r=n,i=n.bind(e),i):n):s?(n!==r&&(r=n,i=n.bind(e)),i):n}})}}}(this);if(t)t(this),e._checkForUserDefinedFunctions(this);else{if(this._isGlobal=!0,window.hitCriticalError)return;e.instance=this;for(const t of Object.getOwnPropertyNames(e.prototype))"_"!==t[0]&&i(t);const t=["constructor","length"];for(const e in this)if(this.hasOwnProperty(e)){if("_"===e[0]||t.includes(e))continue;i(e)}}const s=()=>{this.focused=!0},n=()=>{this.focused=!1};window.addEventListener("focus",s),window.addEventListener("blur",n),e.lifecycleHooks.remove.push(function(){window.removeEventListener("focus",s),window.removeEventListener("blur",n)}),"complete"===document.readyState?this.#S():(this._startListener=this.#S.bind(this),window.addEventListener("load",this._startListener,!1))}get pixels(){return this._renderer.pixels}get drawingContext(){return this._renderer.drawingContext}static _registeredAddons=new Set;static registerAddon(t){const r={};if(e._registeredAddons.has(t))return;e._registeredAddons.add(t),t(e,e.prototype,r);const i=Object.keys(e.lifecycleHooks);for(const t of i)"function"==typeof r[t]&&e.lifecycleHooks[t].push(r[t])}static decorations=new Map;static decorateHelper(t,r){let i=t;Array.isArray(t)||(i=[t]),e.decorations.set(i,r)}#F={};_customActions=new Proxy({},{get:(e,t)=>{if(!this.#F[t]){const e=this._isGlobal?window:this;"function"==typeof e[t]&&(this.#F[t]=e[t].bind(this))}return this.#F[t]}});async#S(){this.hitCriticalError||(this._userNode&&"string"==typeof this._userNode&&(this._userNode=document.getElementById(this._userNode)),await this.#T(),this.hitCriticalError||this._recording||this._draw())}async#T(){if(await this._runLifecycleHook("presetup"),this.hitCriticalError)return;this.createCanvas(100,100,i),this._millisStart=window.performance.now();const e=this._isGlobal?window:this;if("function"==typeof e.setup&&await e.setup(),this.hitCriticalError)return;const t=document.getElementsByTagName("canvas");for(const e of t)e.style.touchAction="none","true"===e.dataset.hidden&&(e.style.visibility="",delete e.dataset.hidden);this._lastTargetFrameTime=window.performance.now(),this._lastRealFrameTime=window.performance.now(),this._setupDone=!0,(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._updateAccsOutput(),await this._runLifecycleHook("postsetup"),this._millisStart=window.performance.now()}async _draw(e){if(this.hitCriticalError)return;const t=e||window.performance.now(),r=t-this._lastTargetFrameTime,i=1e3/this._targetFrameRate;(!this._loop||r>=i-5)&&(this.deltaTime=t-this._lastRealFrameTime,this._frameRate=1e3/this.deltaTime,await this.redraw(),this._lastTargetFrameTime=Math.max(this._lastTargetFrameTime+i,t),this._lastRealFrameTime=t,void 0!==this._updateMouseCoords&&(this._updateMouseCoords(),this.movedX=0,this.movedY=0)),this._loop&&(this._requestAnimId=window.requestAnimationFrame(this._draw.bind(this)))}async remove(){if(this._startListener&&window.removeEventListener("load",this._startListener,!1),this._curElement){this._loop=!1,this._requestAnimId&&window.cancelAnimationFrame(this._requestAnimId),this._removeAbortController.abort();for(const e of this._elements)e.elt&&e.elt.parentNode&&e.elt.parentNode.removeChild(e.elt);await this._runLifecycleHook("remove")}if(this._isGlobal){for(const t in e.prototype)try{delete window[t]}catch(e){window[t]=void 0}for(const e in this)if(this.hasOwnProperty(e))try{delete window[e]}catch(t){window[e]=void 0}e.instance=null}}async _runLifecycleHook(t){await Promise.all(e.lifecycleHooks[t].map(e=>e.call(this)))}_initializeInstanceVariables(){this._accessibleOutputs={text:!1,grid:!1,textLabel:!1,gridLabel:!1},this._styles=[],this._downKeys={},this._downKeyCodes={}}};for(const e in Ue)Po.prototype[e]=Ue[e];function Oo(e,t){const r="_Description",i="_fallbackDesc",s="_fallbackTable",n="_fte_",a="_Label",o="_labelDesc",h="_labelTable",u="_lte_";function l(e){if("label"===e||"fallback"===e)throw new Error("description should not be LABEL or FALLBACK");return e.endsWith(".")||e.endsWith(";")||e.endsWith(",")||e.endsWith("?")||e.endsWith("!")||(e+="."),e}t.describe=function(e,t){if("string"!=typeof e)return;const r=this.canvas.id;e=l(e),this.dummyDOM||(this.dummyDOM=document.getElementById(r).parentNode),this.descriptions||(this.descriptions={}),this.descriptions.fallback?this.descriptions.fallback.innerHTML!==e&&(this.descriptions.fallback.innerHTML=e):this._describeHTML("fallback",e),t===this.LABEL&&(this.descriptions.label?this.descriptions.label.innerHTML!==e&&(this.descriptions.label.innerHTML=e):this._describeHTML("label",e))},t.describeElement=function(e,t,r){if("string"!=typeof t||"string"!=typeof e)return;const i=this.canvas.id;t=l(t);let s=function(e){if("label"===e||"fallback"===e)throw new Error("element name should not be LABEL or FALLBACK");return e.endsWith(".")||e.endsWith(";")||e.endsWith(",")?e=e.replace(/.$/,":"):e.endsWith(":")||(e+=":"),e}(e);e=e.replace(/[^a-zA-Z0-9]/g,"");let n=`<th scope="row">${s}</th><td>${t}</td>`;this.dummyDOM||(this.dummyDOM=document.getElementById(i).parentNode),this.descriptions?this.descriptions.fallbackElements||(this.descriptions.fallbackElements={}):this.descriptions={fallbackElements:{}},this.descriptions.fallbackElements[e]?this.descriptions.fallbackElements[e].innerHTML!==n&&(this.descriptions.fallbackElements[e].innerHTML=n):this._describeElementHTML("fallback",e,n),r===this.LABEL&&(this.descriptions.labelElements||(this.descriptions.labelElements={}),this.descriptions.labelElements[e]?this.descriptions.labelElements[e].innerHTML!==n&&(this.descriptions.labelElements[e].innerHTML=n):this._describeElementHTML("label",e,n))},t._describeHTML=function(e,t){const n=this.canvas.id;if("fallback"===e){if(this.dummyDOM.querySelector(`#${n+r}`))this.dummyDOM.querySelector("#"+n+s).insertAdjacentHTML("beforebegin",`<p id="${n+i}"></p>`);else{let e=`<div id="${n}${r}" role="region" aria-label="Canvas Description"><p id="${n}${i}"></p></div>`;this.dummyDOM.querySelector(`#${n}accessibleOutput`)?this.dummyDOM.querySelector(`#${n}accessibleOutput`).insertAdjacentHTML("beforebegin",e):this.dummyDOM.querySelector(`#${n}`).innerHTML=e}return this.descriptions.fallback=this.dummyDOM.querySelector(`#${n}${i}`),void(this.descriptions.fallback.innerHTML=t)}if("label"===e){if(this.dummyDOM.querySelector(`#${n+a}`))this.dummyDOM.querySelector(`#${n+h}`)&&this.dummyDOM.querySelector(`#${n+h}`).insertAdjacentHTML("beforebegin",`<p id="${n}${o}"></p>`);else{let e=`<div id="${n}${a}" class="p5Label"><p id="${n}${o}"></p></div>`;this.dummyDOM.querySelector(`#${n}accessibleOutputLabel`)?this.dummyDOM.querySelector(`#${n}accessibleOutputLabel`).insertAdjacentHTML("beforebegin",e):this.dummyDOM.querySelector("#"+n).insertAdjacentHTML("afterend",e)}return this.descriptions.label=this.dummyDOM.querySelector("#"+n+o),void(this.descriptions.label.innerHTML=t)}},t._describeElementHTML=function(e,t,l){const c=this.canvas.id;if("fallback"===e){if(this.dummyDOM.querySelector(`#${c+r}`))this.dummyDOM.querySelector("#"+c+s)||this.dummyDOM.querySelector("#"+c+i).insertAdjacentHTML("afterend",`<table id="${c}${s}"><caption>Canvas elements and their descriptions</caption></table>`);else{let e=`<div id="${c}${r}" role="region" aria-label="Canvas Description"><table id="${c}${s}"><caption>Canvas elements and their descriptions</caption></table></div>`;this.dummyDOM.querySelector(`#${c}accessibleOutput`)?this.dummyDOM.querySelector(`#${c}accessibleOutput`).insertAdjacentHTML("beforebegin",e):this.dummyDOM.querySelector("#"+c).innerHTML=e}let e=document.createElement("tr");return e.id=c+n+t,this.dummyDOM.querySelector("#"+c+s).appendChild(e),this.descriptions.fallbackElements[t]=this.dummyDOM.querySelector(`#${c}${n}${t}`),void(this.descriptions.fallbackElements[t].innerHTML=l)}if("label"===e){if(this.dummyDOM.querySelector(`#${c+a}`))this.dummyDOM.querySelector(`#${c+h}`)||this.dummyDOM.querySelector("#"+c+o).insertAdjacentHTML("afterend",`<table id="${c+h}"></table>`);else{let e=`<div id="${c}${a}" class="p5Label"><table id="${c}${h}"></table></div>`;this.dummyDOM.querySelector(`#${c}accessibleOutputLabel`)?this.dummyDOM.querySelector(`#${c}accessibleOutputLabel`).insertAdjacentHTML("beforebegin",e):this.dummyDOM.querySelector("#"+c).insertAdjacentHTML("afterend",e)}let e=document.createElement("tr");e.id=c+u+t,this.dummyDOM.querySelector("#"+c+h).appendChild(e),this.descriptions.labelElements[t]=this.dummyDOM.querySelector(`#${c}${u}${t}`),this.descriptions.labelElements[t].innerHTML=l}}}function Ro(e,t){t._updateGridOutput=function(e){if(this._renderer&&this._renderer.isP3D)return void(this._didOutputGridWebGLMessage||(this._didOutputGridWebGLMessage=!0,console.error("gridOutput() does not yet work in WebGL mode.")));if(!this.dummyDOM.querySelector(`#${e}_summary`))return;let t=this._accessibleOutputs[e],r=function(e,t){let r="",i="",s=0;for(let n in t){let a=0;for(let i in t[n]){let o=`<li id="${e}shape${s}">${t[n][i].color} ${n},`;"line"===n?o+=` location = ${t[n][i].pos}, length = ${t[n][i].length} pixels`:(o+=` location = ${t[n][i].pos}`,"point"!==n&&(o+=`, area = ${t[n][i].area} %`),o+="</li>"),r+=o,a++,s++}i=a>1?`${i} ${a} ${n}s`:`${i} ${a} ${n}`}return{numShapes:[s,i],details:r}}(e,this.ingredients.shapes),i=function(e,t,r,i){let s=`${t} canvas, ${r} by ${i} pixels, contains ${e[0]}`;return s=1===e[0]?`${s} shape: ${e[1]}`:`${s} shapes: ${e[1]}`,s}(r.numShapes,this.ingredients.colors.background,this.width,this.height),s=function(e,t){let r=0,i="",s=Array.from(Array(10),()=>Array(10));for(let i in t)for(let n in t[i]){let a;a="line"!==i?`<a href="#${e}shape${r}">${t[i][n].color} ${i}</a>`:`<a href="#${e}shape${r}">${t[i][n].color} ${i} midpoint</a>`,t[i][n].loc.locY<s.length&&t[i][n].loc.locX<s[t[i][n].loc.locY].length&&(s[t[i][n].loc.locY][t[i][n].loc.locX]?s[t[i][n].loc.locY][t[i][n].loc.locX]=s[t[i][n].loc.locY][t[i][n].loc.locX]+" "+a:s[t[i][n].loc.locY][t[i][n].loc.locX]=a,r++)}for(let e in s){let t="<tr>";for(let r in s[e])t+="<td>",void 0!==s[e][r]&&(t+=s[e][r]),t+="</td>";i=i+t+"</tr>"}return i}(e,this.ingredients.shapes);i!==t.summary.innerHTML&&(t.summary.innerHTML=i),s!==t.map.innerHTML&&(t.map.innerHTML=s),r.details!==t.shapeDetails.innerHTML&&(t.shapeDetails.innerHTML=r.details),this._accessibleOutputs[e]=t}}function No(e,t){t._updateTextOutput=function(e){if(this._renderer&&this._renderer.isP3D)return void(this._didOutputTextWebGLMessage||(this._didOutputTextWebGLMessage=!0,console.error("textOutput() does not yet work in WebGL mode.")));if(!this.dummyDOM.querySelector(`#${e}_summary`))return;let t=this._accessibleOutputs[e],r=function(e,t){let r="",i=0;for(let s in t)for(let n in t[s]){let a=`<li><a href="#${e}shape${i}">${t[s][n].color} ${s}</a>`;"line"===s?a+=`, ${t[s][n].pos}, ${t[s][n].length} pixels long.</li>`:(a+=`, at ${t[s][n].pos}`,"point"!==s&&(a+=`, covering ${t[s][n].area}% of the canvas`),a+=".</li>"),r+=a,i++}return{numShapes:i,listShapes:r}}(e,this.ingredients.shapes),i=function(e,t,r,i){let s=`Your output is a, ${r} by ${i} pixels, ${t} canvas containing the following`;return s=1===e?`${s} shape:`:`${s} ${e} shapes:`,s}(r.numShapes,this.ingredients.colors.background,this.width,this.height),s=function(e,t){let r="",i=0;for(let s in t)for(let n in t[s]){let a=`<tr id="${e}shape${i}"><th>${t[s][n].color} ${s}</th>`;"line"===s?a+=`<td>location = ${t[s][n].pos}</td><td>length = ${t[s][n].length} pixels</td></tr>`:(a+=`<td>location = ${t[s][n].pos}</td>`,"point"!==s&&(a+=`<td> area = ${t[s][n].area}%</td>`),a+="</tr>"),r+=a,i++}return r}(e,this.ingredients.shapes);i!==t.summary.innerHTML&&(t.summary.innerHTML=i),r.listShapes!==t.list.innerHTML&&(t.list.innerHTML=r.listShapes),s!==t.shapeDetails.innerHTML&&(t.shapeDetails.innerHTML=s),this._accessibleOutputs[e]=t}}function Vo(e,t){function r(e,t,r){let i=Math.floor(e[0]/t*10),s=Math.floor(e[1]/r*10);return 10===i&&(i-=1),10===s&&(s-=1),{locX:i,locY:s}}t.textOutput=function(e){this._accessibleOutputs.text||(this._accessibleOutputs.text=!0,this._createOutput("textOutput","Fallback"),e===this.LABEL&&(this._accessibleOutputs.textLabel=!0,this._createOutput("textOutput","Label")))},t.gridOutput=function(e){this._accessibleOutputs.grid||(this._accessibleOutputs.grid=!0,this._createOutput("gridOutput","Fallback"),e===this.LABEL&&(this._accessibleOutputs.gridLabel=!0,this._createOutput("gridOutput","Label")))},t._addAccsOutput=function(){return this._accessibleOutputs||(this._accessibleOutputs={text:!1,grid:!1,textLabel:!1,gridLabel:!1}),this._accessibleOutputs.grid||this._accessibleOutputs.text},t._createOutput=function(e,t){let r,i,s,n=this.canvas.id;this.ingredients||(this.ingredients={shapes:{},colors:{background:"white",fill:"white",stroke:"black"},pShapes:"",pBackground:""}),this.dummyDOM||(this.dummyDOM=document.getElementById(n).parentNode);let a="";"Fallback"===t?(r=n+e,i=n+"accessibleOutput",this.dummyDOM.querySelector(`#${i}`)||(this.dummyDOM.querySelector(`#${n}_Description`)?this.dummyDOM.querySelector(`#${n}_Description`).insertAdjacentHTML("afterend",`<div id="${i}" role="region" aria-label="Canvas Outputs"></div>`):this.dummyDOM.querySelector(`#${n}`).innerHTML=`<div id="${i}" role="region" aria-label="Canvas Outputs"></div>`)):"Label"===t&&(a=t,r=n+e+t,i=n+"accessibleOutput"+t,this.dummyDOM.querySelector(`#${i}`)||(this.dummyDOM.querySelector(`#${n}_Label`)?this.dummyDOM.querySelector(`#${n}_Label`).insertAdjacentHTML("afterend",`<div id="${i}"></div>`):this.dummyDOM.querySelector(`#${n}`).insertAdjacentHTML("afterend",`<div id="${i}"></div>`))),this._accessibleOutputs[r]={},"textOutput"===e?(a=`#${n}gridOutput${a}`,s=`<div id="${r}">Text Output<div id="${r}Summary" aria-label="text output summary"><p id="${r}_summary"></p><ul id="${r}_list"></ul></div><table id="${r}_shapeDetails" summary="text output shape details"></table></div>`,this.dummyDOM.querySelector(a)?this.dummyDOM.querySelector(a).insertAdjacentHTML("beforebegin",s):this.dummyDOM.querySelector(`#${i}`).innerHTML=s,this._accessibleOutputs[r].list=this.dummyDOM.querySelector(`#${r}_list`)):"gridOutput"===e&&(a=`#${n}textOutput${a}`,s=`<div id="${r}">Grid Output<p id="${r}_summary" aria-label="grid output summary"><table id="${r}_map" summary="grid output content"></table><ul id="${r}_shapeDetails" aria-label="grid output shape details"></ul></div>`,this.dummyDOM.querySelector(a)?this.dummyDOM.querySelector(a).insertAdjacentHTML("afterend",s):this.dummyDOM.querySelector(`#${i}`).innerHTML=s,this._accessibleOutputs[r].map=this.dummyDOM.querySelector(`#${r}_map`)),this._accessibleOutputs[r].shapeDetails=this.dummyDOM.querySelector(`#${r}_shapeDetails`),this._accessibleOutputs[r].summary=this.dummyDOM.querySelector(`#${r}_summary`)},t._updateAccsOutput=function(){let e=this.canvas.id;JSON.stringify(this.ingredients.shapes)===this.ingredients.pShapes&&this.ingredients.colors.background===this.ingredients.pBackground||(this.ingredients.pShapes=JSON.stringify(this.ingredients.shapes),this._accessibleOutputs.text&&this._updateTextOutput(e+"textOutput"),this._accessibleOutputs.grid&&this._updateGridOutput(e+"gridOutput"),this._accessibleOutputs.textLabel&&this._updateTextOutput(e+"textOutputLabel"),this._accessibleOutputs.gridLabel&&this._updateGridOutput(e+"gridOutputLabel"))},t._accsBackground=function(e){this.ingredients.pShapes=JSON.stringify(this.ingredients.shapes),this.ingredients.pBackground=this.ingredients.colors.background,this.ingredients.shapes={},this.ingredients.colors.backgroundRGBA!==e&&(this.ingredients.colors.backgroundRGBA=e,this.ingredients.colors.background=this._rgbColorName(e))},t._accsCanvasColors=function(e,t){"fill"===e?this.ingredients.colors.fillRGBA!==t&&(this.ingredients.colors.fillRGBA=t,this.ingredients.colors.fill=this._rgbColorName(t)):"stroke"===e&&this.ingredients.colors.strokeRGBA!==t&&(this.ingredients.colors.strokeRGBA=t,this.ingredients.colors.stroke=this._rgbColorName(t))},t._accsOutput=function(e,t){"ellipse"===e&&t[2]===t[3]?e="circle":"rectangle"===e&&t[2]===t[3]&&(e="square");let i={},s=!0,n=function(e,t){let r,i;return"rectangle"===e||"ellipse"===e||"arc"===e||"circle"===e||"square"===e?(r=Math.round(t[0]+t[2]/2),i=Math.round(t[1]+t[3]/2)):"triangle"===e?(r=(t[0]+t[2]+t[4])/3,i=(t[1]+t[3]+t[5])/3):"quadrilateral"===e?(r=(t[0]+t[2]+t[4]+t[6])/4,i=(t[1]+t[3]+t[5]+t[7])/4):"line"===e?(r=(t[0]+t[2])/2,i=(t[1]+t[3])/2):(r=t[0],i=t[1]),[r,i]}(e,t);if("line"===e){i.color=this.ingredients.colors.stroke,i.length=Math.round(Math.hypot(t[2]-t[0],t[3]-t[1]));let e=this._getPos(t[0],[1]),s=this._getPos(t[2],[3]);i.loc=r(n,this.width,this.height),i.pos=e===s?`at ${e}`:`from ${e} to ${s}`}else"point"===e?i.color=this.ingredients.colors.stroke:(i.color=this.ingredients.colors.fill,i.area=this._getArea(e,t)),i.pos=this._getPos(...n),i.loc=r(n,this.width,this.height);if(this.ingredients.shapes[e]){for(let t in this.ingredients.shapes[e])JSON.stringify(this.ingredients.shapes[e][t])===JSON.stringify(i)&&(s=!1);!0===s&&this.ingredients.shapes[e].push(i)}else this.ingredients.shapes[e]=[i]},t._getPos=function(t,r){const{x:i,y:s}=this.worldToScreen(new e.Vector(t,r)),n=this.width,a=this.height;return i<.4*n?s<.4*a?"top left":s>.6*a?"bottom left":"mid left":i>.6*n?s<.4*a?"top right":s>.6*a?"bottom right":"mid right":s<.4*a?"top middle":s>.6*a?"bottom middle":"middle"},t._getArea=function(e,t){let r=0;if("arc"===e){const e=((t[5]-t[4])%(2*Math.PI)+2*Math.PI)%(2*Math.PI);if(r=e*t[2]*t[3]/8,"open"===t[6]||"chord"===t[6]){const i=t[0],s=t[1],n=t[0]+t[2]/2*Math.cos(t[4]).toFixed(2),a=t[1]+t[3]/2*Math.sin(t[4]).toFixed(2),o=t[0]+t[2]/2*Math.cos(t[5]).toFixed(2),h=t[1]+t[3]/2*Math.sin(t[5]).toFixed(2),u=Math.abs(i*(a-h)+n*(h-s)+o*(s-a))/2;e>Math.PI?r+=u:r-=u}}else"ellipse"===e||"circle"===e?r=3.14*t[2]/2*t[3]/2:"line"===e||"point"===e?r=0:"quadrilateral"===e?r=Math.abs((t[6]+t[0])*(t[7]-t[1])+(t[0]+t[2])*(t[1]-t[3])+(t[2]+t[4])*(t[3]-t[5])+(t[4]+t[6])*(t[5]-t[7]))/2:"rectangle"===e||"square"===e?r=t[2]*t[3]:"triangle"===e&&(r=Math.abs(t[0]*(t[3]-t[5])+t[2]*(t[5]-t[1])+t[4]*(t[1]-t[3]))/2);const i=this.width*this._renderer._pixelDensity,s=this.height*this._renderer._pixelDensity,n=[new DOMPoint(0,0),new DOMPoint(i,0),new DOMPoint(i,s),new DOMPoint(0,s)],a=(this._renderer.isP3D?new DOMMatrix(this._renderer.uMVMatrix.mat4):this.drawingContext.getTransform()).inverse(),o=n.map(e=>e.matrixTransform(a)),h=Math.abs((o[3].x+o[0].x)*(o[3].y-o[0].y)+(o[0].x+o[1].x)*(o[0].y-o[1].y)+(o[1].x+o[2].x)*(o[1].y-o[2].y)+(o[2].x+o[3].x)*(o[2].y-o[3].y))/2;return Math.round(100*r/h)}}Po.registerAddon(ze),Po.registerAddon(Ge),Po.registerAddon(je),Po.registerAddon(xa),Po.registerAddon(function(e,t){e.Renderer=_s}),Po.registerAddon(function(e,t){e.Renderer2D=Lo,e.renderers[i]=Lo,e.renderers["p2d-hdr"]=new Proxy(Lo,{construct:(e,[t,r,i,s,n])=>new e(t,r,i,s,n,{colorSpace:"display-p3"})})}),Po.registerAddon(function(e,t){e.Graphics=ea,Fs(e,e.Graphics.prototype),Ts(0,e.Graphics.prototype),Ms(0,e.Graphics.prototype),ks(0,e.Graphics.prototype),xs(e,e.Graphics.prototype),Is(0,e.Graphics.prototype),on(e,e.Graphics.prototype),Ns(e,e.Graphics.prototype),hn(e,e.Graphics.prototype),ze(e,e.Graphics.prototype),Hn(e,e.Graphics.prototype),qn(0,e.Graphics.prototype),Jn(0,e.Graphics.prototype),Mi(e,e.Graphics.prototype),Qn(0,e.Graphics.prototype)}),void 0!==p5&&Oo(0,p5.prototype),void 0!==p5&&Ro(0,p5.prototype),void 0!==p5&&No(0,p5.prototype),void 0!==p5&&Vo(p5,p5.prototype),Po.ColorConversion={_hsbaToHSLA(e){const t=e[0];let r=e[1];const i=e[2],s=(2-r)*i/2;return 0!==s&&(1===s?r=0:s<.5?r/=2-r:r=r*i/(2-2*s)),[t,r,s,e[3]]},_hsbaToRGBA(e){const t=6*e[0],r=e[1],i=e[2];let s=[];if(0===r)s=[i,i,i,e[3]];else{const n=Math.floor(t),a=i*(1-r),o=i*(1-r*(t-n)),h=i*(1-r*(1+n-t));let u,l,c;1===n?(u=o,l=i,c=a):2===n?(u=a,l=i,c=h):3===n?(u=a,l=o,c=i):4===n?(u=h,l=a,c=i):5===n?(u=i,l=a,c=o):(u=i,l=h,c=a),s=[u,l,c,e[3]]}return s},_hslaToHSBA(e){const t=e[0];let r=e[1];const i=e[2];let s;return s=i<.5?(1+r)*i:i+r-i*r,r=2*(s-i)/s,[t,r,s,e[3]]},_hslaToRGBA(e){const t=6*e[0],r=e[1],i=e[2];let s=[];if(0===r)s=[i,i,i,e[3]];else{let n;n=i<.5?(1+r)*i:i+r-i*r;const a=2*i-n,o=(e,t,r)=>(e<0?e+=6:e>=6&&(e-=6),e<1?t+(r-t)*e:e<3?r:e<4?t+(r-t)*(4-e):t);s=[o(t+2,a,n),o(t,a,n),o(t-2,a,n),e[3]]}return s},_rgbaToHSBA(e){const t=e[0],r=e[1],i=e[2],s=Math.max(t,r,i),n=s-Math.min(t,r,i);let a,o;return 0===n?(a=0,o=0):(o=n/s,t===s?a=(r-i)/n:r===s?a=2+(i-t)/n:i===s&&(a=4+(t-r)/n),a<0?a+=6:a>=6&&(a-=6)),[a/6,o,s,e[3]]},_rgbaToHSLA(e){const t=e[0],r=e[1],i=e[2],s=Math.max(t,r,i),n=Math.min(t,r,i),a=s+n,o=s-n;let h,u;return 0===o?(h=0,u=0):(u=a<1?o/a:o/(2-a),t===s?h=(r-i)/o:r===s?h=2+(i-t)/o:i===s&&(h=4+(t-r)/o),h<0?h+=6:h>=6&&(h-=6)),[h/6,u,a/2,e[3]]}};var Uo=Po.ColorConversion;function zo(e,t){let r;const i=[{h:0,s:0,b:.8275,name:"gray"},{h:0,s:0,b:.8627,name:"gray"},{h:0,s:0,b:.7529,name:"gray"},{h:.0167,s:.1176,b:1,name:"light pink"}],s=[{h:0,s:0,b:0,name:"black"},{h:0,s:0,b:.5,name:"gray"},{h:0,s:0,b:1,name:"white"},{h:0,s:.5,b:.5,name:"dark maroon"},{h:0,s:.5,b:1,name:"salmon pink"},{h:0,s:1,b:0,name:"black"},{h:0,s:1,b:.5,name:"dark red"},{h:0,s:1,b:1,name:"red"},{h:5,s:0,b:1,name:"very light peach"},{h:5,s:.5,b:.5,name:"brown"},{h:5,s:.5,b:1,name:"peach"},{h:5,s:1,b:.5,name:"brick red"},{h:5,s:1,b:1,name:"crimson"},{h:10,s:0,b:1,name:"light peach"},{h:10,s:.5,b:.5,name:"brown"},{h:10,s:.5,b:1,name:"light orange"},{h:10,s:1,b:.5,name:"brown"},{h:10,s:1,b:1,name:"orange"},{h:15,s:0,b:1,name:"very light yellow"},{h:15,s:.5,b:.5,name:"olive green"},{h:15,s:.5,b:1,name:"light yellow"},{h:15,s:1,b:0,name:"dark olive green"},{h:15,s:1,b:.5,name:"olive green"},{h:15,s:1,b:1,name:"yellow"},{h:20,s:0,b:1,name:"very light yellow"},{h:20,s:.5,b:.5,name:"olive green"},{h:20,s:.5,b:1,name:"light yellow green"},{h:20,s:1,b:0,name:"dark olive green"},{h:20,s:1,b:.5,name:"dark yellow green"},{h:20,s:1,b:1,name:"yellow green"},{h:25,s:.5,b:.5,name:"dark yellow green"},{h:25,s:.5,b:1,name:"light green"},{h:25,s:1,b:.5,name:"dark green"},{h:25,s:1,b:1,name:"green"},{h:30,s:.5,b:1,name:"light green"},{h:30,s:1,b:.5,name:"dark green"},{h:30,s:1,b:1,name:"green"},{h:35,s:0,b:.5,name:"light green"},{h:35,s:0,b:1,name:"very light green"},{h:35,s:.5,b:.5,name:"dark green"},{h:35,s:.5,b:1,name:"light green"},{h:35,s:1,b:0,name:"very dark green"},{h:35,s:1,b:.5,name:"dark green"},{h:35,s:1,b:1,name:"green"},{h:40,s:0,b:1,name:"very light green"},{h:40,s:.5,b:.5,name:"dark green"},{h:40,s:.5,b:1,name:"light green"},{h:40,s:1,b:.5,name:"dark green"},{h:40,s:1,b:1,name:"green"},{h:45,s:.5,b:1,name:"light turquoise"},{h:45,s:1,b:.5,name:"dark turquoise"},{h:45,s:1,b:1,name:"turquoise"},{h:50,s:0,b:1,name:"light sky blue"},{h:50,s:.5,b:.5,name:"dark cyan"},{h:50,s:.5,b:1,name:"light cyan"},{h:50,s:1,b:.5,name:"dark cyan"},{h:50,s:1,b:1,name:"cyan"},{h:55,s:0,b:1,name:"light sky blue"},{h:55,s:.5,b:1,name:"light sky blue"},{h:55,s:1,b:.5,name:"dark blue"},{h:55,s:1,b:1,name:"sky blue"},{h:60,s:0,b:.5,name:"gray"},{h:60,s:0,b:1,name:"very light blue"},{h:60,s:.5,b:.5,name:"blue"},{h:60,s:.5,b:1,name:"light blue"},{h:60,s:1,b:.5,name:"navy blue"},{h:60,s:1,b:1,name:"blue"},{h:65,s:0,b:1,name:"lavender"},{h:65,s:.5,b:.5,name:"navy blue"},{h:65,s:.5,b:1,name:"light purple"},{h:65,s:1,b:.5,name:"dark navy blue"},{h:65,s:1,b:1,name:"blue"},{h:70,s:0,b:1,name:"lavender"},{h:70,s:.5,b:.5,name:"navy blue"},{h:70,s:.5,b:1,name:"lavender blue"},{h:70,s:1,b:.5,name:"dark navy blue"},{h:70,s:1,b:1,name:"blue"},{h:75,s:.5,b:1,name:"lavender"},{h:75,s:1,b:.5,name:"dark purple"},{h:75,s:1,b:1,name:"purple"},{h:80,s:.5,b:1,name:"pinkish purple"},{h:80,s:1,b:.5,name:"dark purple"},{h:80,s:1,b:1,name:"purple"},{h:85,s:0,b:1,name:"light pink"},{h:85,s:.5,b:.5,name:"purple"},{h:85,s:.5,b:1,name:"light fuchsia"},{h:85,s:1,b:.5,name:"dark fuchsia"},{h:85,s:1,b:1,name:"fuchsia"},{h:90,s:.5,b:.5,name:"dark fuchsia"},{h:90,s:.5,b:1,name:"hot pink"},{h:90,s:1,b:.5,name:"dark fuchsia"},{h:90,s:1,b:1,name:"fuchsia"},{h:95,s:0,b:1,name:"pink"},{h:95,s:.5,b:1,name:"light pink"},{h:95,s:1,b:.5,name:"dark magenta"},{h:95,s:1,b:1,name:"magenta"}];t._rgbColorName=function(e){let t=Uo._rgbaToHSBA(e);return r=t,function(e){let t;if(0!==e[0]){e[0]=Math.round(100*e[0]);let t=e[0].toString().split("");const r=t.length-1;t[r]=parseInt(t[r]),t[r]<2.5?t[r]=0:t[r]>=2.5&&t[r]<7.5&&(t[r]=5),2===t.length?(t[0]=parseInt(t[0]),t[r]>=7.5&&(t[r]=0,t[0]=t[0]+1),e[0]=10*t[0]+t[1]):t[r]>=7.5?e[0]=10:e[0]=t[r]}e[2]=e[2]/255;for(let t=e.length-1;t>=1;t--)e[t]<=.25?e[t]=0:e[t]>.25&&e[t]<.75?e[t]=.5:e[t]=1;if(0===e[0]&&0===e[1]&&1===e[2]){for(let e=2;e>=0;e--)r[e]=Math.round(1e4*r[e])/1e4;for(let e=0;e<i.length;e++){if(i[e].h===r[0]&&i[e].s===r[1]&&i[e].b===r[2]){t=i[e].name;break}t="white"}}else for(let r=0;r<s.length;r++)if(s[r].h===e[0]&&s[r].s===e[1]&&s[r].b===e[2]){t=s[r].name;break}return t}([t[0],t[1],t[2]])}}function Go(e,t){t.storeItem=function(t,r){"string"!=typeof t&&console.log(`The argument that you passed to storeItem() - ${t} is not a string.`),t.endsWith("p5TypeID")&&console.log(`The argument that you passed to storeItem() - ${t} must not end with 'p5TypeID'.`),void 0===r&&console.log("You cannot store undefined variables using storeItem().");let i=typeof r;switch(i){case"number":case"boolean":r=r.toString();break;case"object":r instanceof e.Color?(i="p5.Color",r=r.toString()):r instanceof e.Vector&&(i="p5.Vector",r=r.values),r=JSON.stringify(r)}localStorage.setItem(t,r);const s=`${t}p5TypeID`;localStorage.setItem(s,i)},t.getItem=function(e){let t=localStorage.getItem(e);const r=localStorage.getItem(`${e}p5TypeID`);if(void 0===r)console.log(`Unable to determine type of item stored under ${e}in local storage. Did you save the item with something other than setItem()?`);else if(null!==t)switch(r){case"number":t=parseFloat(t);break;case"boolean":t="true"===t;break;case"object":t=JSON.parse(t);break;case"p5.Color":t=this.color(JSON.parse(t));break;case"p5.Vector":t=JSON.parse(t),t=this.createVector(...t)}return t},t.clearStorage=function(){Object.keys(localStorage).forEach(e=>{e.endsWith("p5TypeID")&&this.removeItem(e.replace("p5TypeID",""))})},t.removeItem=function(e){"string"!=typeof e&&console.log(`The argument that you passed to removeItem() - ${e} is not a string.`),localStorage.removeItem(e),localStorage.removeItem(`${e}p5TypeID`)}}function jo(e,t){function r(e,t,r){(t._userNode?t._userNode:document.body).appendChild(e);const i=r?new Ds(e,t):new Pi(e,t);return t._elements.push(i),i}t.select=function(e,t){const r=this._getContainer(t).querySelector(e);return r?this._wrapElement(r):null},t.selectAll=function(e,t){const r=[],i=this._getContainer(t).querySelectorAll(e);if(i)for(let e=0;e<i.length;e++){const t=this._wrapElement(i[e]);r.push(t)}return r},t._getContainer=function(e){let t=document;return"string"==typeof e?t=document.querySelector(e)||document:e instanceof Pi?t=e.elt:e instanceof HTMLElement&&(t=e),t},t._wrapElement=function(e){const t=Array.prototype.slice.call(e.children);if("INPUT"===e.tagName&&"checkbox"===e.type){let t=new Pi(e,this);return t.checked=function(...e){return 0===e.length?this.elt.checked:(e[0]?this.elt.checked=!0:this.elt.checked=!1,this)},t}return"VIDEO"===e.tagName||"AUDIO"===e.tagName?new Ds(e,this):"SELECT"===e.tagName?this.createSelect(new Pi(e,this)):t.length>0&&t.every(function(e){return"INPUT"===e.tagName||"LABEL"===e.tagName})&&("DIV"===e.tagName||"SPAN"===e.tagName)?this.createRadio(new Pi(e,this)):new Pi(e,this)},t.createElement=function(e,t){const i=document.createElement(e);return void 0!==t&&(i.innerHTML=t),r(i,this)},t.removeElements=function(e){this._elements.filter(e=>!(e.elt instanceof HTMLCanvasElement)).map(e=>e.remove())},t.createDiv=function(e=""){let t=document.createElement("div");return t.innerHTML=e,r(t,this)},t.createP=function(e=""){let t=document.createElement("p");return t.innerHTML=e,r(t,this)},t.createSpan=function(e=""){let t=document.createElement("span");return t.innerHTML=e,r(t,this)},t.createImg=function(){const e=document.createElement("img"),t=arguments;let i;return t.length>1&&"string"==typeof t[1]&&(e.alt=t[1]),t.length>2&&"string"==typeof t[2]&&(e.crossOrigin=t[2]),e.src=t[0],i=r(e,this),e.addEventListener("load",function(){i.width=e.offsetWidth||e.width,i.height=e.offsetHeight||e.height;const r=t[t.length-1];"function"==typeof r&&r(i)}),i},t.createA=function(e,t,i){const s=document.createElement("a");return s.href=e,s.innerHTML=t,i&&(s.target=i),r(s,this)},t.createSlider=function(e,t,i,s){const n=document.createElement("input");return n.type="range",n.min=e,n.max=t,0===s?n.step=1e-18:s&&(n.step=s),"number"==typeof i&&(n.value=i),r(n,this)},t.createButton=function(e,t){const i=document.createElement("button");return i.innerHTML=e,t&&(i.value=t),r(i,this)},t.createCheckbox=function(...e){const t=document.createElement("div"),i=document.createElement("input");i.type="checkbox";const s=document.createElement("label");s.appendChild(i),t.appendChild(s);const n=r(t,this);if(n.checked=function(...e){const t=n.elt.firstElementChild.getElementsByTagName("input")[0];if(t){if(0===e.length)return t.checked;e[0]?t.checked=!0:t.checked=!1}return n},this.value=function(e){return n.value=e,this},e[0]){n.value(e[0]);const t=document.createElement("span");t.innerHTML=e[0],s.appendChild(t)}return e[1]&&(i.checked=!0),n},t.createSelect=function(...e){let t,i=e[0];if(i instanceof Pi&&i.elt instanceof HTMLSelectElement)t=i,this.elt=i.elt;else if(i instanceof HTMLSelectElement)t=r(i,this),this.elt=i;else{const e=document.createElement("select");i&&"boolean"==typeof i&&e.setAttribute("multiple","true"),t=r(e,this),this.elt=e}return t.option=function(e,t){let r;if(void 0!==e){for(let t=0;t<this.elt.length;t+=1)if(this.elt[t].textContent===e){r=t;break}if(void 0!==r)!1===t?this.elt.remove(r):this.elt[r].value=t;else{const r=document.createElement("option");r.textContent=e,r.value=void 0===t?e:t,this.elt.appendChild(r),this._pInst._elements.push(r)}}},t.selected=function(e){if(void 0!==e){for(let t=0;t<this.elt.length;t+=1)this.elt[t].value.toString()===e.toString()&&(this.elt.selectedIndex=t);return this}if(this.elt.getAttribute("multiple")){let e=[];for(const t of this.elt.selectedOptions)e.push(t.value);return e}return this.elt.value},t.disable=function(e){if("string"==typeof e)for(let t=0;t<this.elt.length;t++)this.elt[t].value.toString()===e&&(this.elt[t].disabled=!0,this.elt[t].selected=!1);else this.elt.disabled=!0;return this},t.enable=function(e){if("string"==typeof e)for(let t=0;t<this.elt.length;t++)this.elt[t].value.toString()===e&&(this.elt[t].disabled=!1,this.elt[t].selected=!1);else{this.elt.disabled=!1;for(let e=0;e<this.elt.length;e++)this.elt[e].disabled=!1,this.elt[e].selected=!1}return this},t};let i=0;t.createRadio=function(...e){let t,s,n;const a=e[0];a instanceof Pi&&(a.elt instanceof HTMLDivElement||a.elt instanceof HTMLSpanElement)?(t=a,this.elt=a.elt):a instanceof HTMLDivElement||a instanceof HTMLSpanElement?(t=r(a,this),this.elt=a,s=a,"string"==typeof e[1]&&(n=e[1])):("string"==typeof a&&(n=a),s=document.createElement("div"),t=r(s,this),this.elt=s),t._name=n||"radioOption_"+i++;const o=e=>e instanceof HTMLInputElement&&"radio"===e.type,h=e=>e instanceof HTMLLabelElement;return t._getOptionsArray=function(){return Array.from(this.elt.children).filter(e=>o(e)||h(e)&&o(e.firstElementChild)).map(e=>o(e)?e:e.firstElementChild)},t.option=function(e,r){let i,s,n;for(const r of t._getOptionsArray())if(r.value===e){i=r;break}return void 0===i&&(i=document.createElement("input"),i.setAttribute("type","radio"),i.setAttribute("value",e)),i.setAttribute("name",t._name),h(i.parentElement)?s=i.parentElement:(s=document.createElement("label"),s.insertAdjacentElement("afterbegin",i)),s.lastElementChild instanceof HTMLSpanElement?n=s.lastElementChild:(n=document.createElement("span"),i.insertAdjacentElement("afterend",n)),n.innerHTML=void 0===r?e:r,this.elt.appendChild(s),i},t.remove=function(e){for(const r of t._getOptionsArray())if(r.value===e)return void(h(r.parentElement)?r.parentElement.remove():r.remove())},t.value=function(){let e="";for(const r of t._getOptionsArray())if(r.checked){e=r.value;break}return e},t.selected=function(e){let r=null;if(void 0===e){for(const e of t._getOptionsArray())if(e.checked){r=e;break}}else{t._getOptionsArray().forEach(e=>{e.checked=!1,e.removeAttribute("checked")});for(const i of t._getOptionsArray())i.value===e&&(i.setAttribute("checked",!0),i.checked=!0,r=i)}return r},t.disable=function(e=!0){for(const r of t._getOptionsArray())r.setAttribute("disabled",e)},t},t.createColorPicker=function(t){const i=document.createElement("input");let s;i.type="color",t?t instanceof e.Color?i.value=t.toString("#rrggbb"):(this.push(),this.colorMode("rgb"),i.value=this.color(t).toString("#rrggbb"),this.pop()):i.value="#000000",s=r(i,this);const n=this;return s.color=function(){n.push(),t&&t.mode&&n.colorMode(t.mode,...t?.maxes&&t.maxes[t.mode]||[]);const e=n.color(this.elt.value);return n.pop(),e},s},t.createInput=function(e="",t="text"){let i=document.createElement("input");return i.setAttribute("value",e),i.setAttribute("type",t),r(i,this)},t.createFileInput=function(e,t=!1){if(!(window.File&&window.FileReader&&window.FileList&&window.Blob))return void console.log("The File APIs are not fully supported in this browser. Cannot create element.");const i=document.createElement("input");return i.setAttribute("type","file"),t&&i.setAttribute("multiple",!0),i.addEventListener("change",function(t){for(const r of t.target.files)Bi._load(r,e)},!1),r(i,this)}}function $o(e,t,r){r.presetup=function(){const e=["deviceorientation","devicemotion"];for(const t of e)window.addEventListener(t,this[`_on${t}`].bind(this),{passive:!1,signal:this._removeSignal})},t.deviceOrientation=window.innerWidth/window.innerHeight>1?"landscape":"portrait",t.accelerationX=0,t.accelerationY=0,t.accelerationZ=0,t.pAccelerationX=0,t.pAccelerationY=0,t.pAccelerationZ=0,t._updatePAccelerations=function(){this.pAccelerationX=this.accelerationX,this.pAccelerationY=this.accelerationY,this.pAccelerationZ=this.accelerationZ},t.rotationX=0,t.rotationY=0,t.rotationZ=0,t.pRotationX=0,t.pRotationY=0,t.pRotationZ=0;let i=0,s=0,n=0,a="clockwise",o="clockwise",h="clockwise";t.pRotateDirectionX=void 0,t.pRotateDirectionY=void 0,t.pRotateDirectionZ=void 0,t._updatePRotations=function(){this.pRotationX=this.rotationX,this.pRotationY=this.rotationY,this.pRotationZ=this.rotationZ},t.turnAxis=void 0;let u=.5,l=30;t.setMoveThreshold=function(e){u=e},t.setShakeThreshold=function(e){l=e},t._ondeviceorientation=function(e){this._updatePRotations(),this.rotationX=this._fromDegrees(e.beta),this.rotationY=this._fromDegrees(e.gamma),this.rotationZ=this._fromDegrees(e.alpha),this._handleMotion()},t._ondevicemotion=function(e){this._updatePAccelerations(),this.accelerationX=2*e.acceleration.x,this.accelerationY=2*e.acceleration.y,this.accelerationZ=2*e.acceleration.z,this._handleMotion()},t._handleMotion=function(){if("landscape-primary"===screen.orientation.type||"landscape-secondary"===screen.orientation.type?this.deviceOrientation="landscape":"portrait-primary"===screen.orientation.type||"portrait-secondary"===screen.orientation.type?this.deviceOrientation="portrait":this.deviceOrientation="undefined","function"==typeof this._customActions.deviceMoved&&(Math.abs(this.accelerationX-this.pAccelerationX)>u||Math.abs(this.accelerationY-this.pAccelerationY)>u||Math.abs(this.accelerationZ-this.pAccelerationZ)>u)&&this._customActions.deviceMoved(),"function"==typeof this._customActions.deviceTurned){const e=this._toDegrees(this.rotationX)+180,t=this._toDegrees(this.pRotationX)+180;let r=i+180;e-t>0&&e-t<270||e-t<-270?a="clockwise":(e-t<0||e-t>270)&&(a="counter-clockwise"),a!==this.pRotateDirectionX&&(r=e),Math.abs(e-r)>90&&Math.abs(e-r)<270&&(r=e,this.turnAxis="X",this._customActions.deviceTurned()),this.pRotateDirectionX=a,i=r-180;const u=this._toDegrees(this.rotationY)+180,l=this._toDegrees(this.pRotationY)+180;let c=s+180;u-l>0&&u-l<270||u-l<-270?o="clockwise":(u-l<0||u-this.pRotationY>270)&&(o="counter-clockwise"),o!==this.pRotateDirectionY&&(c=u),Math.abs(u-c)>90&&Math.abs(u-c)<270&&(c=u,this.turnAxis="Y",this._customActions.deviceTurned()),this.pRotateDirectionY=o,s=c-180;const p=this._toDegrees(this.rotationZ),d=this._toDegrees(this.pRotationZ);p-d>0&&p-d<270||p-d<-270?h="clockwise":(p-d<0||p-d>270)&&(h="counter-clockwise"),h!==this.pRotateDirectionZ&&(n=p),Math.abs(p-n)>90&&Math.abs(p-n)<270&&(n=p,this.turnAxis="Z",this._customActions.deviceTurned()),this.pRotateDirectionZ=h,this.turnAxis=void 0}if("function"==typeof this._customActions.deviceShaken){let e,t;null!==this.pAccelerationX&&(e=Math.abs(this.accelerationX-this.pAccelerationX),t=Math.abs(this.accelerationY-this.pAccelerationY)),e+t>l&&this._customActions.deviceShaken()}}}function Ho(e,t,r){r.presetup=function(){const e=["keydown","keyup","keypress","blur"];for(const t of e)window.addEventListener(t,this[`_on${t}`].bind(this),{passive:!1,signal:this._removeSignal})},t.keyIsPressed=!1,t.key="",t.code="",t.keyCode=0,t._onkeydown=function(e){this._downKeys[e.code]||(this.keyIsPressed=!0,this.keyCode=e.which,this.key=e.key,this.code=e.code,this._downKeyCodes[e.code]=!0,this._downKeys[e.key]=!0,"function"!=typeof this._customActions.keyPressed||e.charCode)||!1===this._customActions.keyPressed(e)&&e.preventDefault()},t._onkeyup=function(e){if("function"==typeof this._customActions.keyReleased&&!1===this._customActions.keyReleased(e)&&e.preventDefault(),delete this._downKeyCodes[e.code],delete this._downKeys[e.key],this._areDownKeys()){const e=Object.keys(this._downKeyCodes).pop();this.code=e;const t=Object.keys(this._downKeys).pop();this.key=t}else this.keyIsPressed=!1,this.key="",this.code=""},t._onkeypress=function(e){e.which===this._lastKeyCodeTyped&&e.repeat||(this._lastKeyCodeTyped=e.which,this.key=e.key||String.fromCharCode(e.which)||e.which,"function"!=typeof this._customActions.keyTyped)||!1===this._customActions.keyTyped(e)&&e.preventDefault()},t._onblur=function(e){this._downKeys={}},t.keyIsDown=function(e){return function(e){return!["Alt","Shift","Control","Meta"].includes(e)&&"string"==typeof e&&e.length>1}(e)?this._downKeyCodes[e]||this._downKeys[e]||!1:this._downKeys[e]||this._downKeyCodes[e]||!1},t._areDownKeys=function(){for(const e in this._downKeys)if(this._downKeys.hasOwnProperty(e)&&!0===this._downKeys[e])return!0;return!1}}function qo(e,t,r){function i(e,t,r,i){const s=e.getBoundingClientRect();return{x:(i.clientX-s.left)/t,y:(i.clientY-s.top)/r,winX:i.clientX,winY:i.clientY,id:i.pointerId}}r.presetup=function(){const e=["pointerdown","pointerup","pointermove","dragend","dragover","click","dblclick","wheel"];for(const t of e)window.addEventListener(t,this[`_on${t}`].bind(this),{passive:!1,signal:this._removeSignal})},t.movedX=0,t.movedY=0,t._hasMouseInteracted=!1,t.mouseX=0,t.mouseY=0,t.pmouseX=0,t.pmouseY=0,t.winMouseX=0,t.winMouseY=0,t.pwinMouseX=0,t.pwinMouseY=0,t.mouseButton={left:!1,right:!1,center:!1},t.touches=[],t._activePointers=new Map,t.mouseIsPressed=!1,t._updatePointerCoords=function(e){if(null!==this._curElement){const t=this._curElement.elt,r=t.scrollWidth/this.width||1,s=t.scrollHeight/this.height||1;if("touch"===e.pointerType){const e=[];for(const n of this._activePointers.values())e.push(i(t,r,s,n));this.touches=e}const n=function(e,t,r,i){const s=e.getBoundingClientRect();return{x:(i.clientX-s.left)/t,y:(i.clientY-s.top)/r,winX:i.clientX,winY:i.clientY}}(t,r,s,e);this.movedX=e.movementX||0,this.movedY=e.movementY||0,this.mouseX=n.x,this.mouseY=n.y,this.winMouseX=n.winX,this.winMouseY=n.winY,this._hasMouseInteracted||(this._updateMouseCoords(),this._hasMouseInteracted=!0)}},t._updateMouseCoords=function(){this.pmouseX=this.mouseX,this.pmouseY=this.mouseY,this.pwinMouseX=this.winMouseX,this.pwinMouseY=this.winMouseY,this._pmouseWheelDeltaY=this._mouseWheelDeltaY},t._setMouseButton=function(e){this.mouseButton.left=Array.from(this._activePointers.values()).some(e=>!!(1&e.buttons)),this.mouseButton.center=Array.from(this._activePointers.values()).some(e=>!!(4&e.buttons)),this.mouseButton.right=Array.from(this._activePointers.values()).some(e=>!!(2&e.buttons))},t._onpointermove=function(e){let t;this._updatePointerCoords(e),this._activePointers.set(e.pointerId,e),this._setMouseButton(e),this.mouseIsPressed||"function"!=typeof this._customActions.mouseMoved?this.mouseIsPressed&&"function"==typeof this._customActions.mouseDragged&&(t=this._customActions.mouseDragged(e),!1===t&&e.preventDefault()):(t=this._customActions.mouseMoved(e),!1===t&&e.preventDefault())},t._onpointerdown=function(e){let t;this.mouseIsPressed=!0,this._activePointers.set(e.pointerId,e),this._setMouseButton(e),this._updatePointerCoords(e),"function"==typeof this._customActions.mousePressed&&(t=this._customActions.mousePressed(e),!1===t&&e.preventDefault())},t._onpointerup=function(e){let t;this.mouseIsPressed=!1,this._activePointers.delete(e.pointerId),this._setMouseButton(e),this._updatePointerCoords(e),"function"==typeof this._customActions.mouseReleased&&(t=this._customActions.mouseReleased(e),!1===t&&e.preventDefault())},t._ondragend=t._onpointerup,t._ondragover=t._onpointermove,t._onclick=function(e){"function"==typeof this._customActions.mouseClicked&&!1===this._customActions.mouseClicked(e)&&e.preventDefault()},t._ondblclick=function(e){"function"==typeof this._customActions.doubleClicked&&!1===this._customActions.doubleClicked(e)&&e.preventDefault()},t._mouseWheelDeltaY=0,t._pmouseWheelDeltaY=0,t._onwheel=function(e){this._mouseWheelDeltaY=e.deltaY,"function"==typeof this._customActions.mouseWheel&&(e.delta=e.deltaY,!1===this._customActions.mouseWheel(e)&&e.preventDefault())},t.requestPointerLock=function(){const e=this._curElement.elt;return e.requestPointerLock=e.requestPointerLock||e.mozRequestPointerLock,e.requestPointerLock?(e.requestPointerLock(),!0):(console.log("requestPointerLock is not implemented in this browser"),!1)},t.exitPointerLock=function(){document.exitPointerLock()}}void 0!==p5&&zo(0,p5.prototype),void 0!==p5&&Go(p5,p5.prototype),void 0!==p5&&jo(p5,p5.prototype),void 0!==p5&&$o(0,p5.prototype),void 0!==p5&&Ho(0,p5.prototype),void 0!==p5&&qo(0,p5.prototype);class Wo{constructor(e){this.columns=[],this.rows=[]}toString(e=","){let t=this.rows.map(e=>e.arr);return this.columns.some(e=>null===e)||(t=[this.columns,...t]),function(e,t={},r=e=>e){const i=Object.create(null);if(i.options=t,i.options.eof=void 0===i.options.eof||i.options.eof,i.row=1,i.col=1,i.output="",i.options.delimiter=void 0===i.options.delimiter?'"':t.delimiter,i.options.delimiter.length>1||0===i.options.delimiter.length)throw Error(`CSVError: delimiter must be one character [${i.options.separator}]`);if(i.options.separator=void 0===i.options.separator?",":t.separator,i.options.separator.length>1||0===i.options.separator.length)throw Error(`CSVError: separator must be one character [${i.options.separator}]`);const s=new RegExp(`${zs(i.options.delimiter)}|${zs(i.options.separator)}|\r\n|\n|\r`);return e.forEach((t,n)=>{let a="";switch(i.col=1,t.forEach((e,n)=>{"string"==typeof e&&(e=e.replace(new RegExp(i.options.delimiter,"g"),`${i.options.delimiter}${i.options.delimiter}`),e=s.test(e)?`${i.options.delimiter}${e}${i.options.delimiter}`:e),a+=r(e,i.row,i.col),n!==t.length-1&&(a+=i.options.separator),i.col++}),!0){case i.options.eof:case!i.options.eof&&n!==e.length-1:i.output+=`${a}\n`;break;default:i.output+=`${a}`}i.row++}),i.output}(t,{separator:e})}addRow(e){const t=e||new p5.TableRow;if(void 0===t.arr||void 0===t.obj)throw new Error(`invalid TableRow: ${t}`);return t.table=this,this.rows.push(t),t}removeRow(e){this.rows[e].table=null;const t=this.rows.splice(e+1,this.rows.length);this.rows.pop(),this.rows=this.rows.concat(t)}getRow(e){return this.rows[e]}getRows(){return this.rows}findRow(e,t){if("string"==typeof t){for(let r=0;r<this.rows.length;r++)if(this.rows[r].obj[this.columns.indexOf(t)]===e)return this.rows[r]}else for(let r=0;r<this.rows.length;r++)if(this.rows[r].arr[t]===e)return this.rows[r];return null}findRows(e,t){const r=[];if("string"==typeof t)for(let i=0;i<this.rows.length;i++)this.rows[i].obj[this.columns.indexOf(t)]===e&&r.push(this.rows[i]);else for(let i=0;i<this.rows.length;i++)this.rows[i].arr[t]===e&&r.push(this.rows[i]);return r}matchRow(e,t){if("number"==typeof t){for(let r=0;r<this.rows.length;r++)if(this.rows[r].arr[t].match(e))return this.rows[r]}else for(let r=0;r<this.rows.length;r++)if(this.rows[r].obj[this.columns.indexOf(t)].match(e))return this.rows[r];return null}matchRows(e,t){const r=[];if("number"==typeof t)for(let i=0;i<this.rows.length;i++)this.rows[i].arr[t].match(e)&&r.push(this.rows[i]);else for(let i=0;i<this.rows.length;i++)this.rows[i].obj[this.columns.indexOf(t)].match(e)&&r.push(this.rows[i]);return r}getColumn(e){const t=[];if("string"==typeof e)for(let r=0;r<this.rows.length;r++)t.push(this.rows[r].obj[this.columns.indexOf(e)]);else for(let r=0;r<this.rows.length;r++)t.push(this.rows[r].arr[e]);return t}clearRows(){delete this.rows,this.rows=[]}addColumn(e){const t=e||null;this.columns.push(t)}getColumnCount(){return this.columns.length}getRowCount(){return this.rows.length}removeTokens(e,t){const r=[];for(let t=0;t<e.length;t++)r.push(e.charAt(t).replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"));const i=new RegExp(r.join("|"),"g");if(void 0===t)for(let e=0;e<this.columns.length;e++)for(let t=0;t<this.rows.length;t++){let r=this.rows[t].arr[e];r=r.replace(i,""),this.rows[t].arr[e]=r,this.rows[t].obj[this.columns[e]]=r}else if("string"==typeof t)for(let e=0;e<this.rows.length;e++){let r=this.rows[e].obj[t];r=r.replace(i,""),this.rows[e].obj[t]=r;const s=this.columns.indexOf(t);this.rows[e].arr[s]=r}else for(let e=0;e<this.rows.length;e++){let r=this.rows[e].arr[t];r=r.replace(i,""),this.rows[e].arr[t]=r,this.rows[e].obj[this.columns[t]]=r}}trim(e){const t=new RegExp(" ","g");if(void 0===e)for(let e=0;e<this.columns.length;e++)for(let r=0;r<this.rows.length;r++){let i=this.rows[r].arr[e];i=i.replace(t,""),this.rows[r].arr[e]=i,this.rows[r].obj[this.columns[e]]=i}else if("string"==typeof e)for(let r=0;r<this.rows.length;r++){let i=this.rows[r].obj[e];i=i.replace(t,""),this.rows[r].obj[e]=i;const s=this.columns.indexOf(e);this.rows[r].arr[s]=i}else for(let r=0;r<this.rows.length;r++){let i=this.rows[r].arr[e];i=i.replace(t,""),this.rows[r].arr[e]=i,this.rows[r].obj[this.columns[e]]=i}}removeColumn(e){let t,r;"string"==typeof e?(t=e,r=this.columns.indexOf(e)):(r=e,t=this.columns[e]);const i=this.columns.splice(r+1,this.columns.length);this.columns.pop(),this.columns=this.columns.concat(i);for(let e=0;e<this.rows.length;e++){const i=this.rows[e].arr,s=i.splice(r+1,i.length);i.pop(),this.rows[e].arr=i.concat(s),delete this.rows[e].obj[t]}}set(e,t,r){this.rows[e].set(t,r)}setNum(e,t,r){this.rows[e].setNum(t,r)}setString(e,t,r){this.rows[e].setString(t,r)}get(e,t){return"string"==typeof t?this.rows[e].get(this.columns.indexOf(t)):this.rows[e].get(t)}getNum(e,t){return this.rows[e].getNum(t)}getString(e,t){return this.rows[e].getString(t)}getObject(e){const t={};let r,i,s;for(let n=0;n<this.rows.length;n++)if(r=this.rows[n].obj,"string"==typeof e){if(i=this.columns.indexOf(e),!(i>=0))throw new Error(`This table has no column named "${e}"`);s=r[e],t[s]=r}else t[n]=this.rows[n].obj;return t}getArray(){const e=[];for(let t=0;t<this.rows.length;t++)e.push(this.rows[t].arr);return e}}function Xo(e,t){e.Table=Wo}void 0!==p5&&Xo(p5);class Yo{constructor(e=[]){let t=e;this.arr=t,this.obj=Object.fromEntries(t.entries()),this.table=null}set(e,t){if("string"==typeof e){const r=this.table.columns.indexOf(e);if(!(r>=0))throw new Error(`This table has no column named "${e}"`);this.obj[e]=t,this.arr[r]=t}else{if(!(e<this.table.columns.length))throw new Error(`Column #${e} is out of the range of this table`);{this.arr[e]=t;const r=this.table.columns[e];this.obj[r]=t}}}setNum(e,t){const r=parseFloat(t);this.set(e,r)}setString(e,t){const r=t.toString();this.set(e,r)}get(e){return"string"==typeof e?this.obj[this.table.columns.indexOf(e)]:this.arr[e]}getNum(e){let t;if(t="string"==typeof e?parseFloat(this.obj[this.table.columns.indexOf(e)]):parseFloat(this.arr[e]),"NaN"===t.toString())throw`Error: ${this.obj[e]} is NaN (Not a Number)`;return t}getString(e){return"string"==typeof e?this.obj[this.table.columns.indexOf(e)].toString():this.arr[e].toString()}}function Ko(e,t){e.TableRow=Yo}function Zo(e,t){t.abs=Math.abs,t.ceil=Math.ceil,t.constrain=function(e,t,r){return Math.max(Math.min(e,r),t)},t.dist=function(...e){return 4===e.length?Math.hypot(e[2]-e[0],e[3]-e[1]):6===e.length?Math.hypot(e[3]-e[0],e[4]-e[1],e[5]-e[2]):void 0},t.exp=Math.exp,t.floor=Math.floor,t.lerp=function(e,t,r){return r*(t-e)+e},t.log=Math.log,t.mag=function(e,t){return Math.hypot(e,t)},t.map=function(e,t,r,i,s,n){const a=(e-t)/(r-t)*(s-i)+i;return n?i<s?this.constrain(a,i,s):this.constrain(a,s,i):a},t.max=function(...e){const t=e=>{let t=-1/0;for(let r of e)t=Math.max(t,r);return t};return e[0]instanceof Array?t(e[0]):t(e)},t.min=function(...e){const t=e=>{let t=1/0;for(let r of e)t=Math.min(t,r);return t};return e[0]instanceof Array?t(e[0]):t(e)},t.norm=function(e,t,r){return this.map(e,t,r,0,1)},t.pow=Math.pow,t.round=function(e,t){if(!t)return Math.round(e);const r=Math.pow(10,t);return Math.round(e*r)/r},t.sq=e=>e*e,t.sqrt=Math.sqrt,t.fract=function(e){let t=0,r=Number(e);if(isNaN(r)||Math.abs(r)===1/0)return r;if(r<0&&(r=-r,t=1),String(r).includes(".")&&!String(r).includes("e")){let e=String(r);return e=Number("0"+e.slice(e.indexOf("."))),Math.abs(t-e)}return r<1?Math.abs(t-r):0}}function Jo(e,t){const r=4095;let i=4,s=.5;const n=e=>.5*(1-Math.cos(e*Math.PI));let a;t.noise=function(e,t=0,o=0){if(null==a){a=new Array(4096);for(let e=0;e<4096;e++)a[e]=Math.random()}e<0&&(e=-e),t<0&&(t=-t),o<0&&(o=-o);let h,u,l,c,p,d=Math.floor(e),f=Math.floor(t),g=Math.floor(o),m=e-d,y=t-f,x=o-g,v=0,b=.5;for(let e=0;e<i;e++){let e=d+(f<<4)+(g<<8);h=n(m),u=n(y),l=a[e&r],l+=h*(a[e+1&r]-l),c=a[e+16&r],c+=h*(a[e+16+1&r]-c),l+=u*(c-l),e+=256,c=a[e&r],c+=h*(a[e+1&r]-c),p=a[e+16&r],p+=h*(a[e+16+1&r]-p),c+=u*(p-c),l+=n(x)*(c-l),v+=l*b,b*=s,d<<=1,m*=2,f<<=1,y*=2,g<<=1,x*=2,m>=1&&(d++,m--),y>=1&&(f++,y--),x>=1&&(g++,x--)}return v},t.noiseDetail=function(e,t=.5){e>0&&(i=e),t>0&&(s=t)},t._getNoiseOctaves=function(){return i},t._getNoiseAmpFalloff=function(){return s},t.noiseSeed=function(e){const t=(()=>{const e=4294967296;let t,r;return{setSeed(i){r=t=(null==i?Math.random()*e:i)>>>0},getSeed:()=>t,rand:()=>(r=(1664525*r+1013904223)%e,r/e)}})();t.setSeed(e),a=new Array(4096);for(let e=0;e<4096;e++)a[e]=t.rand()}}function Qo(e,t){const r="_lcg_random_state",i=4294967296;let s=0;t._lcg=function(e){return this[e]=(1664525*this[e]+1013904223)%i,this[e]/i},t._lcgSetSeed=function(e,t){this[e]=(null==t?Math.random()*i:t)>>>0},t.randomSeed=function(e){this._lcgSetSeed(r,e),this._gaussian_previous=!1},t.random=function(e,t){let i;if(i=null!=this[r]?this._lcg(r):Math.random(),void 0===e)return i;if(void 0===t)return e instanceof Array?e[Math.floor(i*e.length)]:i*e;if(e>t){const r=e;e=t,t=r}return i*(t-e)+e},t.randomGaussian=function(e,t=1){let r,i,n,a;if(this._gaussian_previous)r=s,this._gaussian_previous=!1;else{do{i=this.random(2)-1,n=this.random(2)-1,a=i*i+n*n}while(a>=1);a=Math.sqrt(-2*Math.log(a)/a),r=i*a,s=n*a,this._gaussian_previous=!0}return r*t+(e||0)}}function eh(e,t){t.createVector=function(t,r,i){return 0===arguments.length&&e._friendlyError("In 1.x, createVector() was a shortcut for createVector(0, 0, 0). In 2.x, p5.js has vectors of any dimension, so you must provide your desired number of zeros. Use createVector(0, 0) for a 2D vector and createVector(0, 0, 0) for a 3D vector."),this instanceof e?new e.Vector(this._fromRadians.bind(this),this._toRadians.bind(this),...arguments):new e.Vector(t,r,i)},t.createMatrix=function(...t){return new e.Matrix(...t)}}function th(e,t){t.float=function(e){return e instanceof Array?e.map(parseFloat):parseFloat(e)},t.int=function(e,r=10){return e===1/0||"Infinity"===e?1/0:e===-1/0||"-Infinity"===e?-1/0:"string"==typeof e?parseInt(e,r):"number"==typeof e?0|e:"boolean"==typeof e?e?1:0:e instanceof Array?e.map(e=>t.int(e,r)):void 0},t.str=function(e){return e instanceof Array?e.map(t.str):String(e)},t.boolean=function(e){return"number"==typeof e?0!==e:"string"==typeof e?"true"===e.toLowerCase():"boolean"==typeof e?e:e instanceof Array?e.map(t.boolean):void 0},t.byte=function(e){const r=t.int(e,10);return"number"==typeof r?(r+128)%256-128:r instanceof Array?r.map(t.byte):void 0},t.char=function(e){return"number"!=typeof e||isNaN(e)?e instanceof Array?e.map(t.char):"string"==typeof e?t.char(parseInt(e,10)):void 0:String.fromCharCode(e)},t.unchar=function(e){return"string"==typeof e&&1===e.length?e.charCodeAt(0):e instanceof Array?e.map(t.unchar):void 0},t.hex=function(e,r){if(r=null==r?r=8:r,e instanceof Array)return e.map(e=>t.hex(e,r));if(e===1/0||e===-1/0)return(e===1/0?"F":"0").repeat(r);if("number"==typeof e){e<0&&(e=4294967295+e+1);let t=Number(e).toString(16).toUpperCase();for(;t.length<r;)t=`0${t}`;return t.length>=r&&(t=t.substring(t.length-r,t.length)),t}},t.unhex=function(e){return e instanceof Array?e.map(t.unhex):parseInt(`0x${e}`,16)}}function rh(e,t){function r(e,t,r){let i=e<0;e=Math.abs(e);let[s,n]=e.toString().split(".");if(void 0===r){s=s.padStart(t,"0");let e=n?s+"."+n:s;return i?"-"+e:e}{let a=e.toFixed(r);[s,n]=a.toString().split("."),s=s.padStart(t,"0");let o=void 0===n?s:s+"."+n;return i?"-"+o:o}}function i(e,t){const r=(e=e.toString()).indexOf(".");let i=-1!==r?e.substring(r):"",s=-1!==r?e.substring(0,r):e;if(s=s.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),0===t)i="";else if(void 0!==t)if(t>i.length){i+=-1===r?".":"";const e=t-i.length+1;for(let t=0;t<e;t++)i+="0"}else i=i.substring(0,t+1);return s+i}function s(e){return parseFloat(e)>0?`+${e.toString()}`:e.toString()}function n(e){return parseFloat(e)>=0?` ${e.toString()}`:e.toString()}t.nf=function(e,t,i){return e instanceof Array?e.map(e=>r(e,t,i)):"[object Arguments]"===Object.prototype.toString.call(e)?3===e.length?this.nf(e[0],e[1],e[2]):2===e.length?this.nf(e[0],e[1]):this.nf(e[0]):r(e,t,i)},t.nfc=function(e,t){return e instanceof Array?e.map(e=>i(e,t)):i(e,t)},t.nfp=function(...e){const r=t.nf.apply(this,e);return r instanceof Array?r.map(s):s(r)},t.nfs=function(...e){const r=t.nf.apply(this,e);return r instanceof Array?r.map(n):n(r)},t.splitTokens=function(e,t){let r;if(void 0!==t){let e=t;const i=/\]/g.exec(e);let s=/\[/g.exec(e);s&&i?(e=e.slice(0,i.index)+e.slice(i.index+1),s=/\[/g.exec(e),e=e.slice(0,s.index)+e.slice(s.index+1),r=new RegExp(`[\\[${e}\\]]`,"g")):i?(e=e.slice(0,i.index)+e.slice(i.index+1),r=new RegExp(`[${e}\\]]`,"g")):s?(e=e.slice(0,s.index)+e.slice(s.index+1),r=new RegExp(`[${e}\\[]`,"g")):r=new RegExp(`[${e}]`,"g")}else r=/\s/g;return e.split(r).filter(e=>e)},t.shuffle=function(e,t){const r=ArrayBuffer&&ArrayBuffer.isView&&ArrayBuffer.isView(e);let i,s,n=(e=t||r?e:e.slice()).length;for(;n>1;)i=this.random(0,1)*n|0,s=e[--n],e[n]=e[i],e[i]=s;return e}}function ih(e,t){t.day=function(){return(new Date).getDate()},t.hour=function(){return(new Date).getHours()},t.minute=function(){return(new Date).getMinutes()},t.millis=function(){return-1===this._millisStart?0:window.performance.now()-this._millisStart},t.month=function(){return(new Date).getMonth()+1},t.second=function(){return(new Date).getSeconds()},t.year=function(){return(new Date).getFullYear()}}function sh(e,t){t.orbitControl=function(e,t,r,i){this._assert3d("orbitControl");const s=this._renderer.states.curCamera;void 0===e&&(e=1),void 0===t&&(t=e),void 0===r&&(r=1),"object"!=typeof i&&(i={}),!0!==this.contextMenuDisabled&&(this.canvas.oncontextmenu=()=>!1,this.contextMenuDisabled=!0),!0!==this.wheelDefaultDisabled&&(this.canvas.onwheel=()=>!1,this.wheelDefaultDisabled=!0);const{disableTouchActions:n=!0}=i;!0!==this.touchActionsDisabled&&n&&(this.canvas.style["touch-action"]="none",this.touchActionsDisabled=!0);const{freeRotation:a=!1}=i,o=[];this.touches.forEach(e=>{this._renderer.prevTouches.forEach(t=>{if(e.id===t.id){const r={x:e.x,y:e.y,px:t.x,py:t.y};o.push(r)}})}),this._renderer.prevTouches=this.touches;let h=0,u=0,l=0,c=0,p=0;const d=.85,f=this.height<this.width?this.height:this.width;let g=!1;if(o.length>0){if(g=o[0].x>0&&o[0].x<this.width&&o[0].y>0&&o[0].y<this.height,1===o.length){const r=o[0];u=-e*(r.x-r.px)/f,l=t*(r.y-r.py)/f}else{const e=o[0],t=o[1];h=-(Math.hypot(e.x-t.x,e.y-t.y)-Math.hypot(e.px-t.px,e.py-t.py))*r*4e-4,c=.5*(e.x+t.x)-.5*(e.px+t.px),p=.5*(e.y+t.y)-.5*(e.py+t.py)}this.touches.length>0?g&&(this._renderer.executeRotateAndMove=!0,this._renderer.executeZoom=!0):(this._renderer.executeRotateAndMove=!1,this._renderer.executeZoom=!1)}else g=this.mouseX>0&&this.mouseX<this.width&&this.mouseY>0&&this.mouseY<this.height,0!==this._mouseWheelDeltaY?(h=Math.sign(this._mouseWheelDeltaY)*r,h*=.01,this._mouseWheelDeltaY=0,g&&(this._renderer.executeZoom=!0)):this._renderer.executeZoom=!1,this.mouseIsPressed?(this.mouseButton.left?(u=-e*this.movedX/f,l=t*this.movedY/f):this.mouseButton.right&&(c=this.movedX,p=this.movedY*s.yScale),g&&(this._renderer.executeRotateAndMove=!0)):this._renderer.executeRotateAndMove=!1;if(0!==h&&this._renderer.executeZoom&&(this._renderer.zoomVelocity+=h),Math.abs(this._renderer.zoomVelocity)>.001?(a?s._orbitFree(0,0,this._renderer.zoomVelocity):s._orbit(0,0,this._renderer.zoomVelocity),0!==s.projMatrix.mat4[15]&&(s.projMatrix.mat4[0]*=Math.pow(10,-this._renderer.zoomVelocity),s.projMatrix.mat4[5]*=Math.pow(10,-this._renderer.zoomVelocity),this._renderer.states.setValue("uPMatrix",this._renderer.states.uPMatrix.clone()),this._renderer.states.uPMatrix.mat4[0]=s.projMatrix.mat4[0],this._renderer.states.uPMatrix.mat4[5]=s.projMatrix.mat4[5]),this._renderer.zoomVelocity*=d):this._renderer.zoomVelocity=0,0===u&&0===l||!this._renderer.executeRotateAndMove||this._renderer.rotateVelocity.add(.6*u,.6*l),this._renderer.rotateVelocity.magSq()>1e-6?(a?s._orbitFree(-this._renderer.rotateVelocity.x,this._renderer.rotateVelocity.y,0):s._orbit(this._renderer.rotateVelocity.x,this._renderer.rotateVelocity.y,0),this._renderer.rotateVelocity.mult(d)):this._renderer.rotateVelocity.set(0,0),(0!==c||0!==p)&&this._renderer.executeRotateAndMove){const e=2*c/this.width,t=2*-p/this.height;this._renderer.moveVelocity.add(.15*e,.15*t)}if(this._renderer.moveVelocity.magSq()>1e-6){const e=s._getLocalAxes(),t=s.eyeX-s.centerX,r=s.eyeY-s.centerY,i=s.eyeZ-s.centerZ,n=Math.sqrt(t*t+r*r+i*i);let a,o,h=new Xi(s.centerX,s.centerY,s.centerZ);h=s.cameraMatrix.multiplyPoint(h),h=this._renderer.states.uPMatrix.multiplyAndNormalizePoint(h),h.x-=this._renderer.moveVelocity.x,h.y-=this._renderer.moveVelocity.y;const u=this._renderer.states.uPMatrix.mat4;0===u[15]?(a=(u[8]+h.x)/u[0]*n,o=(u[9]+h.y)/u[5]*n):(a=(h.x-u[12])/u[0],o=(h.y-u[13])/u[5]),s.setPosition(s.eyeX+a*e.x[0]+o*e.y[0],s.eyeY+a*e.x[1]+o*e.y[1],s.eyeZ+a*e.x[2]+o*e.y[2]),this._renderer.moveVelocity.mult(d)}else this._renderer.moveVelocity.set(0,0);return this},t.debugMode=function(...t){this._assert3d("debugMode");for(let t=e.lifecycleHooks.postdraw.length-1;t>=0;t--)e.lifecycleHooks.postdraw[t].toString()!==this._grid().toString()&&e.lifecycleHooks.postdraw[t].toString()!==this._axesIcon().toString()||e.lifecycleHooks.postdraw.splice(t,1);t[0]===Te?e.lifecycleHooks.postdraw.push(this._grid(t[1],t[2],t[3],t[4],t[5])):t[0]===Me?e.lifecycleHooks.postdraw.push(this._axesIcon(t[1],t[2],t[3],t[4])):(e.lifecycleHooks.postdraw.push(this._grid(t[0],t[1],t[2],t[3],t[4])),e.lifecycleHooks.postdraw.push(this._axesIcon(t[5],t[6],t[7],t[8])))},t.noDebugMode=function(){this._assert3d("noDebugMode");for(let t=e.lifecycleHooks.postdraw.length-1;t>=0;t--)e.lifecycleHooks.postdraw[t].toString()!==this._grid().toString()&&e.lifecycleHooks.postdraw[t].toString()!==this._axesIcon().toString()||e.lifecycleHooks.postdraw.splice(t,1)},t._grid=function(e,t,r,i,s){void 0===e&&(e=this.width/2),void 0===t&&(t=Math.round(e/30)<4?4:Math.round(e/30)),void 0===r&&(r=0),void 0===i&&(i=0),void 0===s&&(s=0);const n=e/t,a=e/2;return function(){this.push(),this.stroke(255*this._renderer.states.curStrokeColor[0],255*this._renderer.states.curStrokeColor[1],255*this._renderer.states.curStrokeColor[2]),this._renderer.states.setValue("uModelMatrix",this._renderer.states.uModelMatrix.clone()),this._renderer.states.uModelMatrix.reset();for(let e=0;e<=t;e++)this.beginShape(this.LINES),this.vertex(-a+r,i,e*n-a+s),this.vertex(+a+r,i,e*n-a+s),this.endShape();for(let e=0;e<=t;e++)this.beginShape(this.LINES),this.vertex(e*n-a+r,i,-a+s),this.vertex(e*n-a+r,i,+a+s),this.endShape();this.pop()}},t._axesIcon=function(e,t,r,i){return void 0===e&&(e=this.width/20>40?this.width/20:40),void 0===t&&(t=-this.width/4),void 0===r&&(r=t),void 0===i&&(i=t),()=>{this.push(),this._renderer.states.setValue("uModelMatrix",this._renderer.states.uModelMatrix.clone()),this._renderer.states.uModelMatrix.reset(),this.strokeWeight(2),this.stroke(255,0,0),this.beginShape(this.LINES),this.vertex(t,r,i),this.vertex(t+e,r,i),this.endShape(),this.stroke(0,255,0),this.beginShape(this.LINES),this.vertex(t,r,i),this.vertex(t,r+e,i),this.endShape(),this.stroke(0,0,255),this.beginShape(this.LINES),this.vertex(t,r,i),this.vertex(t,r,i+e),this.endShape(),this.pop()}}}async function nh(e){try{return(await fetch(e,{method:"HEAD"})).ok}catch(e){return!1}}function ah(e,t){async function r(e){let t=null,r={};const{data:i}=await js(e,"text"),s=i.split("\n");for(let e=0;e<s.length;++e){const i=s[e].trim().split(/\s+/);"newmtl"===i[0]?(t=i[1],r[t]={}):"Kd"===i[0]?r[t].diffuseColor=[parseFloat(i[1]),parseFloat(i[2]),parseFloat(i[3])]:"Ka"===i[0]?r[t].ambientColor=[parseFloat(i[1]),parseFloat(i[2]),parseFloat(i[3])]:"Ks"===i[0]?r[t].specularColor=[parseFloat(i[1]),parseFloat(i[2]),parseFloat(i[3])]:"map_Kd"===i[0]&&(r[t].texturePath=i[1])}return r}function i(e,t,r={}){const i={v:[],vt:[],vn:[]},s={};let n=null,a=!1,o=!1;for(let h=0;h<t.length;++h){const u=t[h].trim().split(/\b\s+/);if(u.length>0)if("usemtl"===u[0])n=u[1];else if("v"===u[0]||"vn"===u[0]){const e=new Xi(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3]));i[u[0]].push(e)}else if("vt"===u[0]){const e=[parseFloat(u[1]),1-parseFloat(u[2])];i[u[0]].push(e)}else if("f"===u[0])for(let t=3;t<u.length;++t){const h=[],l=[1,t-1,t];for(let t=0;t<l.length;++t){const c=u[l[t]];let p=c.split("/");for(let e=0;e<p.length;e++)p[e]=parseInt(p[e])-1;if(s[c]||(s[c]={}),void 0===s[c][n]){const t=e.vertices.length;if(e.vertices.push(i.v[p[0]].copy()),e.uvs.push(i.vt[p[1]]?i.vt[p[1]].slice():[0,0]),e.vertexNormals.push(i.vn[p[2]]?i.vn[p[2]].copy():new Xi),s[c][n]=t,h.push(t),n&&r[n]&&r[n].diffuseColor){a=!0;const t=r[n].diffuseColor;e.vertexColors.push(t[0]),e.vertexColors.push(t[1]),e.vertexColors.push(t[2]),e.vertexColors.push(1)}else o=!0}else h.push(s[c][n])}h[0]!==h[1]&&h[0]!==h[2]&&h[1]!==h[2]&&e.faces.push(h)}}if(0===e.vertexNormals.length&&e.computeNormals(),a===o)throw new Error("Model coloring is inconsistent. Either all vertices should have colors or none should.");return e}function s(e,t){if(function(e){const t=new DataView(e),r=[115,111,108,105,100];for(let e=0;e<5;e++)if(n(r,t,e))return!1;return!0}(t))!function(e,t){const r=new DataView(t),i=r.getUint32(80,!0);let s,n,a,o,h,u,l,c=!1;for(let e=0;e<70;e++)1129270351===r.getUint32(e,!1)&&82===r.getUint8(e+4)&&61===r.getUint8(e+5)&&(c=!0,o=[],h=r.getUint8(e+6)/255,u=r.getUint8(e+7)/255,l=r.getUint8(e+8)/255);for(let t=0;t<i;t++){const i=84+50*t,p=r.getFloat32(i,!0),d=r.getFloat32(i+4,!0),f=r.getFloat32(i+8,!0);if(c){const e=r.getUint16(i+48,!0);32768&e?(s=h,n=u,a=l):(s=(31&e)/31,n=(e>>5&31)/31,a=(e>>10&31)/31)}const g=new Xi(p,d,f);for(let t=1;t<=3;t++){const h=i+12*t,u=new Xi(r.getFloat32(h,!0),r.getFloat32(h+4,!0),r.getFloat32(h+8,!0));e.vertices.push(u),e.vertexNormals.push(g),c&&o.push(s,n,a)}e.faces.push([3*t,3*t+1,3*t+2]),e.uvs.push([0,0],[0,0],[0,0])}}(e,t);else{const r=new DataView(t);if(!("TextDecoder"in window))return console.warn("Sorry, ASCII STL loading only works in browsers that support TextDecoder (https://caniuse.com/#feat=textencoder)"),e;!function(e,t){let r,i,s="",n=[];for(let a=0;a<t.length;++a){const o=t[a].trim(),h=o.split(" ");for(let e=0;e<h.length;++e)""===h[e]&&h.splice(e,1);if(0!==h.length)switch(s){case"":if("solid"!==h[0])return console.error(o),void console.error(`Invalid state "${h[0]}", should be "solid"`);s="solid";break;case"solid":if("facet"!==h[0]||"normal"!==h[1])return console.error(o),void console.error(`Invalid state "${h[0]}", should be "facet normal"`);r=new Xi(parseFloat(h[2]),parseFloat(h[3]),parseFloat(h[4])),e.vertexNormals.push(r,r,r),s="facet normal";break;case"facet normal":if("outer"!==h[0]||"loop"!==h[1])return console.error(o),void console.error(`Invalid state "${h[0]}", should be "outer loop"`);s="vertex";break;case"vertex":if("vertex"===h[0])i=new Xi(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3])),e.vertices.push(i),e.uvs.push([0,0]),n.push(e.vertices.indexOf(i));else{if("endloop"!==h[0])return console.error(o),void console.error(`Invalid state "${h[0]}", should be "vertex" or "endloop"`);e.faces.push(n),n=[],s="endloop"}break;case"endloop":if("endfacet"!==h[0])return console.error(o),void console.error(`Invalid state "${h[0]}", should be "endfacet"`);s="endfacet";break;case"endfacet":if("endsolid"===h[0]);else{if("facet"!==h[0]||"normal"!==h[1])return console.error(o),void console.error(`Invalid state "${h[0]}", should be "endsolid" or "facet normal"`);r=new Xi(parseFloat(h[2]),parseFloat(h[3]),parseFloat(h[4])),e.vertexNormals.push(r,r,r),s="facet normal"}break;default:console.error(`Invalid state "${s}"`)}}}(e,new TextDecoder("utf-8").decode(r).split("\n"))}return e}function n(e,t,r){for(let i=0,s=e.length;i<s;i++)if(e[i]!==t.getUint8(r+i,!1))return!1;return!0}t.loadModel=async function(t,n,a,o,h){let u=!1,l=!1;"object"==typeof n?(a=n.normalize||!1,o=n.successCallback,h=n.failureCallback,u=(n=n.fileType||n).flipU||!1,l=n.flipV||!1):("function"==typeof arguments[arguments.length-1]&&("function"==typeof arguments[arguments.length-2]?(o=arguments[arguments.length-2],h=arguments[arguments.length-1]):o=arguments[arguments.length-1]),"string"==typeof n?"boolean"!=typeof a&&(a=!1):"boolean"==typeof n?(a=n,n=t.slice(-4)):(n=t.slice(-4),a=!1)),".obj"!==n.toLowerCase()&&".stl"!==n.toLowerCase()&&(n=".obj");const c=new xn(void 0,void 0,void 0,this._renderer);c.gid=`${t}|${a}`;try{if(n.match(/\.stl$/i)){const{data:e}=await js(t,"arrayBuffer");return s(c,e),a&&c.normalize(),u&&c.flipU(),l&&c.flipV(),c._makeTriangleEdges(),o?o(c):c}if(n.match(/\.obj$/i)){const{data:e}=await js(t,"text"),s=e.split("\n"),n=await async function(e){const i=[];for(let s of e){const e=s.match(/^mtllib (.+)/);if(e){let s="";const n=e[1],a=t.split("/");if(a.length>1){a.pop();const e=a.join("/");s=e+"/"+n}else s=n;i.push(nh(s).then(e=>e?r(s):(console.warn(`MTL file not found or error in parsing; proceeding without materials: ${s}`),{})).catch(e=>(console.warn(`Error loading MTL file: ${s}`,e),{})))}}try{const e=await Promise.all(i);return Object.assign({},...e)}catch(e){return{}}}(s);return i(c,s,n),a&&c.normalize(),u&&c.flipU(),l&&c.flipV(),c._makeTriangleEdges(),o?o(c):c}}catch(r){if(e._friendlyFileLoadError(3,t),h)return h(r);throw r}},t.model=function(e,t=1){this._assert3d("model"),this._renderer.model(e,t)};let a=0;t.createModel=function(t,r=" ",n){let o,h,u=!1,l=!1,c=!1;n&&"object"==typeof n?(u=n.normalize||!1,o=n.successCallback,h=n.failureCallback,l=n.flipU||!1,c=n.flipV||!1):"boolean"==typeof n?(u=n,o=arguments[3],h=arguments[4]):(o="function"==typeof arguments[2]?arguments[2]:void 0,h=arguments[3]);const p=new e.Geometry;if(p.gid=`${r}|${u}|${a++}`,r.match(/\.stl$/i))try{s(p,(new TextEncoder).encode(t).buffer)}catch(t){return void(h?h(t):e._friendlyError("Error during parsing: "+t.message))}else if(r.match(/\.obj$/i))try{i(p,t.split("\n"))}catch(t){return void(h?h(t):e._friendlyError("Error during parsing: "+t.message))}else e._friendlyFileLoadError(3,t),h?h():e._friendlyError("Sorry, the file type is invalid. Only OBJ and STL files are supported.");return u&&p.normalize(),l&&p.flipU(),c&&p.flipV(),p._makeTriangleEdges(),"function"==typeof o&&o(p),p}}void 0!==p5&&Ko(p5),void 0!==p5&&Zo(0,p5.prototype),void 0!==p5&&Jo(0,p5.prototype),void 0!==p5&&Qo(0,p5.prototype),void 0!==p5&&eh(p5,p5.prototype),void 0!==p5&&th(0,p5.prototype),void 0!==p5&&rh(0,p5.prototype),void 0!==p5&&ih(0,p5.prototype),void 0!==p5&&sh(p5,p5.prototype),void 0!==p5&&ah(p5,p5.prototype);var oh={};Object.defineProperty(oh,"__esModule",{value:!0});var hh=function(){function e(){}return e.parse=function(t){for(var r=new Set,i=0,s=t;i<s.length;i++){var n=s[i];if(!e.REGEXP.test(n))throw new TypeError('"'+n+'" is invalid unicode-range.');var a=n.match(e.REGEXP),o=a[1],h=a[2],u=a[3];if(o){if(/\?[^?]+$/.test(o))throw new TypeError('"'+n+'" is invalid unicode-range.');if(o.includes("?"))for(var l=o.replace(/\?/g,"0"),c=o.replace(/\?/g,"F"),p=0,d=e.parse(["U+"+l+"-"+c]);p<d.length;p++){var f=d[p];r.add(f)}else r.add(parseInt(o,16))}if(h&&u){var g=parseInt(h,16),m=parseInt(u,16);for(f=g;f<=m;f++)r.add(f)}}return Array.from(r).sort(function(e,t){return e-t})},e.stringify=function(t){for(var r,i=Array.from(new Set(t)).sort(function(e,t){return e-t}),s=[],n=0;n<i.length;n++){var a=i[n],o=i[n-1];r&&a-o!=1&&(s.push(e.rangeString(r,o)),r=a),r||(r=a),n===i.length-1&&(r===a?s.push(e.rangeString(a)):s.push(e.rangeString(r,a)))}return s},e.rangeString=function(e,t){return t&&e!==t?"U+"+e.toString(16)+"-"+t.toString(16):"U+"+e.toString(16)},e.REGEXP=/^u\+(?:([0-9a-f]?[0-9a-f?]{1,5})|([0-9a-f]{1,6})-([0-9a-f]{1,6}))?$/i,e}(),uh=oh.UnicodeRange=hh;const lh=[{category:"control character",hexrange:["0000","001f"]},{category:"basic latin",hexrange:["0000","007f"]},{category:"latin-1 supplement",hexrange:["0080","00ff"]},{category:"latin extended-a",hexrange:["0100","017f"]},{category:"latin extended-b",hexrange:["0180","024f"]},{category:"ipa extensions",hexrange:["0250","02af"]},{category:"spacing modifier letters",hexrange:["02b0","02ff"]},{category:"combining diacritical marks",hexrange:["0300","036f"]},{category:"greek and coptic",hexrange:["0370","03ff"]},{category:"cyrillic",hexrange:["0400","04ff"]},{category:"cyrillic supplement",hexrange:["0500","052f"]},{category:"armenian",hexrange:["0530","058f"]},{category:"hebrew",hexrange:["0590","05ff"]},{category:"arabic",hexrange:["0600","06ff"]},{category:"syriac",hexrange:["0700","074f"]},{category:"arabic supplement",hexrange:["0750","077f"]},{category:"thaana",hexrange:["0780","07bf"]},{category:"nko",hexrange:["07c0","07ff"]},{category:"samaritan",hexrange:["0800","083f"]},{category:"mandaic",hexrange:["0840","085f"]},{category:"syriac supplement",hexrange:["0860","086f"]},{category:"arabic extended-b",hexrange:["0870","089f"]},{category:"arabic extended-a",hexrange:["08a0","08ff"]},{category:"devanagari",hexrange:["0900","097f"]},{category:"bengali",hexrange:["0980","09ff"]},{category:"gurmukhi",hexrange:["0a00","0a7f"]},{category:"gujarati",hexrange:["0a80","0aff"]},{category:"oriya",hexrange:["0b00","0b7f"]},{category:"tamil",hexrange:["0b80","0bff"]},{category:"telugu",hexrange:["0c00","0c7f"]},{category:"kannada",hexrange:["0c80","0cff"]},{category:"malayalam",hexrange:["0d00","0d7f"]},{category:"sinhala",hexrange:["0d80","0dff"]},{category:"thai",hexrange:["0e00","0e7f"]},{category:"lao",hexrange:["0e80","0eff"]},{category:"tibetan",hexrange:["0f00","0fff"]},{category:"myanmar",hexrange:["1000","109f"]},{category:"georgian",hexrange:["10a0","10ff"]},{category:"hangul jamo",hexrange:["1100","11ff"]},{category:"ethiopic",hexrange:["1200","137f"]},{category:"ethiopic supplement",hexrange:["1380","139f"]},{category:"cherokee",hexrange:["13a0","13ff"]},{category:"unified canadian aboriginal syllabics",hexrange:["1400","167f"]},{category:"ogham",hexrange:["1680","169f"]},{category:"runic",hexrange:["16a0","16ff"]},{category:"tagalog",hexrange:["1700","171f"]},{category:"hanunoo",hexrange:["1720","173f"]},{category:"buhid",hexrange:["1740","175f"]},{category:"tagbanwa",hexrange:["1760","177f"]},{category:"khmer",hexrange:["1780","17ff"]},{category:"mongolian",hexrange:["1800","18af"]},{category:"unified canadian aboriginal syllabics extended",hexrange:["18b0","18ff"]},{category:"limbu",hexrange:["1900","194f"]},{category:"tai le",hexrange:["1950","197f"]},{category:"new tai lue",hexrange:["1980","19df"]},{category:"khmer symbols",hexrange:["19e0","19ff"]},{category:"buginese",hexrange:["1a00","1a1f"]},{category:"tai tham",hexrange:["1a20","1aaf"]},{category:"combining diacritical marks extended",hexrange:["1ab0","1aff"]},{category:"balinese",hexrange:["1b00","1b7f"]},{category:"sundanese",hexrange:["1b80","1bbf"]},{category:"batak",hexrange:["1bc0","1bff"]},{category:"lepcha",hexrange:["1c00","1c4f"]},{category:"ol chiki",hexrange:["1c50","1c7f"]},{category:"cyrillic extended-c",hexrange:["1c80","1c8f"]},{category:"georgian extended",hexrange:["1c90","1cbf"]},{category:"sundanese supplement",hexrange:["1cc0","1ccf"]},{category:"vedic extensions",hexrange:["1cd0","1cff"]},{category:"phonetic extensions",hexrange:["1d00","1d7f"]},{category:"phonetic extensions supplement",hexrange:["1d80","1dbf"]},{category:"combining diacritical marks supplement",hexrange:["1dc0","1dff"]},{category:"latin extended additional",hexrange:["1e00","1eff"]},{category:"greek extended",hexrange:["1f00","1fff"]},{category:"general punctuation",hexrange:["2000","206f"]},{category:"superscripts and subscripts",hexrange:["2070","209f"]},{category:"currency symbols",hexrange:["20a0","20cf"]},{category:"combining diacritical marks for symbols",hexrange:["20d0","20ff"]},{category:"letterlike symbols",hexrange:["2100","214f"]},{category:"number forms",hexrange:["2150","218f"]},{category:"arrows",hexrange:["2190","21ff"]},{category:"mathematical operators",hexrange:["2200","22ff"]},{category:"miscellaneous technical",hexrange:["2300","23ff"]},{category:"control pictures",hexrange:["2400","243f"]},{category:"optical character recognition",hexrange:["2440","245f"]},{category:"enclosed alphanumerics",hexrange:["2460","24ff"]},{category:"box drawing",hexrange:["2500","257f"]},{category:"block elements",hexrange:["2580","259f"]},{category:"geometric shapes",hexrange:["25a0","25ff"]},{category:"miscellaneous symbols",hexrange:["2600","26ff"]},{category:"dingbats",hexrange:["2700","27bf"]},{category:"miscellaneous mathematical symbols-a",hexrange:["27c0","27ef"]},{category:"supplemental arrows-a",hexrange:["27f0","27ff"]},{category:"braille patterns",hexrange:["2800","28ff"]},{category:"supplemental arrows-b",hexrange:["2900","297f"]},{category:"miscellaneous mathematical symbols-b",hexrange:["2980","29ff"]},{category:"supplemental mathematical operators",hexrange:["2a00","2aff"]},{category:"miscellaneous symbols and arrows",hexrange:["2b00","2bff"]},{category:"glagolitic",hexrange:["2c00","2c5f"]},{category:"latin extended-c",hexrange:["2c60","2c7f"]},{category:"coptic",hexrange:["2c80","2cff"]},{category:"georgian supplement",hexrange:["2d00","2d2f"]},{category:"tifinagh",hexrange:["2d30","2d7f"]},{category:"ethiopic extended",hexrange:["2d80","2ddf"]},{category:"cyrillic extended-a",hexrange:["2de0","2dff"]},{category:"supplemental punctuation",hexrange:["2e00","2e7f"]},{category:"cjk radicals supplement",hexrange:["2e80","2eff"]},{category:"kangxi radicals",hexrange:["2f00","2fdf"]},{category:"ideographic description characters",hexrange:["2ff0","2fff"]},{category:"cjk symbols and punctuation",hexrange:["3000","303f"]},{category:"hiragana",hexrange:["3040","309f"]},{category:"katakana",hexrange:["30a0","30ff"]},{category:"bopomofo",hexrange:["3100","312f"]},{category:"hangul compatibility jamo",hexrange:["3130","318f"]},{category:"kanbun",hexrange:["3190","319f"]},{category:"bopomofo extended",hexrange:["31a0","31bf"]},{category:"cjk strokes",hexrange:["31c0","31ef"]},{category:"katakana phonetic extensions",hexrange:["31f0","31ff"]},{category:"enclosed cjk letters and months",hexrange:["3200","32ff"]},{category:"cjk compatibility",hexrange:["3300","33ff"]},{category:"cjk unified ideographs extension a",hexrange:["3400","4dbf"]},{category:"yijing hexagram symbols",hexrange:["4dc0","4dff"]},{category:"cjk unified ideographs",hexrange:["4e00","9fff"]},{category:"yi syllables",hexrange:["a000","a48f"]},{category:"yi radicals",hexrange:["a490","a4cf"]},{category:"lisu",hexrange:["a4d0","a4ff"]},{category:"vai",hexrange:["a500","a63f"]},{category:"cyrillic extended-b",hexrange:["a640","a69f"]},{category:"bamum",hexrange:["a6a0","a6ff"]},{category:"modifier tone letters",hexrange:["a700","a71f"]},{category:"latin extended-d",hexrange:["a720","a7ff"]},{category:"syloti nagri",hexrange:["a800","a82f"]},{category:"common indic number forms",hexrange:["a830","a83f"]},{category:"phags-pa",hexrange:["a840","a87f"]},{category:"saurashtra",hexrange:["a880","a8df"]},{category:"devanagari extended",hexrange:["a8e0","a8ff"]},{category:"kayah li",hexrange:["a900","a92f"]},{category:"rejang",hexrange:["a930","a95f"]},{category:"hangul jamo extended-a",hexrange:["a960","a97f"]},{category:"javanese",hexrange:["a980","a9df"]},{category:"myanmar extended-b",hexrange:["a9e0","a9ff"]},{category:"cham",hexrange:["aa00","aa5f"]},{category:"myanmar extended-a",hexrange:["aa60","aa7f"]},{category:"tai viet",hexrange:["aa80","aadf"]},{category:"meetei mayek extensions",hexrange:["aae0","aaff"]},{category:"ethiopic extended-a",hexrange:["ab00","ab2f"]},{category:"latin extended-e",hexrange:["ab30","ab6f"]},{category:"cherokee supplement",hexrange:["ab70","abbf"]},{category:"meetei mayek",hexrange:["abc0","abff"]},{category:"hangul syllables",hexrange:["ac00","d7af"]},{category:"hangul jamo extended-b",hexrange:["d7b0","d7ff"]},{category:"high surrogates",hexrange:["d800","db7f"]},{category:"high private use surrogates",hexrange:["db80","dbff"]},{category:"low surrogates",hexrange:["dc00","dfff"]},{category:"private use area",hexrange:["e000","f8ff"]},{category:"cjk compatibility ideographs",hexrange:["f900","faff"]},{category:"alphabetic presentation forms",hexrange:["fb00","fb4f"]},{category:"arabic presentation forms-a",hexrange:["fb50","fdff"]},{category:"variation selectors",hexrange:["fe00","fe0f"]},{category:"vertical forms",hexrange:["fe10","fe1f"]},{category:"combining half marks",hexrange:["fe20","fe2f"]},{category:"cjk compatibility forms",hexrange:["fe30","fe4f"]},{category:"small form variants",hexrange:["fe50","fe6f"]},{category:"arabic presentation forms-b",hexrange:["fe70","feff"]},{category:"halfwidth and fullwidth forms",hexrange:["ff00","ffef"]},{category:"specials",hexrange:["fff0","ffff"]},{category:"linear b syllabary",hexrange:["10000","1007f"]},{category:"linear b ideograms",hexrange:["10080","100ff"]},{category:"aegean numbers",hexrange:["10100","1013f"]},{category:"ancient greek numbers",hexrange:["10140","1018f"]},{category:"ancient symbols",hexrange:["10190","101cf"]},{category:"phaistos disc",hexrange:["101d0","101ff"]},{category:"lycian",hexrange:["10280","1029f"]},{category:"carian",hexrange:["102a0","102df"]},{category:"coptic epact numbers",hexrange:["102e0","102ff"]},{category:"old italic",hexrange:["10300","1032f"]},{category:"gothic",hexrange:["10330","1034f"]},{category:"old permic",hexrange:["10350","1037f"]},{category:"ugaritic",hexrange:["10380","1039f"]},{category:"old persian",hexrange:["103a0","103df"]},{category:"deseret",hexrange:["10400","1044f"]},{category:"shavian",hexrange:["10450","1047f"]},{category:"osmanya",hexrange:["10480","104af"]},{category:"osage",hexrange:["104b0","104ff"]},{category:"elbasan",hexrange:["10500","1052f"]},{category:"caucasian albanian",hexrange:["10530","1056f"]},{category:"vithkuqi",hexrange:["10570","105bf"]},{category:"linear a",hexrange:["10600","1077f"]},{category:"latin extended-f",hexrange:["10780","107bf"]},{category:"cypriot syllabary",hexrange:["10800","1083f"]},{category:"imperial aramaic",hexrange:["10840","1085f"]},{category:"palmyrene",hexrange:["10860","1087f"]},{category:"nabataean",hexrange:["10880","108af"]},{category:"hatran",hexrange:["108e0","108ff"]},{category:"phoenician",hexrange:["10900","1091f"]},{category:"lydian",hexrange:["10920","1093f"]},{category:"meroitic hieroglyphs",hexrange:["10980","1099f"]},{category:"meroitic cursive",hexrange:["109a0","109ff"]},{category:"kharoshthi",hexrange:["10a00","10a5f"]},{category:"old south arabian",hexrange:["10a60","10a7f"]},{category:"old north arabian",hexrange:["10a80","10a9f"]},{category:"manichaean",hexrange:["10ac0","10aff"]},{category:"avestan",hexrange:["10b00","10b3f"]},{category:"inscriptional parthian",hexrange:["10b40","10b5f"]},{category:"inscriptional pahlavi",hexrange:["10b60","10b7f"]},{category:"psalter pahlavi",hexrange:["10b80","10baf"]},{category:"old turkic",hexrange:["10c00","10c4f"]},{category:"old hungarian",hexrange:["10c80","10cff"]},{category:"hanifi rohingya",hexrange:["10d00","10d3f"]},{category:"rumi numeral symbols",hexrange:["10e60","10e7f"]},{category:"yezidi",hexrange:["10e80","10ebf"]},{category:"arabic extended-c",hexrange:["10ec0","10eff"]},{category:"old sogdian",hexrange:["10f00","10f2f"]},{category:"sogdian",hexrange:["10f30","10f6f"]},{category:"old uyghur",hexrange:["10f70","10faf"]},{category:"chorasmian",hexrange:["10fb0","10fdf"]},{category:"elymaic",hexrange:["10fe0","10fff"]},{category:"brahmi",hexrange:["11000","1107f"]},{category:"kaithi",hexrange:["11080","110cf"]},{category:"sora sompeng",hexrange:["110d0","110ff"]},{category:"chakma",hexrange:["11100","1114f"]},{category:"mahajani",hexrange:["11150","1117f"]},{category:"sharada",hexrange:["11180","111df"]},{category:"sinhala archaic numbers",hexrange:["111e0","111ff"]},{category:"khojki",hexrange:["11200","1124f"]},{category:"multani",hexrange:["11280","112af"]},{category:"khudawadi",hexrange:["112b0","112ff"]},{category:"grantha",hexrange:["11300","1137f"]},{category:"newa",hexrange:["11400","1147f"]},{category:"tirhuta",hexrange:["11480","114df"]},{category:"siddham",hexrange:["11580","115ff"]},{category:"modi",hexrange:["11600","1165f"]},{category:"mongolian supplement",hexrange:["11660","1167f"]},{category:"takri",hexrange:["11680","116cf"]},{category:"ahom",hexrange:["11700","1174f"]},{category:"dogra",hexrange:["11800","1184f"]},{category:"warang citi",hexrange:["118a0","118ff"]},{category:"dives akuru",hexrange:["11900","1195f"]},{category:"nandinagari",hexrange:["119a0","119ff"]},{category:"zanabazar square",hexrange:["11a00","11a4f"]},{category:"soyombo",hexrange:["11a50","11aaf"]},{category:"unified canadian aboriginal syllabics extended-a",hexrange:["11ab0","11abf"]},{category:"pau cin hau",hexrange:["11ac0","11aff"]},{category:"devanagari extended-a",hexrange:["11b00","11b5f"]},{category:"bhaiksuki",hexrange:["11c00","11c6f"]},{category:"marchen",hexrange:["11c70","11cbf"]},{category:"masaram gondi",hexrange:["11d00","11d5f"]},{category:"gunjala gondi",hexrange:["11d60","11daf"]},{category:"makasar",hexrange:["11ee0","11eff"]},{category:"kawi",hexrange:["11f00","11f5f"]},{category:"lisu supplement",hexrange:["11fb0","11fbf"]},{category:"tamil supplement",hexrange:["11fc0","11fff"]},{category:"cuneiform",hexrange:["12000","123ff"]},{category:"cuneiform numbers and punctuation",hexrange:["12400","1247f"]},{category:"early dynastic cuneiform",hexrange:["12480","1254f"]},{category:"cypro-minoan",hexrange:["12f90","12fff"]},{category:"egyptian hieroglyphs",hexrange:["13000","1342f"]},{category:"egyptian hieroglyph format controls",hexrange:["13430","1345f"]},{category:"anatolian hieroglyphs",hexrange:["14400","1467f"]},{category:"bamum supplement",hexrange:["16800","16a3f"]},{category:"mro",hexrange:["16a40","16a6f"]},{category:"tangsa",hexrange:["16a70","16acf"]},{category:"bassa vah",hexrange:["16ad0","16aff"]},{category:"pahawh hmong",hexrange:["16b00","16b8f"]},{category:"medefaidrin",hexrange:["16e40","16e9f"]},{category:"miao",hexrange:["16f00","16f9f"]},{category:"ideographic symbols and punctuation",hexrange:["16fe0","16fff"]},{category:"tangut",hexrange:["17000","187ff"]},{category:"tangut components",hexrange:["18800","18aff"]},{category:"khitan small script",hexrange:["18b00","18cff"]},{category:"tangut supplement",hexrange:["18d00","18d7f"]},{category:"kana extended-b",hexrange:["1aff0","1afff"]},{category:"kana supplement",hexrange:["1b000","1b0ff"]},{category:"kana extended-a",hexrange:["1b100","1b12f"]},{category:"small kana extension",hexrange:["1b130","1b16f"]},{category:"nushu",hexrange:["1b170","1b2ff"]},{category:"duployan",hexrange:["1bc00","1bc9f"]},{category:"shorthand format controls",hexrange:["1bca0","1bcaf"]},{category:"znamenny musical notation",hexrange:["1cf00","1cfcf"]},{category:"byzantine musical symbols",hexrange:["1d000","1d0ff"]},{category:"musical symbols",hexrange:["1d100","1d1ff"]},{category:"ancient greek musical notation",hexrange:["1d200","1d24f"]},{category:"kaktovik numerals",hexrange:["1d2c0","1d2df"]},{category:"mayan numerals",hexrange:["1d2e0","1d2ff"]},{category:"tai xuan jing symbols",hexrange:["1d300","1d35f"]},{category:"counting rod numerals",hexrange:["1d360","1d37f"]},{category:"mathematical alphanumeric symbols",hexrange:["1d400","1d7ff"]},{category:"sutton signwriting",hexrange:["1d800","1daaf"]},{category:"latin extended-g",hexrange:["1df00","1dfff"]},{category:"glagolitic supplement",hexrange:["1e000","1e02f"]},{category:"cyrillic extended-d",hexrange:["1e030","1e08f"]},{category:"nyiakeng puachue hmong",hexrange:["1e100","1e14f"]},{category:"toto",hexrange:["1e290","1e2bf"]},{category:"wancho",hexrange:["1e2c0","1e2ff"]},{category:"nag mundari",hexrange:["1e4d0","1e4ff"]},{category:"ethiopic extended-b",hexrange:["1e7e0","1e7ff"]},{category:"mende kikakui",hexrange:["1e800","1e8df"]},{category:"adlam",hexrange:["1e900","1e95f"]},{category:"indic siyaq numbers",hexrange:["1ec70","1ecbf"]},{category:"ottoman siyaq numbers",hexrange:["1ed00","1ed4f"]},{category:"arabic mathematical alphabetic symbols",hexrange:["1ee00","1eeff"]},{category:"mahjong tiles",hexrange:["1f000","1f02f"]},{category:"domino tiles",hexrange:["1f030","1f09f"]},{category:"playing cards",hexrange:["1f0a0","1f0ff"]},{category:"enclosed alphanumeric supplement",hexrange:["1f100","1f1ff"]},{category:"enclosed ideographic supplement",hexrange:["1f200","1f2ff"]},{category:"miscellaneous symbols and pictographs",hexrange:["1f300","1f5ff"]},{category:"emoticons (emoji)",hexrange:["1f600","1f64f"]},{category:"ornamental dingbats",hexrange:["1f650","1f67f"]},{category:"transport and map symbols",hexrange:["1f680","1f6ff"]},{category:"alchemical symbols",hexrange:["1f700","1f77f"]},{category:"geometric shapes extended",hexrange:["1f780","1f7ff"]},{category:"supplemental arrows-c",hexrange:["1f800","1f8ff"]},{category:"supplemental symbols and pictographs",hexrange:["1f900","1f9ff"]},{category:"chess symbols",hexrange:["1fa00","1fa6f"]},{category:"symbols and pictographs extended-a",hexrange:["1fa70","1faff"]},{category:"symbols for legacy computing",hexrange:["1fb00","1fbff"]},{category:"cjk unified ideographs extension b",hexrange:["20000","2a6df"]},{category:"cjk unified ideographs extension c",hexrange:["2a700","2b73f"]},{category:"cjk unified ideographs extension d",hexrange:["2b740","2b81f"]},{category:"cjk unified ideographs extension e",hexrange:["2b820","2ceaf"]},{category:"cjk unified ideographs extension f",hexrange:["2ceb0","2ebef"]},{category:"cjk unified ideographs extension i",hexrange:["2ebf0","2ee5f"]},{category:"cjk compatibility ideographs supplement",hexrange:["2f800","2fa1f"]},{category:"cjk unified ideographs extension g",hexrange:["30000","3134f"]},{category:"cjk unified ideographs extension h",hexrange:["31350","323af"]},{category:"tags",hexrange:["e0000","e007f"]},{category:"variation selectors supplement",hexrange:["e0100","e01ef"]},{category:"supplementary private use area-a",hexrange:["f0000","fffff"]},{category:"supplementary private use area-b",hexrange:["100000","10ffff"]}];function ch(e){let t=e.length;for(;--t>=0;)e[t]=0}ch(new Array(576)),ch(new Array(60)),ch(new Array(512)),ch(new Array(256)),ch(new Array(29)),ch(new Array(30));var ph=(e,t,r,i)=>{let s=65535&e,n=e>>>16&65535,a=0;for(;0!==r;){a=r>2e3?2e3:r,r-=a;do{s=s+t[i++]|0,n=n+s|0}while(--a);s%=65521,n%=65521}return s|n<<16};const dh=new Uint32Array((()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t})());var fh=(e,t,r,i)=>{const s=dh,n=i+r;e^=-1;for(let r=i;r<n;r++)e=e>>>8^s[255&(e^t[r])];return~e},gh={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},mh={Z_NO_FLUSH:0,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_DEFLATED:8};const yh=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let xh=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){xh=!1}const vh=new Uint8Array(256);for(let e=0;e<256;e++)vh[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;vh[254]=vh[254]=1;var bh=(e,t)=>{const r=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let i,s;const n=new Array(2*r);for(s=0,i=0;i<r;){let t=e[i++];if(t<128){n[s++]=t;continue}let a=vh[t];if(a>4)n[s++]=65533,i+=a-1;else{for(t&=2===a?31:3===a?15:7;a>1&&i<r;)t=t<<6|63&e[i++],a--;a>1?n[s++]=65533:t<65536?n[s++]=t:(t-=65536,n[s++]=55296|t>>10&1023,n[s++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&xh)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let i=0;i<t;i++)r+=String.fromCharCode(e[i]);return r})(n,s)},_h=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let r=t-1;for(;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+vh[e[r]]>t?r:t},wh=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Ch=16209;var Eh=function(e,t){let r,i,s,n,a,o,h,u,l,c,p,d,f,g,m,y,x,v,b,_,w,C,E,D;const A=e.state;r=e.next_in,E=e.input,i=r+(e.avail_in-5),s=e.next_out,D=e.output,n=s-(t-e.avail_out),a=s+(e.avail_out-257),o=A.dmax,h=A.wsize,u=A.whave,l=A.wnext,c=A.window,p=A.hold,d=A.bits,f=A.lencode,g=A.distcode,m=(1<<A.lenbits)-1,y=(1<<A.distbits)-1;e:do{d<15&&(p+=E[r++]<<d,d+=8,p+=E[r++]<<d,d+=8),x=f[p&m];t:for(;;){if(v=x>>>24,p>>>=v,d-=v,v=x>>>16&255,0===v)D[s++]=65535&x;else{if(!(16&v)){if(64&v){if(32&v){A.mode=16191;break e}e.msg="invalid literal/length code",A.mode=Ch;break e}x=f[(65535&x)+(p&(1<<v)-1)];continue t}for(b=65535&x,v&=15,v&&(d<v&&(p+=E[r++]<<d,d+=8),b+=p&(1<<v)-1,p>>>=v,d-=v),d<15&&(p+=E[r++]<<d,d+=8,p+=E[r++]<<d,d+=8),x=g[p&y];;){if(v=x>>>24,p>>>=v,d-=v,v=x>>>16&255,16&v){if(_=65535&x,v&=15,d<v&&(p+=E[r++]<<d,d+=8,d<v&&(p+=E[r++]<<d,d+=8)),_+=p&(1<<v)-1,_>o){e.msg="invalid distance too far back",A.mode=Ch;break e}if(p>>>=v,d-=v,v=s-n,_>v){if(v=_-v,v>u&&A.sane){e.msg="invalid distance too far back",A.mode=Ch;break e}if(w=0,C=c,0===l){if(w+=h-v,v<b){b-=v;do{D[s++]=c[w++]}while(--v);w=s-_,C=D}}else if(l<v){if(w+=h+l-v,v-=l,v<b){b-=v;do{D[s++]=c[w++]}while(--v);if(w=0,l<b){v=l,b-=v;do{D[s++]=c[w++]}while(--v);w=s-_,C=D}}}else if(w+=l-v,v<b){b-=v;do{D[s++]=c[w++]}while(--v);w=s-_,C=D}for(;b>2;)D[s++]=C[w++],D[s++]=C[w++],D[s++]=C[w++],b-=3;b&&(D[s++]=C[w++],b>1&&(D[s++]=C[w++]))}else{w=s-_;do{D[s++]=D[w++],D[s++]=D[w++],D[s++]=D[w++],b-=3}while(b>2);b&&(D[s++]=D[w++],b>1&&(D[s++]=D[w++]))}break}if(64&v){e.msg="invalid distance code",A.mode=Ch;break e}x=g[(65535&x)+(p&(1<<v)-1)]}}break}}while(r<i&&s<a);b=d>>3,r-=b,d-=b<<3,p&=(1<<d)-1,e.next_in=r,e.next_out=s,e.avail_in=r<i?i-r+5:5-(r-i),e.avail_out=s<a?a-s+257:257-(s-a),A.hold=p,A.bits=d};const Dh=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Ah=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Sh=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Fh=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var Th=(e,t,r,i,s,n,a,o)=>{const h=o.bits;let u,l,c,p,d,f,g=0,m=0,y=0,x=0,v=0,b=0,_=0,w=0,C=0,E=0,D=null;const A=new Uint16Array(16),S=new Uint16Array(16);let F,T,M,k=null;for(g=0;g<=15;g++)A[g]=0;for(m=0;m<i;m++)A[t[r+m]]++;for(v=h,x=15;x>=1&&0===A[x];x--);if(v>x&&(v=x),0===x)return s[n++]=20971520,s[n++]=20971520,o.bits=1,0;for(y=1;y<x&&0===A[y];y++);for(v<y&&(v=y),w=1,g=1;g<=15;g++)if(w<<=1,w-=A[g],w<0)return-1;if(w>0&&(0===e||1!==x))return-1;for(S[1]=0,g=1;g<15;g++)S[g+1]=S[g]+A[g];for(m=0;m<i;m++)0!==t[r+m]&&(a[S[t[r+m]]++]=m);if(0===e?(D=k=a,f=20):1===e?(D=Dh,k=Ah,f=257):(D=Sh,k=Fh,f=0),E=0,m=0,g=y,d=n,b=v,_=0,c=-1,C=1<<v,p=C-1,1===e&&C>852||2===e&&C>592)return 1;for(;;){F=g-_,a[m]+1<f?(T=0,M=a[m]):a[m]>=f?(T=k[a[m]-f],M=D[a[m]-f]):(T=96,M=0),u=1<<g-_,l=1<<b,y=l;do{l-=u,s[d+(E>>_)+l]=F<<24|T<<16|M}while(0!==l);for(u=1<<g-1;E&u;)u>>=1;if(0!==u?(E&=u-1,E+=u):E=0,m++,0==--A[g]){if(g===x)break;g=t[r+a[m]]}if(g>v&&(E&p)!==c){for(0===_&&(_=v),d+=y,b=g-_,w=1<<b;b+_<x&&(w-=A[b+_],!(w<=0));)b++,w<<=1;if(C+=1<<b,1===e&&C>852||2===e&&C>592)return 1;c=E&p,s[c]=v<<24|b<<16|d-n}}return 0!==E&&(s[d+E]=g-_<<24|64<<16),o.bits=v,0};const{Z_FINISH:Mh,Z_BLOCK:kh,Z_TREES:Ih,Z_OK:Bh,Z_STREAM_END:Lh,Z_NEED_DICT:Ph,Z_STREAM_ERROR:Oh,Z_DATA_ERROR:Rh,Z_MEM_ERROR:Nh,Z_BUF_ERROR:Vh,Z_DEFLATED:Uh}=mh,zh=16180,Gh=16190,jh=16191,$h=16192,Hh=16194,qh=16199,Wh=16200,Xh=16206,Yh=16209,Kh=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Zh(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Jh=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<zh||t.mode>16211?1:0},Qh=e=>{if(Jh(e))return Oh;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,(e=>{if(Jh(e))return Oh;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=zh,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Bh})(e)};let eu,tu,ru=!0;const iu=e=>{if(ru){eu=new Int32Array(512),tu=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Th(1,e.lens,0,288,eu,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Th(2,e.lens,0,32,tu,0,e.work,{bits:5}),ru=!1}e.lencode=eu,e.lenbits=9,e.distcode=tu,e.distbits=5},su=(e,t,r,i)=>{let s;const n=e.state;return null===n.window&&(n.wsize=1<<n.wbits,n.wnext=0,n.whave=0,n.window=new Uint8Array(n.wsize)),i>=n.wsize?(n.window.set(t.subarray(r-n.wsize,r),0),n.wnext=0,n.whave=n.wsize):(s=n.wsize-n.wnext,s>i&&(s=i),n.window.set(t.subarray(r-i,r-i+s),n.wnext),(i-=s)?(n.window.set(t.subarray(r-i,r),0),n.wnext=i,n.whave=n.wsize):(n.wnext+=s,n.wnext===n.wsize&&(n.wnext=0),n.whave<n.wsize&&(n.whave+=s))),0};var nu=Qh,au=(e,t)=>{if(!e)return Oh;const r=new Zh;e.state=r,r.strm=e,r.window=null,r.mode=zh;const i=((e,t)=>{let r;if(Jh(e))return Oh;const i=e.state;return t<0?(r=0,t=-t):(r=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Oh:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=r,i.wbits=t,Qh(e))})(e,t);return i!==Bh&&(e.state=null),i},ou=(e,t)=>{let r,i,s,n,a,o,h,u,l,c,p,d,f,g,m,y,x,v,b,_,w,C,E=0;const D=new Uint8Array(4);let A,S;const F=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Jh(e)||!e.output||!e.input&&0!==e.avail_in)return Oh;r=e.state,r.mode===jh&&(r.mode=$h),a=e.next_out,s=e.output,h=e.avail_out,n=e.next_in,i=e.input,o=e.avail_in,u=r.hold,l=r.bits,c=o,p=h,C=Bh;e:for(;;)switch(r.mode){case zh:if(0===r.wrap){r.mode=$h;break}for(;l<16;){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}if(2&r.wrap&&35615===u){0===r.wbits&&(r.wbits=15),r.check=0,D[0]=255&u,D[1]=u>>>8&255,r.check=fh(r.check,D,2,0),u=0,l=0,r.mode=16181;break}if(r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=Yh;break}if((15&u)!==Uh){e.msg="unknown compression method",r.mode=Yh;break}if(u>>>=4,l-=4,w=8+(15&u),0===r.wbits&&(r.wbits=w),w>15||w>r.wbits){e.msg="invalid window size",r.mode=Yh;break}r.dmax=1<<r.wbits,r.flags=0,e.adler=r.check=1,r.mode=512&u?16189:jh,u=0,l=0;break;case 16181:for(;l<16;){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}if(r.flags=u,(255&r.flags)!==Uh){e.msg="unknown compression method",r.mode=Yh;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=Yh;break}r.head&&(r.head.text=u>>8&1),512&r.flags&&4&r.wrap&&(D[0]=255&u,D[1]=u>>>8&255,r.check=fh(r.check,D,2,0)),u=0,l=0,r.mode=16182;case 16182:for(;l<32;){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}r.head&&(r.head.time=u),512&r.flags&&4&r.wrap&&(D[0]=255&u,D[1]=u>>>8&255,D[2]=u>>>16&255,D[3]=u>>>24&255,r.check=fh(r.check,D,4,0)),u=0,l=0,r.mode=16183;case 16183:for(;l<16;){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&r.flags&&4&r.wrap&&(D[0]=255&u,D[1]=u>>>8&255,r.check=fh(r.check,D,2,0)),u=0,l=0,r.mode=16184;case 16184:if(1024&r.flags){for(;l<16;){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}r.length=u,r.head&&(r.head.extra_len=u),512&r.flags&&4&r.wrap&&(D[0]=255&u,D[1]=u>>>8&255,r.check=fh(r.check,D,2,0)),u=0,l=0}else r.head&&(r.head.extra=null);r.mode=16185;case 16185:if(1024&r.flags&&(d=r.length,d>o&&(d=o),d&&(r.head&&(w=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(i.subarray(n,n+d),w)),512&r.flags&&4&r.wrap&&(r.check=fh(r.check,i,d,n)),o-=d,n+=d,r.length-=d),r.length))break e;r.length=0,r.mode=16186;case 16186:if(2048&r.flags){if(0===o)break e;d=0;do{w=i[n+d++],r.head&&w&&r.length<65536&&(r.head.name+=String.fromCharCode(w))}while(w&&d<o);if(512&r.flags&&4&r.wrap&&(r.check=fh(r.check,i,d,n)),o-=d,n+=d,w)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=16187;case 16187:if(4096&r.flags){if(0===o)break e;d=0;do{w=i[n+d++],r.head&&w&&r.length<65536&&(r.head.comment+=String.fromCharCode(w))}while(w&&d<o);if(512&r.flags&&4&r.wrap&&(r.check=fh(r.check,i,d,n)),o-=d,n+=d,w)break e}else r.head&&(r.head.comment=null);r.mode=16188;case 16188:if(512&r.flags){for(;l<16;){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}if(4&r.wrap&&u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=Yh;break}u=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=jh;break;case 16189:for(;l<32;){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}e.adler=r.check=Kh(u),u=0,l=0,r.mode=Gh;case Gh:if(0===r.havedict)return e.next_out=a,e.avail_out=h,e.next_in=n,e.avail_in=o,r.hold=u,r.bits=l,Ph;e.adler=r.check=1,r.mode=jh;case jh:if(t===kh||t===Ih)break e;case $h:if(r.last){u>>>=7&l,l-=7&l,r.mode=Xh;break}for(;l<3;){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}switch(r.last=1&u,u>>>=1,l-=1,3&u){case 0:r.mode=16193;break;case 1:if(iu(r),r.mode=qh,t===Ih){u>>>=2,l-=2;break e}break;case 2:r.mode=16196;break;case 3:e.msg="invalid block type",r.mode=Yh}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=Yh;break}if(r.length=65535&u,u=0,l=0,r.mode=Hh,t===Ih)break e;case Hh:r.mode=16195;case 16195:if(d=r.length,d){if(d>o&&(d=o),d>h&&(d=h),0===d)break e;s.set(i.subarray(n,n+d),a),o-=d,n+=d,h-=d,a+=d,r.length-=d;break}r.mode=jh;break;case 16196:for(;l<14;){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}if(r.nlen=257+(31&u),u>>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=Yh;break}r.have=0,r.mode=16197;case 16197:for(;r.have<r.ncode;){for(;l<3;){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}r.lens[F[r.have++]]=7&u,u>>>=3,l-=3}for(;r.have<19;)r.lens[F[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,A={bits:r.lenbits},C=Th(0,r.lens,0,19,r.lencode,0,r.work,A),r.lenbits=A.bits,C){e.msg="invalid code lengths set",r.mode=Yh;break}r.have=0,r.mode=16198;case 16198:for(;r.have<r.nlen+r.ndist;){for(;E=r.lencode[u&(1<<r.lenbits)-1],m=E>>>24,y=E>>>16&255,x=65535&E,!(m<=l);){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}if(x<16)u>>>=m,l-=m,r.lens[r.have++]=x;else{if(16===x){for(S=m+2;l<S;){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}if(u>>>=m,l-=m,0===r.have){e.msg="invalid bit length repeat",r.mode=Yh;break}w=r.lens[r.have-1],d=3+(3&u),u>>>=2,l-=2}else if(17===x){for(S=m+3;l<S;){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}u>>>=m,l-=m,w=0,d=3+(7&u),u>>>=3,l-=3}else{for(S=m+7;l<S;){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}u>>>=m,l-=m,w=0,d=11+(127&u),u>>>=7,l-=7}if(r.have+d>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=Yh;break}for(;d--;)r.lens[r.have++]=w}}if(r.mode===Yh)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=Yh;break}if(r.lenbits=9,A={bits:r.lenbits},C=Th(1,r.lens,0,r.nlen,r.lencode,0,r.work,A),r.lenbits=A.bits,C){e.msg="invalid literal/lengths set",r.mode=Yh;break}if(r.distbits=6,r.distcode=r.distdyn,A={bits:r.distbits},C=Th(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,A),r.distbits=A.bits,C){e.msg="invalid distances set",r.mode=Yh;break}if(r.mode=qh,t===Ih)break e;case qh:r.mode=Wh;case Wh:if(o>=6&&h>=258){e.next_out=a,e.avail_out=h,e.next_in=n,e.avail_in=o,r.hold=u,r.bits=l,Eh(e,p),a=e.next_out,s=e.output,h=e.avail_out,n=e.next_in,i=e.input,o=e.avail_in,u=r.hold,l=r.bits,r.mode===jh&&(r.back=-1);break}for(r.back=0;E=r.lencode[u&(1<<r.lenbits)-1],m=E>>>24,y=E>>>16&255,x=65535&E,!(m<=l);){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}if(y&&!(240&y)){for(v=m,b=y,_=x;E=r.lencode[_+((u&(1<<v+b)-1)>>v)],m=E>>>24,y=E>>>16&255,x=65535&E,!(v+m<=l);){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}u>>>=v,l-=v,r.back+=v}if(u>>>=m,l-=m,r.back+=m,r.length=x,0===y){r.mode=16205;break}if(32&y){r.back=-1,r.mode=jh;break}if(64&y){e.msg="invalid literal/length code",r.mode=Yh;break}r.extra=15&y,r.mode=16201;case 16201:if(r.extra){for(S=r.extra;l<S;){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=16202;case 16202:for(;E=r.distcode[u&(1<<r.distbits)-1],m=E>>>24,y=E>>>16&255,x=65535&E,!(m<=l);){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}if(!(240&y)){for(v=m,b=y,_=x;E=r.distcode[_+((u&(1<<v+b)-1)>>v)],m=E>>>24,y=E>>>16&255,x=65535&E,!(v+m<=l);){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}u>>>=v,l-=v,r.back+=v}if(u>>>=m,l-=m,r.back+=m,64&y){e.msg="invalid distance code",r.mode=Yh;break}r.offset=x,r.extra=15&y,r.mode=16203;case 16203:if(r.extra){for(S=r.extra;l<S;){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=Yh;break}r.mode=16204;case 16204:if(0===h)break e;if(d=p-h,r.offset>d){if(d=r.offset-d,d>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=Yh;break}d>r.wnext?(d-=r.wnext,f=r.wsize-d):f=r.wnext-d,d>r.length&&(d=r.length),g=r.window}else g=s,f=a-r.offset,d=r.length;d>h&&(d=h),h-=d,r.length-=d;do{s[a++]=g[f++]}while(--d);0===r.length&&(r.mode=Wh);break;case 16205:if(0===h)break e;s[a++]=r.length,h--,r.mode=Wh;break;case Xh:if(r.wrap){for(;l<32;){if(0===o)break e;o--,u|=i[n++]<<l,l+=8}if(p-=h,e.total_out+=p,r.total+=p,4&r.wrap&&p&&(e.adler=r.check=r.flags?fh(r.check,s,p,a-p):ph(r.check,s,p,a-p)),p=h,4&r.wrap&&(r.flags?u:Kh(u))!==r.check){e.msg="incorrect data check",r.mode=Yh;break}u=0,l=0}r.mode=16207;case 16207:if(r.wrap&&r.flags){for(;l<32;){if(0===o)break e;o--,u+=i[n++]<<l,l+=8}if(4&r.wrap&&u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=Yh;break}u=0,l=0}r.mode=16208;case 16208:C=Lh;break e;case Yh:C=Rh;break e;case 16210:return Nh;default:return Oh}return e.next_out=a,e.avail_out=h,e.next_in=n,e.avail_in=o,r.hold=u,r.bits=l,(r.wsize||p!==e.avail_out&&r.mode<Yh&&(r.mode<Xh||t!==Mh))&&su(e,e.output,e.next_out,p-e.avail_out),c-=e.avail_in,p-=e.avail_out,e.total_in+=c,e.total_out+=p,r.total+=p,4&r.wrap&&p&&(e.adler=r.check=r.flags?fh(r.check,s,p,e.next_out-p):ph(r.check,s,p,e.next_out-p)),e.data_type=r.bits+(r.last?64:0)+(r.mode===jh?128:0)+(r.mode===qh||r.mode===Hh?256:0),(0===c&&0===p||t===Mh)&&C===Bh&&(C=Vh),C},hu=e=>{if(Jh(e))return Oh;let t=e.state;return t.window&&(t.window=null),e.state=null,Bh},uu=(e,t)=>{const r=t.length;let i,s,n;return Jh(e)?Oh:(i=e.state,0!==i.wrap&&i.mode!==Gh?Oh:i.mode===Gh&&(s=1,s=ph(s,t,r,0),s!==i.check)?Rh:(n=su(e,t,r,r),n?(i.mode=16210,Nh):(i.havedict=1,Bh)))},lu=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const cu=Object.prototype.toString,{Z_NO_FLUSH:pu,Z_FINISH:du,Z_OK:fu,Z_STREAM_END:gu,Z_NEED_DICT:mu,Z_STREAM_ERROR:yu,Z_DATA_ERROR:xu,Z_MEM_ERROR:vu}=mh;function bu(e){this.options=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const t in r)yh(r,t)&&(e[t]=r[t])}}return e}({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new wh,this.strm.avail_out=0;let r=au(this.strm,t.windowBits);if(r!==fu)throw new Error(gh[r]);if(this.header=new lu,((e,t)=>{if(Jh(e))return Oh;const r=e.state;2&r.wrap&&(r.head=t,t.done=!1)})(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=(e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,r,i,s,n,a=e.length,o=0;for(s=0;s<a;s++)r=e.charCodeAt(s),55296==(64512&r)&&s+1<a&&(i=e.charCodeAt(s+1),56320==(64512&i)&&(r=65536+(r-55296<<10)+(i-56320),s++)),o+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(o),n=0,s=0;n<o;s++)r=e.charCodeAt(s),55296==(64512&r)&&s+1<a&&(i=e.charCodeAt(s+1),56320==(64512&i)&&(r=65536+(r-55296<<10)+(i-56320),s++)),r<128?t[n++]=r:r<2048?(t[n++]=192|r>>>6,t[n++]=128|63&r):r<65536?(t[n++]=224|r>>>12,t[n++]=128|r>>>6&63,t[n++]=128|63&r):(t[n++]=240|r>>>18,t[n++]=128|r>>>12&63,t[n++]=128|r>>>6&63,t[n++]=128|63&r);return t})(t.dictionary):"[object ArrayBuffer]"===cu.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=uu(this.strm,t.dictionary),r!==fu)))throw new Error(gh[r])}bu.prototype.push=function(e,t){const r=this.strm,i=this.options.chunkSize,s=this.options.dictionary;let n,a,o;if(this.ended)return!1;for(a=t===~~t?t:!0===t?du:pu,"[object ArrayBuffer]"===cu.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),n=ou(r,a),n===mu&&s&&(n=uu(r,s),n===fu?n=ou(r,a):n===xu&&(n=mu));r.avail_in>0&&n===gu&&r.state.wrap>0&&0!==e[r.next_in];)nu(r),n=ou(r,a);switch(n){case yu:case xu:case mu:case vu:return this.onEnd(n),this.ended=!0,!1}if(o=r.avail_out,r.next_out&&(0===r.avail_out||n===gu))if("string"===this.options.to){let e=_h(r.output,r.next_out),t=r.next_out-e,s=bh(r.output,e);r.next_out=t,r.avail_out=i-t,t&&r.output.set(r.output.subarray(e,e+t),0),this.onData(s)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(n!==fu||0!==o){if(n===gu)return n=hu(this.strm),this.onEnd(n),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},bu.prototype.onData=function(e){this.chunks.push(e)},bu.prototype.onEnd=function(e){e===fu&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=(e=>{let t=0;for(let r=0,i=e.length;r<i;r++)t+=e[r].length;const r=new Uint8Array(t);for(let t=0,i=0,s=e.length;t<s;t++){let s=e[t];r.set(s,i),i+=s.length}return r})(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var _u={inflate:function(e,t){const r=new bu(t);if(r.push(e),r.err)throw r.msg||gh[r.err];return r.result}};const{inflate:wu}=_u,Cu={inflate:wu};var Eu,Du={};function Au(e){const t=[];for(let r=0;r<e;r++)t.push(r);return t}Du.parse=function(e){var t=Du.B,r=function(e,t,r,i){var s=Du.T,n={cmap:s.cmap,head:s.head,hhea:s.hhea,maxp:s.maxp,hmtx:s.hmtx,name:s.name,"OS/2":s.OS2,post:s.post,loca:s.loca,kern:s.kern,glyf:s.glyf,"CFF ":s.CFF,GSUB:s.GSUB,CBLC:s.CBLC,CBDT:s.CBDT,"SVG ":s.SVG,COLR:s.colr,CPAL:s.cpal,sbix:s.sbix,fvar:s.fvar,gvar:s.gvar,avar:s.avar,HVAR:s.HVAR},a={_data:e,_index:t,_offset:r};for(var o in n){var h=Du.findTable(e,o,r);if(h){var u=h[0],l=i[u];null==l&&(l=n[o].parseTab(e,u,h[1],a)),a[o]=i[u]=l}}return a},i=new Uint8Array(e);let s;119==i[0]&&(s=i,i=function(e){var r=t.readUshort(e,12),i=t.readUint(e,16),s=new Uint8Array(i),n=12+16*r;t.writeASCII(s,0,"OTTO"),t.writeUshort(s,4,r);for(var a=44,o=0;o<r;o++){var h=t.readASCII(e,a,4),u=t.readUint(e,a+4),l=t.readUint(e,a+8),c=t.readUint(e,a+12);a+=20;var p=e.slice(u,u+l);l!=c&&(p=Cu.inflate(p));var d=12+16*o;t.writeASCII(s,d,h),t.writeUint(s,d+8,n),t.writeUint(s,d+12,c),s.set(p,n),n+=c}return s}(i));var n={};if("ttcf"==t.readASCII(i,0,4)){var a=4;t.readUshort(i,a),a+=2,t.readUshort(i,a),a+=2;var o=t.readUint(i,a);a+=4;for(var h=[],u=0;u<o;u++){var l=t.readUint(i,a);a+=4,h.push(r(i,u,l,n))}return h}var c=r(i,0,0,n);c._compressedData=s;var p=c.fvar;if(p){var d=[c];for(u=0;u<p[1].length;u++){var f=p[1][u],g={};for(var m in d.push(g),c)g[m]=c[m];g._index=u;var y=g.name=JSON.parse(JSON.stringify(g.name));y.fontSubfamily=f[0],null==f[3]&&(f[3]=(y.fontFamily+"-"+y.fontSubfamily).replaceAll(" ","")),y.postScriptName=f[3]}return d}return[c]},Du.findTable=function(e,t,r){for(var i=Du.B,s=i.readUshort(e,r+4),n=r+12,a=0;a<s;a++){var o=i.readASCII(e,n,4);i.readUint(e,n+4);var h=i.readUint(e,n+8),u=i.readUint(e,n+12);if(o==t)return[h,u];n+=16}return null},Du.T={},Du.B={readFixed:function(e,t){return(e[t]<<8|e[t+1])+(e[t+2]<<8|e[t+3])/65540},readF2dot14:function(e,t){return Du.B.readShort(e,t)/16384},readInt:function(e,t){var r=Du.B.t.uint8;return r[0]=e[t+3],r[1]=e[t+2],r[2]=e[t+1],r[3]=e[t],Du.B.t.int32[0]},readInt8:function(e,t){return Du.B.t.uint8[0]=e[t],Du.B.t.int8[0]},readShort:function(e,t){return Du.B.t.uint16[0]=e[t]<<8|e[t+1],Du.B.t.int16[0]},readUshort:function(e,t){return e[t]<<8|e[t+1]},writeUshort:function(e,t,r){e[t]=r>>8&255,e[t+1]=255&r},readUshorts:function(e,t,r){for(var i=[],s=0;s<r;s++){var n=Du.B.readUshort(e,t+2*s);i.push(n)}return i},readUint:function(e,t){var r=Du.B.t.uint8;return r[3]=e[t],r[2]=e[t+1],r[1]=e[t+2],r[0]=e[t+3],Du.B.t.uint32[0]},writeUint:function(e,t,r){e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r},readUint64:function(e,t){return 4294967296*Du.B.readUint(e,t)+Du.B.readUint(e,t+4)},readASCII:function(e,t,r){for(var i="",s=0;s<r;s++)i+=String.fromCharCode(e[t+s]);return i},writeASCII:function(e,t,r){for(var i=0;i<r.length;i++)e[t+i]=r.charCodeAt(i)},readUnicode:function(e,t,r){for(var i="",s=0;s<r;s++){var n=e[t++]<<8|e[t++];i+=String.fromCharCode(n)}return i},_tdec:window.TextDecoder?new window.TextDecoder:null,readUTF8:function(e,t,r){var i=Du.B._tdec;return i&&0==t&&r==e.length?i.decode(e):Du.B.readASCII(e,t,r)},readBytes:function(e,t,r){for(var i=[],s=0;s<r;s++)i.push(e[t+s]);return i},readASCIIArray:function(e,t,r){for(var i=[],s=0;s<r;s++)i.push(String.fromCharCode(e[t+s]));return i},t:(Eu=new ArrayBuffer(8),{buff:Eu,int8:new Int8Array(Eu),uint8:new Uint8Array(Eu),int16:new Int16Array(Eu),uint16:new Uint16Array(Eu),int32:new Int32Array(Eu),uint32:new Uint32Array(Eu)})},Du.T.CFF={parseTab:function(e,t,r){var i=Du.B,s=Du.T.CFF;e=new Uint8Array(e.buffer,t,r),t=0,t++,t++,t++,t++;var n=[];t=s.readIndex(e,t,n);for(var a=[],o=0;o<n.length-1;o++)a.push(i.readASCII(e,t+n[o],n[o+1]-n[o]));t+=n[n.length-1];var h=[];t=s.readIndex(e,t,h);var u=[];for(o=0;o<h.length-1;o++)u.push(s.readDict(e,t+h[o],t+h[o+1]));t+=h[h.length-1];var l=u[0],c=[];t=s.readIndex(e,t,c);var p=[];for(o=0;o<c.length-1;o++)p.push(i.readASCII(e,t+c[o],c[o+1]-c[o]));if(t+=c[c.length-1],s.readSubrs(e,t,l),l.CharStrings&&(l.CharStrings=s.readBytes(e,l.CharStrings)),l.ROS){t=l.FDArray;var d=[];for(t=s.readIndex(e,t,d),l.FDArray=[],o=0;o<d.length-1;o++){var f=s.readDict(e,t+d[o],t+d[o+1]);s._readFDict(e,f,p),l.FDArray.push(f)}t+=d[d.length-1],t=l.FDSelect,l.FDSelect=[];var g=e[t];if(t++,3!=g)throw g;var m=i.readUshort(e,t);for(t+=2,o=0;o<m+1;o++)l.FDSelect.push(i.readUshort(e,t),e[t+2]),t+=3}return l.charset&&(l.charset=s.readCharset(e,l.charset,l.CharStrings.length)),s._readFDict(e,l,p),l},_readFDict:function(e,t,r){var i,s=Du.T.CFF;for(var n in t.Private&&(i=t.Private[1],t.Private=s.readDict(e,i,i+t.Private[0]),t.Private.Subrs&&s.readSubrs(e,i+t.Private.Subrs,t.Private)),t)-1!=["FamilyName","FontName","FullName","Notice","version","Copyright"].indexOf(n)&&(t[n]=r[t[n]-426+35])},readSubrs:function(e,t,r){r.Subrs=Du.T.CFF.readBytes(e,t);var i,s=r.Subrs.length+1;i=s<1240?107:s<33900?1131:32768,r.Bias=i},readBytes:function(e,t){var r=[];t=Du.T.CFF.readIndex(e,t,r);for(var i=[],s=r.length-1,n=e.byteOffset+t,a=0;a<s;a++){var o=r[a];i.push(new Uint8Array(e.buffer,n+o,r[a+1]-o))}return i},tableSE:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,0,111,112,113,114,0,115,116,117,118,119,120,121,122,0,123,0,124,125,126,127,128,129,130,131,0,132,133,0,134,135,136,137,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,138,0,139,0,0,0,0,140,141,142,143,0,0,0,0,0,144,0,0,0,145,0,0,146,147,148,149,0,0,0,0],glyphByUnicode:function(e,t){for(var r=0;r<e.charset.length;r++)if(e.charset[r]==t)return r;return-1},glyphBySE:function(e,t){return t<0||t>255?-1:Du.T.CFF.glyphByUnicode(e,Du.T.CFF.tableSE[t])},readCharset:function(e,t,r){var i=Du.B,s=[".notdef"],n=e[t];if(t++,0==n)for(var a=0;a<r;a++){var o=i.readUshort(e,t);t+=2,s.push(o)}else{if(1!=n&&2!=n)throw"error: format: "+n;for(;s.length<r;){o=i.readUshort(e,t),t+=2;var h=0;for(1==n?(h=e[t],t++):(h=i.readUshort(e,t),t+=2),a=0;a<=h;a++)s.push(o),o++}}return s},readIndex:function(e,t,r){var i=Du.B,s=i.readUshort(e,t)+1,n=e[t+=2];if(t++,1==n)for(var a=0;a<s;a++)r.push(e[t+a]);else if(2==n)for(a=0;a<s;a++)r.push(i.readUshort(e,t+2*a));else if(3==n)for(a=0;a<s;a++)r.push(16777215&i.readUint(e,t+3*a-1));else if(4==n)for(a=0;a<s;a++)r.push(i.readUint(e,t+4*a));else if(1!=s)throw"unsupported offset size: "+n+", count: "+s;return(t+=s*n)-1},getCharString:function(e,t,r){var i=Du.B,s=e[t],n=e[t+1],a=1,o=null,h=null;s<=20&&(o=s,a=1),12==s&&(o=100*s+n,a=2),21<=s&&s<=27&&(o=s,a=1),28==s&&(h=i.readShort(e,t+1),a=3),29<=s&&s<=31&&(o=s,a=1),32<=s&&s<=246&&(h=s-139,a=1),247<=s&&s<=250&&(h=256*(s-247)+n+108,a=2),251<=s&&s<=254&&(h=256*-(s-251)-n-108,a=2),255==s&&(h=i.readInt(e,t+1)/65535,a=5),r.val=null!=h?h:"o"+o,r.size=a},readCharString:function(e,t,r){for(var i=t+r,s=Du.B,n=[];t<i;){var a=e[t],o=e[t+1],h=1,u=null,l=null;a<=20&&(u=a,h=1),12==a&&(u=100*a+o,h=2),19!=a&&20!=a||(u=a,h=2),21<=a&&a<=27&&(u=a,h=1),28==a&&(l=s.readShort(e,t+1),h=3),29<=a&&a<=31&&(u=a,h=1),32<=a&&a<=246&&(l=a-139,h=1),247<=a&&a<=250&&(l=256*(a-247)+o+108,h=2),251<=a&&a<=254&&(l=256*-(a-251)-o-108,h=2),255==a&&(l=s.readInt(e,t+1)/65535,h=5),n.push(null!=l?l:"o"+u),t+=h}return n},readDict:function(e,t,r){for(var i=Du.B,s={},n=[];t<r;){var a=e[t],o=e[t+1],h=1,u=null,l=null;if(28==a&&(l=i.readShort(e,t+1),h=3),29==a&&(l=i.readInt(e,t+1),h=5),32<=a&&a<=246&&(l=a-139,h=1),247<=a&&a<=250&&(l=256*(a-247)+o+108,h=2),251<=a&&a<=254&&(l=256*-(a-251)-o-108,h=2),255==a)throw l=i.readInt(e,t+1)/65535,h=5,"unknown number";if(30==a){var c=[];for(h=1;;){var p=e[t+h];h++;var d=p>>4,f=15&p;if(15!=d&&c.push(d),15!=f&&c.push(f),15==f)break}for(var g="",m=[0,1,2,3,4,5,6,7,8,9,".","e","e-","reserved","-","endOfNumber"],y=0;y<c.length;y++)g+=m[c[y]];l=parseFloat(g)}a<=21&&(u=["version","Notice","FullName","FamilyName","Weight","FontBBox","BlueValues","OtherBlues","FamilyBlues","FamilyOtherBlues","StdHW","StdVW","escape","UniqueID","XUID","charset","Encoding","CharStrings","Private","Subrs","defaultWidthX","nominalWidthX"][a],h=1,12==a&&(u=["Copyright","isFixedPitch","ItalicAngle","UnderlinePosition","UnderlineThickness","PaintType","CharstringType","FontMatrix","StrokeWidth","BlueScale","BlueShift","BlueFuzz","StemSnapH","StemSnapV","ForceBold","","","LanguageGroup","ExpansionFactor","initialRandomSeed","SyntheticBase","PostScript","BaseFontName","BaseFontBlend","","","","","","","ROS","CIDFontVersion","CIDFontRevision","CIDFontType","CIDCount","UIDBase","FDArray","FDSelect","FontName"][o],h=2)),null!=u?(s[u]=1==n.length?n[0]:n,n=[]):n.push(l),t+=h}return s}},Du.T.cmap={parseTab:function(e,t,r){var i={tables:[],ids:{},off:t};e=new Uint8Array(e.buffer,t,r),t=0;var s=Du.B,n=s.readUshort,a=Du.T.cmap;n(e,t);var o=n(e,t+=2);t+=2;for(var h=[],u=0;u<o;u++){var l=n(e,t),c=n(e,t+=2);t+=2;var p=s.readUint(e,t);t+=4;var d="p"+l+"e"+c,f=h.indexOf(p);if(-1==f){f=i.tables.length;var g={};h.push(p);var m=g.format=n(e,p);0==m?g=a.parse0(e,p,g):4==m?g=a.parse4(e,p,g):6==m?g=a.parse6(e,p,g):12==m&&(g=a.parse12(e,p,g)),i.tables.push(g)}null!=i.ids[d]&&console.log("multiple tables for one platform+encoding: "+d),i.ids[d]=f}return i},parse0:function(e,t,r){var i=Du.B;t+=2;var s=i.readUshort(e,t);t+=2,i.readUshort(e,t),t+=2,r.map=[];for(var n=0;n<s-6;n++)r.map.push(e[t+n]);return r},parse4:function(e,t,r){var i=Du.B,s=i.readUshort,n=i.readUshorts,a=t,o=s(e,t+=2);s(e,t+=2);var h=s(e,t+=2);t+=2;var u=h>>>1;r.searchRange=s(e,t),t+=2,r.entrySelector=s(e,t),t+=2,r.rangeShift=s(e,t),t+=2,r.endCount=n(e,t,u),t+=2*u,t+=2,r.startCount=n(e,t,u),t+=2*u,r.idDelta=[];for(var l=0;l<u;l++)r.idDelta.push(i.readShort(e,t)),t+=2;return r.idRangeOffset=n(e,t,u),t+=2*u,r.glyphIdArray=n(e,t,a+o-t>>1),r},parse6:function(e,t,r){var i=Du.B;t+=2,i.readUshort(e,t),t+=2,i.readUshort(e,t),t+=2,r.firstCode=i.readUshort(e,t),t+=2;var s=i.readUshort(e,t);t+=2,r.glyphIdArray=[];for(var n=0;n<s;n++)r.glyphIdArray.push(i.readUshort(e,t)),t+=2;return r},parse12:function(e,t,r){var i=Du.B.readUint;i(e,t+=4),i(e,t+=4);var s=3*i(e,t+=4);t+=4;for(var n=r.groups=new Uint32Array(s),a=0;a<s;a+=3)n[a]=i(e,t+(a<<2)),n[a+1]=i(e,t+(a<<2)+4),n[a+2]=i(e,t+(a<<2)+8);return r}},Du.T.CBLC={parseTab:function(e,t,r){var i=Du.B,s=t;i.readUshort(e,t),t+=2,i.readUshort(e,t),t+=2;var n=i.readUint(e,t);t+=4;for(var a=[],o=0;o<n;o++){var h=i.readUint(e,t);t+=4,i.readUint(e,t),t+=4,i.readUint(e,t),t+=4,t+=4,t+=24,i.readUshort(e,t),t+=2,i.readUshort(e,t),t+=2,t+=4;for(var u=s+h,l=0;l<3;l++){var c=i.readUshort(e,u);u+=2;var p=i.readUshort(e,u);u+=2;var d=i.readUint(e,u);u+=4;var f=p-c+1,g=s+h+d,m=i.readUshort(e,g);if(g+=2,1!=m)throw m;var y=i.readUshort(e,g);g+=2;var x=i.readUint(e,g);g+=4;for(var v=[],b=0;b<f;b++){var _=i.readUint(e,g+4*b);v.push(x+_)}a.push([c,p,y,v])}}return a}},Du.T.CBDT={parseTab:function(e,t,r){return new Uint8Array(e.buffer,e.byteOffset+t,r)}},Du.T.glyf={parseTab:function(e,t,r,i){for(var s=[],n=i.maxp.numGlyphs,a=0;a<n;a++)s.push(null);return s},_parseGlyf:function(e,t){var r=Du.B,i=e._data,s=e.loca;if(s[t]==s[t+1])return null;var n=Du.findTable(i,"glyf",e._offset)[0]+s[t],a={};if(a.noc=r.readShort(i,n),n+=2,a.xMin=r.readShort(i,n),n+=2,a.yMin=r.readShort(i,n),n+=2,a.xMax=r.readShort(i,n),n+=2,a.yMax=r.readShort(i,n),n+=2,a.xMin>=a.xMax||a.yMin>=a.yMax)return null;if(a.noc>0){a.endPts=[];for(var o=0;o<a.noc;o++)a.endPts.push(r.readUshort(i,n)),n+=2;var h=r.readUshort(i,n);if(n+=2,i.length-n<h)return null;a.instructions=r.readBytes(i,n,h),n+=h;var u=a.endPts[a.noc-1]+1;for(a.flags=[],o=0;o<u;o++){var l=i[n];if(n++,a.flags.push(l),8&l){var c=i[n];n++;for(var p=0;p<c;p++)a.flags.push(l),o++}}for(a.xs=[],o=0;o<u;o++){var d=!!(2&a.flags[o]),f=!!(16&a.flags[o]);d?(a.xs.push(f?i[n]:-i[n]),n++):f?a.xs.push(0):(a.xs.push(r.readShort(i,n)),n+=2)}for(a.ys=[],o=0;o<u;o++)d=!!(4&a.flags[o]),f=!!(32&a.flags[o]),d?(a.ys.push(f?i[n]:-i[n]),n++):f?a.ys.push(0):(a.ys.push(r.readShort(i,n)),n+=2);var g=0,m=0;for(o=0;o<u;o++)g+=a.xs[o],m+=a.ys[o],a.xs[o]=g,a.ys[o]=m}else{var y;a.parts=[];do{y=r.readUshort(i,n),n+=2;var x={m:{a:1,b:0,c:0,d:1,tx:0,ty:0},p1:-1,p2:-1};if(a.parts.push(x),x.glyphIndex=r.readUshort(i,n),n+=2,1&y){var v=r.readShort(i,n);n+=2;var b=r.readShort(i,n);n+=2}else v=r.readInt8(i,n),n++,b=r.readInt8(i,n),n++;2&y?(x.m.tx=v,x.m.ty=b):(x.p1=v,x.p2=b),8&y?(x.m.a=x.m.d=r.readF2dot14(i,n),n+=2):64&y?(x.m.a=r.readF2dot14(i,n),n+=2,x.m.d=r.readF2dot14(i,n),n+=2):128&y&&(x.m.a=r.readF2dot14(i,n),n+=2,x.m.b=r.readF2dot14(i,n),n+=2,x.m.c=r.readF2dot14(i,n),n+=2,x.m.d=r.readF2dot14(i,n),n+=2)}while(32&y);if(256&y){var _=r.readUshort(i,n);for(n+=2,a.instr=[],o=0;o<_;o++)a.instr.push(i[n]),n++}}return a}},Du.T.head={parseTab:function(e,t,r){var i=Du.B,s={};return i.readFixed(e,t),t+=4,s.fontRevision=i.readFixed(e,t),t+=4,i.readUint(e,t),t+=4,i.readUint(e,t),t+=4,s.flags=i.readUshort(e,t),t+=2,s.unitsPerEm=i.readUshort(e,t),t+=2,s.created=i.readUint64(e,t),t+=8,s.modified=i.readUint64(e,t),t+=8,s.xMin=i.readShort(e,t),t+=2,s.yMin=i.readShort(e,t),t+=2,s.xMax=i.readShort(e,t),t+=2,s.yMax=i.readShort(e,t),t+=2,s.macStyle=i.readUshort(e,t),t+=2,s.lowestRecPPEM=i.readUshort(e,t),t+=2,s.fontDirectionHint=i.readShort(e,t),t+=2,s.indexToLocFormat=i.readShort(e,t),t+=2,s.glyphDataFormat=i.readShort(e,t),t+=2,s}},Du.T.hhea={parseTab:function(e,t,r){var i=Du.B,s={};i.readFixed(e,t),t+=4;for(var n=["ascender","descender","lineGap","advanceWidthMax","minLeftSideBearing","minRightSideBearing","xMaxExtent","caretSlopeRise","caretSlopeRun","caretOffset","res0","res1","res2","res3","metricDataFormat","numberOfHMetrics"],a=0;a<n.length;a++){var o=n[a],h="advanceWidthMax"==o||"numberOfHMetrics"==o?i.readUshort:i.readShort;s[o]=h(e,t+2*a)}return s}},Du.T.hmtx={parseTab:function(e,t,r,i){for(var s=Du.B,n=[],a=[],o=i.maxp.numGlyphs,h=i.hhea.numberOfHMetrics,u=0,l=0,c=0;c<h;)u=s.readUshort(e,t+(c<<2)),l=s.readShort(e,t+(c<<2)+2),n.push(u),a.push(l),c++;for(;c<o;)n.push(u),a.push(l),c++;return{aWidth:n,lsBearing:a}}},Du.T.kern={parseTab:function(e,t,r,i){var s=Du.B,n=Du.T.kern;if(1==s.readUshort(e,t))return n.parseV1(e,t,r,i);var a=s.readUshort(e,t+2);t+=4;for(var o={glyph1:[],rval:[]},h=0;h<a;h++){t+=2,r=s.readUshort(e,t),t+=2;var u=s.readUshort(e,t);t+=2;var l=u>>>8;0==(l&=15)&&(t=n.readFormat0(e,t,o))}return o},parseV1:function(e,t,r,i){var s=Du.B,n=Du.T.kern;s.readFixed(e,t);var a=s.readUint(e,t+4);t+=8;for(var o={glyph1:[],rval:[]},h=0;h<a;h++){s.readUint(e,t),t+=4;var u=s.readUshort(e,t);t+=2,s.readUshort(e,t),t+=2,!(255&u)&&(t=n.readFormat0(e,t,o))}return o},readFormat0:function(e,t,r){var i=Du.B,s=i.readUshort,n=-1,a=s(e,t);s(e,t+2),s(e,t+4),s(e,t+6),t+=8;for(var o=0;o<a;o++){var h=s(e,t),u=s(e,t+=2);t+=2;var l=i.readShort(e,t);t+=2,h!=n&&(r.glyph1.push(h),r.rval.push({glyph2:[],vals:[]}));var c=r.rval[r.rval.length-1];c.glyph2.push(u),c.vals.push(l),n=h}return t}},Du.T.loca={parseTab:function(e,t,r,i){var s=Du.B,n=[],a=i.head.indexToLocFormat,o=i.maxp.numGlyphs+1;if(0==a)for(var h=0;h<o;h++)n.push(s.readUshort(e,t+(h<<1))<<1);if(1==a)for(h=0;h<o;h++)n.push(s.readUint(e,t+(h<<2)));return n}},Du.T.maxp={parseTab:function(e,t,r){var i=Du.B,s=i.readUshort,n={};return i.readUint(e,t),t+=4,n.numGlyphs=s(e,t),t+=2,n}},Du.T.name={parseTab:function(e,t,r){var i=Du.B,s={};i.readUshort(e,t),t+=2;var n=i.readUshort(e,t);t+=2;for(var a=i.readUshort(e,t),o=(t+=2)-6+a,h=["copyright","fontFamily","fontSubfamily","ID","fullName","version","postScriptName","trademark","manufacturer","designer","description","urlVendor","urlDesigner","licence","licenceURL","---","typoFamilyName","typoSubfamilyName","compatibleFull","sampleText","postScriptCID","wwsFamilyName","wwsSubfamilyName","lightPalette","darkPalette"],u=i.readUshort,l=0;l<n;l++){var c=u(e,t),p=u(e,t+=2),d=u(e,t+=2),f=u(e,t+=2),g=u(e,t+=2),m=u(e,t+=2);t+=2;var y,x=o+m;0==c||3==c&&0==p||1==c&&25==p?y=i.readUnicode(e,x,g/2):0==p?y=i.readASCII(e,x,g):1==p||3==p||4==p||5==p||10==p?y=i.readUnicode(e,x,g/2):1==c?(y=i.readASCII(e,x,g),console.log("reading unknown MAC encoding "+p+" as ASCII")):(console.log("unknown encoding "+p+", platformID: "+c),y=i.readASCII(e,x,g));var v="p"+c+","+d.toString(16);null==s[v]&&(s[v]={});var b=h[f];null==b&&(b="_"+f),s[v][b]=y,s[v]._lang=d}var _=Du.T.name.selectOne(s),w="fontFamily";if(null==_[w])for(var C in s)null!=s[C][w]&&(_[w]=s[C][w]);return _},selectOne:function(e){var t,r="postScriptName";for(var i in e)if(null!=e[i][r]&&1033==e[i]._lang)return e[i];for(var i in e)if(null!=e[i][r]&&0==e[i]._lang)return e[i];for(var i in e)if(null!=e[i][r]&&3084==e[i]._lang)return e[i];for(var i in e)if(null!=e[i][r])return e[i];for(var i in e){t=e[i];break}return console.log("returning name table with languageID "+t._lang),null==t[r]&&null!=t.ID&&(t[r]=t.ID),t}},Du.T.OS2={parseTab:function(e,t,r){var i=Du.B.readUshort(e,t);t+=2;var s=Du.T.OS2,n={};if(0==i)s.version0(e,t,n);else if(1==i)s.version1(e,t,n);else if(2==i||3==i||4==i)s.version2(e,t,n);else{if(5!=i)throw"unknown OS/2 table version: "+i;s.version5(e,t,n)}return n},version0:function(e,t,r){var i=Du.B;return r.xAvgCharWidth=i.readShort(e,t),t+=2,r.usWeightClass=i.readUshort(e,t),t+=2,r.usWidthClass=i.readUshort(e,t),t+=2,r.fsType=i.readUshort(e,t),t+=2,r.ySubscriptXSize=i.readShort(e,t),t+=2,r.ySubscriptYSize=i.readShort(e,t),t+=2,r.ySubscriptXOffset=i.readShort(e,t),t+=2,r.ySubscriptYOffset=i.readShort(e,t),t+=2,r.ySuperscriptXSize=i.readShort(e,t),t+=2,r.ySuperscriptYSize=i.readShort(e,t),t+=2,r.ySuperscriptXOffset=i.readShort(e,t),t+=2,r.ySuperscriptYOffset=i.readShort(e,t),t+=2,r.yStrikeoutSize=i.readShort(e,t),t+=2,r.yStrikeoutPosition=i.readShort(e,t),t+=2,r.sFamilyClass=i.readShort(e,t),t+=2,r.panose=i.readBytes(e,t,10),t+=10,r.ulUnicodeRange1=i.readUint(e,t),t+=4,r.ulUnicodeRange2=i.readUint(e,t),t+=4,r.ulUnicodeRange3=i.readUint(e,t),t+=4,r.ulUnicodeRange4=i.readUint(e,t),t+=4,r.achVendID=i.readASCII(e,t,4),t+=4,r.fsSelection=i.readUshort(e,t),t+=2,r.usFirstCharIndex=i.readUshort(e,t),t+=2,r.usLastCharIndex=i.readUshort(e,t),t+=2,r.sTypoAscender=i.readShort(e,t),t+=2,r.sTypoDescender=i.readShort(e,t),t+=2,r.sTypoLineGap=i.readShort(e,t),t+=2,r.usWinAscent=i.readUshort(e,t),t+=2,r.usWinDescent=i.readUshort(e,t),t+2},version1:function(e,t,r){var i=Du.B;return t=Du.T.OS2.version0(e,t,r),r.ulCodePageRange1=i.readUint(e,t),t+=4,r.ulCodePageRange2=i.readUint(e,t),t+4},version2:function(e,t,r){var i=Du.B,s=i.readUshort;return t=Du.T.OS2.version1(e,t,r),r.sxHeight=i.readShort(e,t),t+=2,r.sCapHeight=i.readShort(e,t),t+=2,r.usDefault=s(e,t),t+=2,r.usBreak=s(e,t),t+=2,r.usMaxContext=s(e,t),t+2},version5:function(e,t,r){var i=Du.B.readUshort;return t=Du.T.OS2.version2(e,t,r),r.usLowerOpticalPointSize=i(e,t),t+=2,r.usUpperOpticalPointSize=i(e,t),t+2}},Du.T.post={parseTab:function(e,t,r){var i=Du.B,s={};return s.version=i.readFixed(e,t),t+=4,s.italicAngle=i.readFixed(e,t),t+=4,s.underlinePosition=i.readShort(e,t),t+=2,s.underlineThickness=i.readShort(e,t),t+=2,s}},Du.T.SVG={parseTab:function(e,t,r){var i=Du.B,s={entries:[],svgs:[]},n=t;i.readUshort(e,t),t+=2;var a=i.readUint(e,t);t+=4,i.readUint(e,t),t+=4,t=a+n;var o=i.readUshort(e,t);t+=2;for(var h=0;h<o;h++){var u=i.readUshort(e,t);t+=2;var l=i.readUshort(e,t);t+=2;var c=i.readUint(e,t);t+=4;var p=i.readUint(e,t);t+=4;var d=new Uint8Array(e.buffer,n+c+a,p);31==d[0]&&139==d[1]&&8==d[2]&&(d=Cu.inflate(d));for(var f=i.readUTF8(d,0,d.length),g=u;g<=l;g++)s.entries[g]=s.svgs.length;s.svgs.push(f)}return s}},Du.T.sbix={parseTab:function(e,t,r,i){for(var s=i.maxp.numGlyphs,n=t,a=Du.B,o=a.readUint(e,t+4),h=[],u=o-1;u<o;u++)for(var l=n+a.readUint(e,t+8+4*u),c=0;c<s;c++){var p=a.readUint(e,l+4+4*c),d=a.readUint(e,l+4+4*c+4);if(p!=d){var f=l+p,g=a.readASCII(e,f+4,4);if("png "!=g)throw g;h[c]=new Uint8Array(e.buffer,e.byteOffset+f+8,d-p-8)}else h[c]=null}return h}},Du.T.colr={parseTab:function(e,t,r){var i=Du.B,s=t;t+=2;var n=i.readUshort(e,t);t+=2;var a=i.readUint(e,t);t+=4;var o=i.readUint(e,t);t+=4;var h=i.readUshort(e,t);t+=2;for(var u={},l=s+a,c=0;c<n;c++)u["g"+i.readUshort(e,l)]=[i.readUshort(e,l+2),i.readUshort(e,l+4)],l+=6;var p=[];for(l=s+o,c=0;c<h;c++)p.push(i.readUshort(e,l),i.readUshort(e,l+2)),l+=4;return[u,p]}},Du.T.cpal={parseTab:function(e,t,r){var i=Du.B,s=t,n=i.readUshort(e,t);if(t+=2,0==n){i.readUshort(e,t),t+=2,i.readUshort(e,t),t+=2;var a=i.readUshort(e,t);t+=2;var o=i.readUint(e,t);return t+=4,new Uint8Array(e.buffer,s+o,4*a)}throw n}},Du.T.GSUB={parseTab:function(e,t,r,i){var s=Du.B,n=s.readUshort,a=t;n(e,a),n(e,a+=2),n(e,a+=2);var o=n(e,a+=2);n(e,a+=2),a+=2;var h={},u=n(e,a=t+o);a+=2;for(var l=0;l<u;l++){var c=s.readASCII(e,a,4);n(e,a+=4),a+=2,h[c]=!0}return h}},Du.T.fvar={parseTab:function(e,t,r,i){var s=i.name,n=t,a=Du.B,o=[],h=[];n+=8;var u=a.readUshort(e,n);n+=2,n+=2;var l=a.readUshort(e,n);n+=2;var c=a.readUshort(e,n);n+=2;for(var p=0;p<u;p++){var d=a.readASCII(e,n,4),f=a.readFixed(e,n+4),g=a.readFixed(e,n+8),m=a.readFixed(e,n+12),y=a.readUshort(e,n+16),x=a.readUshort(e,n+18);o.push([d,f,g,m,y,s["_"+x]]),n+=20}for(p=0;p<l;p++){for(var v=a.readUshort(e,n),b=null,_=(y=a.readUshort(e,n+2),[]),w=0;w<u;w++)_.push(a.readFixed(e,n+4+4*w));n+=4+4*u,2==(3&c)&&(b=a.readUshort(e,n),n+=2),h.push([s["_"+v],y,_,b])}return[o,h]}},Du.T.gvar=function(){var e=Du.B;function t(t,r,i){for(var s=[],n=0;n<i;n++)s.push(e.readF2dot14(t,r+2*n));return s}function r(r,i,s,n,a){for(var o=[],h=0;h<s;h++){var u=e.readUshort(r,i);i+=2;var l=e.readUshort(r,i),c=61440&l;l&=4095,i+=2;var p=null,d=null,f=null;32768&c&&(p=t(r,i,n),i+=2*n),16384&c&&(d=t(r,i,n),i+=2*n),16384&c&&(f=t(r,i,n),i+=2*n),o.push([u,l,c,d,p,f])}return o}function i(t,r,i){var s=t[r];if(r++,0==s)return[[],r];127<s&&(s=(127&s)<<8|t[r++]);for(var n=[],a=0;n.length<s;){var o=t[r];r++;var h=!!(128&o);o=1+(127&o);for(var u=0;u<o;u++){var l=0;h?(l=e.readUshort(t,r),r+=2):(l=t[r],r++),a+=l,n.push(a)}}return[n,r]}return{parseTab:function(s,n,a,o){var h=n+4,u=e.readUshort(s,h);h+=2;var l=e.readUshort(s,h);h+=2;var c=e.readUint(s,h);h+=4;var p=e.readUshort(s,h);h+=2,e.readUshort(s,h),h+=2;var d=e.readUint(s,h);h+=4;for(var f=[],g=0;g<p+1;g++)f.push(e.readUint(s,h+4*g));var m=[],y=[],x=[];for(h=n+c,g=0;g<l;g++){var v=t(s,h+g*u*2,u),b=[],_=[];m.push(v),y.push(b),x.push(_);for(var w=0;w<u;w++)b[w]=Math.min(v[w],0),_[w]=Math.max(v[w],0)}var C=new Int8Array(s.buffer),E=[];for(g=0;g<p;g++){h=n+d+f[g];var D=e.readUshort(s,h);h+=2;var A=32768&D;D&=4095;var S=e.readUshort(s,h),F=r(s,h+=2,D,u),T=[];E.push(T),h=n+d+f[g]+S;var M=null;A&&(M=(I=i(s,h))[0],h=I[1]);for(var k=0;k<D;k++){var I,B=F[k],L=h+B[0],P=M;8192&B[2]&&(P=(I=i(s,h))[0],h=I[1]);for(var O=[];h<L;){var R=s[h++],N=1+(63&R);if(128&R)for(w=0;w<N;w++)O.push(0);else if(64&R){for(w=0;w<N;w++)O.push(e.readShort(s,h+2*w));h+=2*N}else{for(w=0;w<N;w++)O.push(C[h+w]);h+=N}}var V=B[1];if(T.push([[B[3]?B[3]:y[V],B[4]?B[4]:m[V],B[5]?B[5]:x[V]],O,0==P.length?null:P]),0!=P.length&&2*P.length!=O.length)throw"e"}}return E}}}(),Du.T.avar={parseTab:function(e,t,r,i){var s=t,n=Du.B,a=[];s+=6;var o=n.readUshort(e,s);s+=2;for(var h=0;h<o;h++){var u=n.readUshort(e,s);s+=2;var l=[];a.push(l);for(var c=0;c<u;c++){var p=n.readF2dot14(e,s),d=n.readF2dot14(e,s+2);s+=4,l.push(p,d)}}return a}},Du.T.HVAR={parseTab:function(e,t,r,i){var s=t,n=t,a=Du.B;s+=4;var o=a.readUint(e,s);s+=4;var h=a.readUint(e,s);s+=4;var u=a.readUint(e,s);s+=4;var l=a.readUint(e,s);if(s+=4,0!=u||0!=l)throw u;var c=s=n+o,p=a.readUshort(e,s);if(s+=2,1!=p)throw"e";var d=a.readUint(e,s);s+=4;var f=a.readUshort(e,s);s+=2;for(var g=[],m=0;m<f;m++)g.push(a.readUint(e,s+4*m));s+=4*f,s=c+d;var y=a.readUshort(e,s);s+=2;var x=a.readUshort(e,s);s+=2;var v=[];for(m=0;m<x;m++){var b=[[],[],[]];v.push(b);for(var _=0;_<y;_++)b[0].push(a.readF2dot14(e,s+0)),b[1].push(a.readF2dot14(e,s+2)),b[2].push(a.readF2dot14(e,s+4)),s+=6}var w=new Int8Array(e.buffer),C=[];for(m=0;m<g.length;m++){s=n+o+g[m];var E=[];C.push(E);var D=a.readUshort(e,s);s+=2;var A=a.readUshort(e,s);if(s+=2,32768&A)throw"e";x=a.readUshort(e,s),s+=2;var S=[];for(_=0;_<x;_++)S.push(a.readUshort(e,s+2*_));s+=2*x;for(var F=0;F<D;F++){for(var T=[],M=0;M<x;M++)T.push(M<A?a.readShort(e,s):w[s]),s+=M<A?2:1;var k=new Array(v.length);for(k.fill(0),E.push(k),_=0;_<S.length;_++)k[S[_]]=T[_]}}if(s=n+h,0!=(p=e[s++]))throw"e";var I=e[s++],B=a.readUshort(e,s);s+=2;var L=1+((48&I)>>4),P=[];for(m=0;m<B;m++){var O=0;1==L?O=e[s++]:(O=a.readUshort(e,s),s+=2);var R=O>>1+(15&I),N=O&(1<<1+(15&I))-1;P.push(C[R][N])}return[v,P]}},Du.U=function(){var e=function(e,t,r){e.cmds.push("M"),e.crds.push(t,r)},t=function(e,t,r){e.cmds.push("L"),e.crds.push(t,r)},r=function(e,t,r,i,s,n,a){e.cmds.push("C"),e.crds.push(t,r,i,s,n,a)},i=function(e,t,r,i,s){e.cmds.push("Q"),e.crds.push(t,r,i,s)},s=function(e){e.cmds.push("Z")};function n(e,t,r,i){var s=t[r],n=t[r+1],a=e.kern;if(a){var o=a.glyph1.indexOf(s);if(-1!=o){var h=a.rval[o].glyph2.indexOf(n);if(-1!=h)return[0,0,a.rval[o].vals[h],0]}}return[0,0,0,0]}function a(e,t,r){for(var i=0,s=~~(e.length/t);i+1!=s;){var n=i+(s-i>>>1);e[n*t]<=r?i=n:s=n}return i*t}for(var o,h,u=[9,10,11,12,13,32,133,160,5760,6158,8232,8233,8239,8288,12288,65279],l={},c=0;c<u.length;c++)l[u[c]]=1;for(c=8192;c<=8205;c++)l[c]=1;function p(e,t){if(null==e._ctab){for(var r=e.cmap,i=-1,s=["p3e10","p0e4","p3e1","p1e0","p0e3","p0e1","p3e0","p3e5"],n=0;n<s.length;n++)if(null!=r.ids[s[n]]){i=r.ids[s[n]];break}if(-1==i)throw"no familiar platform and encoding!";e._ctab=r.tables[i]}var o=e._ctab,h=o.format,u=-1;if(0==h)u=t>=o.map.length?0:o.map[t];else if(4==h){var c=o.endCount;if(u=0,t<=c[c.length-1]){var p=a(c,1,t);c[p]<t&&p++,t>=o.startCount[p]&&(u=65535&(0!=o.idRangeOffset[p]?o.glyphIdArray[t-o.startCount[p]+(o.idRangeOffset[p]>>1)-(o.idRangeOffset.length-p)]:t+o.idDelta[p]))}}else if(6==h){var d=t-o.firstCode,f=o.glyphIdArray;u=d<0||d>=f.length?0:f[d]}else{if(12!=h)throw"unknown cmap table format "+o.format;var g=o.groups;u=0,t<=g[g.length-2]&&g[n=a(g,3,t)]<=t&&t<=g[n+1]&&(u=g[n+2]+(t-g[n]))}var m=e["SVG "],y=e.loca;return 0==u||null!=e["CFF "]||null!=m&&null!=m.entries[u]||!y||y[u]!=y[u+1]||null!=l[t]||(u=0),u}function d(e,t,r,i){var s={cmds:[],crds:[]};e.fvar&&(null==i&&(i=e.fvar[1][e._index][2]),i=m(e,i));var n=e["SVG "],a=e["CFF "],o=e.COLR,h=e.CBLC,u=e.CBDT,l=e.sbix,c=window.UPNG,p=null;if(h&&c)for(var g=0;g<h.length;g++)h[g][0]<=t&&t<=h[g][1]&&(p=h[g]);if(p||l&&l[t]){if(p&&17!=p[2])throw"not a PNG";null==e.__tmp&&(e.__tmp={});var y=e.__tmp["g"+t];if(null==y){var x,b;if(l)b=(x=l[t]).length;else{var _=p[3][t-p[0]]+5;b=u[_+1]<<16|u[_+2]<<8|u[_+3],_+=4,x=new Uint8Array(u.buffer,u.byteOffset+_,b)}var w="";for(g=0;g<b;g++)w+=String.fromCharCode(x[g]);y=e.__tmp["g"+t]="data:image/png;base64,"+btoa(w)}s.cmds.push(y);var C=1.15*e.head.unitsPerEm,E=Math.round(C),D=Math.round(C),A=Math.round(.15*-D);s.crds.push(0,D+A,E,D+A,E,A,0,A)}else if(n&&n.entries[t]){var S=n.entries[t];if(null!=S){if("number"==typeof S){var F=n.svgs[S];if("string"==typeof F){var T=(new DOMParser).parseFromString(F,"image/svg+xml");F=n.svgs[S]=T.getElementsByTagName("svg")[0]}S=Du.U.SVG.toPath(F,t),n.entries[t]=S}s=S}}else if(1!=r&&o&&o[0]["g"+t]&&o[0]["g"+t][1]>1){function U(e){var t=e.toString(16);return(1==t.length?"0":"")+t}var M=e.CPAL,k=o[0]["g"+t];for(g=0;g<k[1];g++){var I=k[0]+g,B=o[1][2*I],L=4*o[1][2*I+1],P=d(e,B,B==t),O="#"+U(M[L+2])+U(M[L+1])+U(M[L+0]);s.cmds.push(O),s.cmds=s.cmds.concat(P.cmds),s.crds=s.crds.concat(P.crds),s.cmds.push("X")}}else if(a){var R=a.Private,N={x:0,y:0,stack:[],nStems:0,haveWidth:!1,width:R?R.defaultWidthX:0,open:!1};if(a.ROS){for(var V=0;a.FDSelect[V+2]<=t;)V+=2;R=a.FDArray[a.FDSelect[V+1]].Private}v(a.CharStrings[t],N,a,R,s)}else e.glyf&&f(t,e,s,i);return{cmds:s.cmds,crds:s.crds}}function f(r,n,a,o){var h=n.glyf[r];null==h&&(h=n.glyf[r]=Du.T.glyf._parseGlyf(n,r)),null!=h&&(h.noc>-1?function(r,n,a,o,h){var u=r.xs,l=r.ys;if(n.fvar&&h){u=u.slice(0),l=l.slice(0);for(var c=n.gvar,p=c?c[a]:null,d=0;d<p.length;d++){var f=g(p[d][0],h);if(!(f<1e-9)){var m=p[d][1],x=p[d][2];if(x&&(m=p[d][1]=y(m,x,u,l,r.endPts),p[d][2]=null),m.length==2*u.length+8)for(var v=0;v<u.length;v++)u[v]+=f*m[v],l[v]+=f*m[v+u.length+4]}}}for(var b=0;b<r.noc;b++){var _=0==b?0:r.endPts[b-1]+1,w=r.endPts[b];for(v=_;v<=w;v++){var C=v==_?w:v-1,E=v==w?_:v+1,D=1&r.flags[v],A=1&r.flags[C],S=1&r.flags[E],F=u[v],T=l[v];if(v==_)if(D){if(!A){e(o,F,T);continue}e(o,u[C],l[C])}else A?e(o,u[C],l[C]):e(o,Math.floor(.5*(u[C]+F)),Math.floor(.5*(l[C]+T)));D?A&&t(o,F,T):S?i(o,F,T,u[E],l[E]):i(o,F,T,Math.floor(.5*(F+u[E])),Math.floor(.5*(T+l[E])))}s(o)}}(h,n,r,a,o):function(e,t,r,i,s){var n=[0,0,0,0,0,0],a=[0,0,0,0,0,0],o=e.parts.length;if(t.fvar&&s)for(var h=t.gvar,u=h?h[r]:null,l=0;l<u.length;l++){var c=g(u[l][0],s);if(!(c<1e-6)){var p=u[l][1],d=u[l][2];if(null==d)for(var m=0;m<o;m++)n[m]+=c*p[m],a[m]+=c*p[m+o+4];else for(var y=0;y<d.length;y++)n[m=d[y]]+=c*p[0],a[m]+=c*p[0+o]}}for(y=0;y<o;y++){var x={cmds:[],crds:[]},v=e.parts[y];f(v.glyphIndex,t,x,s);var b=v.m,_=b.tx+n[y],w=b.ty+a[y];for(m=0;m<x.crds.length;m+=2){var C=x.crds[m],E=x.crds[m+1];i.crds.push(C*b.a+E*b.c+_),i.crds.push(C*b.b+E*b.d+w)}for(m=0;m<x.cmds.length;m++)i.cmds.push(x.cmds[m])}}(h,n,r,a,o))}function g(e,t){for(var r=1,i=e[0],s=e[1],n=e[2],a=0;a<t.length;a++)r*=i[a]>s[a]||s[a]>n[a]||i[a]<0&&n[a]>0&&0!=s[a]||0==s[a]?1:t[a]<i[a]||t[a]>n[a]?0:t[a]==s[a]?1:t[a]<s[a]?(t[a]-i[a])/(s[a]-i[a]):(n[a]-t[a])/(n[a]-s[a]);return r}function m(e,t){for(var r=e.fvar,i=e.avar,s=r?r[0]:null,n=[],a=0;a<s.length;a++){var o=s[a][1],h=s[a][2],u=s[a][3],l=Math.max(o,Math.min(u,t[a]));if(n[a]=l<h?(h-l)/(o-h):l>h?(l-h)/(u-h):0,i&&-1!=n[a]){for(var c=i[a],p=0;p<c.length&&!(c[p]>=n[a]);p+=2);var d=(n[a]-c[p-2])/(c[p]-c[p-2]);n[a]=d*c[p+1]+(1-d)*c[p-1]}}return n}function y(e,t,r,i,s){var n=r.length,a=new Array(2*n+8);a.fill(0);for(var o=0;o<n;o++){var h=0,u=0,l=t.indexOf(o);if(-1!=l)h=e[l],u=e[t.length+l];else{for(var c=0;s[c]<o;)c++;for(var p=0==c?0:s[c-1]+1,d=s[c],f=-1,g=-1,m=0;m<t.length;m++)(y=t[m])<p||y>d||y>=n||(f=m,-1==g&&(g=m));for(m=0;m<t.length;m++){var y;if(!((y=t[m])<p||y>d||y>=n)&&(y<o&&(f=m),o<y)){g=m;break}}for(var x=0;x<2;x++){var v=0==x?r:i,b=x*t.length,_=0,w=v[t[f]],C=v[t[g]],E=v[o],D=e[b+f],A=e[b+g];if(w==C)_=D==A?D:0;else if(E<=Math.min(w,C))_=w<C?D:A;else if(Math.max(w,C)<=E)_=w<C?A:D;else{var S=(E-w)/(C-w);_=S*A+(1-S)*D}0==x?h=_:u=_}}a[o]=h,a[n+4+o]=u}return a}function x(e,t,r,i){for(var s=t>>1,n=r>>1,a=new Uint8Array(s*n*4),o=new Uint32Array(e.buffer),h=new Uint32Array(a.buffer),u=0;u<n;u++)for(var l=0;l<s;l++){var c=u*s+l,p=(u<<1)*t+(l<<1),d=o[p],f=o[p+1],g=o[p+t],m=o[p+t+1],y=d>>>24,x=f>>>24,v=g>>>24,b=m>>>24,_=y+x+v+b;if(1020==_){var w=(d>>>0&255)+(f>>>0&255)+(g>>>0&255)+(m>>>0&255)+2>>>2,C=(d>>>8&255)+(f>>>8&255)+(g>>>8&255)+(m>>>8&255)+2>>>2,E=(d>>>16&255)+(f>>>16&255)+(g>>>16&255)+(m>>>16&255)+2>>>2;h[c]=255<<24|E<<16|C<<8|w}else if(0==_)h[c]=0;else{var D=1/_;w=~~((w=(d>>>0&255)*y+(f>>>0&255)*x+(g>>>0&255)*v+(m>>>0&255)*b)*D+.5),C=~~((C=(d>>>8&255)*y+(f>>>8&255)*x+(g>>>8&255)*v+(m>>>8&255)*b)*D+.5),E=~~((E=(d>>>16&255)*y+(f>>>16&255)*x+(g>>>16&255)*v+(m>>>16&255)*b)*D+.5),h[c]=_+2>>>2<<24|E<<16|C<<8|w}}return{buff:a,w:s,h:n}}function v(i,n,a,o,h){for(var u=n.stack,l=n.nStems,c=n.haveWidth,p=n.width,d=n.open,f=0,g=n.x,m=n.y,y=0,x=0,b=0,_=0,w=0,C=0,E=0,D=0,A=0,S=0,F=Du.T.CFF,T=o.nominalWidthX,M={val:0,size:0};f<i.length;){F.getCharString(i,f,M);var k=M.val;if(f+=M.size,"o1"==k||"o18"==k)u.length%2!=0&&!c&&(p=u.shift()+T),l+=u.length>>1,u.length=0,c=!0;else if("o3"==k||"o23"==k)u.length%2!=0&&!c&&(p=u.shift()+T),l+=u.length>>1,u.length=0,c=!0;else if("o4"==k)u.length>1&&!c&&(p=u.shift()+T,c=!0),d&&s(h),m+=u.pop(),e(h,g,m),d=!0;else if("o5"==k)for(;u.length>0;)g+=u.shift(),m+=u.shift(),t(h,g,m);else if("o6"==k||"o7"==k)for(var I=u.length,B="o6"==k,L=0;L<I;L++){var P=u.shift();B?g+=P:m+=P,B=!B,t(h,g,m)}else if("o8"==k||"o24"==k){I=u.length;for(var O=0;O+6<=I;)y=g+u.shift(),x=m+u.shift(),b=y+u.shift(),_=x+u.shift(),g=b+u.shift(),m=_+u.shift(),r(h,y,x,b,_,g,m),O+=6;"o24"==k&&(g+=u.shift(),m+=u.shift(),t(h,g,m))}else{if("o11"==k)break;if("o1234"==k||"o1235"==k||"o1236"==k||"o1237"==k)"o1234"==k&&(x=m,b=(y=g+u.shift())+u.shift(),S=_=x+u.shift(),C=_,D=m,g=(E=(w=(A=b+u.shift())+u.shift())+u.shift())+u.shift(),r(h,y,x,b,_,A,S),r(h,w,C,E,D,g,m)),"o1235"==k&&(y=g+u.shift(),x=m+u.shift(),b=y+u.shift(),_=x+u.shift(),A=b+u.shift(),S=_+u.shift(),w=A+u.shift(),C=S+u.shift(),E=w+u.shift(),D=C+u.shift(),g=E+u.shift(),m=D+u.shift(),u.shift(),r(h,y,x,b,_,A,S),r(h,w,C,E,D,g,m)),"o1236"==k&&(y=g+u.shift(),x=m+u.shift(),b=y+u.shift(),S=_=x+u.shift(),C=_,E=(w=(A=b+u.shift())+u.shift())+u.shift(),D=C+u.shift(),g=E+u.shift(),r(h,y,x,b,_,A,S),r(h,w,C,E,D,g,m)),"o1237"==k&&(y=g+u.shift(),x=m+u.shift(),b=y+u.shift(),_=x+u.shift(),A=b+u.shift(),S=_+u.shift(),w=A+u.shift(),C=S+u.shift(),E=w+u.shift(),D=C+u.shift(),Math.abs(E-g)>Math.abs(D-m)?g=E+u.shift():m=D+u.shift(),r(h,y,x,b,_,A,S),r(h,w,C,E,D,g,m));else if("o14"==k){if(u.length>0&&4!=u.length&&!c&&(p=u.shift()+a.nominalWidthX,c=!0),4==u.length){var R=u.shift(),N=u.shift(),V=u.shift(),U=u.shift(),z=F.glyphBySE(a,V),G=F.glyphBySE(a,U);v(a.CharStrings[z],n,a,o,h),n.x=R,n.y=N,v(a.CharStrings[G],n,a,o,h)}d&&(s(h),d=!1)}else if("o19"==k||"o20"==k)u.length%2!=0&&!c&&(p=u.shift()+T),l+=u.length>>1,u.length=0,c=!0,f+=l+7>>3;else if("o21"==k)u.length>2&&!c&&(p=u.shift()+T,c=!0),m+=u.pop(),g+=u.pop(),d&&s(h),e(h,g,m),d=!0;else if("o22"==k)u.length>1&&!c&&(p=u.shift()+T,c=!0),g+=u.pop(),d&&s(h),e(h,g,m),d=!0;else if("o25"==k){for(;u.length>6;)g+=u.shift(),m+=u.shift(),t(h,g,m);y=g+u.shift(),x=m+u.shift(),b=y+u.shift(),_=x+u.shift(),g=b+u.shift(),m=_+u.shift(),r(h,y,x,b,_,g,m)}else if("o26"==k)for(u.length%2&&(g+=u.shift());u.length>0;)y=g,x=m+u.shift(),g=b=y+u.shift(),m=(_=x+u.shift())+u.shift(),r(h,y,x,b,_,g,m);else if("o27"==k)for(u.length%2&&(m+=u.shift());u.length>0;)x=m,b=(y=g+u.shift())+u.shift(),_=x+u.shift(),g=b+u.shift(),r(h,y,x,b,_,g,m=_);else if("o10"==k||"o29"==k){var j="o10"==k?o:a;if(0==u.length)console.log("error: empty stack");else{var $=u.pop(),H=j.Subrs[$+j.Bias];n.x=g,n.y=m,n.nStems=l,n.haveWidth=c,n.width=p,n.open=d,v(H,n,a,o,h),g=n.x,m=n.y,l=n.nStems,c=n.haveWidth,p=n.width,d=n.open}}else if("o30"==k||"o31"==k){var q=u.length,W=(O=0,"o31"==k);for(O+=q-(I=-3&q);O<I;)W?(x=m,b=(y=g+u.shift())+u.shift(),m=(_=x+u.shift())+u.shift(),I-O==5?(g=b+u.shift(),O++):g=b,W=!1):(y=g,x=m+u.shift(),b=y+u.shift(),_=x+u.shift(),g=b+u.shift(),I-O==5?(m=_+u.shift(),O++):m=_,W=!0),r(h,y,x,b,_,g,m),O+=4}else{if("o"==(k+"").charAt(0))throw console.log("Unknown operation: "+k,i),k;u.push(k)}}}n.x=g,n.y=m,n.nStems=l,n.haveWidth=c,n.width=p,n.open=d}return{shape:function(e,t,r){null==r&&(r={});var i=r.axs;e.fvar&&null==i&&(i=e.fvar[1][e._index][2]);var s=e.HVAR;i&&s&&(i=m(e,i));for(var a=[],o=0;o<t.length;o++){var h=t.codePointAt(o);h>65535&&o++,a.push(p(e,h))}var u=[];for(o=0;o<a.length;o++){var l=n(e,a,o),c=a[o],d=e.hmtx.aWidth[c]+l[2];if(s&&s[1][c])for(var f=s[1][c],y=0;y<s[0].length;y++)d+=g(s[0][y],i)*f[y];u.push({g:c,cl:o,dx:0,dy:0,ax:d,ay:0})}return u},shapeToPath:function(e,t,r){var i,s,n={cmds:[],crds:[]},a=0,o=0;r&&(i=r.clr,s=r.axs);for(var h=0;h<t.length;h++){for(var u=t[h],l=d(e,u.g,!1,s),c=l.crds,p=0;p<c.length;p+=2)n.crds.push(c[p]+a+u.dx),n.crds.push(c[p+1]+o+u.dy);for(i&&n.cmds.push(i),p=0;p<l.cmds.length;p++)n.cmds.push(l.cmds[p]);var f=n.cmds.length;i&&0!=f&&"X"!=n.cmds[f-1]&&n.cmds.push("X"),a+=u.ax,o+=u.ay}return{cmds:n.cmds,crds:n.crds}},codeToGlyph:p,glyphToPath:d,pathToSVG:function(e,t){var r=e.cmds,i=e.crds;function s(e){return parseFloat(e.toFixed(t))}null==t&&(t=5);for(var n=[],a=0,o={M:2,L:2,Q:4,C:6},h=0,u=0,l=0,c=0,p=0,d=0,f=0;f<r.length;f++){var g,m,y,x,v=r[f],b=o[v]?o[v]:0,_=[];if("L"==v)g=i[a]-h,m=i[a+1]-u,y=s(g+l),x=s(m+c),"Z"==r[f+1]&&i[a]==p&&i[a+1]==d?(y=g,x=m):0==y&&0==x||(0==y?_.push("v",x):0==x?_.push("h",y):_.push("l",y,x));else{_.push(v.toLowerCase());for(var w=0;w<b;w+=2)g=i[a+w]-h,m=i[a+w+1]-u,y=s(g+l),x=s(m+c),_.push(y,x)}0!=b&&(l+=g-y,c+=m-x);var C=_;for(w=0;w<C.length;w++)n.push(C[w]);0!=b&&(h=i[(a+=b)-2],u=i[a-1]),"M"==v&&(p=h,d=u),"Z"==v&&(h=p,u=d)}return function(e){for(var t=[],r=!1,i="",s=0;s<e.length;s++){var n=e[s],a="number"==typeof n;if(!a){if(n==i&&1==n.length&&"m"!=n)continue;i=n}r&&a&&n>=0&&t.push(" "),t.push(n),r=a}return t.join("")}(n)},SVGToPath:function(e){var t={cmds:[],crds:[]};return Du.U.SVG.svgToPath(e,t),{cmds:t.cmds,crds:t.crds}},pathToContext:function(e,t){for(var r=0,i=e.cmds,s=e.crds,n=0;n<i.length;n++){var a=i[n];if("M"==a)t.moveTo(s[r],s[r+1]),r+=2;else if("L"==a)t.lineTo(s[r],s[r+1]),r+=2;else if("C"==a)t.bezierCurveTo(s[r],s[r+1],s[r+2],s[r+3],s[r+4],s[r+5]),r+=6;else if("Q"==a)t.quadraticCurveTo(s[r],s[r+1],s[r+2],s[r+3]),r+=4;else if("d"==a[0]){var u=window.UPNG,l=s[r],c=s[r+1],p=s[r+2],d=s[r+3],f=s[r+4],g=s[r+5],m=s[r+6],y=s[r+7];if(r+=8,null==u){t.moveTo(l,c),t.lineTo(p,d),t.lineTo(f,g),t.lineTo(m,y),t.closePath();continue}for(var v=p-l,b=d-c,_=m-l,w=y-c,C=atob(a.slice(22)),E=new Uint8Array(C.length),D=0;D<C.length;D++)E[D]=C.charCodeAt(D);for(var A=u.decode(E.buffer),S=A.width,F=A.height,T=new Uint8Array(u.toRGBA8(A)[0]),M=t.getTransform(),k=Math.sqrt(Math.abs(M.a*M.d-M.b*M.c))*Math.sqrt(_*_+w*w)/F;k<.5;){var I=x(T,S,F);T=I.buff,S=I.w,F=I.h,k*=2}null==o&&(o=document.createElement("canvas"),h=o.getContext("2d")),o.width==S&&o.height==F||(o.width=S,o.height=F),h.putImageData(new ImageData(new Uint8ClampedArray(T.buffer),S,F),0,0),t.save(),t.transform(v,b,_,w,l,c),t.scale(1/S,1/F),t.drawImage(o,0,0),t.restore()}else if("#"==a.charAt(0)||"r"==a.charAt(0))t.beginPath(),t.fillStyle=a;else if("O"==a.charAt(0)&&"OX"!=a){t.beginPath();var B=a.split("-");t.lineWidth=parseFloat(B[2]),t.lineCap=["butt","round","square"][parseFloat(B[3])],t.lineJoin=["miter","round","bevel"][parseFloat(B[4])],t.miterLimit=parseFloat(B[5]),t.lineDashOffset=parseFloat(B[6]),t.setLineDash(B[7].split(",").map(parseFloat)),t.strokeStyle=B[1]}else"Z"==a?t.closePath():"X"==a?t.fill():"OX"==a&&t.stroke()}},initHB:function(e,t){var r=function(e){var t=0;return 4294967168&e?4294965248&e?4294901760&e?4292870144&e||(t=4):t=3:t=2:t=1,t};fetch(e).then(function(e){return e.arrayBuffer()}).then(function(e){return WebAssembly.instantiate(e)}).then(function(e){console.log("HB ready");var i,s,n,a,o,h,u,l,c,p,d=e.instance.exports,f=d.memory;Du.U.shapeHB=function(e,t,g){var m=e._data,y=e.name.postScriptName,x=g.ltr,v=g.fts,b=g.axs;if(e.fvar&&null==b&&(b=e.fvar[1][e._index][2]),i=new Uint8Array(f.buffer),s=new Uint32Array(f.buffer),n=new Int32Array(f.buffer),a=new Float32Array(f.buffer),o!=y&&(null!=h&&(d.hb_blob_destroy(h),d.free(u),d.hb_face_destroy(l),d.hb_font_destroy(c)),u=d.malloc(m.byteLength),i.set(m,u),h=d.hb_blob_create(u,m.byteLength,2,0,0),l=d.hb_face_create(h,e._index),c=d.hb_font_create(l),o=y),null!=window.TextEncoder){null==p&&(p=new window.TextEncoder("utf8"));var _=d.hb_buffer_create(),w=p.encode(t),C=w.length,E=d.malloc(C);i.set(w,E),d.hb_buffer_add_utf8(_,E,C,0,C),d.free(E);var D=Du.B,A=0;if(v){A=d.malloc(16*v.length);for(var S=0;S<v.length;S++){var F=v[S],T=(I=A+16*S)>>>2;D.writeASCII(i,I,F[0].split("").reverse().join("")),s[T+1]=F[1],s[T+2]=F[2],s[T+3]=F[3]}}var M=0;if(b&&e.fvar){var k=e.fvar[0];for(M=d.malloc(8*b.length),S=0;S<b.length;S++){var I;T=(I=M+8*S)>>>2,D.writeASCII(i,I,k[S][0].split("").reverse().join("")),a[T+1]=b[S]}}b&&d.hb_font_set_variations(c,M,b.length),d.hb_buffer_set_direction(_,x?4:5),d.hb_buffer_guess_segment_properties(_),d.hb_shape(c,_,A,v?v.length:0);var B=function(e){for(var t=d.hb_buffer_get_length(e),r=[],i=d.hb_buffer_get_glyph_infos(e,0)>>>2,a=d.hb_buffer_get_glyph_positions(e,0)>>>2,o=0;o<t;++o){var h=i+5*o,u=a+5*o;r.push({g:s[h+0],cl:s[h+2],ax:n[u+0],ay:n[u+1],dx:n[u+2],dy:n[u+3]})}return r}(_);d.hb_buffer_destroy(_),v&&d.free(A),b&&d.free(M);var L=B.slice(0);x||L.reverse();var P=0,O=0;for(S=1;S<L.length;S++){for(var R=L[S],N=R.cl;;){var V=t.codePointAt(P),U=r(V);if(!(O+U<=N))break;O+=U,P+=V<=65535?1:2}R.cl=P}return B}alert("Your browser is too old. Please, update it.")},t()})}}}();class Su{constructor(e,t,r,i){this._totalLength=void 0,this.A=e,this.B=t,this.C=r,this.D=i}static sampleSpacing(){return 2}tangentAtParameter(e){const t=Math.max(0,Math.min(1,e));if(0===t||1===t){let e,r;0===t?this.A.x===this.B.x&&this.A.y===this.B.y?(e=this.C.x-this.A.x,r=this.C.y-this.A.y):(e=this.B.x-this.A.x,r=this.B.y-this.A.y):this.D.x===this.C.x&&this.D.y===this.C.y?(e=this.D.x-this.B.x,r=this.D.y-this.B.y):(e=this.D.x-this.C.x,r=this.D.y-this.C.y);const i=Math.hypot(e,r);return Math.abs(i)>1e-4&&(e/=i,r/=i),{x:e,y:r}}const r=1-t;let i=3*this.D.x*Math.pow(t,2)-3*this.C.x*Math.pow(t,2)+6*this.C.x*r*t-6*this.B.x*r*t+3*this.B.x*Math.pow(r,2)-3*this.A.x*Math.pow(r,2),s=3*this.D.y*Math.pow(t,2)-3*this.C.y*Math.pow(t,2)+6*this.C.y*r*t-6*this.B.y*r*t+3*this.B.y*Math.pow(r,2)-3*this.A.y*Math.pow(r,2);const n=Math.hypot(i,s);return Math.abs(n)>1e-4&&(i/=n,s/=n),{x:i,y:s}}isLinear(){return this.A.x===this.B.x&&this.A.y===this.B.y&&this.C.x===this.D.x&&this.C.y===this.D.y}pointAtParameter(e){const t=Math.max(0,Math.min(1,e));return{x:Math.pow(1-t,3)*this.A.x+3*Math.pow(1-t,2)*t*this.B.x+3*(1-t)*Math.pow(t,2)*this.C.x+Math.pow(t,3)*this.D.x,y:Math.pow(1-t,3)*this.A.y+3*Math.pow(1-t,2)*t*this.B.y+3*(1-t)*Math.pow(t,2)*this.C.y+Math.pow(t,3)*this.D.y}}getTotalLength(){if(void 0===this._totalLength)if(this.isLinear())this._totalLength=Math.hypot(this.D.x-this.A.x,this.D.y-this.A.y);else{const e=Math.max(10,Math.ceil((Math.hypot(this.B.x-this.A.x,this.B.y-this.A.y)+Math.hypot(this.C.x-this.B.x,this.C.y-this.B.y)+Math.hypot(this.D.x-this.C.x,this.D.y-this.C.y))/Su.sampleSpacing())),t=Au(e).map(t=>this.pointAtParameter(t/(e-1)));let r=0;for(let e=1;e<t.length;e++)r+=Math.hypot(t[e].x-t[e-1].x,t[e].y-t[e-1].y);this._totalLength=r}return this._totalLength}}class Fu{constructor(e){this.samples=[],this.segments=e;const t=e.map(e=>e.getTotalLength()),r=[0];for(let e=1;e<t.length;e++)r.push(r[e-1]+t[e-1]);this._totalLength=r[r.length-1]+t[t.length-1];const i=e.map(e=>Math.max(4,Math.ceil(e.getTotalLength()/Su.sampleSpacing()))),s=i.reduce((e,t)=>e+t),n=1/s/10,a=this._totalLength/s;this.samples.push({dist:0,pt:this.segments[0].A,tan:this.segments[0].tangentAtParameter(0),segIdx:0,t:0}),e.forEach((e,t)=>{const s=i[t],o=Au(s+1).map(e=>e/s),h=o.map(t=>e.pointAtParameter(t));let u;for(let t=0;t<4;t++){u=Au(s).map(e=>Math.hypot(h[e+1].x-h[e].x,h[e+1].y-h[e].y));const t=u.map(e=>e-a);let r=0;for(let i=1;i<o.length-1;i++)r+=t[i-1],o[i]-=n*r,h[i]=e.pointAtParameter(o[i])}let l=0;h.slice(1).forEach((e,i)=>{l+=u[i],this.samples.push({dist:r[t]+l,pt:e,tan:this.segments[t].tangentAtParameter(o[i+1]),segIdx:t,t:o[i+1]})})}),this._jumps=[],this.segmentStartEnds=[{start:0,end:0}];for(let e=1;e<this.samples.length;e++){let t=this.samples[e-1],r=this.samples[e];if(r.segIdx===t.segIdx)this.segmentStartEnds[this.segmentStartEnds.length-1].end=r.dist;else{const i=r.dist-Math.hypot(this.segments[r.segIdx].A.x-r.pt.x,this.segments[r.segIdx].A.y-r.pt.y);if(this.segments[t.segIdx].D.x!==this.segments[r.segIdx].A.x||this.segments[t.segIdx].D.y!==this.segments[r.segIdx].A.y){const s={dist:i-1e-8,pt:this.segments[t.segIdx].D,tan:this.segments[t.segIdx].tangentAtParameter(1),segIdx:t.segIdx,t:1},n={dist:i+1e-8,pt:this.segments[r.segIdx].A,tan:this.segments[r.segIdx].tangentAtParameter(0),segIdx:r.segIdx,t:0};this._jumps.push(i),this.samples.splice(e,0,s,n),this.segmentStartEnds[s.segIdx].end=s.dist,this.segmentStartEnds[n.segIdx]={start:n.dist,end:r.dist},e+=2}else if(0!==r.t){const t=Object.assign(Object.assign({},r),{t:0,pt:this.segments[r.segIdx].A,tan:this.segments[r.segIdx].tangentAtParameter(0),dist:i});this.samples.splice(e,0,t),this.segmentStartEnds[r.segIdx]={start:t.dist,end:r.dist},e++}else this.segmentStartEnds[r.segIdx]={start:r.dist,end:r.dist}}}}jumps(){return[...this._jumps]}getTotalLength(){return this._totalLength}findClosestSampleIdx(e){let t=0,r=this.samples.length-1;for(;t<r;){const i=Math.floor((t+r)/2);if(this.samples[i].dist>e)r=i-1;else{if(!(this.samples[i].dist<e))return i;t=i+1}}return Math.max(0,Math.min(this.samples.length-1,Math.floor((t+r)/2)))}getPointAtLength(e,t=!1){if(e<=0)return this.samples[0].pt;if(e>=this._totalLength)return this.samples[this.samples.length-1].pt;const r=this.findClosestSampleIdx(e),i=this.samples[r].dist<e?Math.min(r+1,this.samples.length-1):Math.max(0,r-1),s=Math.abs(this.samples[i].dist-this.samples[r].dist)<1e-6?0:(e-this.samples[r].dist)/(this.samples[i].dist-this.samples[r].dist);if(t||this.samples[r].segIdx>this.samples[i].segIdx)return{x:(1-s)*this.samples[r].pt.x+s*this.samples[i].pt.x,y:(1-s)*this.samples[r].pt.y+s*this.samples[i].pt.y};if(this.samples[r].segIdx!==this.samples[i].segIdx){const e=1-this.samples[r].t+this.samples[i].t,t=e>0?(1-this.samples[r].t)/e:.5;if(s<t){const e=this.segments[this.samples[r].segIdx],i=s/t,n=(1-i)*this.samples[r].t+i;return e.pointAtParameter(n)}{const e=this.segments[this.samples[i].segIdx],r=(s-t)/(1-t)*this.samples[i].t;return e.pointAtParameter(r)}}{const e=this.segments[this.samples[r].segIdx],t=(1-s)*this.samples[r].t+s*this.samples[i].t;return e.pointAtParameter(t)}}getAngleAtLength(e,t=!1){const r=this.getTangentAtLength(e,t);return Math.atan2(r.y,r.x)}getTangentAtLength(e,t=!1){if(e<=0)return this.samples[0].tan;if(e>=this._totalLength)return this.samples[this.samples.length-1].tan;const r=this.findClosestSampleIdx(e),i=this.samples[r].dist<e?Math.min(r+1,this.samples.length-1):Math.max(0,r-1),s=(e-this.samples[r].dist)/(this.samples[i].dist-this.samples[r].dist);if(t||this.samples[r].segIdx>this.samples[i].segIdx){let e=(1-s)*this.samples[r].tan.x+s*this.samples[i].tan.x,t=(1-s)*this.samples[r].tan.y+s*this.samples[i].tan.y;const n=Math.max(Math.hypot(e,t),1e-4);return e/=n,t/=n,{x:e,y:t}}if(this.samples[r].segIdx!==this.samples[i].segIdx){if(s<.5){const e=this.segments[this.samples[r].segIdx],t=2*s,i=(1-t)*this.samples[r].t+t;return e.tangentAtParameter(i)}{const e=this.segments[this.samples[i].segIdx],t=2*(s-.5)*this.samples[i].t;return e.tangentAtParameter(t)}}{const e=this.segments[this.samples[r].segIdx],t=(1-s)*this.samples[r].t+s*this.samples[i].t;return e.tangentAtParameter(t)}}}const Tu={M:2,L:2,C:6,Q:4},Mu=["ttf","otf","woff"],ku=new RegExp(`\\.(${Mu.join("|")})`,"i"),Iu=new RegExp(`([^/]+)(\\.(?:${Mu.join("|")}))`,"i"),Bu="Sorry, only TTF, OTF and WOFF files are supported.",Lu=["weight","stretch","style"];class Pu{constructor(e,t,r,i,s){if(!(t instanceof FontFace))throw Error("FontFace is required");this._pInst=e,this.name=r,this.path=i,this.data=s,this.face=t}static hasGlyphData(e){let{font:t}=e;return"object"==typeof t&&void 0!==t.data}fontBounds(e,t,r,i,s,n){({width:i,height:s,options:n}=this._parseArgs(i,s,n));let a=n?.graphics?._renderer||this._pInst._renderer;if(!a)throw Error("p5 or graphics required for fontBounds()");return a.fontBounds(e,t,r,i,s)}textBounds(e,t,r,i,s,n){({width:i,height:s,options:n}=this._parseArgs(i,s,n));let a=n?.graphics?._renderer||this._pInst._renderer;if(!a)throw Error("p5 or graphics required for fontBounds()");return a.textBounds(e,t,r,i,s)}textToPaths(e,t,r,i,s,n){if(({width:i,height:s,options:n}=this._parseArgs(i,s,n)),!this.data)throw Error('No font data available for "'+this.name+'"\nTry downloading a local copy of the font file');return this._lineateAndPathify(e,t,r,i,s,n).map(e=>e.glyphs).flat().map(e=>e.path.commands).flat()}textToPoints(e,t,r,i,s,n){return this.textToContours(e,t,r,i,s,n).reduce((e,t)=>(e.push(...t),e),[])}textToContours(e,t=0,r=0,i,s,n){({width:i,height:s,options:n}=this._parseArgs(i,s,n));const a=this.textToPaths(e,t,r,i,s,n),o=[];for(const e of a)"M"===e[0]&&o.push([]),o[o.length-1].push(e);return o.map(e=>function(e,t,r){const i=(e,t)=>{const r=e.length;return e[t<0?t%r+r:t%r]},s=(e,t,r,i)=>{if(!i)return 0===n(e,t,r);void 0===s.tmpPoint1&&(s.tmpPoint1=[],s.tmpPoint2=[]);const a=s.tmpPoint1,o=s.tmpPoint2;a.x=t.x-e.x,a.y=t.y-e.y,o.x=r.x-t.x,o.y=r.y-t.y;const h=a.x*o.x+a.y*o.y,u=Math.sqrt(a.x*a.x+a.y*a.y),l=Math.sqrt(o.x*o.x+o.y*o.y);return Math.acos(h/(u*l))<i},n=(e,t,r)=>(t[0]-e[0])*(r[1]-e[1])-(r[0]-e[0])*(t[1]-e[1]),a=(e=>{const t=e.slice();if(t.length<2)throw new Error(`Path doesn't have enough commands: ${JSON.stringify(t)}`);if("M"!==t[0].type)throw new Error(`Path starts with ${t[0].type} instead of M!`);let r={x:t[0].x,y:t[0].y},i=Object.assign({},r);const s=[];for(;t.length>0;){const e=t.shift();if("M"===e.type)i={x:e.x,y:e.y},r=i;else if("C"===e.type)s.push(new Su(r,{x:e.x1,y:e.y1},{x:e.x2,y:e.y2},{x:e.x,y:e.y})),r={x:e.x,y:e.y};else if("L"===e.type)e.x===r.x&&e.y===r.y||s.push(new Su(r,r,{x:e.x,y:e.y},{x:e.x,y:e.y})),r={x:e.x,y:e.y};else if("H"===e.type)e.x!==r.x&&s.push(new Su(r,r,{x:e.x,y:r.y},{x:e.x,y:r.y})),r={x:e.x,y:r.y};else if("V"===e.type)e.y!==r.y&&s.push(new Su(r,r,{x:r.x,y:e.y},{x:r.x,y:e.y})),r={x:r.x,y:e.y};else if("Q"===e.type)s.push(new Su(r,{x:r.x+2/3*(e.x1-r.x),y:r.y+2/3*(e.y1-r.y)},{x:e.x+2/3*(e.x1-e.x),y:e.y+2/3*(e.y1-e.y)},{x:e.x,y:e.y})),r={x:e.x,y:e.y};else{if("Z"!==e.type)throw new Error(`Unsupported path command ${e.type}; use only H, V, M, L, C, Z!`);Math.hypot(r.x-i.x,r.y-i.y)>0&&s.push(new Su(r,r,i,i))}}return new Fu(s)})(Vu(e));let o=((e,t)=>{if("object"!=typeof e)e=t;else for(const r in t)void 0===e[r]&&(e[r]=t[r]);return e})(t,{sampleFactor:.1,simplifyThreshold:0});const h=Math.max(1,Math.ceil(a.getTotalLength()*o.sampleFactor));let u=[];const l=r._pInst.angleMode(),c=r._pInst.DEGREES;for(let e=0;e<h;e++){const t=a.getTotalLength()*(1===h?0:e/(h-1));u.push({...a.getPointAtLength(t),get angle(){const e=a.getAngleAtLength(t);return l===c?180*e/Math.PI:e},get alpha(){return this.angle}})}return o.simplifyThreshold&&((e,t)=>{t=t||0;for(let r=e.length-1;e.length>3&&r>=0;--r)s(i(e,r-1),i(e,r),i(e,r+1),t)&&e.splice(r%e.length,1)})(u,o.simplifyThreshold),u}(e,n,this))}textToModel(e,t,r,i,s,n){({width:i,height:s,options:n}=this._parseArgs(i,s,n));const a=n?.extrude||0;let o=this.textToContours(e,t,r,i,s,n);if(!o||0===o.length)return new p5.Geometry;const h=this._pInst.buildGeometry(()=>{const e=this._pInst._renderer._validateFaces;this._pInst._renderer._validateFaces=!0,this._pInst.beginShape();for(const e of o){this._pInst.beginContour();for(const t of e)this._pInst.vertex(t.x,t.y,0);this._pInst.endContour(this._pInst.CLOSE)}this._pInst.endShape(this._pInst.CLOSE),this._pInst._renderer._validateFaces=e});if(0===a)return h;const u={},l=e=>`${e.x.toFixed(6)}-${e.y.toFixed(6)}-${e.z.toFixed(6)}`,c=[],p=[];for(const e of h.vertices){const t=l(e);if(!(t in u)){const r=c.length;u[t]=r,c.push(e.copy())}p.push(u[t])}const d=h.faces.map(e=>e.map(e=>p[e])),f={};for(const e of d)for(let t=0;t<e.length;t++){const r=e[t],i=e[(t+1)%e.length],s=`${Math.min(r,i)}-${Math.max(r,i)}`;f[s]||(f[s]=[]),f[s].push([r,i])}const g=[];for(const e in f)1===f[e].length&&g.push(f[e][0]);const m=this._pInst.buildGeometry(()=>{}),y=.5*a;m.vertices=[],m.faces=[],m.edges=[];for(const[e,t]of g){const r=c[e],i=c[t],s=new Xi(i.x-r.x,i.y-r.y,i.z-r.z),n=new Xi(0,0,a),o=Xi.cross(s,n),h=s.mag();if(o.mag()<1e-4||h<1e-4)continue;const u=m.vertices.length;m.vertices.push(new Xi(r.x,r.y,r.z+y));const l=m.vertices.length;m.vertices.push(new Xi(i.x,i.y,i.z+y));const p=m.vertices.length;m.vertices.push(new Xi(r.x,r.y,r.z-y));const d=m.vertices.length;m.vertices.push(new Xi(i.x,i.y,i.z-y)),m.faces.push([u,p,d]),m.faces.push([u,d,l]),m.edges.push([u,l]),m.edges.push([p,d]),m.edges.push([u,p]),m.edges.push([l,d])}const x=m.vertices.length;for(const e of c)m.vertices.push(new Xi(e.x,e.y,e.z+y));for(const e of d){if(e.length<3)continue;const t=e.map(e=>e+x);m.faces.push(t);for(let e=0;e<t.length;e++){const r=(e+1)%t.length;m.edges.push([t[e],t[r]])}}const v=m.vertices.length;for(const e of c)m.vertices.push(new Xi(e.x,e.y,e.z-y));for(const e of d){if(e.length<3)continue;const t=[...e].reverse().map(e=>e+v);m.faces.push(t);for(let e=0;e<t.length;e++){const r=(e+1)%t.length;m.edges.push([t[e],t[r]])}}return m.computeNormals(),m}variations(){let e={};if(this.data){let t=this.face?.axes;t&&t.forEach(t=>{e[t.tag]=t.value})}return Lu.forEach(t=>{let r=this.face[t];"normal"!==r&&(e[t]=e[t]||r)}),e}metadata(){let e=this.data?.name||{};for(let t in this.face)/^load/.test(t)||(e[t]=e[t]||this.face[t]);return e}static async list(e=!1){if(e){console.log("There are",document.fonts.size,"font-faces\n");let e=0;for(let t of document.fonts.values()){console.log("FontFace: {");for(let e in t)console.log(" "+e+": "+t[e]);console.log("}\n"),"loaded"===t.status&&e++}console.log(e+" loaded")}return await Array.from(document.fonts)}_lineateAndPathify(e,t,r,i,s,n={}){let a=n?.graphics?._renderer||this._pInst._renderer;a.push(),a.textFont(this);let{lines:o,bounds:h}=a._computeBounds(Pn,e,t,r,i,s,{ignoreRectMode:!0,...n});o=this._position(a,o,h,i,s);let u=this.data?.head?.unitsPerEm||1e3,l=a.states.textSize/u;const c=this._currentAxes(a);let p=o.map(e=>this._lineToGlyphs(e,{scale:l,axs:c}));return a.pop(),p}_currentAxes(e){let t;return(this.data?.fvar?.length??0)>0&&(t=this.data.fvar[0].map(([t,r,i,s,n,a])=>{if(!e)return i;if("wght"===t)return e.states.fontWeight;if("wdth"===t)return 100;if(e.textCanvas().style.fontVariationSettings){const r=new RegExp(`\\b${t}s+(d+)`).exec(e.textCanvas().style.fontVariationSettings);return r?parseInt(r[1]):i}return i})),t}_textToPathPoints(e,t,r,i,s,n){({width:i,height:s,options:n}=this._parseArgs(i,s,n));let a=this.textToPaths(e,t,r,i,s,n);const o=(e,t,r,i)=>{if(fn.dist(t.x,t.y,r.x,r.y)>i){let s={x:(t.x+r.x)/2,y:(t.y+r.y)/2};e.push(s),o(e,t,s,i),o(e,s,r,i)}};let h=[],{textSize:u}=this._pInst._renderer.states,l=u/this.data.head.unitsPerEm*500;for(let e=0;e<a.length;e++){let{type:t,data:r}=a[e];if("Z"!==t){let e={x:r[r.length-2],y:r[r.length-1]};"L"===t&&h.length&&!n?.nodivide>0&&o(h,h[h.length-1],e,l),h.push(e)}}return h}_parseArgs(e,t,r={}){return"object"==typeof e?(r=e,e=t=void 0):"object"==typeof t&&(r=t,t=void 0),{width:e,height:t,options:r}}_position(e,t,r,i,s){let{textAlign:n,textLeading:a}=e.states,o=this._measureTextDefault(e,"X").fontBoundingBoxAscent;return t.map((t,h)=>{let u=r.x,l=r.y+h*a+o,c=e._fontWidthSingle(t);if(n===A?u+=(r.w-c)/2:n===E&&(u+=r.w-c),void 0!==i)switch(e.states.rectMode){case A:u-=i/2,l-=s/2;break;case C:u-=i,l-=s}return{text:t,x:u,y:l}})}_lineToGlyphs(e,{scale:t=1,axs:r}={}){if(!this.data)throw Error('No font data available for "'+this.name+'"\nTry downloading a local copy of the font file');let i=Du.U.shape(this.data,e.text,{axs:r});return e.glyphShapes=i,e.glyphs=this._shapeToPaths(i,e,{scale:t,axs:r}),e}_positionGlyphs(e,t){let r=t?.graphics?._renderer||this._pInst._renderer;const i=this._currentAxes(r),s=Du.U.shape(this.data,e,{axs:i}),n=[];let a=0;for(const e of s)n.push({x:a,index:e.g,shape:e}),a+=e.ax;return n}_singleShapeToPath(e,{scale:t=1,x:r=0,y:i=0,lineX:s=0,lineY:n=0,axs:a}={}){let o=this.data,h=0,{g:u,ax:l,ay:c,dx:p,dy:d}=e,{crds:f,cmds:g}=Du.U.glyphToPath(o,u,!0,a),m={path:{commands:[]}};for(let e=0;e<g.length;e++){let a=g[e],o=[a];if(a in Tu){let e=Tu[a];for(let a=0;a<e;a+=2){let e=s+(f[a+h]+r+p)*t,u=n+(f[a+h+1]+i+d)*-t;o.push(e),o.push(u)}h+=e}m.path.commands.push(o)}return{glyph:m,ax:l,ay:c}}_shapeToPaths(e,t,{scale:r=1,axs:i}={}){let s=0,n=0,a=[];if(e.length!==t.text.length)throw Error("Invalid shape data");for(let o=0;o<e.length;o++){const{glyph:h,ax:u,ay:l}=this._singleShapeToPath(e[o],{scale:r,x:s,y:n,lineX:t.x,lineY:t.y,axs:i});a.push(h),s+=u,n+=l}return a}_measureTextDefault(e,t){let{textAlign:r,textBaseline:i}=e.states,s=e.textDrawingContext();s.textAlign="left",s.textBaseline="alphabetic";let n=s.measureText(t);return s.textAlign=r,s.textBaseline=i,n}drawPaths(e,t,r){e.strokeStyle=r?.stroke||e.strokeStyle,e.fillStyle=r?.fill||e.fillStyle,e.beginPath(),t.forEach(([t,...r])=>{"M"===t?e.moveTo(...r):"L"===t?e.lineTo(...r):"C"===t?e.bezierCurveTo(...r):"Q"===t?e.quadraticCurveTo(...r):"Z"===t&&e.closePath()}),r?.fill&&e.fill(),r?.stroke&&e.stroke()}_pathsToCommands(e,t){let r=[];for(let i=0;i<e.length;i++){let s=e[i],{x:n,y:a,path:o}=s,{crds:h,cmds:u}=o;for(let e=0,i=0;i<u.length;i++){let s=u[i],o={type:s,data:[]};if("M"===s||"L"===s)o.data.push(n+h[e]*t,a+h[e+1]*-t),e+=2;else if("C"===s){for(let r=0;r<6;r+=2)o.data.push(n+h[e+r]*t,a+h[e+r+1]*-t);e+=6}else if("Q"===s){for(let r=0;r<4;r+=2)o.data.push(n+h[e+r]*t,a+h[e+r+1]*-t);e+=4}r.push(o)}}return r}}async function Ou(e,t,r,i,s){let n=function(e,t,r,i){e=function(e){return/^[A-Za-z][A-Za-z0-9_-]*$/.test(e)||(e="'"+String(e).replace(/'/g,"\\'")+"'"),e}(e);let s=i?._compressedData??i?._data;if(!s){if(!ku.test(t))throw Error(Bu);t.startsWith("url(")||(t="url("+t+")"),s=t}if((i?.fvar?.length??0)>0){r=r||{};for(const[e,t,s,n,a,o]of i.fvar[0])"wght"===e?r.weight=`${t} ${n}`:"wdth"===e&&(r.stretch=`${t}% ${n}%`)}let n=new FontFace(e,s,r);if("error"===n.status)throw Error('Failed to create FontFace for "'+e+'"');return n}(t,r,i,s);return"loaded"!==n.status&&await n.load(),document.fonts.add(n),await document.fonts.ready,new Pu(e,n,t,r,s)}function Ru(e){return(e.startsWith('"')||e.startsWith("'"))&&e.at(0)===e.at(-1)?e.slice(1,-1).replace(/\/(['"])/g,"$1"):e}function Nu(e,t){e.Font=Pu,t.parseFontData=async function(e){let r=e instanceof Uint8Array?e:await t.loadBytes(e);if(!r)throw Error("Failed to load font data");let i=Du.parse(r);if(0===i.length||void 0===i[0].cmap)throw Error("parsing font data");return i[0]},t.loadFont=async function(...e){let r,{path:i,name:s,success:n,error:a,options:{sets:o,...h}={}}=function(...e){let t,r,i,s,n=e.shift();"string"==typeof n&&0!==n.length||p5._friendlyError(Bu,"p5.loadFont"),"string"==typeof e[0]&&(t=e.shift());for(let t=0;t<e.length;t++){const n=e[t];"function"==typeof n?r?i=n:r=n:"object"==typeof n&&(s=n)}return{path:n,name:t,success:r,error:i,options:s}}(...e),u=i.includes("@font-face");if(!u){let e;try{e=await fetch(i,{method:"HEAD"})}catch(t){e=await fetch(i)}const t=e.headers.get("content-type")?.startsWith("text/css");t&&(u=!0,i=await fetch(i).then(e=>e.text()))}if(u){const e=new CSSStyleSheet;await e.replace(i);const r=[];for(const i of e.cssRules)if(i instanceof CSSFontFaceRule){const e=i.style;let s=Ru(e.getPropertyValue("font-family"));const n=e.getPropertyValue("src"),a={...h||{}};for(const t of e){if("font-family"===t||"src"===t)continue;const r=t.replace(/^font-/,"").split("-").map((e,t)=>0===t?e:`${e[0].toUpperCase()}${e.slice(1)}`).join("");a[r]=e.getPropertyValue(t)}r.push({name:s,src:n,fontDescriptors:a,loadWithData:async()=>{let e;try{const r=/url\(([^\)]+)\)/.exec(n);if(r){let i=r[1];/^['"]/.exec(i)&&i.at(0)===i.at(-1)&&(i=i.slice(1,-1)),e=await t.parseFontData(i)}}catch(e){}return Ou(this,s,n,a,e)},loadWithoutData:()=>Ou(this,s,n,a)})}o=o||["latin"];const s=(o instanceof Array?o:[o]).map(e=>e.toLowerCase()),n=lh.filter(e=>s.some(t=>e.category.includes(t)&&e.category.includes("ext")===t.includes("ext"))),a=new Set(uh.parse(n.map(e=>`U+${e.hexrange[0]}-${e.hexrange[1]}`)));let u,l=0,c=0;for(const e of r){if(!e.fontDescriptors.unicodeRange)continue;const t=[...new Set(uh.parse(e.fontDescriptors.unicodeRange.split(/,\s*/g))).values()].filter(e=>a.has(e)).length,r={style:"normal",weight:400,...h},i=Object.keys(e.fontDescriptors).filter(t=>e.fontDescriptors[t]===r[t]).length;(i>c||i===c&&t>=l)&&(c=i,l=t,u=e)}const p=u||r.at(-1);for(const e of r)e!==p&&e.loadWithoutData();return p?.loadWithData()}try{const e=await t.parseFontData(i);s=s||function(e,t){let r,i=e?.name;if(i){if(i.fullName)return i.fullName;i.familyName&&(r=i.familyName)}if(!r){let e=Iu.exec(t);r=e&&e.length>=3?e[1]:t}return r.includes(" ")&&(r=r.replace(/ /g,"_")),r}(e,i),r=await Ou(this,s,i,h,e)}catch(e){let t=s||i.substring(i.lastIndexOf("/")+1).replace(/\.[^/.]+$/,"");console.warn(`WARN: No glyph data for '${t}', retrying as FontFace`);try{r=await Ou(this,t,i,h)}catch(e){if(a)return a(e);throw e}}return n?n(r):r}}const Vu=e=>e.map(e=>{const t=e[0];switch(t){case"Z":return{type:t};case"M":case"L":{const[,r,i]=e;return{type:t,x:r,y:i}}case"Q":{const[,r,i,s,n]=e;return{type:t,x1:r,y1:i,x:s,y:n}}case"C":{const[,r,i,s,n,a,o]=e;return{type:t,x1:r,y1:i,x2:s,y2:n,x:a,y:o}}default:throw new Error(`Unexpected path command: ${t}`)}});function Uu(e,t){jn.prototype.maxCachedGlyphs=function(){return 200},Pu.prototype._getFontInfo=function(e){this._fontInfos=this._fontInfos||{};const t=JSON.stringify(e);if(this._fontInfos[t])return this._fontInfos[t];{const r=new n(this,{axs:e});return this._fontInfos[t]=r,r}};class r{constructor(e,t){this.width=e,this.height=t,this.infos=[]}findImage(e){const t=this.width*this.height;if(e>t)throw new Error("font is too complex to render in 3D");let r,i;for(let s=this.infos.length-1;s>=0;--s){const n=this.infos[s];if(n.index+e<t){r=n,i=n.imageData;break}}if(!r){try{i=new ImageData(this.width,this.height)}catch(e){let t=document.getElementsByTagName("canvas")[0];const r=!t;t||(t=document.createElement("canvas"),t.style.display="none",document.body.appendChild(t));const s=t.getContext("2d");s&&(i=s.createImageData(this.width,this.height)),r&&document.body.removeChild(t)}r={index:0,imageData:i},this.infos.push(r)}const s=r.index;return r.index+=e,i._dirty=!0,{imageData:i,index:s}}}function i(e,t,r,i,s){const n=e.imageData.data;let a=4*e.index++;n[a++]=t,n[a++]=r,n[a++]=i,n[a++]=s}const s=Math.sqrt(3);class n{constructor(e,{axs:t}={}){this.font=e,this.axs=t,this.strokeImageInfos=new r(64,64),this.colDimImageInfos=new r(64,64),this.rowDimImageInfos=new r(64,64),this.colCellImageInfos=new r(64,64),this.rowCellImageInfos=new r(64,64),this.glyphInfos={}}getGlyphInfo(e){let t=this.glyphInfos[e.index];if(t)return t;const r=this.axs,{glyph:{path:{commands:n}}}=this.font._singleShapeToPath(e.shape,{axs:r});let a=1/0,o=-1/0,h=1/0,u=-1/0;for(const e of n)for(let t=1;t<e.length;t+=2)a=Math.min(a,e[t]),o=Math.max(o,e[t]),h=Math.min(h,e[t+1]),u=Math.max(u,e[t+1]);if(a>=o||h>=u||!n.length)return this.glyphInfos[e.index]={};const l=o-a,c=u-h,p=Vu(n);let d;const f=[],g=[],m=[];for(d=8;d>=0;--d)m.push([]);for(d=8;d>=0;--d)g.push([]);function y(e,t,r){const i=f.length;function s(e,t,r){for(let i=e.length;i-- >0;){const s=e[i];t>s&&(t=s),r<s&&(r=s)}return{min:t,max:r}}f.push(r);const n=.5,a=s(e,1,0),o=Math.max(Math.floor(9*a.min-n),0),h=Math.min(Math.ceil(9*a.max+n),9);for(let e=o;e<h;++e)m[e].push(i);const u=s(t,1,0),l=Math.max(Math.floor(9*u.min-n),0),c=Math.min(Math.ceil(9*u.max+n),9);for(let e=l;e<c;++e)g[e].push(i)}function x(e){return function(e){return e<0?0:e>255?255:e}(255*e)}class v{constructor(e,t,r,i){this.p0=e,this.c0=t,this.c1=r,this.p1=i}toQuadratic(){return{x:this.p0.x,y:this.p0.y,x1:this.p1.x,y1:this.p1.y,cx:(3*(this.c0.x+this.c1.x)-(this.p0.x+this.p1.x))/4,cy:(3*(this.c0.y+this.c1.y)-(this.p0.y+this.p1.y))/4}}quadError(){return Xi.sub(Xi.sub(this.p1,this.p0),Xi.mult(Xi.sub(this.c1,this.c0),3)).mag()/2}split(e){const t=Xi.lerp(this.p0,this.c0,e),r=Xi.lerp(this.c0,this.c1,e),i=Xi.lerp(t,r,e);this.c1=Xi.lerp(this.c1,this.p1,e),this.c0=Xi.lerp(r,this.c1,e);const s=Xi.lerp(i,this.c0,e),n=new v(this.p0,t,i,s);return this.p0=s,n}splitInflections(){const e=Xi.sub(this.c0,this.p0),t=Xi.sub(Xi.sub(this.c1,this.c0),e),r=Xi.sub(Xi.sub(Xi.sub(this.p1,this.c1),e),Xi.mult(t,2)),i=[];let s=t.x*r.y-t.y*r.x;if(0!==s){let n=e.x*r.y-e.y*r.x,a=e.x*t.y-e.y*t.x;const o=n*n-4*s*a;if(o>=0){s<0&&(s=-s,n=-n,a=-a);const e=Math.sqrt(o),t=(-n-e)/(2*s);let r=(-n+e)/(2*s);t>0&&t<1&&(i.push(this.split(t)),r=1-(1-r)/(1-t)),r>0&&r<1&&i.push(this.split(r))}}return i.push(this),i}}function b(e,t,r,i,n,a,o,h){const u=new v(new Xi(e,t),new Xi(r,i),new Xi(n,a),new Xi(o,h)).splitInflections(),l=[],c=30/s;for(let e of u){const t=[];let r;for(;r=c/e.quadError(),!(r>=.125);){const i=Math.pow(r,1/3),s=e.split(i),n=e.split(1-i/(1-i));l.push(s),t.push(e),e=n}r<1&&l.push(e.split(.5)),l.push(e),Array.prototype.push.apply(l,t.reverse())}return l}function _(e,t,r,i){y([e,r],[t,i],{x:e,y:t,cx:(e+r)/2,cy:(t+i)/2})}function w(e,t,r,i){return Math.abs(r-e)<1e-5&&Math.abs(i-t)<1e-5}let C,E,D,A;for(const e of p){const t=(e.x-a)/l,r=(e.y-h)/c;if(!w(C,E,t,r)){switch(e.type){case"M":D=t,A=r;break;case"L":_(C,E,t,r);break;case"Q":{const i=(e.x1-a)/l,s=(e.y1-h)/c;y([C,t,i],[E,r,s],{x:C,y:E,cx:i,cy:s});break}case"Z":w(C,E,D,A)?f.push({x:C,y:E}):(_(C,E,D,A),f.push({x:D,y:A}));break;case"C":{const i=b(C,E,(e.x1-a)/l,(e.y1-h)/c,(e.x2-a)/l,(e.y2-h)/c,t,r);for(let e=0;e<i.length;e++){const t=i[e].toQuadratic();y([t.x,t.x1,t.cx],[t.y,t.y1,t.cy],t)}break}default:throw new Error(`unknown command type: ${e.type}`)}C=t,E=r}}const S=f.length,F=this.strokeImageInfos.findImage(S),T=F.index;for(let e=0;e<S;++e){const t=f[e];i(F,x(t.x),x(t.y),x(t.cx),x(t.cy))}function M(e,t,r){const s=e.length,n=t.findImage(s),a=n.index;let o=0;for(let t=0;t<s;++t)o+=e[t].length;const h=r.findImage(o);for(let t=0;t<s;++t){const r=e[t],s=r.length,a=h.index;i(n,a>>7,127&a,s>>7,127&s);for(let e=0;e<s;++e){const t=r[e]+T;i(h,t>>7,127&t,0,0)}}return{cellImageInfo:h,dimOffset:a,dimImageInfo:n}}return t=this.glyphInfos[e.index]={glyph:e,uGlyphRect:[a,h,o,u],strokeImageInfo:F,strokes:f,colInfo:M(m,this.colDimImageInfos,this.colCellImageInfos),rowInfo:M(g,this.rowDimImageInfos,this.rowCellImageInfos)},t.uGridOffset=[t.colInfo.dimOffset,t.rowInfo.dimOffset],t}}jn.prototype._renderText=function(t,r,i,s,n){if(!this.states.textFont||"string"==typeof this.states.textFont)return void console.log("WEBGL: you must load and set a font before drawing text. See `loadFont` and `textFont` for more details.");if(i>=s||!this.states.fillColor)return;if(!e.Font.hasGlyphData(this.states.textFont))return void console.log("WEBGL: only Opentype (.otf) and Truetype (.ttf) fonts with glyph data are supported");this.push();const a=this.states.strokeColor,o=this.states.drawMode;this.states.setValue("strokeColor",null),this.states.setValue("drawMode",xe);const{font:h}=this.states.textFont;if(!h)throw new Error("In WebGL mode, textFont() needs to be given the result of loadFont() instead of a font family name.");const u=h._currentAxes(this);let l=h._getFontInfo(u);const c={x:r,y:i},p=this.states.textSize/(h.data?.head?.unitsPerEm||1e3);this.translate(c.x,c.y,0),this.scale(p,p,1);const d=!this._defaultFontShader,f=this._getFontShader();f.init(),f.bindShader("text"),d&&(f.setUniform("uGridImageSize",[64,64]),f.setUniform("uCellsImageSize",[64,64]),f.setUniform("uStrokeImageSize",[64,64]),f.setUniform("uGridSize",[9,9]));const g=this.states.fillSet?this.states.curFillColor:[0,0,0,1];this._setGlobalUniforms(f),this._applyColorBlend(g);let m=this.geometryBufferCache.getGeometryByID("glyph");m||(m=this._textGeom=new xn(1,1,function(){for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)this.vertices.push(new Xi(t,e,0)),this.uvs.push(t,e)},this),m.gid="glyph",m.computeFaces().computeNormals(),this.geometryBufferCache.ensureCached(m));for(const e of this.buffers.text)e._prepareBuffer(m,f);f.setUniform("uMaterialColor",g),this._disableRemainingAttributes(f),this._beforeDrawText(),this.glyphDataCache=this.glyphDataCache||new Set;try{const e=h._positionGlyphs(t);for(const t of e){const e=l.getGlyphInfo(t);if(e.uGlyphRect){const r=e.rowInfo,i=e.colInfo,s=[e.strokeImageInfo.imageData,r.cellImageInfo.imageData,r.dimImageInfo.imageData,i.cellImageInfo.imageData,i.dimImageInfo.imageData];for(const e of s)this.glyphDataCache.delete(e),this.glyphDataCache.add(e);for(;this.glyphDataCache.size>this.maxCachedGlyphs();){const e=this.glyphDataCache.values().next().value;this.glyphDataCache.delete(e);const t=this.textures.get(e);t&&(t.remove(),this.textures.delete(e))}f.setUniform("uSamplerStrokes",e.strokeImageInfo.imageData),f.setUniform("uSamplerRowStrokes",r.cellImageInfo.imageData),f.setUniform("uSamplerRows",r.dimImageInfo.imageData),f.setUniform("uSamplerColStrokes",i.cellImageInfo.imageData),f.setUniform("uSamplerCols",i.dimImageInfo.imageData),f.setUniform("uGridOffset",e.uGridOffset),f.setUniform("uGlyphRect",e.uGlyphRect),f.setUniform("uGlyphOffset",t.x),f.bindTextures(),this._drawBuffers(m,{mode:4,count:1})}}}finally{f.unbindShader(),this.states.setValue("strokeColor",a),this.states.setValue("drawMode",o),this._afterDrawText(),this.pop()}}}void 0!==p5&&Nu(p5,p5.prototype);var zu='#define PI 3.141592\n\nprecision highp float;\nprecision highp int;\n\nuniform mat4 uViewMatrix;\nuniform mat3 uCameraNormalMatrix;\n\nuniform bool uUseLighting;\n\nuniform int uDirectionalLightCount;\nuniform vec3 uLightingDirection[5];\nuniform vec3 uDirectionalDiffuseColors[5];\nuniform vec3 uDirectionalSpecularColors[5];\n\nuniform int uPointLightCount;\nuniform vec3 uPointLightLocation[5];\nuniform vec3 uPointLightDiffuseColors[5];\t\nuniform vec3 uPointLightSpecularColors[5];\n\nuniform int uSpotLightCount;\nuniform float uSpotLightAngle[5];\nuniform float uSpotLightConc[5];\nuniform vec3 uSpotLightDiffuseColors[5];\nuniform vec3 uSpotLightSpecularColors[5];\nuniform vec3 uSpotLightLocation[5];\nuniform vec3 uSpotLightDirection[5];\n\nuniform bool uSpecular;\nuniform float uShininess;\nuniform float uMetallic;\n\nuniform float uConstantAttenuation;\nuniform float uLinearAttenuation;\nuniform float uQuadraticAttenuation;\n\n// setting from _setImageLightUniforms()\n// boolean to initiate the calculateImageDiffuse and calculateImageSpecular\nuniform bool uUseImageLight;\n// texture for use in calculateImageDiffuse\nuniform sampler2D environmentMapDiffused;\n// texture for use in calculateImageSpecular\nuniform sampler2D environmentMapSpecular;\n\nconst float specularFactor = 2.0;\nconst float diffuseFactor = 0.73;\n\nstruct LightResult {\n float specular;\n float diffuse;\n};\n\nfloat _phongSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float shininess) {\n\n vec3 R = reflect(lightDirection, surfaceNormal);\n return pow(max(0.0, dot(R, viewDirection)), shininess);\n}\n\nfloat _lambertDiffuse(vec3 lightDirection, vec3 surfaceNormal) {\n return max(0.0, dot(-lightDirection, surfaceNormal));\n}\n\nLightResult _light(vec3 viewDirection, vec3 normal, vec3 lightVector, float shininess, float metallic) {\n\n vec3 lightDir = normalize(lightVector);\n\n //compute our diffuse & specular terms\n LightResult lr;\n float specularIntensity = mix(1.0, 0.4, metallic);\n float diffuseIntensity = mix(1.0, 0.1, metallic);\n if (uSpecular)\n lr.specular = (_phongSpecular(lightDir, viewDirection, normal, shininess)) * specularIntensity;\n lr.diffuse = _lambertDiffuse(lightDir, normal) * diffuseIntensity;\n return lr;\n}\n\n// converts the range of "value" from [min1 to max1] to [min2 to max2]\nfloat map(float value, float min1, float max1, float min2, float max2) {\n return min2 + (value - min1) * (max2 - min2) / (max1 - min1);\n}\n\nvec2 mapTextureToNormal( vec3 v ){\n // x = r sin(phi) cos(theta) \n // y = r cos(phi) \n // z = r sin(phi) sin(theta)\n float phi = acos( v.y );\n // if phi is 0, then there are no x, z components\n float theta = 0.0;\n // else \n theta = acos(v.x / sin(phi));\n float sinTheta = v.z / sin(phi);\n if (sinTheta < 0.0) {\n // Turn it into -theta, but in the 0-2PI range\n theta = 2.0 * PI - theta;\n }\n theta = theta / (2.0 * 3.14159);\n phi = phi / 3.14159 ;\n \n vec2 angles = vec2( fract(theta + 0.25), 1.0 - phi );\n return angles;\n}\n\n\nvec3 calculateImageDiffuse(vec3 vNormal, vec3 vViewPosition, float metallic){\n // make 2 seperate builds \n vec3 worldCameraPosition = vec3(0.0, 0.0, 0.0); // hardcoded world camera position\n vec3 worldNormal = normalize(vNormal * uCameraNormalMatrix);\n vec2 newTexCoor = mapTextureToNormal( worldNormal );\n vec4 texture = TEXTURE( environmentMapDiffused, newTexCoor );\n // this is to make the darker sections more dark\n // png and jpg usually flatten the brightness so it is to reverse that\n return mix(smoothstep(vec3(0.0), vec3(1.0), texture.xyz), vec3(0.0), metallic);\n}\n\nvec3 calculateImageSpecular(vec3 vNormal, vec3 vViewPosition, float shininess, float metallic){\n vec3 worldCameraPosition = vec3(0.0, 0.0, 0.0);\n vec3 worldNormal = normalize(vNormal);\n vec3 lightDirection = normalize( vViewPosition - worldCameraPosition );\n vec3 R = reflect(lightDirection, worldNormal) * uCameraNormalMatrix;\n vec2 newTexCoor = mapTextureToNormal( R );\n#ifdef WEBGL2\n // In p5js the range of shininess is >= 1,\n // Therefore roughness range will be ([0,1]*8)*20 or [0, 160]\n // The factor of 8 is because currently the getSpecularTexture\n // only calculated 8 different levels of roughness\n // The factor of 20 is just to spread up this range so that,\n // [1, max] of shininess is converted to [0,160] of roughness\n float roughness = 20. / shininess;\n vec4 outColor = textureLod(environmentMapSpecular, newTexCoor, roughness * 8.);\n#else\n vec4 outColor = TEXTURE(environmentMapSpecular, newTexCoor);\n#endif\n // this is to make the darker sections more dark\n // png and jpg usually flatten the brightness so it is to reverse that\n return mix(\n pow(outColor.xyz, vec3(10)),\n pow(outColor.xyz, vec3(1.2)),\n metallic \n );\n}\n\nvoid totalLight(\n vec3 modelPosition,\n vec3 normal,\n float shininess,\n float metallic,\n out vec3 totalDiffuse,\n out vec3 totalSpecular\n) {\n\n totalSpecular = vec3(0.0);\n\n if (!uUseLighting) {\n totalDiffuse = vec3(1.0);\n return;\n }\n\n totalDiffuse = vec3(0.0);\n\n vec3 viewDirection = normalize(-modelPosition);\n\n for (int j = 0; j < 5; j++) {\n if (j < uDirectionalLightCount) {\n vec3 lightVector = (uViewMatrix * vec4(uLightingDirection[j], 0.0)).xyz;\n vec3 lightColor = uDirectionalDiffuseColors[j];\n vec3 specularColor = uDirectionalSpecularColors[j];\n LightResult result = _light(viewDirection, normal, lightVector, shininess, metallic);\n totalDiffuse += result.diffuse * lightColor;\n totalSpecular += result.specular * lightColor * specularColor;\n }\n\n if (j < uPointLightCount) {\n vec3 lightPosition = (uViewMatrix * vec4(uPointLightLocation[j], 1.0)).xyz;\n vec3 lightVector = modelPosition - lightPosition;\n //calculate attenuation\n float lightDistance = length(lightVector);\n float lightFalloff = 1.0 / (uConstantAttenuation + lightDistance * uLinearAttenuation + (lightDistance * lightDistance) * uQuadraticAttenuation);\n vec3 lightColor = lightFalloff * uPointLightDiffuseColors[j];\n vec3 specularColor = lightFalloff * uPointLightSpecularColors[j];\n\n LightResult result = _light(viewDirection, normal, lightVector, shininess, metallic);\n totalDiffuse += result.diffuse * lightColor;\n totalSpecular += result.specular * lightColor * specularColor;\n }\n\n if(j < uSpotLightCount) {\n vec3 lightPosition = (uViewMatrix * vec4(uSpotLightLocation[j], 1.0)).xyz;\n vec3 lightVector = modelPosition - lightPosition;\n \n float lightDistance = length(lightVector);\n float lightFalloff = 1.0 / (uConstantAttenuation + lightDistance * uLinearAttenuation + (lightDistance * lightDistance) * uQuadraticAttenuation);\n\n vec3 lightDirection = (uViewMatrix * vec4(uSpotLightDirection[j], 0.0)).xyz;\n float spotDot = dot(normalize(lightVector), normalize(lightDirection));\n float spotFalloff;\n if(spotDot < uSpotLightAngle[j]) {\n spotFalloff = 0.0;\n }\n else {\n spotFalloff = pow(spotDot, uSpotLightConc[j]);\n }\n lightFalloff *= spotFalloff;\n\n vec3 lightColor = uSpotLightDiffuseColors[j];\n vec3 specularColor = uSpotLightSpecularColors[j];\n \n LightResult result = _light(viewDirection, normal, lightVector, shininess, metallic);\n \n totalDiffuse += result.diffuse * lightColor * lightFalloff;\n totalSpecular += result.specular * lightColor * specularColor * lightFalloff;\n }\n }\n\n if( uUseImageLight ){\n totalDiffuse += calculateImageDiffuse(normal, modelPosition, metallic);\n totalSpecular += calculateImageSpecular(normal, modelPosition, shininess, metallic);\n }\n\n totalDiffuse *= diffuseFactor;\n totalSpecular *= specularFactor;\n}\n';const{lineDefs:Gu}=Un((e,t)=>`#define ${e} ${t}\n`),ju={normalVert:"IN vec3 aPosition;\nIN vec3 aNormal;\nIN vec2 aTexCoord;\nIN vec4 aVertexColor;\n\n#define HOOK_DEFINES\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\nuniform mat4 uModelMatrix;\nuniform mat4 uViewMatrix;\nuniform mat3 uModelNormalMatrix;\nuniform mat3 uCameraNormalMatrix;\n#else\nuniform mat4 uModelViewMatrix;\nuniform mat3 uNormalMatrix;\n#endif\nuniform mat4 uProjectionMatrix;\n\nuniform vec4 uMaterialColor;\nuniform bool uUseVertexColor;\n\nOUT vec3 vVertexNormal;\nOUT highp vec2 vVertTexCoord;\nOUT vec4 vColor;\n\nstruct Vertex {\n vec3 position;\n vec3 normal;\n vec2 texCoord;\n vec4 color;\n};\n\nvoid main(void) {\n HOOK_beforeVertex();\n\n Vertex inputs;\n inputs.position = aPosition;\n inputs.normal = aNormal;\n inputs.texCoord = aTexCoord;\n inputs.color = (uUseVertexColor && aVertexColor.x >= 0.0) ? aVertexColor : uMaterialColor;\n#ifdef AUGMENTED_HOOK_getObjectInputs\n inputs = HOOK_getObjectInputs(inputs);\n#endif\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\n inputs.position = (uModelMatrix * vec4(inputs.position, 1.)).xyz;\n inputs.normal = uModelNormalMatrix * inputs.normal;\n inputs = HOOK_getWorldInputs(inputs);\n#endif\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\n // Already multiplied by the model matrix, just apply view\n inputs.position = (uViewMatrix * vec4(inputs.position, 1.)).xyz;\n inputs.normal = uCameraNormalMatrix * inputs.normal;\n#else\n // Apply both at once\n inputs.position = (uModelViewMatrix * vec4(inputs.position, 1.)).xyz;\n inputs.normal = uNormalMatrix * inputs.normal;\n#endif\n#ifdef AUGMENTED_HOOK_getCameraInputs\n inputs = HOOK_getCameraInputs(inputs);\n#endif\n\n // Pass varyings to fragment shader\n vVertTexCoord = inputs.texCoord;\n vVertexNormal = normalize(inputs.normal);\n vColor = inputs.color;\n\n gl_Position = uProjectionMatrix * vec4(inputs.position, 1.);\n\n HOOK_afterVertex();\n}\n",normalFrag:"IN vec3 vVertexNormal;\nvoid main(void) {\n HOOK_beforeFragment();\n OUT_COLOR = HOOK_getFinalColor(vec4(vVertexNormal, 1.0));\n HOOK_afterFragment();\n}\n",basicFrag:"IN vec4 vColor;\nvoid main(void) {\n HOOK_beforeFragment();\n OUT_COLOR = HOOK_getFinalColor(vColor);\n OUT_COLOR.rgb *= OUT_COLOR.a; // Premultiply alpha before rendering\n HOOK_afterFragment();\n}\n",lightVert:zu+"// include lighting.glgl\n\nIN vec3 aPosition;\nIN vec3 aNormal;\nIN vec2 aTexCoord;\nIN vec4 aVertexColor;\n\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\nuniform mat3 uNormalMatrix;\n\nuniform bool uUseVertexColor;\nuniform vec4 uMaterialColor;\n\nOUT highp vec2 vVertTexCoord;\nOUT vec3 vDiffuseColor;\nOUT vec3 vSpecularColor;\nOUT vec4 vColor;\n\nvoid main(void) {\n\n vec4 viewModelPosition = uModelViewMatrix * vec4(aPosition, 1.0);\n gl_Position = uProjectionMatrix * viewModelPosition;\n\n vec3 vertexNormal = normalize(uNormalMatrix * aNormal);\n vVertTexCoord = aTexCoord;\n\n totalLight(viewModelPosition.xyz, vertexNormal, vDiffuseColor, vSpecularColor);\n\n for (int i = 0; i < 8; i++) {\n if (i < uAmbientLightCount) {\n vDiffuseColor += uAmbientColor[i];\n }\n }\n \n vColor = ((uUseVertexColor && aVertexColor.x >= 0.0) ? aVertexColor : uMaterialColor);\n}\n",lightTextureFrag:"uniform vec4 uTint;\nuniform sampler2D uSampler;\nuniform bool isTexture;\nuniform bool uEmissive;\n\nIN highp vec2 vVertTexCoord;\nIN vec3 vDiffuseColor;\nIN vec3 vSpecularColor;\nIN vec4 vColor;\n\nvoid main(void) {\n if(uEmissive && !isTexture) {\n OUT_COLOR = vColor;\n }\n else {\n vec4 baseColor = isTexture\n // Textures come in with premultiplied alpha. To apply tint and still have\n // premultiplied alpha output, we need to multiply the RGB channels by the\n // tint RGB, and all channels by the tint alpha.\n ? TEXTURE(uSampler, vVertTexCoord) * vec4(uTint.rgb/255., 1.) * (uTint.a/255.)\n // Colors come in with unmultiplied alpha, so we need to multiply the RGB\n // channels by alpha to convert it to premultiplied alpha.\n : vec4(vColor.rgb * vColor.a, vColor.a);\n OUT_COLOR = vec4(baseColor.rgb * vDiffuseColor + vSpecularColor, baseColor.a);\n }\n}\n",phongVert:"precision highp int;\n\n#define HOOK_DEFINES\n\nIN vec3 aPosition;\nIN vec3 aNormal;\nIN vec2 aTexCoord;\nIN vec4 aVertexColor;\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\nuniform mat4 uModelMatrix;\nuniform mat4 uViewMatrix;\nuniform mat3 uModelNormalMatrix;\nuniform mat3 uCameraNormalMatrix;\n#else\nuniform mat4 uModelViewMatrix;\nuniform mat3 uNormalMatrix;\n#endif\nuniform mat4 uProjectionMatrix;\n\nuniform bool uUseVertexColor;\nuniform vec4 uMaterialColor;\n\nOUT vec3 vNormal;\nOUT vec2 vTexCoord;\nOUT vec3 vViewPosition;\nOUT vec3 vAmbientColor;\nOUT vec4 vColor;\n\nstruct Vertex {\n vec3 position;\n vec3 normal;\n vec2 texCoord;\n vec4 color;\n};\n\nvoid main(void) {\n HOOK_beforeVertex();\n\n Vertex inputs;\n inputs.position = aPosition;\n inputs.normal = aNormal;\n inputs.texCoord = aTexCoord;\n inputs.color = (uUseVertexColor && aVertexColor.x >= 0.0) ? aVertexColor : uMaterialColor;\n#ifdef AUGMENTED_HOOK_getObjectInputs\n inputs = HOOK_getObjectInputs(inputs);\n#endif\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\n inputs.position = (uModelMatrix * vec4(inputs.position, 1.)).xyz;\n inputs.normal = uModelNormalMatrix * inputs.normal;\n inputs = HOOK_getWorldInputs(inputs);\n#endif\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\n // Already multiplied by the model matrix, just apply view\n inputs.position = (uViewMatrix * vec4(inputs.position, 1.)).xyz;\n inputs.normal = uCameraNormalMatrix * inputs.normal;\n#else\n // Apply both at once\n inputs.position = (uModelViewMatrix * vec4(inputs.position, 1.)).xyz;\n inputs.normal = uNormalMatrix * inputs.normal;\n#endif\n#ifdef AUGMENTED_HOOK_getCameraInputs\n inputs = HOOK_getCameraInputs(inputs);\n#endif\n\n // Pass varyings to fragment shader\n vViewPosition = inputs.position;\n vTexCoord = inputs.texCoord;\n vNormal = inputs.normal;\n vColor = inputs.color;\n\n gl_Position = uProjectionMatrix * vec4(inputs.position, 1.);\n HOOK_afterVertex();\n}\n",phongFrag:zu+"// include lighting.glsl\nprecision highp int;\n\nuniform bool uHasSetAmbient;\nuniform vec3 uAmbientColor;\nuniform vec4 uSpecularMatColor;\nuniform vec4 uAmbientMatColor;\nuniform vec4 uEmissiveMatColor;\n\nuniform vec4 uTint;\nuniform sampler2D uSampler;\nuniform bool isTexture;\n\nIN vec3 vNormal;\nIN vec2 vTexCoord;\nIN vec3 vViewPosition;\nIN vec4 vColor;\n\nstruct ColorComponents {\n vec3 baseColor;\n float opacity;\n vec3 ambientColor;\n vec3 specularColor;\n vec3 diffuse;\n vec3 ambient;\n vec3 specular;\n vec3 emissive;\n};\n\nstruct Inputs {\n vec3 normal;\n vec2 texCoord;\n vec3 ambientLight;\n vec3 ambientMaterial;\n vec3 specularMaterial;\n vec3 emissiveMaterial;\n vec4 color;\n float shininess;\n float metalness;\n};\n\nvoid main(void) {\n HOOK_beforeFragment();\n\n Inputs inputs;\n inputs.normal = normalize(vNormal);\n inputs.texCoord = vTexCoord;\n inputs.ambientLight = uAmbientColor;\n inputs.color = isTexture\n ? TEXTURE(uSampler, vTexCoord) * (vec4(uTint.rgb/255., 1.) * uTint.a/255.)\n : vColor;\n if (isTexture && inputs.color.a > 0.0) {\n // Textures come in with premultiplied alpha. Temporarily unpremultiply it\n // so hooks users don't have to think about premultiplied alpha.\n inputs.color.rgb /= inputs.color.a;\n }\n inputs.shininess = uShininess;\n inputs.metalness = uMetallic;\n inputs.ambientMaterial = uHasSetAmbient ? uAmbientMatColor.rgb : inputs.color.rgb;\n inputs.specularMaterial = uSpecularMatColor.rgb;\n inputs.emissiveMaterial = uEmissiveMatColor.rgb;\n inputs = HOOK_getPixelInputs(inputs);\n\n vec3 diffuse;\n vec3 specular;\n totalLight(vViewPosition, inputs.normal, inputs.shininess, inputs.metalness, diffuse, specular);\n\n // Calculating final color as result of all lights (plus emissive term).\n\n vec4 baseColor = inputs.color;\n ColorComponents c;\n c.opacity = baseColor.a;\n c.baseColor = baseColor.rgb;\n c.ambientColor = inputs.ambientMaterial;\n c.specularColor = inputs.specularMaterial;\n c.diffuse = diffuse;\n c.ambient = inputs.ambientLight;\n c.specular = specular;\n c.emissive = inputs.emissiveMaterial;\n OUT_COLOR = HOOK_getFinalColor(HOOK_combineColors(c));\n OUT_COLOR.rgb *= OUT_COLOR.a; // Premultiply alpha before rendering\n HOOK_afterFragment();\n}\n",fontVert:"IN vec3 aPosition;\nIN vec2 aTexCoord;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nuniform vec4 uGlyphRect;\nuniform float uGlyphOffset;\n\nOUT vec2 vTexCoord;\n\nvoid main() {\n vec4 positionVec4 = vec4(aPosition, 1.0);\n\n // scale by the size of the glyph's rectangle\n positionVec4.xy *= uGlyphRect.zw - uGlyphRect.xy;\n\n // Expand glyph bounding boxes by 1px on each side to give a bit of room\n // for antialiasing\n vec3 newOrigin = (uModelViewMatrix * vec4(0., 0., 0., 1.)).xyz;\n vec3 newDX = (uModelViewMatrix * vec4(1., 0., 0., 1.)).xyz;\n vec3 newDY = (uModelViewMatrix * vec4(0., 1., 0., 1.)).xyz;\n vec2 pixelScale = vec2(\n 1. / length(newOrigin - newDX),\n 1. / length(newOrigin - newDY)\n );\n vec2 offset = pixelScale * normalize(aTexCoord - vec2(0.5, 0.5));\n vec2 textureOffset = offset * (1. / vec2(\n uGlyphRect.z - uGlyphRect.x,\n uGlyphRect.w - uGlyphRect.y\n ));\n\n // move to the corner of the glyph\n positionVec4.xy += uGlyphRect.xy;\n\n // move to the letter's line offset\n positionVec4.x += uGlyphOffset;\n\n positionVec4.xy += offset;\n \n gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n vTexCoord = aTexCoord + textureOffset;\n}\n",fontFrag:"#ifndef WEBGL2\n#extension GL_OES_standard_derivatives : enable\n#endif\n\n#if 0\n // simulate integer math using floats\n\t#define int float\n\t#define ivec2 vec2\n\t#define INT(x) float(x)\n\n\tint ifloor(float v) { return floor(v); }\n\tivec2 ifloor(vec2 v) { return floor(v); }\n\n#else\n // use native integer math\n\tprecision highp int;\n\t#define INT(x) x\n\n\tint ifloor(float v) { return int(v); }\n\tint ifloor(int v) { return v; }\n\tivec2 ifloor(vec2 v) { return ivec2(v); }\n\n#endif\n\nuniform sampler2D uSamplerStrokes;\nuniform sampler2D uSamplerRowStrokes;\nuniform sampler2D uSamplerRows;\nuniform sampler2D uSamplerColStrokes;\nuniform sampler2D uSamplerCols;\n\nuniform ivec2 uStrokeImageSize;\nuniform ivec2 uCellsImageSize;\nuniform ivec2 uGridImageSize;\n\nuniform ivec2 uGridOffset;\nuniform ivec2 uGridSize;\nuniform vec4 uMaterialColor;\n\nIN vec2 vTexCoord;\n\n// some helper functions\nint ROUND(float v) { return ifloor(v + 0.5); }\nivec2 ROUND(vec2 v) { return ifloor(v + 0.5); }\nfloat saturate(float v) { return clamp(v, 0.0, 1.0); }\nvec2 saturate(vec2 v) { return clamp(v, 0.0, 1.0); }\n\nint mul(float v1, int v2) {\n return ifloor(v1 * float(v2));\n}\n\nivec2 mul(vec2 v1, ivec2 v2) {\n return ifloor(v1 * vec2(v2) + 0.5);\n}\n\n// unpack a 16-bit integer from a float vec2\nint getInt16(vec2 v) {\n ivec2 iv = ROUND(v * 255.0);\n return iv.x * INT(128) + iv.y;\n}\n\nvec2 pixelScale;\nvec2 coverage = vec2(0.0);\nvec2 weight = vec2(0.5);\nconst float minDistance = 1.0/8192.0;\nconst float hardness = 1.05; // amount of antialias\n\n// the maximum number of curves in a glyph\nconst int N = INT(250);\n\n// retrieves an indexed pixel from a sampler\nvec4 getTexel(sampler2D sampler, int pos, ivec2 size) {\n int width = size.x;\n int y = ifloor(pos / width);\n int x = pos - y * width; // pos % width\n\n return TEXTURE(sampler, (vec2(x, y) + 0.5) / vec2(size));\n}\n\nvoid calulateCrossings(vec2 p0, vec2 p1, vec2 p2, out vec2 C1, out vec2 C2) {\n\n // get the coefficients of the quadratic in t\n vec2 a = p0 - p1 * 2.0 + p2;\n vec2 b = p0 - p1;\n vec2 c = p0 - vTexCoord;\n\n // found out which values of 't' it crosses the axes\n vec2 surd = sqrt(max(vec2(0.0), b * b - a * c));\n vec2 t1 = ((b - surd) / a).yx;\n vec2 t2 = ((b + surd) / a).yx;\n\n // approximate straight lines to avoid rounding errors\n if (abs(a.y) < 0.001)\n t1.x = t2.x = c.y / (2.0 * b.y);\n\n if (abs(a.x) < 0.001)\n t1.y = t2.y = c.x / (2.0 * b.x);\n\n // plug into quadratic formula to find the corrdinates of the crossings\n C1 = ((a * t1 - b * 2.0) * t1 + c) * pixelScale;\n C2 = ((a * t2 - b * 2.0) * t2 + c) * pixelScale;\n}\n\nvoid coverageX(vec2 p0, vec2 p1, vec2 p2) {\n\n vec2 C1, C2;\n calulateCrossings(p0, p1, p2, C1, C2);\n\n // determine on which side of the x-axis the points lie\n bool y0 = p0.y > vTexCoord.y;\n bool y1 = p1.y > vTexCoord.y;\n bool y2 = p2.y > vTexCoord.y;\n\n // could web be under the curve (after t1)?\n if (y1 ? !y2 : y0) {\n // add the coverage for t1\n coverage.x += saturate(C1.x + 0.5);\n // calculate the anti-aliasing for t1\n weight.x = min(weight.x, abs(C1.x));\n }\n\n // are we outside the curve (after t2)?\n if (y1 ? !y0 : y2) {\n // subtract the coverage for t2\n coverage.x -= saturate(C2.x + 0.5);\n // calculate the anti-aliasing for t2\n weight.x = min(weight.x, abs(C2.x));\n }\n}\n\n// this is essentially the same as coverageX, but with the axes swapped\nvoid coverageY(vec2 p0, vec2 p1, vec2 p2) {\n\n vec2 C1, C2;\n calulateCrossings(p0, p1, p2, C1, C2);\n\n bool x0 = p0.x > vTexCoord.x;\n bool x1 = p1.x > vTexCoord.x;\n bool x2 = p2.x > vTexCoord.x;\n\n if (x1 ? !x2 : x0) {\n coverage.y -= saturate(C1.y + 0.5);\n weight.y = min(weight.y, abs(C1.y));\n }\n\n if (x1 ? !x0 : x2) {\n coverage.y += saturate(C2.y + 0.5);\n weight.y = min(weight.y, abs(C2.y));\n }\n}\n\nvoid main() {\n\n // calculate the pixel scale based on screen-coordinates\n pixelScale = hardness / fwidth(vTexCoord);\n\n // which grid cell is this pixel in?\n ivec2 gridCoord = ifloor(vTexCoord * vec2(uGridSize));\n\n // intersect curves in this row\n {\n // the index into the row info bitmap\n int rowIndex = gridCoord.y + uGridOffset.y;\n // fetch the info texel\n vec4 rowInfo = getTexel(uSamplerRows, rowIndex, uGridImageSize);\n // unpack the rowInfo\n int rowStrokeIndex = getInt16(rowInfo.xy);\n int rowStrokeCount = getInt16(rowInfo.zw);\n\n for (int iRowStroke = INT(0); iRowStroke < N; iRowStroke++) {\n if (iRowStroke >= rowStrokeCount)\n break;\n\n // each stroke is made up of 3 points: the start and control point\n // and the start of the next curve.\n // fetch the indices of this pair of strokes:\n vec4 strokeIndices = getTexel(uSamplerRowStrokes, rowStrokeIndex++, uCellsImageSize);\n\n // unpack the stroke index\n int strokePos = getInt16(strokeIndices.xy);\n\n // fetch the two strokes\n vec4 stroke0 = getTexel(uSamplerStrokes, strokePos + INT(0), uStrokeImageSize);\n vec4 stroke1 = getTexel(uSamplerStrokes, strokePos + INT(1), uStrokeImageSize);\n\n // calculate the coverage\n coverageX(stroke0.xy, stroke0.zw, stroke1.xy);\n }\n }\n\n // intersect curves in this column\n {\n int colIndex = gridCoord.x + uGridOffset.x;\n vec4 colInfo = getTexel(uSamplerCols, colIndex, uGridImageSize);\n int colStrokeIndex = getInt16(colInfo.xy);\n int colStrokeCount = getInt16(colInfo.zw);\n \n for (int iColStroke = INT(0); iColStroke < N; iColStroke++) {\n if (iColStroke >= colStrokeCount)\n break;\n\n vec4 strokeIndices = getTexel(uSamplerColStrokes, colStrokeIndex++, uCellsImageSize);\n\n int strokePos = getInt16(strokeIndices.xy);\n vec4 stroke0 = getTexel(uSamplerStrokes, strokePos + INT(0), uStrokeImageSize);\n vec4 stroke1 = getTexel(uSamplerStrokes, strokePos + INT(1), uStrokeImageSize);\n coverageY(stroke0.xy, stroke0.zw, stroke1.xy);\n }\n }\n\n weight = saturate(1.0 - weight * 2.0);\n float distance = max(weight.x + weight.y, minDistance); // manhattan approx.\n float antialias = abs(dot(coverage, weight) / distance);\n float cover = min(abs(coverage.x), abs(coverage.y));\n OUT_COLOR = vec4(uMaterialColor.rgb, 1.) * uMaterialColor.a;\n OUT_COLOR *= saturate(max(antialias, cover));\n}\n",lineVert:Gu+"/*\n Part of the Processing project - http://processing.org\n Copyright (c) 2012-15 The Processing Foundation\n Copyright (c) 2004-12 Ben Fry and Casey Reas\n Copyright (c) 2001-04 Massachusetts Institute of Technology\n This library is free software; you can redistribute it and/or\n modify it under the terms of the GNU Lesser General Public\n License as published by the Free Software Foundation, version 2.1.\n This library is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n You should have received a copy of the GNU Lesser General\n Public License along with this library; if not, write to the\n Free Software Foundation, Inc., 59 Temple Place, Suite 330,\n Boston, MA 02111-1307 USA\n*/\n\n#define PROCESSING_LINE_SHADER\n\n#define HOOK_DEFINES\n\nprecision highp int;\nprecision highp float;\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\nuniform mat4 uModelMatrix;\nuniform mat4 uViewMatrix;\n#else\nuniform mat4 uModelViewMatrix;\n#endif\n\nuniform mat4 uProjectionMatrix;\nuniform float uStrokeWeight;\n\nuniform bool uUseLineColor;\nuniform bool uSimpleLines;\nuniform vec4 uMaterialColor;\n\nuniform vec4 uViewport;\nuniform int uPerspective;\nuniform int uStrokeJoin;\n\nIN vec3 aPosition;\nIN vec3 aTangentIn;\nIN vec3 aTangentOut;\nIN float aSide;\nIN vec4 aVertexColor;\n\nOUT vec4 vColor;\nOUT vec2 vTangent;\nOUT vec2 vCenter;\nOUT vec2 vPosition;\nOUT float vMaxDist;\nOUT float vCap;\nOUT float vJoin;\nOUT float vStrokeWeight;\n\nvec2 lineIntersection(vec2 aPoint, vec2 aDir, vec2 bPoint, vec2 bDir) {\n // Rotate and translate so a starts at the origin and goes out to the right\n bPoint -= aPoint;\n vec2 rotatedBFrom = vec2(\n bPoint.x*aDir.x + bPoint.y*aDir.y,\n bPoint.y*aDir.x - bPoint.x*aDir.y\n );\n vec2 bTo = bPoint + bDir;\n vec2 rotatedBTo = vec2(\n bTo.x*aDir.x + bTo.y*aDir.y,\n bTo.y*aDir.x - bTo.x*aDir.y\n );\n float intersectionDistance =\n rotatedBTo.x + (rotatedBFrom.x - rotatedBTo.x) * rotatedBTo.y /\n (rotatedBTo.y - rotatedBFrom.y);\n return aPoint + aDir * intersectionDistance;\n}\n\nstruct StrokeVertex {\n vec3 position;\n vec3 tangentIn;\n vec3 tangentOut;\n vec4 color;\n float weight;\n};\n\nvoid main() {\n HOOK_beforeVertex();\n\n if (!uSimpleLines) {\n // Caps have one of either the in or out tangent set to 0\n vCap = (aTangentIn == vec3(0.)) != (aTangentOut == vec3(0.)) ? 1. : 0.;\n\n // Joins have two unique, defined tangents\n vJoin = (\n aTangentIn != vec3(0.) &&\n aTangentOut != vec3(0.) &&\n aTangentIn != aTangentOut\n ) ? 1. : 0.;\n }\n\n StrokeVertex inputs;\n inputs.position = aPosition.xyz;\n inputs.color = uUseLineColor ? aVertexColor : uMaterialColor;\n inputs.weight = uStrokeWeight;\n inputs.tangentIn = aTangentIn;\n inputs.tangentOut = aTangentOut;\n\n#ifdef AUGMENTED_HOOK_getObjectInputs\n inputs = HOOK_getObjectInputs(inputs);\n#endif\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\n inputs.position = (uModelMatrix * vec4(inputs.position, 1.)).xyz;\n inputs.tangentIn = (uModelMatrix * vec4(aTangentIn, 0.)).xyz;\n inputs.tangentOut = (uModelMatrix * vec4(aTangentOut, 0.)).xyz;\n inputs = HOOK_getWorldInputs(inputs);\n#endif\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\n // Already multiplied by the model matrix, just apply view\n inputs.position = (uViewMatrix * vec4(inputs.position, 1.)).xyz;\n inputs.tangentIn = (uViewMatrix * vec4(aTangentIn, 0.)).xyz;\n inputs.tangentOut = (uViewMatrix * vec4(aTangentOut, 0.)).xyz;\n#else\n // Apply both at once\n inputs.position = (uModelViewMatrix * vec4(inputs.position, 1.)).xyz;\n inputs.tangentIn = (uModelViewMatrix * vec4(aTangentIn, 0.)).xyz;\n inputs.tangentOut = (uModelViewMatrix * vec4(aTangentOut, 0.)).xyz;\n#endif\n#ifdef AUGMENTED_HOOK_getCameraInputs\n inputs = HOOK_getCameraInputs(inputs);\n#endif\n\n vec4 posp = vec4(inputs.position, 1.);\n vec4 posqIn = vec4(inputs.position + inputs.tangentIn, 1.);\n vec4 posqOut = vec4(inputs.position + inputs.tangentOut, 1.);\n vStrokeWeight = inputs.weight;\n\n float facingCamera = pow(\n // The word space tangent's z value is 0 if it's facing the camera\n abs(normalize(posqIn-posp).z),\n\n // Using pow() here to ramp `facingCamera` up from 0 to 1 really quickly\n // so most lines get scaled and don't get clipped\n 0.25\n );\n\n // Moving vertices slightly toward the camera\n // to avoid depth-fighting with the fill triangles.\n // A mix of scaling and offsetting is used based on distance\n // Discussion here:\n // https://github.com/processing/p5.js/issues/7200 \n\n // using a scale <1 moves the lines towards nearby camera\n // in order to prevent popping effects due to half of\n // the line disappearing behind the geometry faces.\n float zDistance = -posp.z; \n float distanceFactor = smoothstep(0.0, 800.0, zDistance); \n \n // Discussed here:\n // http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=252848 \n float scale = mix(1., 0.995, facingCamera);\n float dynamicScale = mix(scale, 1.0, distanceFactor); // Closer = more scale, farther = less\n\n posp.xyz = posp.xyz * dynamicScale;\n posqIn.xyz = posqIn.xyz * dynamicScale;\n posqOut.xyz = posqOut.xyz * dynamicScale;\n\n // Moving vertices slightly toward camera when far away \n // https://github.com/processing/p5.js/issues/6956 \n float zOffset = mix(0., -1., facingCamera);\n float dynamicZAdjustment = mix(0.0, zOffset, distanceFactor); // Closer = less zAdjustment, farther = more\n\n posp.z -= dynamicZAdjustment;\n posqIn.z -= dynamicZAdjustment;\n posqOut.z -= dynamicZAdjustment;\n \n vec4 p = uProjectionMatrix * posp;\n vec4 qIn = uProjectionMatrix * posqIn;\n vec4 qOut = uProjectionMatrix * posqOut;\n\n // formula to convert from clip space (range -1..1) to screen space (range 0..[width or height])\n // screen_p = (p.xy/p.w + <1,1>) * 0.5 * uViewport.zw\n\n // prevent division by W by transforming the tangent formula (div by 0 causes\n // the line to disappear, see https://github.com/processing/processing/issues/5183)\n // t = screen_q - screen_p\n //\n // tangent is normalized and we don't care which aDirection it points to (+-)\n // t = +- normalize( screen_q - screen_p )\n // t = +- normalize( (q.xy/q.w+<1,1>)*0.5*uViewport.zw - (p.xy/p.w+<1,1>)*0.5*uViewport.zw )\n //\n // extract common factor, <1,1> - <1,1> cancels out\n // t = +- normalize( (q.xy/q.w - p.xy/p.w) * 0.5 * uViewport.zw )\n //\n // convert to common divisor\n // t = +- normalize( ((q.xy*p.w - p.xy*q.w) / (p.w*q.w)) * 0.5 * uViewport.zw )\n //\n // remove the common scalar divisor/factor, not needed due to normalize and +-\n // (keep uViewport - can't remove because it has different components for x and y\n // and corrects for aspect ratio, see https://github.com/processing/processing/issues/5181)\n // t = +- normalize( (q.xy*p.w - p.xy*q.w) * uViewport.zw )\n\n vec2 tangentIn = normalize((qIn.xy*p.w - p.xy*qIn.w) * uViewport.zw);\n vec2 tangentOut = normalize((qOut.xy*p.w - p.xy*qOut.w) * uViewport.zw);\n\n vec2 curPerspScale;\n if(uPerspective == 1) {\n // Perspective ---\n // convert from world to clip by multiplying with projection scaling factor\n // to get the right thickness (see https://github.com/processing/processing/issues/5182)\n\n // The y value of the projection matrix may be flipped if rendering to a Framebuffer.\n // Multiplying again by its sign here negates the flip to get just the scale.\n curPerspScale = (uProjectionMatrix * vec4(1, sign(uProjectionMatrix[1][1]), 0, 0)).xy;\n } else {\n // No Perspective ---\n // multiply by W (to cancel out division by W later in the pipeline) and\n // convert from screen to clip (derived from clip to screen above)\n curPerspScale = p.w / (0.5 * uViewport.zw);\n }\n\n vec2 offset;\n if (vJoin == 1. && !uSimpleLines) {\n vTangent = normalize(tangentIn + tangentOut);\n vec2 normalIn = vec2(-tangentIn.y, tangentIn.x);\n vec2 normalOut = vec2(-tangentOut.y, tangentOut.x);\n float side = sign(aSide);\n float sideEnum = abs(aSide);\n\n // We generate vertices for joins on either side of the centerline, but\n // the \"elbow\" side is the only one needing a join. By not setting the\n // offset for the other side, all its vertices will end up in the same\n // spot and not render, effectively discarding it.\n if (sign(dot(tangentOut, vec2(-tangentIn.y, tangentIn.x))) != side) {\n // Side enums:\n // 1: the side going into the join\n // 2: the middle of the join\n // 3: the side going out of the join\n if (sideEnum == 2.) {\n // Calculate the position + tangent on either side of the join, and\n // find where the lines intersect to find the elbow of the join\n vec2 c = (posp.xy/posp.w + vec2(1.,1.)) * 0.5 * uViewport.zw;\n vec2 intersection = lineIntersection(\n c + (side * normalIn * inputs.weight / 2.),\n tangentIn,\n c + (side * normalOut * inputs.weight / 2.),\n tangentOut\n );\n offset = (intersection - c);\n\n // When lines are thick and the angle of the join approaches 180, the\n // elbow might be really far from the center. We'll apply a limit to\n // the magnitude to avoid lines going across the whole screen when this\n // happens.\n float mag = length(offset);\n float maxMag = 3. * inputs.weight;\n if (mag > maxMag) {\n offset *= maxMag / mag;\n }\n } else if (sideEnum == 1.) {\n offset = side * normalIn * inputs.weight / 2.;\n } else if (sideEnum == 3.) {\n offset = side * normalOut * inputs.weight / 2.;\n }\n }\n if (uStrokeJoin == STROKE_JOIN_BEVEL) {\n vec2 avgNormal = vec2(-vTangent.y, vTangent.x);\n vMaxDist = abs(dot(avgNormal, normalIn * inputs.weight / 2.));\n } else {\n vMaxDist = inputs.weight / 2.;\n }\n } else {\n vec2 tangent = aTangentIn == vec3(0.) ? tangentOut : tangentIn;\n\n vTangent = tangent;\n vec2 normal = vec2(-tangent.y, tangent.x);\n\n float normalOffset = sign(aSide);\n // Caps will have side values of -2 or 2 on the edge of the cap that\n // extends out from the line\n float tangentOffset = abs(aSide) - 1.;\n offset = (normal * normalOffset + tangent * tangentOffset) *\n inputs.weight * 0.5;\n vMaxDist = inputs.weight / 2.;\n }\n\n vCenter = p.xy;\n vPosition = vCenter + offset;\n vColor = inputs.color;\n\n gl_Position.xy = p.xy + offset.xy * curPerspScale;\n gl_Position.zw = p.zw;\n \n HOOK_afterVertex();\n}\n",lineFrag:Gu+"precision highp int;\nprecision highp float;\n\nuniform vec4 uMaterialColor;\nuniform int uStrokeCap;\nuniform int uStrokeJoin;\n\nIN vec4 vColor;\nIN vec2 vTangent;\nIN vec2 vCenter;\nIN vec2 vPosition;\nIN float vStrokeWeight;\nIN float vMaxDist;\nIN float vCap;\nIN float vJoin;\n\nfloat distSquared(vec2 a, vec2 b) {\n vec2 aToB = b - a;\n return dot(aToB, aToB);\n}\n\nstruct Inputs {\n vec4 color;\n vec2 tangent;\n vec2 center;\n vec2 position;\n float strokeWeight;\n};\n\nvoid main() {\n HOOK_beforeFragment();\n\n Inputs inputs;\n inputs.color = vColor;\n inputs.tangent = vTangent;\n inputs.center = vCenter;\n inputs.position = vPosition;\n inputs.strokeWeight = vStrokeWeight;\n inputs = HOOK_getPixelInputs(inputs);\n\n if (vCap > 0.) {\n if (\n uStrokeCap == STROKE_CAP_ROUND &&\n HOOK_shouldDiscard(distSquared(inputs.position, inputs.center) > inputs.strokeWeight * inputs.strokeWeight * 0.25)\n ) {\n discard;\n } else if (\n uStrokeCap == STROKE_CAP_SQUARE &&\n HOOK_shouldDiscard(dot(inputs.position - inputs.center, inputs.tangent) > 0.)\n ) {\n discard;\n // Use full area for PROJECT\n } else if (HOOK_shouldDiscard(false)) {\n discard;\n }\n } else if (vJoin > 0.) {\n if (\n uStrokeJoin == STROKE_JOIN_ROUND &&\n HOOK_shouldDiscard(distSquared(inputs.position, inputs.center) > inputs.strokeWeight * inputs.strokeWeight * 0.25)\n ) {\n discard;\n } else if (uStrokeJoin == STROKE_JOIN_BEVEL) {\n vec2 normal = vec2(-inputs.tangent.y, inputs.tangent.x);\n if (HOOK_shouldDiscard(abs(dot(inputs.position - inputs.center, normal)) > vMaxDist)) {\n discard;\n }\n // Use full area for MITER\n } else if (HOOK_shouldDiscard(false)) {\n discard;\n }\n }\n OUT_COLOR = HOOK_getFinalColor(vec4(inputs.color.rgb, 1.) * inputs.color.a);\n HOOK_afterFragment();\n}\n",imageLightVert:"precision highp float;\nIN vec3 aPosition;\nIN vec3 aNormal;\nIN vec2 aTexCoord;\n\nOUT vec3 localPos;\nOUT vec3 vWorldNormal;\nOUT vec3 vWorldPosition;\nOUT vec2 vTexCoord;\n\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\nuniform mat3 uNormalMatrix;\n\nvoid main() {\n // Multiply the position by the matrix.\n vec4 viewModelPosition = uModelViewMatrix * vec4(aPosition, 1.0);\n gl_Position = uProjectionMatrix * viewModelPosition; \n \n // orient the normals and pass to the fragment shader\n vWorldNormal = uNormalMatrix * aNormal;\n \n // send the view position to the fragment shader\n vWorldPosition = (uModelViewMatrix * vec4(aPosition, 1.0)).xyz;\n \n localPos = vWorldPosition;\n vTexCoord = aTexCoord;\n}\n\n\n/*\nin the vertex shader we'll compute the world position and world oriented normal of the vertices and pass those to the fragment shader as varyings.\n*/\n",imageLightDiffusedFrag:"precision highp float;\nIN vec3 localPos;\n\n// the HDR cubemap converted (can be from an equirectangular environment map.)\nuniform sampler2D environmentMap;\nIN vec2 vTexCoord;\n\nconst float PI = 3.14159265359;\n\nvec2 nTOE( vec3 v ){\n // x = r sin(phi) cos(theta) \n // y = r cos(phi) \n // z = r sin(phi) sin(theta)\n float phi = acos( v.y );\n // if phi is 0, then there are no x, z components\n float theta = 0.0;\n // else \n theta = acos(v.x / sin(phi));\n float sinTheta = v.z / sin(phi);\n if (sinTheta < 0.0) {\n // Turn it into -theta, but in the 0-2PI range\n theta = 2.0 * PI - theta;\n }\n theta = theta / (2.0 * 3.14159);\n phi = phi / 3.14159 ;\n \n vec2 angles = vec2( phi, theta );\n return angles;\n}\n\nfloat random(vec2 p) {\n vec3 p3 = fract(vec3(p.xyx) * .1031);\n p3 += dot(p3, p3.yzx + 33.33);\n return fract((p3.x + p3.y) * p3.z);\n}\n\nvoid main()\n{ \t \n\t// the sample direction equals the hemisphere's orientation\n float phi = vTexCoord.x * 2.0 * PI;\n float theta = vTexCoord.y * PI;\n float x = sin(theta) * cos(phi);\n float y = sin(theta) * sin(phi);\n float z = cos(theta);\n vec3 normal = vec3( x, y, z);\n\n\t// Discretely sampling the hemisphere given the integral's\n // spherical coordinates translates to the following fragment code:\n\tvec3 irradiance = vec3(0.0); \n\tvec3 up\t= vec3(0.0, 1.0, 0.0);\n\tvec3 right = normalize(cross(up, normal));\n\tup = normalize(cross(normal, right));\n\n\t// We specify a fixed sampleDelta delta value to traverse\n // the hemisphere; decreasing or increasing the sample delta\n // will increase or decrease the accuracy respectively.\n\tconst float sampleDelta = 0.100;\n\tfloat nrSamples = 0.0;\n float randomOffset = random(gl_FragCoord.xy) * sampleDelta;\n\tfor(float rawPhi = 0.0; rawPhi < 2.0 * PI; rawPhi += sampleDelta)\n\t{\n float phi = rawPhi + randomOffset;\n for(float rawTheta = 0.0; rawTheta < ( 0.5 ) * PI; rawTheta += sampleDelta)\n {\n float theta = rawTheta + randomOffset;\n // spherical to cartesian (in tangent space) // tangent space to world // add each sample result to irradiance\n float x = sin(theta) * cos(phi);\n float y = sin(theta) * sin(phi);\n float z = cos(theta);\n vec3 tangentSample = vec3( x, y, z);\n \n vec3 sampleVec = tangentSample.x * right + tangentSample.y * up + tangentSample.z * normal;\n irradiance += (TEXTURE(environmentMap, nTOE(sampleVec)).xyz) * cos(theta) * sin(theta);\n nrSamples++;\n }\n\t}\n\t// divide by the total number of samples taken, giving us the average sampled irradiance.\n\tirradiance = PI * irradiance * (1.0 / float(nrSamples )) ;\n \n \n\tOUT_COLOR = vec4(irradiance, 1.0);\n}",imageLightSpecularFrag:"precision highp float;\r\nIN vec3 localPos;\r\nIN vec2 vTexCoord;\r\n\r\n// our texture\r\nuniform sampler2D environmentMap;\r\nuniform float roughness;\r\n\r\nconst float PI = 3.14159265359;\r\n\r\nfloat VanDerCorput(int bits);\r\nvec2 HammersleyNoBitOps(int i, int N);\r\nvec3 ImportanceSampleGGX(vec2 Xi, vec3 N, float roughness);\r\n\r\n\r\nvec2 nTOE( vec3 v ){\r\n // x = r sin(phi) cos(theta) \r\n // y = r cos(phi) \r\n // z = r sin(phi) sin(theta)\r\n float phi = acos( v.y );\r\n // if phi is 0, then there are no x, z components\r\n float theta = 0.0;\r\n // else \r\n theta = acos(v.x / sin(phi));\r\n float sinTheta = v.z / sin(phi);\r\n if (sinTheta < 0.0) {\r\n // Turn it into -theta, but in the 0-2PI range\r\n theta = 2.0 * PI - theta;\r\n }\r\n theta = theta / (2.0 * 3.14159);\r\n phi = phi / 3.14159 ;\r\n \r\n vec2 angles = vec2( phi, theta );\r\n return angles;\r\n}\r\n\r\n\r\nvoid main(){\r\n const int SAMPLE_COUNT = 400; // 4096\r\n int lowRoughnessLimit = int(pow(2.0,(roughness+0.1)*20.0));\r\n float totalWeight = 0.0;\r\n vec3 prefilteredColor = vec3(0.0);\r\n float phi = vTexCoord.x * 2.0 * PI;\r\n float theta = vTexCoord.y * PI;\r\n float x = sin(theta) * cos(phi);\r\n float y = sin(theta) * sin(phi);\r\n float z = cos(theta);\r\n vec3 N = vec3(x,y,z);\r\n vec3 V = N;\r\n for (int i = 0; i < SAMPLE_COUNT; ++i)\r\n {\r\n // break at smaller sample numbers for low roughness levels\r\n if(i == lowRoughnessLimit)\r\n {\r\n break;\r\n }\r\n vec2 Xi = HammersleyNoBitOps(i, SAMPLE_COUNT);\r\n vec3 H = ImportanceSampleGGX(Xi, N, roughness);\r\n vec3 L = normalize(2.0 * dot(V, H) * H - V);\r\n\r\n float NdotL = max(dot(N, L), 0.0);\r\n if (NdotL > 0.0)\r\n {\r\n prefilteredColor += TEXTURE(environmentMap, nTOE(L)).xyz * NdotL;\r\n totalWeight += NdotL;\r\n }\r\n }\r\n prefilteredColor = prefilteredColor / totalWeight;\r\n\r\n OUT_COLOR = vec4(prefilteredColor, 1.0);\r\n}\r\n\r\nvec3 ImportanceSampleGGX(vec2 Xi, vec3 N, float roughness){\r\n float a = roughness * roughness;\r\n\r\n float phi = 2.0 * PI * Xi.x;\r\n float cosTheta = sqrt((1.0 - Xi.y) / (1.0 + (a * a - 1.0) * Xi.y));\r\n float sinTheta = sqrt(1.0 - cosTheta * cosTheta);\r\n // from spherical coordinates to cartesian coordinates\r\n vec3 H;\r\n H.x = cos(phi) * sinTheta;\r\n H.y = sin(phi) * sinTheta;\r\n H.z = cosTheta;\r\n\r\n // from tangent-space vector to world-space sample vector\r\n vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\r\n vec3 tangent = normalize(cross(up, N));\r\n vec3 bitangent = cross(N, tangent);\r\n\r\n vec3 sampleVec = tangent * H.x + bitangent * H.y + N * H.z;\r\n return normalize(sampleVec);\r\n}\r\n\r\n\r\nfloat VanDerCorput(int n, int base)\r\n{\r\n#ifdef WEBGL2\r\n\r\n uint bits = uint(n);\r\n bits = (bits << 16u) | (bits >> 16u);\r\n bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\r\n bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\r\n bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\r\n bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\r\n return float(bits) * 2.3283064365386963e-10; // / 0x100000000\r\n\r\n#else\r\n\r\n float invBase = 1.0 / float(base);\r\n float denom = 1.0;\r\n float result = 0.0;\r\n\r\n\r\n for (int i = 0; i < 32; ++i)\r\n {\r\n if (n > 0)\r\n {\r\n denom = mod(float(n), 2.0);\r\n result += denom * invBase;\r\n invBase = invBase / 2.0;\r\n n = int(float(n) / 2.0);\r\n }\r\n }\r\n\r\n\r\n return result;\r\n\r\n#endif\r\n}\r\n\r\nvec2 HammersleyNoBitOps(int i, int N)\r\n{\r\n return vec2(float(i) / float(N), VanDerCorput(i, 2));\r\n}\r\n",filterBaseVert:ba,filterBaseFrag:va};for(const e in ju)ju[e]=_a+ju[e];class $u extends jn{constructor(e,t,r,i,s){super(e,t,r,i,s),this.webglVersion===n?this.blendExt=this.GL:this.blendExt=this.GL.getExtension("EXT_blend_minmax"),this._userEnabledStencil=!1,this._internalEnable=this.drawingContext.enable,this._internalDisable=this.drawingContext.disable,this.drawingContext.enable=e=>(e===this.drawingContext.STENCIL_TEST&&(this._clipping||(this._userEnabledStencil=!0)),this._internalEnable.call(this.drawingContext,e)),this.drawingContext.disable=e=>(e===this.drawingContext.STENCIL_TEST&&(this._userEnabledStencil=!1),this._internalDisable.call(this.drawingContext,e)),this._cachedBlendMode=void 0,this.strandsBackend=To}setupContext(){this._setAttributeDefaults(this._pInst),this._initContext(),this.GL=this.drawingContext}_applyBlendMode(){if(this._cachedBlendMode===this.states.curBlendMode)return;const e=this.GL;switch(this.states.curBlendMode){case $:e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case q:e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ONE);break;case H:e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_ALPHA);break;case J:e.blendEquation(e.FUNC_ADD),e.blendFunc(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA);break;case Q:e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_COLOR);break;case Z:e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ONE_MINUS_DST_COLOR,e.ONE_MINUS_SRC_COLOR,e.ONE,e.ONE);break;case ee:e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO);break;case K:e.blendEquationSeparate(e.FUNC_REVERSE_SUBTRACT,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case W:this.blendExt?(e.blendEquationSeparate(this.blendExt.MIN||this.blendExt.MIN_EXT,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE,e.ONE,e.ONE)):console.warn("blendMode(DARKEST) does not work in your browser in WEBGL mode.");break;case X:this.blendExt?(e.blendEquationSeparate(this.blendExt.MAX||this.blendExt.MAX_EXT,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE,e.ONE,e.ONE)):console.warn("blendMode(LIGHTEST) does not work in your browser in WEBGL mode.");break;default:console.error("Oops! Somehow Renderer3D set curBlendMode to an unsupported mode.")}this._cachedBlendMode=this.states.curBlendMode}_shaderOptions(){}_useShader(e){this.GL.useProgram(e._glProgram)}_disableRemainingAttributes(e){for(const t of this.registerEnabled.values())Object.keys(e.attributes).some(r=>e.attributes[r].location===t)||(this.GL.disableVertexAttribArray(t),this.registerEnabled.delete(t))}_drawBuffers(e,{mode:t=4,count:r}){const i=this.GL,s=this.geometryBufferCache.getCached(e);if(s)if("stroke"===this._curShader.shaderType)if(1===r)i.drawArrays(i.TRIANGLES,0,e.lineVertices.length/3);else try{i.drawArraysInstanced(i.TRIANGLES,0,e.lineVertices.length/3,r)}catch(e){console.log("🌸 p5.js says: Instancing is only supported in WebGL2 mode")}else if("text"===this._curShader.shaderType)this._bindBuffer(s.indexBuffer,i.ELEMENT_ARRAY_BUFFER),i.drawElements(i.TRIANGLES,6,i.UNSIGNED_SHORT,0);else if(s.indexBuffer){if(this._bindBuffer(s.indexBuffer,i.ELEMENT_ARRAY_BUFFER),this._pInst.webglVersion!==n&&s.indexBufferType===i.UNSIGNED_INT&&!i.getExtension("OES_element_index_uint"))throw new Error("Unable to render a 3d model with > 65535 triangles. Your web browser does not support the WebGL Extension OES_element_index_uint.");if(1===r)i.drawElements(i.TRIANGLES,3*e.faces.length,s.indexBufferType,0);else try{i.drawElementsInstanced(i.TRIANGLES,3*e.faces.length,s.indexBufferType,0,r)}catch(e){console.log("🌸 p5.js says: Instancing is only supported in WebGL2 mode")}}else{const s=4===t?i.TRIANGLES:i.TRIANGLE_STRIP;if(1===r)i.drawArrays(s,0,e.vertices.length);else try{i.drawArraysInstanced(s,0,e.vertices.length,r)}catch(e){console.log("🌸 p5.js says: Instancing is only supported in WebGL2 mode")}}}_beforeDrawText(){this.GL.pixelStorei(this.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1)}_afterDrawText(){this.GL.pixelStorei(this.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}_setAttributeDefaults(e){const t={alpha:!0,depth:!0,stencil:!0,antialias:navigator.userAgent.toLowerCase().includes("safari"),premultipliedAlpha:!0,preserveDrawingBuffer:!0,perPixelLighting:!0,version:2};null===e._glAttributes?e._glAttributes=t:e._glAttributes=Object.assign(t,e._glAttributes)}_setAttributes(e,t){if(void 0===this._pInst._glAttributes)return void console.log("You are trying to use setAttributes on a p5.Graphics object that does not use a WEBGL renderer.");let r=!0;void 0!==t?(null===this._pInst._glAttributes&&(this._pInst._glAttributes={}),this._pInst._glAttributes[e]!==t&&(this._pInst._glAttributes[e]=t,r=!1)):e instanceof Object&&this._pInst._glAttributes!==e&&(this._pInst._glAttributes=e,r=!1),this.isP3D&&!r&&(!this._pInst._setupDone&&this.geometryBufferCache.numCached()>0?p5._friendlyError("Sorry, Could not set the attributes, you need to call setAttributes() before calling the other drawing methods in setup()"):(this._resetContext(null,null,$u),this.states.curCamera&&(this.states.curCamera._renderer=this._renderer)))}_initContext(){if(1!==this._pInst._glAttributes?.version&&(this.drawingContext=this.canvas.getContext("webgl2",this._pInst._glAttributes)),this.webglVersion=this.drawingContext?n:s,this._pInst.webglVersion=this.webglVersion,this.drawingContext||(this.drawingContext=this.canvas.getContext("webgl",this._pInst._glAttributes)||this.canvas.getContext("experimental-webgl",this._pInst._glAttributes)),null===this.drawingContext)throw new Error("Error creating webgl context");{const e=this.drawingContext;e.enable(e.DEPTH_TEST),e.depthFunc(e.LEQUAL),e.viewport(0,0,e.drawingBufferWidth,e.drawingBufferHeight),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this._viewport=this.drawingContext.getParameter(this.drawingContext.VIEWPORT)}}_updateSize(){}_getMaxTextureSize(){const e=this.drawingContext;return e.getParameter(e.MAX_TEXTURE_SIZE)}_adjustDimensions(e,t){this._maxTextureSize||(this._maxTextureSize=this._getMaxTextureSize());let r=this._maxTextureSize,i=Math.floor(r/this._pixelDensity),s=Math.min(e,i),n=Math.min(t,i);return s===e&&n===t||console.warn(`Warning: The requested width/height exceeds hardware limits. Adjusting dimensions to width: ${s}, height: ${n}.`),{adjustedWidth:s,adjustedHeight:n}}_resetBuffersBeforeDraw(){this.GL.clearStencil(0),this.GL.clear(this.GL.DEPTH_BUFFER_BIT|this.GL.STENCIL_BUFFER_BIT),this._userEnabledStencil||this._internalDisable.call(this.GL,this.GL.STENCIL_TEST)}_applyClip(){const e=this.GL;e.clearStencil(0),e.clear(e.STENCIL_BUFFER_BIT),this._internalEnable.call(e,e.STENCIL_TEST),this._stencilTestOn=!0,e.stencilFunc(e.ALWAYS,1,255),e.stencilOp(e.KEEP,e.KEEP,e.REPLACE),e.disable(e.DEPTH_TEST)}_unapplyClip(){const e=this.GL;e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.stencilFunc(this._clipInvert?e.EQUAL:e.NOTEQUAL,0,255),e.enable(e.DEPTH_TEST)}_clearClipBuffer(){this.GL.clearStencil(1),this.GL.clear(this.GL.STENCIL_BUFFER_BIT),this._userEnabledStencil||this._internalDisable.call(this.GL,this.GL.STENCIL_TEST)}_getPixel(e,t){const r=this.GL;return na(r,null,e,t,r.RGBA,r.UNSIGNED_BYTE,this._pInst.height*this._pInst.pixelDensity())}loadPixels(){if(!0!==this._pInst._glAttributes.preserveDrawingBuffer)return void console.log("loadPixels only works in WebGL when preserveDrawingBuffer is true.");const e=this._pixelDensity,t=this.GL;this.pixels=sa(this.pixels,t,null,0,0,this.width*e,this.height*e,t.RGBA,t.UNSIGNED_BYTE,this.height*e)}updatePixels(){const e=this._getTempFramebuffer();e.pixels=this.pixels,e.updatePixels(),this.push(),this.resetMatrix(),this.clear(),this.states.setValue("imageMode",_),this.image(e,0,0,e.width,e.height,-e.width/2,-e.height/2,e.width,e.height),this.pop(),this.GL.clearDepth(1),this.GL.clear(this.GL.DEPTH_BUFFER_BIT)}zClipRange(){return[-1,1]}defaultNearScale(){return.1}defaultFarScale(){return 10}viewport(e,t){this._viewport=[0,0,e,t],this.GL.viewport(0,0,e,t)}_updateViewport(){this._origViewport={width:this.GL.drawingBufferWidth,height:this.GL.drawingBufferHeight},this.viewport(this._origViewport.width,this._origViewport.height)}_createPixelsArray(){this.pixels=new Uint8Array(this.GL.drawingBufferWidth*this.GL.drawingBufferHeight*4)}clear(...e){const t=e[0]||0,r=e[1]||0,i=e[2]||0;let s=e[3]||0;const n=this.activeFramebuffer();n&&n.format===Be&&!n.antialias&&0===s&&(s=1e-10),this.GL.clearColor(t*s,r*s,i*s,s),this.GL.clearDepth(1),this.GL.clear(this.GL.COLOR_BUFFER_BIT|this.GL.DEPTH_BUFFER_BIT)}clearDepth(e=1){this.GL.clearDepth(e),this.GL.clear(this.GL.DEPTH_BUFFER_BIT)}_applyStencilTestIfClipping(){const e=this.drawTarget();e._isClipApplied!==this._stencilTestOn&&(e._isClipApplied?(this._internalEnable.call(this.GL,this.GL.STENCIL_TEST),this._stencilTestOn=!0):(this._userEnabledStencil||this._internalDisable.call(this.GL,this.GL.STENCIL_TEST),this._stencilTestOn=!1))}baseMaterialShader(){if(!this._pInst._glAttributes.perPixelLighting)throw new Error("The material shader does not support hooks without perPixelLighting. Try turning it back on.");return super.baseMaterialShader()}_getLightShader(){return this._defaultLightShader||(this._pInst._glAttributes.perPixelLighting?this._defaultLightShader=new Xn(this,this._webGL2CompatibilityPrefix("vert","highp")+ju.phongVert,this._webGL2CompatibilityPrefix("frag","highp")+ju.phongFrag,{vertex:{"void beforeVertex":"() {}","Vertex getObjectInputs":"(Vertex inputs) { return inputs; }","Vertex getWorldInputs":"(Vertex inputs) { return inputs; }","Vertex getCameraInputs":"(Vertex inputs) { return inputs; }","void afterVertex":"() {}"},fragment:{"void beforeFragment":"() {}","Inputs getPixelInputs":"(Inputs inputs) { return inputs; }","vec4 combineColors":"(ColorComponents components) {\n vec4 color = vec4(0.);\n color.rgb += components.diffuse * components.baseColor;\n color.rgb += components.ambient * components.ambientColor;\n color.rgb += components.specular * components.specularColor;\n color.rgb += components.emissive;\n color.a = components.opacity;\n return color;\n }","vec4 getFinalColor":"(vec4 color) { return color; }","void afterFragment":"() {}"}}):this._defaultLightShader=new Xn(this,this._webGL2CompatibilityPrefix("vert","highp")+ju.lightVert,this._webGL2CompatibilityPrefix("frag","highp")+ju.lightTextureFrag)),this._defaultLightShader}_getNormalShader(){return this._defaultNormalShader||(this._defaultNormalShader=new Xn(this,this._webGL2CompatibilityPrefix("vert","highp")+ju.normalVert,this._webGL2CompatibilityPrefix("frag","highp")+ju.normalFrag,{vertex:{"void beforeVertex":"() {}","Vertex getObjectInputs":"(Vertex inputs) { return inputs; }","Vertex getWorldInputs":"(Vertex inputs) { return inputs; }","Vertex getCameraInputs":"(Vertex inputs) { return inputs; }","void afterVertex":"() {}"},fragment:{"void beforeFragment":"() {}","vec4 getFinalColor":"(vec4 color) { return color; }","void afterFragment":"() {}"}})),this._defaultNormalShader}_getColorShader(){return this._defaultColorShader||(this._defaultColorShader=new Xn(this,this._webGL2CompatibilityPrefix("vert","highp")+ju.normalVert,this._webGL2CompatibilityPrefix("frag","highp")+ju.basicFrag,{vertex:{"void beforeVertex":"() {}","Vertex getObjectInputs":"(Vertex inputs) { return inputs; }","Vertex getWorldInputs":"(Vertex inputs) { return inputs; }","Vertex getCameraInputs":"(Vertex inputs) { return inputs; }","void afterVertex":"() {}"},fragment:{"void beforeFragment":"() {}","vec4 getFinalColor":"(vec4 color) { return color; }","void afterFragment":"() {}"}})),this._defaultColorShader}_getLineShader(){return this._defaultLineShader||(this._defaultLineShader=new Xn(this,this._webGL2CompatibilityPrefix("vert","highp")+ju.lineVert,this._webGL2CompatibilityPrefix("frag","highp")+ju.lineFrag,{vertex:{"void beforeVertex":"() {}","StrokeVertex getObjectInputs":"(StrokeVertex inputs) { return inputs; }","StrokeVertex getWorldInputs":"(StrokeVertex inputs) { return inputs; }","StrokeVertex getCameraInputs":"(StrokeVertex inputs) { return inputs; }","void afterVertex":"() {}"},fragment:{"void beforeFragment":"() {}","Inputs getPixelInputs":"(Inputs inputs) { return inputs; }","vec4 getFinalColor":"(vec4 color) { return color; }","bool shouldDiscard":"(bool outside) { return outside; }","void afterFragment":"() {}"}})),this._defaultLineShader}_getFontShader(){return this._defaultFontShader||(this.webglVersion===s&&this.GL.getExtension("OES_standard_derivatives"),this._defaultFontShader=new Xn(this,this._webGL2CompatibilityPrefix("vert","highp")+ju.fontVert,this._webGL2CompatibilityPrefix("frag","highp")+ju.fontFrag)),this._defaultFontShader}baseFilterShader(){return this._baseFilterShader||(this._baseFilterShader=new Xn(this,this._webGL2CompatibilityPrefix("vert","highp")+ju.filterBaseVert,this._webGL2CompatibilityPrefix("frag","highp")+ju.filterBaseFrag,{vertex:{},fragment:{"vec4 getColor":"(FilterInputs inputs, in sampler2D canvasContent) {\n return getTexture(canvasContent, inputs.texCoord);\n }"},hookAliases:{getColor:["filterColor"]}})),this._baseFilterShader}_webGL2CompatibilityPrefix(e,t){let r="";return this.webglVersion===n&&(r+="#version 300 es\n#define WEBGL2\n"),"vert"===e?r+="#define VERTEX_SHADER\n":"frag"===e&&(r+="#define FRAGMENT_SHADER\n"),t&&(r+=`precision ${t} float;\n`),r}_createImageLightShader(e){if("diffused"===e)return new Xn(this,this._webGL2CompatibilityPrefix("vert","highp")+ju.imageLightVert,this._webGL2CompatibilityPrefix("frag","highp")+ju.imageLightDiffusedFrag);if("specular"===e)return new Xn(this,this._webGL2CompatibilityPrefix("vert","highp")+ju.imageLightVert,this._webGL2CompatibilityPrefix("frag","highp")+ju.imageLightSpecularFrag);throw new Error(`Unknown imageLight shader type: ${e}`)}_createMipmapTexture(e){return new ra(this,e,{})}_prepareMipmapData(e,t){return{levels:[],size:e,mipLevels:t}}_accumulateMipLevel(e,t,r,i,s){const n=e.get().drawingContext.getImageData(0,0,i,s);t.levels.push(n)}_finalizeMipmapTexture(e){return new ra(this,e.levels,{minFilter:be,magFilter:me})}createMipmapTextureHandle({levels:e,format:t,dataType:r,width:i,height:s}){const n=this.GL,a=n.createTexture();n.bindTexture(n.TEXTURE_2D,a);const o=n.RGBA,h=n.UNSIGNED_BYTE;for(let t=0;t<e.length;t++)n.texImage2D(n.TEXTURE_2D,t,o,o,h,e[t]);return n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR_MIPMAP_LINEAR),n.bindTexture(n.TEXTURE_2D,null),{texture:a,glFormat:o,glDataType:h}}_bindBuffer(e,t,r,i,s){const n=this.GL;if(t||(t=n.ARRAY_BUFFER),n.bindBuffer(t,e),void 0!==r){const e=this._normalizeBufferData(r,i);n.bufferData(t,e,s||n.STATIC_DRAW)}}_prepareBuffer(e,t,r){const i=r.attributes,s=this.GL,n=this._getOrMakeCachedBuffers(t),a=i[e.attr];if(!a)return;let o=n[e.dst];const h=t[e.src];if(h&&h.length>0){const i=!o;if(i&&(n[e.dst]=o=s.createBuffer()),s.bindBuffer(s.ARRAY_BUFFER,o),i||!1!==t.dirtyFlags[e.src]){const r=e.map,i=r?r(h):h;this._bindBuffer(o,s.ARRAY_BUFFER,i),t.dirtyFlags[e.src]=!1}r.enableAttrib(a,e.size)}else{const e=a.location;if(-1===e||!this.registerEnabled.has(e))return;s.disableVertexAttribArray(e),this.registerEnabled.delete(e)}}_enableAttrib(e,t,r,i,s,n,a){const o=t.location,h=this.GL;this.registerEnabled.has(o)||(h.enableVertexAttribArray(o),this.registerEnabled.add(o)),h.vertexAttribPointer(o,r,i||h.FLOAT,s||!1,n||0,a||0)}_ensureGeometryBuffers(e,t,r){const i=this.GL;if(t){let s=e.indexBuffer;s||(s=i.createBuffer()),this._bindBuffer(s,i.ELEMENT_ARRAY_BUFFER,t,r),e.indexBuffer=s,e.indexBufferType=r===Uint32Array?i.UNSIGNED_INT:i.UNSIGNED_SHORT}else e.indexBuffer&&(i.deleteBuffer(e.indexBuffer),e.indexBuffer=null)}_freeBuffers(e){const t=this.GL;function r(r){for(const i of r)e[i.dst]&&(t.deleteBuffer(e[i.dst]),e[i.dst]=null)}e.indexBuffer&&t.deleteBuffer(e.indexBuffer),r(this.buffers.stroke),r(this.buffers.fill),r(this.buffers.user)}_initShader(e){const t=this.GL,r=t.createShader(t.VERTEX_SHADER);if(t.shaderSource(r,e.vertSrc()),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new Error(`Yikes! An error occurred compiling the vertex shader: ${t.getShaderInfoLog(r)} in:\n\n${e.vertSrc()}`);const i=t.createShader(t.FRAGMENT_SHADER);if(t.shaderSource(i,e.fragSrc()),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS))throw new Error(`Darn! An error occurred compiling the fragment shader: ${t.getShaderInfoLog(i)}`);const s=t.createProgram();if(t.attachShader(s,r),t.attachShader(s,i),t.linkProgram(s),!t.getProgramParameter(s,t.LINK_STATUS))throw new Error(`Snap! Error linking shader program: ${t.getProgramInfoLog(s)}`);e._glProgram=s,e._vertShader=r,e._fragShader=i}_finalizeShader(){}_getShaderAttributes(e){return ua(e,this.GL)}getUniformMetadata(e){return ha(e,this.GL)}updateUniformValue(e,t,r){return oa(e,t,r,e=>this.getTexture(e),this.GL)}_updateTexture(e,t){const r=this.GL;r.activeTexture(r.TEXTURE0+e.samplerIndex),t.bindTexture(),t.update(),r.uniform1i(e.location,e.samplerIndex)}bindTexture(e){this.GL.bindTexture(this.GL.TEXTURE_2D,e.getTexture().texture)}unbindTexture(){this.GL.bindTexture(this.GL.TEXTURE_2D,null)}_unbindFramebufferTexture(e){const t=this.GL,r=this._getEmptyTexture();t.activeTexture(t.TEXTURE0+e.samplerIndex),r.bindTexture(),t.uniform1i(e.location,e.samplerIndex)}createTexture({width:e,height:t,format:r,dataType:i}){const s=this.GL,n=s.createTexture();return s.bindTexture(s.TEXTURE_2D,n),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,e,t,0,s.RGBA,s.UNSIGNED_BYTE,null),{texture:n,glFormat:s.RGBA,glDataType:s.UNSIGNED_BYTE}}createFramebufferTextureHandle(e){return null}uploadTextureFromSource({texture:e,glFormat:t,glDataType:r},i){const s=this.GL;s.texImage2D(s.TEXTURE_2D,0,t,t,r,i)}uploadTextureFromData({texture:e,glFormat:t,glDataType:r},i,s,n){const a=this.GL;a.texImage2D(a.TEXTURE_2D,0,t,s,n,0,t,r,i)}getSampler(e){}bindTextureToShader({texture:e},t,r,i){const s=this.GL;s.activeTexture(s.TEXTURE0+i),s.bindTexture(s.TEXTURE_2D,e);const n=s.getUniformLocation(glProgram,r);s.uniform1i(n,i)}setTextureParams(e){return aa(e,this.GL,this.webglVersion)}deleteTexture({texture:e}){this.GL.deleteTexture(e)}_applyColorBlend(e,t){const r=this.GL,i=this.states.drawMode===xe,s=t||this.states.userFillShader||this.states.userStrokeShader||i||this.states.curBlendMode!==$||e[e.length-1]<1||this._isErasing;return s!==this._isBlending&&(s||this.states.curBlendMode!==$&&this.states.curBlendMode!==q?r.enable(r.BLEND):r.disable(r.BLEND),r.depthMask(!0),this._isBlending=s),this._applyBlendMode(),e}uniformNameFromHookKey(e){return e.slice(e.indexOf(" ")+1)}populateHooks(e,t,r){return la(e,t,r)}getShaderHookTypes(e,t){return Mo(e,t)}defaultFramebufferAlpha(){return this._pInst._glAttributes.alpha}defaultFramebufferAntialias(){return!!this.supportsFramebufferAntialias()&&this._pInst._glAttributes.antialias}supportsFramebufferAntialias(){return this.webglVersion===n}createFramebufferResources(e){const t=this.GL;if(e.framebuffer=t.createFramebuffer(),!e.framebuffer)throw new Error("Unable to create a framebuffer");if(e.antialias&&(e.aaFramebuffer=t.createFramebuffer(),!e.aaFramebuffer))throw new Error("Unable to create a framebuffer for antialiasing")}validateFramebufferFormats(e){const t=this.GL;e.useDepth&&this.webglVersion===s&&!t.getExtension("WEBGL_depth_texture")&&(console.warn("Unable to create depth textures in this environment. Falling back to a framebuffer without depth."),e.useDepth=!1),e.useDepth&&this.webglVersion===s&&e.depthFormat===Pe&&(console.warn("FLOAT depth format is unavailable in WebGL 1. Defaulting to UNSIGNED_INT."),e.depthFormat=Le),[Be,Pe,Oe].includes(e.format)||(console.warn("Unknown Framebuffer format. Please use UNSIGNED_BYTE, FLOAT, or HALF_FLOAT. Defaulting to UNSIGNED_BYTE."),e.format=Be),e.useDepth&&![Le,Pe].includes(e.depthFormat)&&(console.warn("Unknown Framebuffer depth format. Please use UNSIGNED_INT or FLOAT. Defaulting to FLOAT."),e.depthFormat=Pe);const r=ca(this);r.float||e.format!==Pe||(console.warn("This environment does not support FLOAT textures. Falling back to UNSIGNED_BYTE."),e.format=Be),e.useDepth&&!r.float&&e.depthFormat===Pe&&(console.warn("This environment does not support FLOAT depth textures. Falling back to UNSIGNED_INT."),e.depthFormat=Le),r.halfFloat||e.format!==Oe||(console.warn("This environment does not support HALF_FLOAT textures. Falling back to UNSIGNED_BYTE."),e.format=Be),e.channels===bi&&[Pe,Oe].includes(e.format)&&(console.warn("FLOAT and HALF_FLOAT formats do not work cross-platform with only RGB channels. Falling back to RGBA."),e.channels=Ti)}recreateFramebufferTextures(e){const t=this.GL,r=t.getParameter(t.TEXTURE_BINDING_2D),i=t.getParameter(t.FRAMEBUFFER_BINDING),s=t.createTexture();if(!s)throw new Error("Unable to create color texture");t.bindTexture(t.TEXTURE_2D,s);const n=this._getFramebufferColorFormat(e);if(t.texImage2D(t.TEXTURE_2D,0,n.internalFormat,e.width*e.density,e.height*e.density,0,n.format,n.type,null),e.colorTexture=s,t.bindFramebuffer(t.FRAMEBUFFER,e.framebuffer),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0),e.useDepth){const r=t.createTexture();if(!r)throw new Error("Unable to create depth texture");const i=this._getFramebufferDepthFormat(e);t.bindTexture(t.TEXTURE_2D,r),t.texImage2D(t.TEXTURE_2D,0,i.internalFormat,e.width*e.density,e.height*e.density,0,i.format,i.type,null),t.framebufferTexture2D(t.FRAMEBUFFER,e.useStencil?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,t.TEXTURE_2D,r,0),e.depthTexture=r}if(e.antialias){if(e.colorRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,e.colorRenderbuffer),t.renderbufferStorageMultisample(t.RENDERBUFFER,Math.max(0,Math.min(e.antialiasSamples,t.getParameter(t.MAX_SAMPLES))),n.internalFormat,e.width*e.density,e.height*e.density),e.useDepth){const r=this._getFramebufferDepthFormat(e);e.depthRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,e.depthRenderbuffer),t.renderbufferStorageMultisample(t.RENDERBUFFER,Math.max(0,Math.min(e.antialiasSamples,t.getParameter(t.MAX_SAMPLES))),r.internalFormat,e.width*e.density,e.height*e.density)}t.bindFramebuffer(t.FRAMEBUFFER,e.aaFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,e.colorRenderbuffer),e.useDepth&&t.framebufferRenderbuffer(t.FRAMEBUFFER,e.useStencil?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e.depthRenderbuffer)}t.bindTexture(t.TEXTURE_2D,r),t.bindFramebuffer(t.FRAMEBUFFER,i)}_getFramebufferColorFormat(e){let t,r,i;const s=this.GL;return t=e.format===Pe?s.FLOAT:e.format===Oe?this.webglVersion===n?s.HALF_FLOAT:s.getExtension("OES_texture_half_float").HALF_FLOAT_OES:s.UNSIGNED_BYTE,r=e.channels===Ti?s.RGBA:s.RGB,i=this.webglVersion===n?{[s.FLOAT]:{[s.RGBA]:s.RGBA32F},[s.HALF_FLOAT]:{[s.RGBA]:s.RGBA16F},[s.UNSIGNED_BYTE]:{[s.RGBA]:s.RGBA8,[s.RGB]:s.RGB8}}[t][r]:e.format===Oe?s.RGBA:r,{internalFormat:i,format:r,type:t}}_getFramebufferDepthFormat(e){let t,r,i;const s=this.GL;return t=e.useStencil?e.depthFormat===Pe?s.FLOAT_32_UNSIGNED_INT_24_8_REV:this.webglVersion===n?s.UNSIGNED_INT_24_8:s.getExtension("WEBGL_depth_texture").UNSIGNED_INT_24_8_WEBGL:e.depthFormat===Pe?s.FLOAT:s.UNSIGNED_INT,r=e.useStencil?s.DEPTH_STENCIL:s.DEPTH_COMPONENT,i=e.useStencil?e.depthFormat===Pe?s.DEPTH32F_STENCIL8:this.webglVersion===n?s.DEPTH24_STENCIL8:s.DEPTH_STENCIL:this.webglVersion===n?e.depthFormat===Pe?s.DEPTH_COMPONENT32F:s.DEPTH_COMPONENT24:s.DEPTH_COMPONENT,{internalFormat:i,format:r,type:t}}_deleteFramebufferTexture(e){this.GL.deleteTexture(e.rawTexture().texture),this.textures.delete(e)}deleteFramebufferTextures(e){this._deleteFramebufferTexture(e.color),e.depth&&this._deleteFramebufferTexture(e.depth);const t=this.GL;e.colorRenderbuffer&&t.deleteRenderbuffer(e.colorRenderbuffer),e.depthRenderbuffer&&t.deleteRenderbuffer(e.depthRenderbuffer)}deleteFramebufferResources(e){const t=this.GL;t.deleteFramebuffer(e.framebuffer),e.aaFramebuffer&&t.deleteFramebuffer(e.aaFramebuffer),e.depthRenderbuffer&&t.deleteRenderbuffer(e.depthRenderbuffer),e.colorRenderbuffer&&t.deleteRenderbuffer(e.colorRenderbuffer)}getFramebufferToBind(e){return e.antialias?e.aaFramebuffer:e.framebuffer}updateFramebufferTexture(e,t){if(e.antialias){const r=this.GL;r.bindFramebuffer(r.READ_FRAMEBUFFER,e.aaFramebuffer),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,e.framebuffer);const i={colorTexture:[r.COLOR_BUFFER_BIT,e.colorP5Texture.magFilter===me?r.LINEAR:r.NEAREST]};e.useDepth&&(i.depthTexture=[r.DEPTH_BUFFER_BIT,e.depthP5Texture.magFilter===me?r.LINEAR:r.NEAREST]);const[s,n]=i[t];r.blitFramebuffer(0,0,e.width*e.density,e.height*e.density,0,0,e.width*e.density,e.height*e.density,s,n);const a=this.activeFramebuffer();this.bindFramebuffer(a)}}bindFramebuffer(e){const t=this.GL;t.bindFramebuffer(t.FRAMEBUFFER,e?this.getFramebufferToBind(e):null)}framebufferYScale(){return-1}readFramebufferPixels(e){const t=this.GL,r=this.activeFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,e.framebuffer);const i=this._getFramebufferColorFormat(e),s=sa(e.pixels,t,e.framebuffer,0,0,e.width*e.density,e.height*e.density,i.format,i.type);return this.bindFramebuffer(r),s}readFramebufferPixel(e,t,r){const i=this._getFramebufferColorFormat(e);return na(this.GL,e.framebuffer,t,r,i.format,i.type)}readFramebufferRegion(e,t,r,i,s){const n=this.GL,a=this._getFramebufferColorFormat(e),o=sa(void 0,n,e.framebuffer,t*e.density,r*e.density,i*e.density,s*e.density,a.format,a.type),h=new Uint8ClampedArray(i*s*e.density*e.density*4);h.fill(255);const u=a.format===n.RGB?3:4;for(let t=0;t<s*e.density;t++)for(let r=0;r<i*e.density;r++)for(let s=0;s<4;s++){const n=4*(t*i*e.density+r)+s;if(s<u){const a=4===u?n:(t*i*e.density+r)*u+s;h[n]=o[a]}}const l=new $i(i*e.density,s*e.density);return l.imageData=l.canvas.getContext("2d").createImageData(l.width,l.height),l.imageData.data.set(h),l.pixels=l.imageData.data,l.updatePixels(),1!==e.density&&l.pixelDensity(e.density),l}updateFramebufferPixels(e){const t=this.GL;e.colorP5Texture.bindTexture();const r=this._getFramebufferColorFormat(e),i=r.format===t.RGBA?4:3,s=e.width*e.height*e.density*e.density*i,n=r.type===t.UNSIGNED_BYTE?Uint8Array:Float32Array;if(!(e.pixels instanceof n)||e.pixels.length!==s)throw new Error("The pixels array has not been set correctly. Please call loadPixels() before updatePixels().");t.texImage2D(t.TEXTURE_2D,0,r.internalFormat,e.width*e.density,e.height*e.density,0,r.format,r.type,e.pixels),e.colorP5Texture.unbindTexture(),e.dirty.colorTexture=!1;const a=this.activeFramebuffer();e.antialias?(e.begin(),this.push(),this.states.setValue("imageMode",_),this.setCamera(e.filterCamera),this.resetMatrix(),this.states.setValue("strokeColor",null),this.clear(),this._drawingFilter=!0,this.image(e,0,0,e.width,e.height,-this.width/2,-this.height/2,this.width,this.height),this._drawingFilter=!1,this.pop(),e.useDepth&&(t.clearDepth(1),t.clear(t.DEPTH_BUFFER_BIT)),e.end()):(t.bindFramebuffer(t.FRAMEBUFFER,e.framebuffer),e.useDepth&&(t.clearDepth(1),t.clear(t.DEPTH_BUFFER_BIT)),this.bindFramebuffer(a))}getNoiseShaderSnippet(){return ko}}function Hu(e,t){e.RendererGL=$u,t.setAttributes=function(e,t){return this._renderer._setAttributes(e,t)},t._assert3d=function(e){if(!this._renderer.isP3D)throw new Error(`${e}() is only supported in WEBGL mode. If you'd like to use 3D graphics and WebGL, see https://p5js.org/examples/form-3d-primitives.html for more information.`)},e.renderers[s]=e.RendererGL,e.renderers[n]=e.RendererGL}void 0!==p5&&Hu(p5,p5.prototype);var qu=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],Wu=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],Xu="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-Ꟑꟑꟓꟕ-ꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",Yu={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},Ku="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",Zu={5:Ku,"5module":Ku+" export import",6:Ku+" const class extends export import super"},Ju=/^in(stanceof)?$/,Qu=new RegExp("["+Xu+"]"),el=new RegExp("["+Xu+"·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・]");function tl(e,t){for(var r=65536,i=0;i<t.length;i+=2){if((r+=t[i])>e)return!1;if((r+=t[i+1])>=e)return!0}return!1}function rl(e,t){return e<65?36===e:e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&Qu.test(String.fromCharCode(e)):!1!==t&&tl(e,Wu)))}function il(e,t){return e<48?36===e:e<58||!(e<65)&&(e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&el.test(String.fromCharCode(e)):!1!==t&&(tl(e,Wu)||tl(e,qu)))))}var sl=function(e,t){void 0===t&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null};function nl(e,t){return new sl(e,{beforeExpr:!0,binop:t})}var al={beforeExpr:!0},ol={startsExpr:!0},hl={};function ul(e,t){return void 0===t&&(t={}),t.keyword=e,hl[e]=new sl(e,t)}var ll={num:new sl("num",ol),regexp:new sl("regexp",ol),string:new sl("string",ol),name:new sl("name",ol),privateId:new sl("privateId",ol),eof:new sl("eof"),bracketL:new sl("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new sl("]"),braceL:new sl("{",{beforeExpr:!0,startsExpr:!0}),braceR:new sl("}"),parenL:new sl("(",{beforeExpr:!0,startsExpr:!0}),parenR:new sl(")"),comma:new sl(",",al),semi:new sl(";",al),colon:new sl(":",al),dot:new sl("."),question:new sl("?",al),questionDot:new sl("?."),arrow:new sl("=>",al),template:new sl("template"),invalidTemplate:new sl("invalidTemplate"),ellipsis:new sl("...",al),backQuote:new sl("`",ol),dollarBraceL:new sl("${",{beforeExpr:!0,startsExpr:!0}),eq:new sl("=",{beforeExpr:!0,isAssign:!0}),assign:new sl("_=",{beforeExpr:!0,isAssign:!0}),incDec:new sl("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new sl("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:nl("||",1),logicalAND:nl("&&",2),bitwiseOR:nl("|",3),bitwiseXOR:nl("^",4),bitwiseAND:nl("&",5),equality:nl("==/!=/===/!==",6),relational:nl("</>/<=/>=",7),bitShift:nl("<</>>/>>>",8),plusMin:new sl("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:nl("%",10),star:nl("*",10),slash:nl("/",10),starstar:new sl("**",{beforeExpr:!0}),coalesce:nl("??",1),_break:ul("break"),_case:ul("case",al),_catch:ul("catch"),_continue:ul("continue"),_debugger:ul("debugger"),_default:ul("default",al),_do:ul("do",{isLoop:!0,beforeExpr:!0}),_else:ul("else",al),_finally:ul("finally"),_for:ul("for",{isLoop:!0}),_function:ul("function",ol),_if:ul("if"),_return:ul("return",al),_switch:ul("switch"),_throw:ul("throw",al),_try:ul("try"),_var:ul("var"),_const:ul("const"),_while:ul("while",{isLoop:!0}),_with:ul("with"),_new:ul("new",{beforeExpr:!0,startsExpr:!0}),_this:ul("this",ol),_super:ul("super",ol),_class:ul("class",ol),_extends:ul("extends",al),_export:ul("export"),_import:ul("import",ol),_null:ul("null",ol),_true:ul("true",ol),_false:ul("false",ol),_in:ul("in",{beforeExpr:!0,binop:7}),_instanceof:ul("instanceof",{beforeExpr:!0,binop:7}),_typeof:ul("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:ul("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:ul("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},cl=/\r\n?|\n|\u2028|\u2029/,pl=new RegExp(cl.source,"g");function dl(e){return 10===e||13===e||8232===e||8233===e}function fl(e,t,r){void 0===r&&(r=e.length);for(var i=t;i<r;i++){var s=e.charCodeAt(i);if(dl(s))return i<r-1&&13===s&&10===e.charCodeAt(i+1)?i+2:i+1}return-1}var gl=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,ml=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,yl=Object.prototype,xl=yl.hasOwnProperty,vl=yl.toString,bl=Object.hasOwn||function(e,t){return xl.call(e,t)},_l=Array.isArray||function(e){return"[object Array]"===vl.call(e)},wl=Object.create(null);function Cl(e){return wl[e]||(wl[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function El(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}var Dl=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Al=function(e,t){this.line=e,this.column=t};Al.prototype.offset=function(e){return new Al(this.line,this.column+e)};var Sl=function(e,t,r){this.start=t,this.end=r,null!==e.sourceFile&&(this.source=e.sourceFile)};function Fl(e,t){for(var r=1,i=0;;){var s=fl(e,i,t);if(s<0)return new Al(r,t-i);++r,i=s}}var Tl={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},Ml=!1;function kl(e,t){return 2|(e?4:0)|(t?8:0)}var Il=function(e,t,r){this.options=e=function(e){var t={};for(var r in Tl)t[r]=e&&bl(e,r)?e[r]:Tl[r];if("latest"===t.ecmaVersion?t.ecmaVersion=1e8:null==t.ecmaVersion?(!Ml&&"object"==typeof console&&console.warn&&(Ml=!0,console.warn("Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future.")),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),null==t.allowReserved&&(t.allowReserved=t.ecmaVersion<5),e&&null!=e.allowHashBang||(t.allowHashBang=t.ecmaVersion>=14),_l(t.onToken)){var i=t.onToken;t.onToken=function(e){return i.push(e)}}return _l(t.onComment)&&(t.onComment=function(e,t){return function(r,i,s,n,a,o){var h={type:r?"Block":"Line",value:i,start:s,end:n};e.locations&&(h.loc=new Sl(this,a,o)),e.ranges&&(h.range=[s,n]),t.push(h)}}(t,t.onComment)),t}(e),this.sourceFile=e.sourceFile,this.keywords=Cl(Zu[e.ecmaVersion>=6?6:"module"===e.sourceType?"5module":5]);var i="";!0!==e.allowReserved&&(i=Yu[e.ecmaVersion>=6?6:5===e.ecmaVersion?5:3],"module"===e.sourceType&&(i+=" await")),this.reservedWords=Cl(i);var s=(i?i+" ":"")+Yu.strict;this.reservedWordsStrict=Cl(s),this.reservedWordsStrictBind=Cl(s+" "+Yu.strictBind),this.input=String(t),this.containsEsc=!1,r?(this.pos=r,this.lineStart=this.input.lastIndexOf("\n",r-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(cl).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=ll.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule="module"===e.sourceType,this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),0===this.pos&&e.allowHashBang&&"#!"===this.input.slice(0,2)&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(1),this.regexpState=null,this.privateNameStack=[]},Bl={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};Il.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)},Bl.inFunction.get=function(){return(2&this.currentVarScope().flags)>0},Bl.inGenerator.get=function(){return(8&this.currentVarScope().flags)>0},Bl.inAsync.get=function(){return(4&this.currentVarScope().flags)>0},Bl.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(768&t)return!1;if(2&t)return(4&t)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},Bl.allowSuper.get=function(){return(64&this.currentThisScope().flags)>0||this.options.allowSuperOutsideMethod},Bl.allowDirectSuper.get=function(){return(128&this.currentThisScope().flags)>0},Bl.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},Bl.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(768&t||2&t&&!(16&t))return!0}return!1},Bl.inClassStaticBlock.get=function(){return(256&this.currentVarScope().flags)>0},Il.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var r=this,i=0;i<e.length;i++)r=e[i](r);return r},Il.parse=function(e,t){return new this(t,e).parse()},Il.parseExpressionAt=function(e,t,r){var i=new this(r,e,t);return i.nextToken(),i.parseExpression()},Il.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(Il.prototype,Bl);var Ll=Il.prototype,Pl=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;Ll.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){ml.lastIndex=e,e+=ml.exec(this.input)[0].length;var t=Pl.exec(this.input.slice(e));if(!t)return!1;if("use strict"===(t[1]||t[2])){ml.lastIndex=e+t[0].length;var r=ml.exec(this.input),i=r.index+r[0].length,s=this.input.charAt(i);return";"===s||"}"===s||cl.test(r[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(s)||"!"===s&&"="===this.input.charAt(i+1))}e+=t[0].length,ml.lastIndex=e,e+=ml.exec(this.input)[0].length,";"===this.input[e]&&e++}},Ll.eat=function(e){return this.type===e&&(this.next(),!0)},Ll.isContextual=function(e){return this.type===ll.name&&this.value===e&&!this.containsEsc},Ll.eatContextual=function(e){return!!this.isContextual(e)&&(this.next(),!0)},Ll.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},Ll.canInsertSemicolon=function(){return this.type===ll.eof||this.type===ll.braceR||cl.test(this.input.slice(this.lastTokEnd,this.start))},Ll.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},Ll.semicolon=function(){this.eat(ll.semi)||this.insertSemicolon()||this.unexpected()},Ll.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},Ll.expect=function(e){this.eat(e)||this.unexpected()},Ll.unexpected=function(e){this.raise(null!=e?e:this.start,"Unexpected token")};var Ol=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};Ll.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var r=t?e.parenthesizedAssign:e.parenthesizedBind;r>-1&&this.raiseRecoverable(r,t?"Assigning to rvalue":"Parenthesized pattern")}},Ll.checkExpressionErrors=function(e,t){if(!e)return!1;var r=e.shorthandAssign,i=e.doubleProto;if(!t)return r>=0||i>=0;r>=0&&this.raise(r,"Shorthand property assignments are valid only in destructuring patterns"),i>=0&&this.raiseRecoverable(i,"Redefinition of __proto__ property")},Ll.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")},Ll.isSimpleAssignTarget=function(e){return"ParenthesizedExpression"===e.type?this.isSimpleAssignTarget(e.expression):"Identifier"===e.type||"MemberExpression"===e.type};var Rl=Il.prototype;Rl.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==ll.eof;){var r=this.parseStatement(null,!0,t);e.body.push(r)}if(this.inModule)for(var i=0,s=Object.keys(this.undefinedExports);i<s.length;i+=1){var n=s[i];this.raiseRecoverable(this.undefinedExports[n].start,"Export '"+n+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType,this.finishNode(e,"Program")};var Nl={kind:"loop"},Vl={kind:"switch"};Rl.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;ml.lastIndex=this.pos;var t=ml.exec(this.input),r=this.pos+t[0].length,i=this.input.charCodeAt(r);if(91===i||92===i)return!0;if(e)return!1;if(123===i||i>55295&&i<56320)return!0;if(rl(i,!0)){for(var s=r+1;il(i=this.input.charCodeAt(s),!0);)++s;if(92===i||i>55295&&i<56320)return!0;var n=this.input.slice(r,s);if(!Ju.test(n))return!0}return!1},Rl.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;ml.lastIndex=this.pos;var e,t=ml.exec(this.input),r=this.pos+t[0].length;return!(cl.test(this.input.slice(this.pos,r))||"function"!==this.input.slice(r,r+8)||r+8!==this.input.length&&(il(e=this.input.charCodeAt(r+8))||e>55295&&e<56320))},Rl.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;ml.lastIndex=this.pos;var r=ml.exec(this.input),i=this.pos+r[0].length;if(cl.test(this.input.slice(this.pos,i)))return!1;if(e){var s,n=i+5;if("using"!==this.input.slice(i,n)||n===this.input.length||il(s=this.input.charCodeAt(n))||s>55295&&s<56320)return!1;ml.lastIndex=n;var a=ml.exec(this.input);if(a&&cl.test(this.input.slice(n,n+a[0].length)))return!1}if(t){var o,h=i+2;if(!("of"!==this.input.slice(i,h)||h!==this.input.length&&(il(o=this.input.charCodeAt(h))||o>55295&&o<56320)))return!1}var u=this.input.charCodeAt(i);return rl(u,!0)||92===u},Rl.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},Rl.isUsing=function(e){return this.isUsingKeyword(!1,e)},Rl.parseStatement=function(e,t,r){var i,s=this.type,n=this.startNode();switch(this.isLet(e)&&(s=ll._var,i="let"),s){case ll._break:case ll._continue:return this.parseBreakContinueStatement(n,s.keyword);case ll._debugger:return this.parseDebuggerStatement(n);case ll._do:return this.parseDoStatement(n);case ll._for:return this.parseForStatement(n);case ll._function:return e&&(this.strict||"if"!==e&&"label"!==e)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(n,!1,!e);case ll._class:return e&&this.unexpected(),this.parseClass(n,!0);case ll._if:return this.parseIfStatement(n);case ll._return:return this.parseReturnStatement(n);case ll._switch:return this.parseSwitchStatement(n);case ll._throw:return this.parseThrowStatement(n);case ll._try:return this.parseTryStatement(n);case ll._const:case ll._var:return i=i||this.value,e&&"var"!==i&&this.unexpected(),this.parseVarStatement(n,i);case ll._while:return this.parseWhileStatement(n);case ll._with:return this.parseWithStatement(n);case ll.braceL:return this.parseBlock(!0,n);case ll.semi:return this.parseEmptyStatement(n);case ll._export:case ll._import:if(this.options.ecmaVersion>10&&s===ll._import){ml.lastIndex=this.pos;var a=ml.exec(this.input),o=this.pos+a[0].length,h=this.input.charCodeAt(o);if(40===h||46===h)return this.parseExpressionStatement(n,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),s===ll._import?this.parseImport(n):this.parseExport(n,r);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(n,!0,!e);var u=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(u)return t&&"script"===this.options.sourceType&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),"await using"===u&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(n,!1,u),this.semicolon(),this.finishNode(n,"VariableDeclaration");var l=this.value,c=this.parseExpression();return s===ll.name&&"Identifier"===c.type&&this.eat(ll.colon)?this.parseLabeledStatement(n,l,c,e):this.parseExpressionStatement(n,c)}},Rl.parseBreakContinueStatement=function(e,t){var r="break"===t;this.next(),this.eat(ll.semi)||this.insertSemicolon()?e.label=null:this.type!==ll.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var i=0;i<this.labels.length;++i){var s=this.labels[i];if(null==e.label||s.name===e.label.name){if(null!=s.kind&&(r||"loop"===s.kind))break;if(e.label&&r)break}}return i===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,r?"BreakStatement":"ContinueStatement")},Rl.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")},Rl.parseDoStatement=function(e){return this.next(),this.labels.push(Nl),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(ll._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(ll.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")},Rl.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(Nl),this.enterScope(0),this.expect(ll.parenL),this.type===ll.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var r=this.isLet();if(this.type===ll._var||this.type===ll._const||r){var i=this.startNode(),s=r?"let":this.value;return this.next(),this.parseVar(i,!0,s),this.finishNode(i,"VariableDeclaration"),this.parseForAfterInit(e,i,t)}var n=this.isContextual("let"),a=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var h=this.startNode();return this.next(),"await using"===o&&this.next(),this.parseVar(h,!0,o),this.finishNode(h,"VariableDeclaration"),this.parseForAfterInit(e,h,t)}var u=this.containsEsc,l=new Ol,c=this.start,p=t>-1?this.parseExprSubscripts(l,"await"):this.parseExpression(!0,l);return this.type===ll._in||(a=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===ll._in&&this.unexpected(t),e.await=!0):a&&this.options.ecmaVersion>=8&&(p.start!==c||u||"Identifier"!==p.type||"async"!==p.name?this.options.ecmaVersion>=9&&(e.await=!1):this.unexpected()),n&&a&&this.raise(p.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(p,!1,l),this.checkLValPattern(p),this.parseForIn(e,p)):(this.checkExpressionErrors(l,!0),t>-1&&this.unexpected(t),this.parseFor(e,p))},Rl.parseForAfterInit=function(e,t,r){return(this.type===ll._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&1===t.declarations.length?(this.options.ecmaVersion>=9&&(this.type===ll._in?r>-1&&this.unexpected(r):e.await=r>-1),this.parseForIn(e,t)):(r>-1&&this.unexpected(r),this.parseFor(e,t))},Rl.parseFunctionStatement=function(e,t,r){return this.next(),this.parseFunction(e,zl|(r?0:Gl),!1,t)},Rl.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(ll._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")},Rl.parseReturnStatement=function(e){return this.inFunction||this.options.allowReturnOutsideFunction||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(ll.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")},Rl.parseSwitchStatement=function(e){var t;this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(ll.braceL),this.labels.push(Vl),this.enterScope(0);for(var r=!1;this.type!==ll.braceR;)if(this.type===ll._case||this.type===ll._default){var i=this.type===ll._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),i?t.test=this.parseExpression():(r&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),r=!0,t.test=null),this.expect(ll.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")},Rl.parseThrowStatement=function(e){return this.next(),cl.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var Ul=[];Rl.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t="Identifier"===e.type;return this.enterScope(t?32:0),this.checkLValPattern(e,t?4:2),this.expect(ll.parenR),e},Rl.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===ll._catch){var t=this.startNode();this.next(),this.eat(ll.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(ll._finally)?this.parseBlock():null,e.handler||e.finalizer||this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")},Rl.parseVarStatement=function(e,t,r){return this.next(),this.parseVar(e,!1,t,r),this.semicolon(),this.finishNode(e,"VariableDeclaration")},Rl.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Nl),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")},Rl.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement("with"),this.finishNode(e,"WithStatement")},Rl.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")},Rl.parseLabeledStatement=function(e,t,r,i){for(var s=0,n=this.labels;s<n.length;s+=1)n[s].name===t&&this.raise(r.start,"Label '"+t+"' is already declared");for(var a=this.type.isLoop?"loop":this.type===ll._switch?"switch":null,o=this.labels.length-1;o>=0;o--){var h=this.labels[o];if(h.statementStart!==e.start)break;h.statementStart=this.start,h.kind=a}return this.labels.push({name:t,kind:a,statementStart:this.start}),e.body=this.parseStatement(i?-1===i.indexOf("label")?i+"label":i:"label"),this.labels.pop(),e.label=r,this.finishNode(e,"LabeledStatement")},Rl.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")},Rl.parseBlock=function(e,t,r){for(void 0===e&&(e=!0),void 0===t&&(t=this.startNode()),t.body=[],this.expect(ll.braceL),e&&this.enterScope(0);this.type!==ll.braceR;){var i=this.parseStatement(null);t.body.push(i)}return r&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")},Rl.parseFor=function(e,t){return e.init=t,this.expect(ll.semi),e.test=this.type===ll.semi?null:this.parseExpression(),this.expect(ll.semi),e.update=this.type===ll.parenR?null:this.parseExpression(),this.expect(ll.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")},Rl.parseForIn=function(e,t){var r=this.type===ll._in;return this.next(),"VariableDeclaration"===t.type&&null!=t.declarations[0].init&&(!r||this.options.ecmaVersion<8||this.strict||"var"!==t.kind||"Identifier"!==t.declarations[0].id.type)&&this.raise(t.start,(r?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=r?this.parseExpression():this.parseMaybeAssign(),this.expect(ll.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,r?"ForInStatement":"ForOfStatement")},Rl.parseVar=function(e,t,r,i){for(e.declarations=[],e.kind=r;;){var s=this.startNode();if(this.parseVarId(s,r),this.eat(ll.eq)?s.init=this.parseMaybeAssign(t):i||"const"!==r||this.type===ll._in||this.options.ecmaVersion>=6&&this.isContextual("of")?i||"using"!==r&&"await using"!==r||!(this.options.ecmaVersion>=17)||this.type===ll._in||this.isContextual("of")?i||"Identifier"===s.id.type||t&&(this.type===ll._in||this.isContextual("of"))?s.init=null:this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):this.raise(this.lastTokEnd,"Missing initializer in "+r+" declaration"):this.unexpected(),e.declarations.push(this.finishNode(s,"VariableDeclarator")),!this.eat(ll.comma))break}return e},Rl.parseVarId=function(e,t){e.id="using"===t||"await using"===t?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,"var"===t?1:2,!1)};var zl=1,Gl=2;function jl(e,t){var r=t.key.name,i=e[r],s="true";return"MethodDefinition"!==t.type||"get"!==t.kind&&"set"!==t.kind||(s=(t.static?"s":"i")+t.kind),"iget"===i&&"iset"===s||"iset"===i&&"iget"===s||"sget"===i&&"sset"===s||"sset"===i&&"sget"===s?(e[r]="true",!1):!!i||(e[r]=s,!1)}function $l(e,t){var r=e.computed,i=e.key;return!r&&("Identifier"===i.type&&i.name===t||"Literal"===i.type&&i.value===t)}Rl.parseFunction=function(e,t,r,i,s){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!i)&&(this.type===ll.star&&t&Gl&&this.unexpected(),e.generator=this.eat(ll.star)),this.options.ecmaVersion>=8&&(e.async=!!i),t&zl&&(e.id=4&t&&this.type!==ll.name?null:this.parseIdent(),!e.id||t&Gl||this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?1:2:3));var n=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(kl(e.async,e.generator)),t&zl||(e.id=this.type===ll.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,r,!1,s),this.yieldPos=n,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,t&zl?"FunctionDeclaration":"FunctionExpression")},Rl.parseFunctionParams=function(e){this.expect(ll.parenL),e.params=this.parseBindingList(ll.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},Rl.parseClass=function(e,t){this.next();var r=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var i=this.enterClassBody(),s=this.startNode(),n=!1;for(s.body=[],this.expect(ll.braceL);this.type!==ll.braceR;){var a=this.parseClassElement(null!==e.superClass);a&&(s.body.push(a),"MethodDefinition"===a.type&&"constructor"===a.kind?(n&&this.raiseRecoverable(a.start,"Duplicate constructor in the same class"),n=!0):a.key&&"PrivateIdentifier"===a.key.type&&jl(i,a)&&this.raiseRecoverable(a.key.start,"Identifier '#"+a.key.name+"' has already been declared"))}return this.strict=r,this.next(),e.body=this.finishNode(s,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")},Rl.parseClassElement=function(e){if(this.eat(ll.semi))return null;var t=this.options.ecmaVersion,r=this.startNode(),i="",s=!1,n=!1,a="method",o=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(ll.braceL))return this.parseClassStaticBlock(r),r;this.isClassElementNameStart()||this.type===ll.star?o=!0:i="static"}if(r.static=o,!i&&t>=8&&this.eatContextual("async")&&(!this.isClassElementNameStart()&&this.type!==ll.star||this.canInsertSemicolon()?i="async":n=!0),!i&&(t>=9||!n)&&this.eat(ll.star)&&(s=!0),!i&&!n&&!s){var h=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?a=h:i=h)}if(i?(r.computed=!1,r.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),r.key.name=i,this.finishNode(r.key,"Identifier")):this.parseClassElementName(r),t<13||this.type===ll.parenL||"method"!==a||s||n){var u=!r.static&&$l(r,"constructor"),l=u&&e;u&&"method"!==a&&this.raise(r.key.start,"Constructor can't have get/set modifier"),r.kind=u?"constructor":a,this.parseClassMethod(r,s,n,l)}else this.parseClassField(r);return r},Rl.isClassElementNameStart=function(){return this.type===ll.name||this.type===ll.privateId||this.type===ll.num||this.type===ll.string||this.type===ll.bracketL||this.type.keyword},Rl.parseClassElementName=function(e){this.type===ll.privateId?("constructor"===this.value&&this.raise(this.start,"Classes can't have an element named '#constructor'"),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)},Rl.parseClassMethod=function(e,t,r,i){var s=e.key;"constructor"===e.kind?(t&&this.raise(s.start,"Constructor can't be a generator"),r&&this.raise(s.start,"Constructor can't be an async method")):e.static&&$l(e,"prototype")&&this.raise(s.start,"Classes may not have a static property named prototype");var n=e.value=this.parseMethod(t,r,i);return"get"===e.kind&&0!==n.params.length&&this.raiseRecoverable(n.start,"getter should have no params"),"set"===e.kind&&1!==n.params.length&&this.raiseRecoverable(n.start,"setter should have exactly one param"),"set"===e.kind&&"RestElement"===n.params[0].type&&this.raiseRecoverable(n.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")},Rl.parseClassField=function(e){return $l(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&$l(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(ll.eq)?(this.enterScope(576),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")},Rl.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(320);this.type!==ll.braceR;){var r=this.parseStatement(null);e.body.push(r)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")},Rl.parseClassId=function(e,t){this.type===ll.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,2,!1)):(!0===t&&this.unexpected(),e.id=null)},Rl.parseClassSuper=function(e){e.superClass=this.eat(ll._extends)?this.parseExprSubscripts(null,!1):null},Rl.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},Rl.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,r=e.used;if(this.options.checkPrivateFields)for(var i=this.privateNameStack.length,s=0===i?null:this.privateNameStack[i-1],n=0;n<r.length;++n){var a=r[n];bl(t,a.name)||(s?s.used.push(a):this.raiseRecoverable(a.start,"Private field '#"+a.name+"' must be declared in an enclosing class"))}},Rl.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual("from"),this.type!==ll.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")},Rl.parseExport=function(e,t){if(this.next(),this.eat(ll.star))return this.parseExportAllDeclaration(e,t);if(this.eat(ll._default))return this.checkExport(t,"default",this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),"VariableDeclaration"===e.declaration.type?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==ll.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var r=0,i=e.specifiers;r<i.length;r+=1){var s=i[r];this.checkUnreserved(s.local),this.checkLocalExport(s.local),"Literal"===s.local.type&&this.raise(s.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,"ExportNamedDeclaration")},Rl.parseExportDeclaration=function(e){return this.parseStatement(null)},Rl.parseExportDefaultDeclaration=function(){var e;if(this.type===ll._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,4|zl,!1,e)}if(this.type===ll._class){var r=this.startNode();return this.parseClass(r,"nullableID")}var i=this.parseMaybeAssign();return this.semicolon(),i},Rl.checkExport=function(e,t,r){e&&("string"!=typeof t&&(t="Identifier"===t.type?t.name:t.value),bl(e,t)&&this.raiseRecoverable(r,"Duplicate export '"+t+"'"),e[t]=!0)},Rl.checkPatternExport=function(e,t){var r=t.type;if("Identifier"===r)this.checkExport(e,t,t.start);else if("ObjectPattern"===r)for(var i=0,s=t.properties;i<s.length;i+=1){var n=s[i];this.checkPatternExport(e,n)}else if("ArrayPattern"===r)for(var a=0,o=t.elements;a<o.length;a+=1){var h=o[a];h&&this.checkPatternExport(e,h)}else"Property"===r?this.checkPatternExport(e,t.value):"AssignmentPattern"===r?this.checkPatternExport(e,t.left):"RestElement"===r&&this.checkPatternExport(e,t.argument)},Rl.checkVariableExport=function(e,t){if(e)for(var r=0,i=t;r<i.length;r+=1){var s=i[r];this.checkPatternExport(e,s.id)}},Rl.shouldParseExportStatement=function(){return"var"===this.type.keyword||"const"===this.type.keyword||"class"===this.type.keyword||"function"===this.type.keyword||this.isLet()||this.isAsyncFunction()},Rl.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual("as")?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,"ExportSpecifier")},Rl.parseExportSpecifiers=function(e){var t=[],r=!0;for(this.expect(ll.braceL);!this.eat(ll.braceR);){if(r)r=!1;else if(this.expect(ll.comma),this.afterTrailingComma(ll.braceR))break;t.push(this.parseExportSpecifier(e))}return t},Rl.parseImport=function(e){return this.next(),this.type===ll.string?(e.specifiers=Ul,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===ll.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")},Rl.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual("as")?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,2),this.finishNode(e,"ImportSpecifier")},Rl.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,2),this.finishNode(e,"ImportDefaultSpecifier")},Rl.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,2),this.finishNode(e,"ImportNamespaceSpecifier")},Rl.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===ll.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(ll.comma)))return e;if(this.type===ll.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(ll.braceL);!this.eat(ll.braceR);){if(t)t=!1;else if(this.expect(ll.comma),this.afterTrailingComma(ll.braceR))break;e.push(this.parseImportSpecifier())}return e},Rl.parseWithClause=function(){var e=[];if(!this.eat(ll._with))return e;this.expect(ll.braceL);for(var t={},r=!0;!this.eat(ll.braceR);){if(r)r=!1;else if(this.expect(ll.comma),this.afterTrailingComma(ll.braceR))break;var i=this.parseImportAttribute(),s="Identifier"===i.key.type?i.key.name:i.key.value;bl(t,s)&&this.raiseRecoverable(i.key.start,"Duplicate attribute key '"+s+"'"),t[s]=!0,e.push(i)}return e},Rl.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===ll.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved),this.expect(ll.colon),this.type!==ll.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")},Rl.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===ll.string){var e=this.parseLiteral(this.value);return Dl.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)},Rl.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)},Rl.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&"ExpressionStatement"===e.type&&"Literal"===e.expression.type&&"string"==typeof e.expression.value&&('"'===this.input[e.start]||"'"===this.input[e.start])};var Hl=Il.prototype;Hl.toAssignable=function(e,t,r){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&"await"===e.name&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",r&&this.checkPatternErrors(r,!0);for(var i=0,s=e.properties;i<s.length;i+=1){var n=s[i];this.toAssignable(n,t),"RestElement"!==n.type||"ArrayPattern"!==n.argument.type&&"ObjectPattern"!==n.argument.type||this.raise(n.argument.start,"Unexpected token")}break;case"Property":"init"!==e.kind&&this.raise(e.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(e.value,t);break;case"ArrayExpression":e.type="ArrayPattern",r&&this.checkPatternErrors(r,!0),this.toAssignableList(e.elements,t);break;case"SpreadElement":e.type="RestElement",this.toAssignable(e.argument,t),"AssignmentPattern"===e.argument.type&&this.raise(e.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":"="!==e.operator&&this.raise(e.left.end,"Only '=' operator can be used for specifying default value."),e.type="AssignmentPattern",delete e.operator,this.toAssignable(e.left,t);break;case"ParenthesizedExpression":this.toAssignable(e.expression,t,r);break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!t)break;default:this.raise(e.start,"Assigning to rvalue")}else r&&this.checkPatternErrors(r,!0);return e},Hl.toAssignableList=function(e,t){for(var r=e.length,i=0;i<r;i++){var s=e[i];s&&this.toAssignable(s,t)}if(r){var n=e[r-1];6===this.options.ecmaVersion&&t&&n&&"RestElement"===n.type&&"Identifier"!==n.argument.type&&this.unexpected(n.argument.start)}return e},Hl.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")},Hl.parseRestBinding=function(){var e=this.startNode();return this.next(),6===this.options.ecmaVersion&&this.type!==ll.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")},Hl.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case ll.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(ll.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case ll.braceL:return this.parseObj(!0)}return this.parseIdent()},Hl.parseBindingList=function(e,t,r,i){for(var s=[],n=!0;!this.eat(e);)if(n?n=!1:this.expect(ll.comma),t&&this.type===ll.comma)s.push(null);else{if(r&&this.afterTrailingComma(e))break;if(this.type===ll.ellipsis){var a=this.parseRestBinding();this.parseBindingListItem(a),s.push(a),this.type===ll.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}s.push(this.parseAssignableListItem(i))}return s},Hl.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},Hl.parseBindingListItem=function(e){return e},Hl.parseMaybeDefault=function(e,t,r){if(r=r||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(ll.eq))return r;var i=this.startNodeAt(e,t);return i.left=r,i.right=this.parseMaybeAssign(),this.finishNode(i,"AssignmentPattern")},Hl.checkLValSimple=function(e,t,r){void 0===t&&(t=0);var i=0!==t;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(i?"Binding ":"Assigning to ")+e.name+" in strict mode"),i&&(2===t&&"let"===e.name&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),r&&(bl(r,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),r[e.name]=!0),5!==t&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":i&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return i&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,r);default:this.raise(e.start,(i?"Binding":"Assigning to")+" rvalue")}},Hl.checkLValPattern=function(e,t,r){switch(void 0===t&&(t=0),e.type){case"ObjectPattern":for(var i=0,s=e.properties;i<s.length;i+=1){var n=s[i];this.checkLValInnerPattern(n,t,r)}break;case"ArrayPattern":for(var a=0,o=e.elements;a<o.length;a+=1){var h=o[a];h&&this.checkLValInnerPattern(h,t,r)}break;default:this.checkLValSimple(e,t,r)}},Hl.checkLValInnerPattern=function(e,t,r){switch(void 0===t&&(t=0),e.type){case"Property":this.checkLValInnerPattern(e.value,t,r);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,r);break;case"RestElement":this.checkLValPattern(e.argument,t,r);break;default:this.checkLValPattern(e,t,r)}};var ql=function(e,t,r,i,s){this.token=e,this.isExpr=!!t,this.preserveSpace=!!r,this.override=i,this.generator=!!s},Wl={b_stat:new ql("{",!1),b_expr:new ql("{",!0),b_tmpl:new ql("${",!1),p_stat:new ql("(",!1),p_expr:new ql("(",!0),q_tmpl:new ql("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new ql("function",!1),f_expr:new ql("function",!0),f_expr_gen:new ql("function",!0,!1,null,!0),f_gen:new ql("function",!1,!1,null,!0)},Xl=Il.prototype;Xl.initialContext=function(){return[Wl.b_stat]},Xl.curContext=function(){return this.context[this.context.length-1]},Xl.braceIsBlock=function(e){var t=this.curContext();return t===Wl.f_expr||t===Wl.f_stat||(e!==ll.colon||t!==Wl.b_stat&&t!==Wl.b_expr?e===ll._return||e===ll.name&&this.exprAllowed?cl.test(this.input.slice(this.lastTokEnd,this.start)):e===ll._else||e===ll.semi||e===ll.eof||e===ll.parenR||e===ll.arrow||(e===ll.braceL?t===Wl.b_stat:e!==ll._var&&e!==ll._const&&e!==ll.name&&!this.exprAllowed):!t.isExpr)},Xl.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if("function"===t.token)return t.generator}return!1},Xl.updateContext=function(e){var t,r=this.type;r.keyword&&e===ll.dot?this.exprAllowed=!1:(t=r.updateContext)?t.call(this,e):this.exprAllowed=r.beforeExpr},Xl.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},ll.parenR.updateContext=ll.braceR.updateContext=function(){if(1!==this.context.length){var e=this.context.pop();e===Wl.b_stat&&"function"===this.curContext().token&&(e=this.context.pop()),this.exprAllowed=!e.isExpr}else this.exprAllowed=!0},ll.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?Wl.b_stat:Wl.b_expr),this.exprAllowed=!0},ll.dollarBraceL.updateContext=function(){this.context.push(Wl.b_tmpl),this.exprAllowed=!0},ll.parenL.updateContext=function(e){var t=e===ll._if||e===ll._for||e===ll._with||e===ll._while;this.context.push(t?Wl.p_stat:Wl.p_expr),this.exprAllowed=!0},ll.incDec.updateContext=function(){},ll._function.updateContext=ll._class.updateContext=function(e){!e.beforeExpr||e===ll._else||e===ll.semi&&this.curContext()!==Wl.p_stat||e===ll._return&&cl.test(this.input.slice(this.lastTokEnd,this.start))||(e===ll.colon||e===ll.braceL)&&this.curContext()===Wl.b_stat?this.context.push(Wl.f_stat):this.context.push(Wl.f_expr),this.exprAllowed=!1},ll.colon.updateContext=function(){"function"===this.curContext().token&&this.context.pop(),this.exprAllowed=!0},ll.backQuote.updateContext=function(){this.curContext()===Wl.q_tmpl?this.context.pop():this.context.push(Wl.q_tmpl),this.exprAllowed=!1},ll.star.updateContext=function(e){if(e===ll._function){var t=this.context.length-1;this.context[t]===Wl.f_expr?this.context[t]=Wl.f_expr_gen:this.context[t]=Wl.f_gen}this.exprAllowed=!0},ll.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==ll.dot&&("of"===this.value&&!this.exprAllowed||"yield"===this.value&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var Yl=Il.prototype;function Kl(e){return"Identifier"===e.type||"ParenthesizedExpression"===e.type&&Kl(e.expression)}function Zl(e){return"MemberExpression"===e.type&&"PrivateIdentifier"===e.property.type||"ChainExpression"===e.type&&Zl(e.expression)||"ParenthesizedExpression"===e.type&&Zl(e.expression)}Yl.checkPropClash=function(e,t,r){if(!(this.options.ecmaVersion>=9&&"SpreadElement"===e.type||this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var i,s=e.key;switch(s.type){case"Identifier":i=s.name;break;case"Literal":i=String(s.value);break;default:return}var n=e.kind;if(this.options.ecmaVersion>=6)"__proto__"===i&&"init"===n&&(t.proto&&(r?r.doubleProto<0&&(r.doubleProto=s.start):this.raiseRecoverable(s.start,"Redefinition of __proto__ property")),t.proto=!0);else{var a=t[i="$"+i];a?("init"===n?this.strict&&a.init||a.get||a.set:a.init||a[n])&&this.raiseRecoverable(s.start,"Redefinition of property"):a=t[i]={init:!1,get:!1,set:!1},a[n]=!0}}},Yl.parseExpression=function(e,t){var r=this.start,i=this.startLoc,s=this.parseMaybeAssign(e,t);if(this.type===ll.comma){var n=this.startNodeAt(r,i);for(n.expressions=[s];this.eat(ll.comma);)n.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(n,"SequenceExpression")}return s},Yl.parseMaybeAssign=function(e,t,r){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var i=!1,s=-1,n=-1,a=-1;t?(s=t.parenthesizedAssign,n=t.trailingComma,a=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new Ol,i=!0);var o=this.start,h=this.startLoc;this.type!==ll.parenL&&this.type!==ll.name||(this.potentialArrowAt=this.start,this.potentialArrowInForAwait="await"===e);var u=this.parseMaybeConditional(e,t);if(r&&(u=r.call(this,u,o,h)),this.type.isAssign){var l=this.startNodeAt(o,h);return l.operator=this.value,this.type===ll.eq&&(u=this.toAssignable(u,!1,t)),i||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=u.start&&(t.shorthandAssign=-1),this.type===ll.eq?this.checkLValPattern(u):this.checkLValSimple(u),l.left=u,this.next(),l.right=this.parseMaybeAssign(e),a>-1&&(t.doubleProto=a),this.finishNode(l,"AssignmentExpression")}return i&&this.checkExpressionErrors(t,!0),s>-1&&(t.parenthesizedAssign=s),n>-1&&(t.trailingComma=n),u},Yl.parseMaybeConditional=function(e,t){var r=this.start,i=this.startLoc,s=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return s;if(this.eat(ll.question)){var n=this.startNodeAt(r,i);return n.test=s,n.consequent=this.parseMaybeAssign(),this.expect(ll.colon),n.alternate=this.parseMaybeAssign(e),this.finishNode(n,"ConditionalExpression")}return s},Yl.parseExprOps=function(e,t){var r=this.start,i=this.startLoc,s=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||s.start===r&&"ArrowFunctionExpression"===s.type?s:this.parseExprOp(s,r,i,-1,e)},Yl.parseExprOp=function(e,t,r,i,s){var n=this.type.binop;if(null!=n&&(!s||this.type!==ll._in)&&n>i){var a=this.type===ll.logicalOR||this.type===ll.logicalAND,o=this.type===ll.coalesce;o&&(n=ll.logicalAND.binop);var h=this.value;this.next();var u=this.start,l=this.startLoc,c=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,s),u,l,n,s),p=this.buildBinary(t,r,e,c,h,a||o);return(a&&this.type===ll.coalesce||o&&(this.type===ll.logicalOR||this.type===ll.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(p,t,r,i,s)}return e},Yl.buildBinary=function(e,t,r,i,s,n){"PrivateIdentifier"===i.type&&this.raise(i.start,"Private identifier can only be left side of binary expression");var a=this.startNodeAt(e,t);return a.left=r,a.operator=s,a.right=i,this.finishNode(a,n?"LogicalExpression":"BinaryExpression")},Yl.parseMaybeUnary=function(e,t,r,i){var s,n=this.start,a=this.startLoc;if(this.isContextual("await")&&this.canAwait)s=this.parseAwait(i),t=!0;else if(this.type.prefix){var o=this.startNode(),h=this.type===ll.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,h,i),this.checkExpressionErrors(e,!0),h?this.checkLValSimple(o.argument):this.strict&&"delete"===o.operator&&Kl(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):"delete"===o.operator&&Zl(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):t=!0,s=this.finishNode(o,h?"UpdateExpression":"UnaryExpression")}else if(t||this.type!==ll.privateId){if(s=this.parseExprSubscripts(e,i),this.checkExpressionErrors(e))return s;for(;this.type.postfix&&!this.canInsertSemicolon();){var u=this.startNodeAt(n,a);u.operator=this.value,u.prefix=!1,u.argument=s,this.checkLValSimple(s),this.next(),s=this.finishNode(u,"UpdateExpression")}}else(i||0===this.privateNameStack.length)&&this.options.checkPrivateFields&&this.unexpected(),s=this.parsePrivateIdent(),this.type!==ll._in&&this.unexpected();return r||!this.eat(ll.starstar)?s:t?void this.unexpected(this.lastTokStart):this.buildBinary(n,a,s,this.parseMaybeUnary(null,!1,!1,i),"**",!1)},Yl.parseExprSubscripts=function(e,t){var r=this.start,i=this.startLoc,s=this.parseExprAtom(e,t);if("ArrowFunctionExpression"===s.type&&")"!==this.input.slice(this.lastTokStart,this.lastTokEnd))return s;var n=this.parseSubscripts(s,r,i,!1,t);return e&&"MemberExpression"===n.type&&(e.parenthesizedAssign>=n.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=n.start&&(e.parenthesizedBind=-1),e.trailingComma>=n.start&&(e.trailingComma=-1)),n},Yl.parseSubscripts=function(e,t,r,i,s){for(var n=this.options.ecmaVersion>=8&&"Identifier"===e.type&&"async"===e.name&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start==5&&this.potentialArrowAt===e.start,a=!1;;){var o=this.parseSubscript(e,t,r,i,n,a,s);if(o.optional&&(a=!0),o===e||"ArrowFunctionExpression"===o.type){if(a){var h=this.startNodeAt(t,r);h.expression=o,o=this.finishNode(h,"ChainExpression")}return o}e=o}},Yl.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(ll.arrow)},Yl.parseSubscriptAsyncArrow=function(e,t,r,i){return this.parseArrowExpression(this.startNodeAt(e,t),r,!0,i)},Yl.parseSubscript=function(e,t,r,i,s,n,a){var o=this.options.ecmaVersion>=11,h=o&&this.eat(ll.questionDot);i&&h&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var u=this.eat(ll.bracketL);if(u||h&&this.type!==ll.parenL&&this.type!==ll.backQuote||this.eat(ll.dot)){var l=this.startNodeAt(t,r);l.object=e,u?(l.property=this.parseExpression(),this.expect(ll.bracketR)):this.type===ll.privateId&&"Super"!==e.type?l.property=this.parsePrivateIdent():l.property=this.parseIdent("never"!==this.options.allowReserved),l.computed=!!u,o&&(l.optional=h),e=this.finishNode(l,"MemberExpression")}else if(!i&&this.eat(ll.parenL)){var c=new Ol,p=this.yieldPos,d=this.awaitPos,f=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var g=this.parseExprList(ll.parenR,this.options.ecmaVersion>=8,!1,c);if(s&&!h&&this.shouldParseAsyncArrow())return this.checkPatternErrors(c,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=p,this.awaitPos=d,this.awaitIdentPos=f,this.parseSubscriptAsyncArrow(t,r,g,a);this.checkExpressionErrors(c,!0),this.yieldPos=p||this.yieldPos,this.awaitPos=d||this.awaitPos,this.awaitIdentPos=f||this.awaitIdentPos;var m=this.startNodeAt(t,r);m.callee=e,m.arguments=g,o&&(m.optional=h),e=this.finishNode(m,"CallExpression")}else if(this.type===ll.backQuote){(h||n)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var y=this.startNodeAt(t,r);y.tag=e,y.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(y,"TaggedTemplateExpression")}return e},Yl.parseExprAtom=function(e,t,r){this.type===ll.slash&&this.readRegexp();var i,s=this.potentialArrowAt===this.start;switch(this.type){case ll._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),i=this.startNode(),this.next(),this.type!==ll.parenL||this.allowDirectSuper||this.raise(i.start,"super() call outside constructor of a subclass"),this.type!==ll.dot&&this.type!==ll.bracketL&&this.type!==ll.parenL&&this.unexpected(),this.finishNode(i,"Super");case ll._this:return i=this.startNode(),this.next(),this.finishNode(i,"ThisExpression");case ll.name:var n=this.start,a=this.startLoc,o=this.containsEsc,h=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&"async"===h.name&&!this.canInsertSemicolon()&&this.eat(ll._function))return this.overrideContext(Wl.f_expr),this.parseFunction(this.startNodeAt(n,a),0,!1,!0,t);if(s&&!this.canInsertSemicolon()){if(this.eat(ll.arrow))return this.parseArrowExpression(this.startNodeAt(n,a),[h],!1,t);if(this.options.ecmaVersion>=8&&"async"===h.name&&this.type===ll.name&&!o&&(!this.potentialArrowInForAwait||"of"!==this.value||this.containsEsc))return h=this.parseIdent(!1),!this.canInsertSemicolon()&&this.eat(ll.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(n,a),[h],!0,t)}return h;case ll.regexp:var u=this.value;return(i=this.parseLiteral(u.value)).regex={pattern:u.pattern,flags:u.flags},i;case ll.num:case ll.string:return this.parseLiteral(this.value);case ll._null:case ll._true:case ll._false:return(i=this.startNode()).value=this.type===ll._null?null:this.type===ll._true,i.raw=this.type.keyword,this.next(),this.finishNode(i,"Literal");case ll.parenL:var l=this.start,c=this.parseParenAndDistinguishExpression(s,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(c)&&(e.parenthesizedAssign=l),e.parenthesizedBind<0&&(e.parenthesizedBind=l)),c;case ll.bracketL:return i=this.startNode(),this.next(),i.elements=this.parseExprList(ll.bracketR,!0,!0,e),this.finishNode(i,"ArrayExpression");case ll.braceL:return this.overrideContext(Wl.b_expr),this.parseObj(!1,e);case ll._function:return i=this.startNode(),this.next(),this.parseFunction(i,0);case ll._class:return this.parseClass(this.startNode(),!1);case ll._new:return this.parseNew();case ll.backQuote:return this.parseTemplate();case ll._import:return this.options.ecmaVersion>=11?this.parseExprImport(r):this.unexpected();default:return this.parseExprAtomDefault()}},Yl.parseExprAtomDefault=function(){this.unexpected()},Yl.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===ll.parenL&&!e)return this.parseDynamicImport(t);if(this.type===ll.dot){var r=this.startNodeAt(t.start,t.loc&&t.loc.start);return r.name="import",t.meta=this.finishNode(r,"Identifier"),this.parseImportMeta(t)}this.unexpected()},Yl.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(ll.parenR)?e.options=null:(this.expect(ll.comma),this.afterTrailingComma(ll.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(ll.parenR)||(this.expect(ll.comma),this.afterTrailingComma(ll.parenR)||this.unexpected())));else if(!this.eat(ll.parenR)){var t=this.start;this.eat(ll.comma)&&this.eat(ll.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")},Yl.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),"meta"!==e.property.name&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),"module"===this.options.sourceType||this.options.allowImportExportEverywhere||this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")},Yl.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),110===t.raw.charCodeAt(t.raw.length-1)&&(t.bigint=null!=t.value?t.value.toString():t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")},Yl.parseParenExpression=function(){this.expect(ll.parenL);var e=this.parseExpression();return this.expect(ll.parenR),e},Yl.shouldParseArrow=function(e){return!this.canInsertSemicolon()},Yl.parseParenAndDistinguishExpression=function(e,t){var r,i=this.start,s=this.startLoc,n=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a,o=this.start,h=this.startLoc,u=[],l=!0,c=!1,p=new Ol,d=this.yieldPos,f=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==ll.parenR;){if(l?l=!1:this.expect(ll.comma),n&&this.afterTrailingComma(ll.parenR,!0)){c=!0;break}if(this.type===ll.ellipsis){a=this.start,u.push(this.parseParenItem(this.parseRestBinding())),this.type===ll.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}u.push(this.parseMaybeAssign(!1,p,this.parseParenItem))}var g=this.lastTokEnd,m=this.lastTokEndLoc;if(this.expect(ll.parenR),e&&this.shouldParseArrow(u)&&this.eat(ll.arrow))return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=d,this.awaitPos=f,this.parseParenArrowList(i,s,u,t);u.length&&!c||this.unexpected(this.lastTokStart),a&&this.unexpected(a),this.checkExpressionErrors(p,!0),this.yieldPos=d||this.yieldPos,this.awaitPos=f||this.awaitPos,u.length>1?((r=this.startNodeAt(o,h)).expressions=u,this.finishNodeAt(r,"SequenceExpression",g,m)):r=u[0]}else r=this.parseParenExpression();if(this.options.preserveParens){var y=this.startNodeAt(i,s);return y.expression=r,this.finishNode(y,"ParenthesizedExpression")}return r},Yl.parseParenItem=function(e){return e},Yl.parseParenArrowList=function(e,t,r,i){return this.parseArrowExpression(this.startNodeAt(e,t),r,!1,i)};var Jl=[];Yl.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===ll.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var r=this.containsEsc;return e.property=this.parseIdent(!0),"target"!==e.property.name&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),r&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var i=this.start,s=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),i,s,!0,!1),this.eat(ll.parenL)?e.arguments=this.parseExprList(ll.parenR,this.options.ecmaVersion>=8,!1):e.arguments=Jl,this.finishNode(e,"NewExpression")},Yl.parseTemplateElement=function(e){var t=e.isTagged,r=this.startNode();return this.type===ll.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),r.value={raw:this.value.replace(/\r\n?/g,"\n"),cooked:null}):r.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),r.tail=this.type===ll.backQuote,this.finishNode(r,"TemplateElement")},Yl.parseTemplate=function(e){void 0===e&&(e={});var t=e.isTagged;void 0===t&&(t=!1);var r=this.startNode();this.next(),r.expressions=[];var i=this.parseTemplateElement({isTagged:t});for(r.quasis=[i];!i.tail;)this.type===ll.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(ll.dollarBraceL),r.expressions.push(this.parseExpression()),this.expect(ll.braceR),r.quasis.push(i=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(r,"TemplateLiteral")},Yl.isAsyncProp=function(e){return!e.computed&&"Identifier"===e.key.type&&"async"===e.key.name&&(this.type===ll.name||this.type===ll.num||this.type===ll.string||this.type===ll.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===ll.star)&&!cl.test(this.input.slice(this.lastTokEnd,this.start))},Yl.parseObj=function(e,t){var r=this.startNode(),i=!0,s={};for(r.properties=[],this.next();!this.eat(ll.braceR);){if(i)i=!1;else if(this.expect(ll.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(ll.braceR))break;var n=this.parseProperty(e,t);e||this.checkPropClash(n,s,t),r.properties.push(n)}return this.finishNode(r,e?"ObjectPattern":"ObjectExpression")},Yl.parseProperty=function(e,t){var r,i,s,n,a=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(ll.ellipsis))return e?(a.argument=this.parseIdent(!1),this.type===ll.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(a,"RestElement")):(a.argument=this.parseMaybeAssign(!1,t),this.type===ll.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(a,"SpreadElement"));this.options.ecmaVersion>=6&&(a.method=!1,a.shorthand=!1,(e||t)&&(s=this.start,n=this.startLoc),e||(r=this.eat(ll.star)));var o=this.containsEsc;return this.parsePropertyName(a),!e&&!o&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(a)?(i=!0,r=this.options.ecmaVersion>=9&&this.eat(ll.star),this.parsePropertyName(a)):i=!1,this.parsePropertyValue(a,e,r,i,s,n,t,o),this.finishNode(a,"Property")},Yl.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var r="get"===e.kind?0:1;if(e.value.params.length!==r){var i=e.value.start;"get"===e.kind?this.raiseRecoverable(i,"getter should have no params"):this.raiseRecoverable(i,"setter should have exactly one param")}else"set"===e.kind&&"RestElement"===e.value.params[0].type&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")},Yl.parsePropertyValue=function(e,t,r,i,s,n,a,o){(r||i)&&this.type===ll.colon&&this.unexpected(),this.eat(ll.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),e.kind="init"):this.options.ecmaVersion>=6&&this.type===ll.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(r,i),e.kind="init"):t||o||!(this.options.ecmaVersion>=5)||e.computed||"Identifier"!==e.key.type||"get"!==e.key.name&&"set"!==e.key.name||this.type===ll.comma||this.type===ll.braceR||this.type===ll.eq?this.options.ecmaVersion>=6&&!e.computed&&"Identifier"===e.key.type?((r||i)&&this.unexpected(),this.checkUnreserved(e.key),"await"!==e.key.name||this.awaitIdentPos||(this.awaitIdentPos=s),t?e.value=this.parseMaybeDefault(s,n,this.copyNode(e.key)):this.type===ll.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),e.value=this.parseMaybeDefault(s,n,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected():((r||i)&&this.unexpected(),this.parseGetterSetter(e))},Yl.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(ll.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(ll.bracketR),e.key;e.computed=!1}return e.key=this.type===ll.num||this.type===ll.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved)},Yl.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},Yl.parseMethod=function(e,t,r){var i=this.startNode(),s=this.yieldPos,n=this.awaitPos,a=this.awaitIdentPos;return this.initFunction(i),this.options.ecmaVersion>=6&&(i.generator=e),this.options.ecmaVersion>=8&&(i.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(64|kl(t,i.generator)|(r?128:0)),this.expect(ll.parenL),i.params=this.parseBindingList(ll.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(i,!1,!0,!1),this.yieldPos=s,this.awaitPos=n,this.awaitIdentPos=a,this.finishNode(i,"FunctionExpression")},Yl.parseArrowExpression=function(e,t,r,i){var s=this.yieldPos,n=this.awaitPos,a=this.awaitIdentPos;return this.enterScope(16|kl(r,!1)),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!r),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,i),this.yieldPos=s,this.awaitPos=n,this.awaitIdentPos=a,this.finishNode(e,"ArrowFunctionExpression")},Yl.parseFunctionBody=function(e,t,r,i){var s=t&&this.type!==ll.braceL,n=this.strict,a=!1;if(s)e.body=this.parseMaybeAssign(i),e.expression=!0,this.checkParams(e,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);n&&!o||(a=this.strictDirective(this.end))&&o&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list");var h=this.labels;this.labels=[],a&&(this.strict=!0),this.checkParams(e,!n&&!a&&!t&&!r&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,5),e.body=this.parseBlock(!1,void 0,a&&!n),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=h}this.exitScope()},Yl.isSimpleParamList=function(e){for(var t=0,r=e;t<r.length;t+=1)if("Identifier"!==r[t].type)return!1;return!0},Yl.checkParams=function(e,t){for(var r=Object.create(null),i=0,s=e.params;i<s.length;i+=1){var n=s[i];this.checkLValInnerPattern(n,1,t?null:r)}},Yl.parseExprList=function(e,t,r,i){for(var s=[],n=!0;!this.eat(e);){if(n)n=!1;else if(this.expect(ll.comma),t&&this.afterTrailingComma(e))break;var a=void 0;r&&this.type===ll.comma?a=null:this.type===ll.ellipsis?(a=this.parseSpread(i),i&&this.type===ll.comma&&i.trailingComma<0&&(i.trailingComma=this.start)):a=this.parseMaybeAssign(!1,i),s.push(a)}return s},Yl.checkUnreserved=function(e){var t=e.start,r=e.end,i=e.name;this.inGenerator&&"yield"===i&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&"await"===i&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),259&this.currentThisScope().flags||"arguments"!==i||this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),!this.inClassStaticBlock||"arguments"!==i&&"await"!==i||this.raise(t,"Cannot use "+i+" in class static initialization block"),this.keywords.test(i)&&this.raise(t,"Unexpected keyword '"+i+"'"),this.options.ecmaVersion<6&&-1!==this.input.slice(t,r).indexOf("\\")||(this.strict?this.reservedWordsStrict:this.reservedWords).test(i)&&(this.inAsync||"await"!==i||this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+i+"' is reserved"))},Yl.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,"Identifier"),e||(this.checkUnreserved(t),"await"!==t.name||this.awaitIdentPos||(this.awaitIdentPos=t.start)),t},Yl.parseIdentNode=function(){var e=this.startNode();return this.type===ll.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,"class"!==e.name&&"function"!==e.name||this.lastTokEnd===this.lastTokStart+1&&46===this.input.charCodeAt(this.lastTokStart)||this.context.pop(),this.type=ll.name):this.unexpected(),e},Yl.parsePrivateIdent=function(){var e=this.startNode();return this.type===ll.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(0===this.privateNameStack.length?this.raise(e.start,"Private field '#"+e.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e},Yl.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===ll.semi||this.canInsertSemicolon()||this.type!==ll.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(ll.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")},Yl.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,"AwaitExpression")};var Ql=Il.prototype;Ql.raise=function(e,t){var r=Fl(this.input,e);t+=" ("+r.line+":"+r.column+")",this.sourceFile&&(t+=" in "+this.sourceFile);var i=new SyntaxError(t);throw i.pos=e,i.loc=r,i.raisedAt=this.pos,i},Ql.raiseRecoverable=Ql.raise,Ql.curPosition=function(){if(this.options.locations)return new Al(this.curLine,this.pos-this.lineStart)};var ec=Il.prototype,tc=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};ec.enterScope=function(e){this.scopeStack.push(new tc(e))},ec.exitScope=function(){this.scopeStack.pop()},ec.treatFunctionsAsVarInScope=function(e){return 2&e.flags||!this.inModule&&1&e.flags},ec.declareName=function(e,t,r){var i=!1;if(2===t){var s=this.currentScope();i=s.lexical.indexOf(e)>-1||s.functions.indexOf(e)>-1||s.var.indexOf(e)>-1,s.lexical.push(e),this.inModule&&1&s.flags&&delete this.undefinedExports[e]}else if(4===t)this.currentScope().lexical.push(e);else if(3===t){var n=this.currentScope();i=this.treatFunctionsAsVar?n.lexical.indexOf(e)>-1:n.lexical.indexOf(e)>-1||n.var.indexOf(e)>-1,n.functions.push(e)}else for(var a=this.scopeStack.length-1;a>=0;--a){var o=this.scopeStack[a];if(o.lexical.indexOf(e)>-1&&!(32&o.flags&&o.lexical[0]===e)||!this.treatFunctionsAsVarInScope(o)&&o.functions.indexOf(e)>-1){i=!0;break}if(o.var.push(e),this.inModule&&1&o.flags&&delete this.undefinedExports[e],259&o.flags)break}i&&this.raiseRecoverable(r,"Identifier '"+e+"' has already been declared")},ec.checkLocalExport=function(e){-1===this.scopeStack[0].lexical.indexOf(e.name)&&-1===this.scopeStack[0].var.indexOf(e.name)&&(this.undefinedExports[e.name]=e)},ec.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},ec.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(771&t.flags)return t}},ec.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(771&t.flags&&!(16&t.flags))return t}};var rc=function(e,t,r){this.type="",this.start=t,this.end=0,e.options.locations&&(this.loc=new Sl(e,r)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},ic=Il.prototype;function sc(e,t,r,i){return e.type=t,e.end=r,this.options.locations&&(e.loc.end=i),this.options.ranges&&(e.range[1]=r),e}ic.startNode=function(){return new rc(this,this.start,this.startLoc)},ic.startNodeAt=function(e,t){return new rc(this,e,t)},ic.finishNode=function(e,t){return sc.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},ic.finishNodeAt=function(e,t,r,i){return sc.call(this,e,t,r,i)},ic.copyNode=function(e){var t=new rc(this,e.start,this.startLoc);for(var r in e)t[r]=e[r];return t};var nc="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",ac=nc+" Extended_Pictographic",oc=ac+" EBase EComp EMod EPres ExtPict",hc={9:nc,10:ac,11:ac,12:oc,13:oc,14:oc},uc={9:"",10:"",11:"",12:"",13:"",14:"Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji"},lc="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",cc="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",pc=cc+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",dc=pc+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",fc=dc+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",gc=fc+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",mc={9:cc,10:pc,11:dc,12:fc,13:gc,14:gc+" Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz"},yc={};function xc(e){var t=yc[e]={binary:Cl(hc[e]+" "+lc),binaryOfStrings:Cl(uc[e]),nonBinary:{General_Category:Cl(lc),Script:Cl(mc[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(var vc=0,bc=[9,10,11,12,13,14];vc<bc.length;vc+=1)xc(bc[vc]);var _c=Il.prototype,wc=function(e,t){this.parent=e,this.base=t||this};wc.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var r=e;r;r=r.parent)if(t.base===r.base&&t!==r)return!0;return!1},wc.prototype.sibling=function(){return new wc(this.parent,this.base)};var Cc=function(e){this.parser=e,this.validFlags="gim"+(e.options.ecmaVersion>=6?"uy":"")+(e.options.ecmaVersion>=9?"s":"")+(e.options.ecmaVersion>=13?"d":"")+(e.options.ecmaVersion>=15?"v":""),this.unicodeProperties=yc[e.options.ecmaVersion>=14?14:e.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};function Ec(e){return 105===e||109===e||115===e}function Dc(e){return 36===e||e>=40&&e<=43||46===e||63===e||e>=91&&e<=94||e>=123&&e<=125}function Ac(e){return e>=65&&e<=90||e>=97&&e<=122}function Sc(e){return Ac(e)||95===e}function Fc(e){return Sc(e)||Tc(e)}function Tc(e){return e>=48&&e<=57}function Mc(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function kc(e){return e>=65&&e<=70?e-65+10:e>=97&&e<=102?e-97+10:e-48}function Ic(e){return e>=48&&e<=55}Cc.prototype.reset=function(e,t,r){var i=-1!==r.indexOf("v"),s=-1!==r.indexOf("u");this.start=0|e,this.source=t+"",this.flags=r,i&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=s&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=s&&this.parser.options.ecmaVersion>=9)},Cc.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)},Cc.prototype.at=function(e,t){void 0===t&&(t=!1);var r=this.source,i=r.length;if(e>=i)return-1;var s=r.charCodeAt(e);if(!t&&!this.switchU||s<=55295||s>=57344||e+1>=i)return s;var n=r.charCodeAt(e+1);return n>=56320&&n<=57343?(s<<10)+n-56613888:s},Cc.prototype.nextIndex=function(e,t){void 0===t&&(t=!1);var r=this.source,i=r.length;if(e>=i)return i;var s,n=r.charCodeAt(e);return!t&&!this.switchU||n<=55295||n>=57344||e+1>=i||(s=r.charCodeAt(e+1))<56320||s>57343?e+1:e+2},Cc.prototype.current=function(e){return void 0===e&&(e=!1),this.at(this.pos,e)},Cc.prototype.lookahead=function(e){return void 0===e&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},Cc.prototype.advance=function(e){void 0===e&&(e=!1),this.pos=this.nextIndex(this.pos,e)},Cc.prototype.eat=function(e,t){return void 0===t&&(t=!1),this.current(t)===e&&(this.advance(t),!0)},Cc.prototype.eatChars=function(e,t){void 0===t&&(t=!1);for(var r=this.pos,i=0,s=e;i<s.length;i+=1){var n=s[i],a=this.at(r,t);if(-1===a||a!==n)return!1;r=this.nextIndex(r,t)}return this.pos=r,!0},_c.validateRegExpFlags=function(e){for(var t=e.validFlags,r=e.flags,i=!1,s=!1,n=0;n<r.length;n++){var a=r.charAt(n);-1===t.indexOf(a)&&this.raise(e.start,"Invalid regular expression flag"),r.indexOf(a,n+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),"u"===a&&(i=!0),"v"===a&&(s=!0)}this.options.ecmaVersion>=15&&i&&s&&this.raise(e.start,"Invalid regular expression flag")},_c.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&function(e){for(var t in e)return!0;return!1}(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},_c.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,r=e.backReferenceNames;t<r.length;t+=1){var i=r[t];e.groupNames[i]||e.raise("Invalid named capture referenced")}},_c.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new wc(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")},_c.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},_c.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise("Invalid quantifier"),!0):!!(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))&&(this.regexp_eatQuantifier(e),!0)},_c.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var r=!1;if(this.options.ecmaVersion>=9&&(r=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!r,!0}return e.pos=t,!1},_c.regexp_eatQuantifier=function(e,t){return void 0===t&&(t=!1),!!this.regexp_eatQuantifierPrefix(e,t)&&(e.eat(63),!0)},_c.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},_c.regexp_eatBracedQuantifier=function(e,t){var r=e.pos;if(e.eat(123)){var i=0,s=-1;if(this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(s=e.lastIntValue),e.eat(125)))return-1!==s&&s<i&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=r}return!1},_c.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)},_c.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},_c.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var r=this.regexp_eatModifiers(e),i=e.eat(45);if(r||i){for(var s=0;s<r.length;s++){var n=r.charAt(s);r.indexOf(n,s+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(i){var a=this.regexp_eatModifiers(e);r||a||58!==e.current()||e.raise("Invalid regular expression modifiers");for(var o=0;o<a.length;o++){var h=a.charAt(o);(a.indexOf(h,o+1)>-1||r.indexOf(h)>-1)&&e.raise("Duplicate regular expression modifiers")}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise("Unterminated group")}}e.pos=t}return!1},_c.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):63===e.current()&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1},_c.regexp_eatModifiers=function(e){for(var t="",r=0;-1!==(r=e.current())&&Ec(r);)t+=El(r),e.advance();return t},_c.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)},_c.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1},_c.regexp_eatSyntaxCharacter=function(e){var t=e.current();return!!Dc(t)&&(e.lastIntValue=t,e.advance(),!0)},_c.regexp_eatPatternCharacters=function(e){for(var t=e.pos,r=0;-1!==(r=e.current())&&!Dc(r);)e.advance();return e.pos!==t},_c.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return!(-1===t||36===t||t>=40&&t<=43||46===t||63===t||91===t||94===t||124===t||(e.advance(),0))},_c.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,r=e.groupNames[e.lastStringValue];if(r)if(t)for(var i=0,s=r;i<s.length;i+=1)s[i].separatedFrom(e.branchID)||e.raise("Duplicate capture group name");else e.raise("Duplicate capture group name");t?(r||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}},_c.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1},_c.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=El(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=El(e.lastIntValue);return!0}return!1},_c.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,r=this.options.ecmaVersion>=11,i=e.current(r);return e.advance(r),92===i&&this.regexp_eatRegExpUnicodeEscapeSequence(e,r)&&(i=e.lastIntValue),function(e){return rl(e,!0)||36===e||95===e}(i)?(e.lastIntValue=i,!0):(e.pos=t,!1)},_c.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,r=this.options.ecmaVersion>=11,i=e.current(r);return e.advance(r),92===i&&this.regexp_eatRegExpUnicodeEscapeSequence(e,r)&&(i=e.lastIntValue),function(e){return il(e,!0)||36===e||95===e||8204===e||8205===e}(i)?(e.lastIntValue=i,!0):(e.pos=t,!1)},_c.regexp_eatAtomEscape=function(e){return!!(this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e))||(e.switchU&&(99===e.current()&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)},_c.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var r=e.lastIntValue;if(e.switchU)return r>e.maxBackReference&&(e.maxBackReference=r),!0;if(r<=e.numCapturingParens)return!0;e.pos=t}return!1},_c.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1},_c.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)},_c.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},_c.regexp_eatZero=function(e){return 48===e.current()&&!Tc(e.lookahead())&&(e.lastIntValue=0,e.advance(),!0)},_c.regexp_eatControlEscape=function(e){var t=e.current();return 116===t?(e.lastIntValue=9,e.advance(),!0):110===t?(e.lastIntValue=10,e.advance(),!0):118===t?(e.lastIntValue=11,e.advance(),!0):102===t?(e.lastIntValue=12,e.advance(),!0):114===t&&(e.lastIntValue=13,e.advance(),!0)},_c.regexp_eatControlLetter=function(e){var t=e.current();return!!Ac(t)&&(e.lastIntValue=t%32,e.advance(),!0)},_c.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){void 0===t&&(t=!1);var r,i=e.pos,s=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var n=e.lastIntValue;if(s&&n>=55296&&n<=56319){var a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var o=e.lastIntValue;if(o>=56320&&o<=57343)return e.lastIntValue=1024*(n-55296)+(o-56320)+65536,!0}e.pos=a,e.lastIntValue=n}return!0}if(s&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&(r=e.lastIntValue)>=0&&r<=1114111)return!0;s&&e.raise("Invalid unicode escape"),e.pos=i}return!1},_c.regexp_eatIdentityEscape=function(e){if(e.switchU)return!!this.regexp_eatSyntaxCharacter(e)||!!e.eat(47)&&(e.lastIntValue=47,!0);var t=e.current();return!(99===t||e.switchN&&107===t||(e.lastIntValue=t,e.advance(),0))},_c.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do{e.lastIntValue=10*e.lastIntValue+(t-48),e.advance()}while((t=e.current())>=48&&t<=57);return!0}return!1},_c.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(function(e){return 100===e||68===e||115===e||83===e||119===e||87===e}(t))return e.lastIntValue=-1,e.advance(),1;var r=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((r=80===t)||112===t)){var i;if(e.lastIntValue=-1,e.advance(),e.eat(123)&&(i=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return r&&2===i&&e.raise("Invalid property name"),i;e.raise("Invalid property name")}return 0},_c.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var r=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,r,i),1}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var s=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,s)}return 0},_c.regexp_validateUnicodePropertyNameAndValue=function(e,t,r){bl(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(r)||e.raise("Invalid property value")},_c.regexp_validateUnicodePropertyNameOrValue=function(e,t){return e.unicodeProperties.binary.test(t)?1:e.switchV&&e.unicodeProperties.binaryOfStrings.test(t)?2:void e.raise("Invalid property name")},_c.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";Sc(t=e.current());)e.lastStringValue+=El(t),e.advance();return""!==e.lastStringValue},_c.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";Fc(t=e.current());)e.lastStringValue+=El(t),e.advance();return""!==e.lastStringValue},_c.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},_c.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),r=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&2===r&&e.raise("Negated character class may contain strings"),!0}return!1},_c.regexp_classContents=function(e){return 93===e.current()?1:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),1)},_c.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var r=e.lastIntValue;!e.switchU||-1!==t&&-1!==r||e.raise("Invalid character class"),-1!==t&&-1!==r&&t>r&&e.raise("Range out of order in character class")}}},_c.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var r=e.current();(99===r||Ic(r))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var i=e.current();return 93!==i&&(e.lastIntValue=i,e.advance(),!0)},_c.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)},_c.regexp_classSetExpression=function(e){var t,r=1;if(this.regexp_eatClassSetRange(e));else if(t=this.regexp_eatClassSetOperand(e)){2===t&&(r=2);for(var i=e.pos;e.eatChars([38,38]);)38!==e.current()&&(t=this.regexp_eatClassSetOperand(e))?2!==t&&(r=1):e.raise("Invalid character in character class");if(i!==e.pos)return r;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(i!==e.pos)return r}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(!(t=this.regexp_eatClassSetOperand(e)))return r;2===t&&(r=2)}},_c.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var i=e.lastIntValue;return-1!==r&&-1!==i&&r>i&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1},_c.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?1:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},_c.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var r=e.eat(94),i=this.regexp_classContents(e);if(e.eat(93))return r&&2===i&&e.raise("Negated character class may contain strings"),i;e.pos=t}if(e.eat(92)){var s=this.regexp_eatCharacterClassEscape(e);if(s)return s;e.pos=t}return null},_c.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var r=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return r}else e.raise("Invalid escape");e.pos=t}return null},_c.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)2===this.regexp_classString(e)&&(t=2);return t},_c.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return 1===t?1:2},_c.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return!(!this.regexp_eatCharacterEscape(e)&&!this.regexp_eatClassSetReservedPunctuator(e)&&(e.eat(98)?(e.lastIntValue=8,0):(e.pos=t,1)));var r=e.current();return!(r<0||r===e.lookahead()&&function(e){return 33===e||e>=35&&e<=38||e>=42&&e<=44||46===e||e>=58&&e<=64||94===e||96===e||126===e}(r)||function(e){return 40===e||41===e||45===e||47===e||e>=91&&e<=93||e>=123&&e<=125}(r)||(e.advance(),e.lastIntValue=r,0))},_c.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return!!function(e){return 33===e||35===e||37===e||38===e||44===e||45===e||e>=58&&e<=62||64===e||96===e||126===e}(t)&&(e.lastIntValue=t,e.advance(),!0)},_c.regexp_eatClassControlLetter=function(e){var t=e.current();return!(!Tc(t)&&95!==t||(e.lastIntValue=t%32,e.advance(),0))},_c.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1},_c.regexp_eatDecimalDigits=function(e){var t=e.pos,r=0;for(e.lastIntValue=0;Tc(r=e.current());)e.lastIntValue=10*e.lastIntValue+(r-48),e.advance();return e.pos!==t},_c.regexp_eatHexDigits=function(e){var t=e.pos,r=0;for(e.lastIntValue=0;Mc(r=e.current());)e.lastIntValue=16*e.lastIntValue+kc(r),e.advance();return e.pos!==t},_c.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var r=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=64*t+8*r+e.lastIntValue:e.lastIntValue=8*t+r}else e.lastIntValue=t;return!0}return!1},_c.regexp_eatOctalDigit=function(e){var t=e.current();return Ic(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)},_c.regexp_eatFixedHexDigits=function(e,t){var r=e.pos;e.lastIntValue=0;for(var i=0;i<t;++i){var s=e.current();if(!Mc(s))return e.pos=r,!1;e.lastIntValue=16*e.lastIntValue+kc(s),e.advance()}return!0};var Bc=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new Sl(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},Lc=Il.prototype;function Pc(e){return"function"!=typeof BigInt?null:BigInt(e.replace(/_/g,""))}Lc.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new Bc(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},Lc.getToken=function(){return this.next(),new Bc(this)},"undefined"!=typeof Symbol&&(Lc[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===ll.eof,value:t}}}}),Lc.nextToken=function(){var e=this.curContext();return e&&e.preserveSpace||this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length?this.finishToken(ll.eof):e.override?e.override(this):void this.readToken(this.fullCharCodeAtPos())},Lc.readToken=function(e){return rl(e,this.options.ecmaVersion>=6)||92===e?this.readWord():this.getTokenFromCode(e)},Lc.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var t=this.input.charCodeAt(this.pos+1);return t<=56319||t>=57344?e:(e<<10)+t-56613888},Lc.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,r=this.input.indexOf("*/",this.pos+=2);if(-1===r&&this.raise(this.pos-2,"Unterminated comment"),this.pos=r+2,this.options.locations)for(var i=void 0,s=t;(i=fl(this.input,s,this.pos))>-1;)++this.curLine,s=this.lineStart=i;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,r),t,this.pos,e,this.curPosition())},Lc.skipLineComment=function(e){for(var t=this.pos,r=this.options.onComment&&this.curPosition(),i=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!dl(i);)i=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,r,this.curPosition())},Lc.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:10===this.input.charCodeAt(this.pos+1)&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(!(e>8&&e<14||e>=5760&&gl.test(String.fromCharCode(e))))break e;++this.pos}}},Lc.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var r=this.type;this.type=e,this.value=t,this.updateContext(r)},Lc.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&46===e&&46===t?(this.pos+=3,this.finishToken(ll.ellipsis)):(++this.pos,this.finishToken(ll.dot))},Lc.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===e?this.finishOp(ll.assign,2):this.finishOp(ll.slash,1)},Lc.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),r=1,i=42===e?ll.star:ll.modulo;return this.options.ecmaVersion>=7&&42===e&&42===t&&(++r,i=ll.starstar,t=this.input.charCodeAt(this.pos+2)),61===t?this.finishOp(ll.assign,r+1):this.finishOp(i,r)},Lc.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?this.options.ecmaVersion>=12&&61===this.input.charCodeAt(this.pos+2)?this.finishOp(ll.assign,3):this.finishOp(124===e?ll.logicalOR:ll.logicalAND,2):61===t?this.finishOp(ll.assign,2):this.finishOp(124===e?ll.bitwiseOR:ll.bitwiseAND,1)},Lc.readToken_caret=function(){return 61===this.input.charCodeAt(this.pos+1)?this.finishOp(ll.assign,2):this.finishOp(ll.bitwiseXOR,1)},Lc.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?45!==t||this.inModule||62!==this.input.charCodeAt(this.pos+2)||0!==this.lastTokEnd&&!cl.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(ll.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===t?this.finishOp(ll.assign,2):this.finishOp(ll.plusMin,1)},Lc.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),r=1;return t===e?(r=62===e&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+r)?this.finishOp(ll.assign,r+1):this.finishOp(ll.bitShift,r)):33!==t||60!==e||this.inModule||45!==this.input.charCodeAt(this.pos+2)||45!==this.input.charCodeAt(this.pos+3)?(61===t&&(r=2),this.finishOp(ll.relational,r)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},Lc.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return 61===t?this.finishOp(ll.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===e&&62===t&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(ll.arrow)):this.finishOp(61===e?ll.eq:ll.prefix,1)},Lc.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(46===t){var r=this.input.charCodeAt(this.pos+2);if(r<48||r>57)return this.finishOp(ll.questionDot,2)}if(63===t)return e>=12&&61===this.input.charCodeAt(this.pos+2)?this.finishOp(ll.assign,3):this.finishOp(ll.coalesce,2)}return this.finishOp(ll.question,1)},Lc.readToken_numberSign=function(){var e=35;if(this.options.ecmaVersion>=13&&(++this.pos,rl(e=this.fullCharCodeAtPos(),!0)||92===e))return this.finishToken(ll.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+El(e)+"'")},Lc.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(ll.parenL);case 41:return++this.pos,this.finishToken(ll.parenR);case 59:return++this.pos,this.finishToken(ll.semi);case 44:return++this.pos,this.finishToken(ll.comma);case 91:return++this.pos,this.finishToken(ll.bracketL);case 93:return++this.pos,this.finishToken(ll.bracketR);case 123:return++this.pos,this.finishToken(ll.braceL);case 125:return++this.pos,this.finishToken(ll.braceR);case 58:return++this.pos,this.finishToken(ll.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(ll.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(120===t||88===t)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(111===t||79===t)return this.readRadixNumber(8);if(98===t||66===t)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(ll.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+El(e)+"'")},Lc.finishOp=function(e,t){var r=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,r)},Lc.readRegexp=function(){for(var e,t,r=this.pos;;){this.pos>=this.input.length&&this.raise(r,"Unterminated regular expression");var i=this.input.charAt(this.pos);if(cl.test(i)&&this.raise(r,"Unterminated regular expression"),e)e=!1;else{if("["===i)t=!0;else if("]"===i&&t)t=!1;else if("/"===i&&!t)break;e="\\"===i}++this.pos}var s=this.input.slice(r,this.pos);++this.pos;var n=this.pos,a=this.readWord1();this.containsEsc&&this.unexpected(n);var o=this.regexpState||(this.regexpState=new Cc(this));o.reset(r,s,a),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var h=null;try{h=new RegExp(s,a)}catch(e){}return this.finishToken(ll.regexp,{pattern:s,flags:a,value:h})},Lc.readInt=function(e,t,r){for(var i=this.options.ecmaVersion>=12&&void 0===t,s=r&&48===this.input.charCodeAt(this.pos),n=this.pos,a=0,o=0,h=0,u=null==t?1/0:t;h<u;++h,++this.pos){var l=this.input.charCodeAt(this.pos),c=void 0;if(i&&95===l)s&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),95===o&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),0===h&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=l;else{if((c=l>=97?l-97+10:l>=65?l-65+10:l>=48&&l<=57?l-48:1/0)>=e)break;o=l,a=a*e+c}}return i&&95===o&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===n||null!=t&&this.pos-n!==t?null:a},Lc.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var r=this.readInt(e);return null==r&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&110===this.input.charCodeAt(this.pos)?(r=Pc(this.input.slice(t,this.pos)),++this.pos):rl(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(ll.num,r)},Lc.readNumber=function(e){var t=this.pos;e||null!==this.readInt(10,void 0,!0)||this.raise(t,"Invalid number");var r=this.pos-t>=2&&48===this.input.charCodeAt(t);r&&this.strict&&this.raise(t,"Invalid number");var i=this.input.charCodeAt(this.pos);if(!r&&!e&&this.options.ecmaVersion>=11&&110===i){var s=Pc(this.input.slice(t,this.pos));return++this.pos,rl(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(ll.num,s)}r&&/[89]/.test(this.input.slice(t,this.pos))&&(r=!1),46!==i||r||(++this.pos,this.readInt(10),i=this.input.charCodeAt(this.pos)),69!==i&&101!==i||r||(43!==(i=this.input.charCodeAt(++this.pos))&&45!==i||++this.pos,null===this.readInt(10)&&this.raise(t,"Invalid number")),rl(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var n,a=(n=this.input.slice(t,this.pos),r?parseInt(n,8):parseFloat(n.replace(/_/g,"")));return this.finishToken(ll.num,a)},Lc.readCodePoint=function(){var e;if(123===this.input.charCodeAt(this.pos)){this.options.ecmaVersion<6&&this.unexpected();var t=++this.pos;e=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,e>1114111&&this.invalidStringToken(t,"Code point out of bounds")}else e=this.readHexChar(4);return e},Lc.readString=function(e){for(var t="",r=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var i=this.input.charCodeAt(this.pos);if(i===e)break;92===i?(t+=this.input.slice(r,this.pos),t+=this.readEscapedChar(!1),r=this.pos):8232===i||8233===i?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(dl(i)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(r,this.pos++),this.finishToken(ll.string,t)};var Oc={};function Rc(e,t,r,i,s){var n=[];r||(r=Uc),function e(i,s,a){var o=a||i.type,h=i!==n[n.length-1];h&&n.push(i),r[o](i,s,e),t[o]&&t[o](i,s||n,n),h&&n.pop()}(e,i,s)}function Nc(e,t,r){r(e,t)}function Vc(e,t,r){}Lc.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e!==Oc)throw e;this.readInvalidTemplateToken()}this.inTemplateElement=!1},Lc.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Oc;this.raise(e,t)},Lc.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var r=this.input.charCodeAt(this.pos);if(96===r||36===r&&123===this.input.charCodeAt(this.pos+1))return this.pos!==this.start||this.type!==ll.template&&this.type!==ll.invalidTemplate?(e+=this.input.slice(t,this.pos),this.finishToken(ll.template,e)):36===r?(this.pos+=2,this.finishToken(ll.dollarBraceL)):(++this.pos,this.finishToken(ll.backQuote));if(92===r)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(dl(r)){switch(e+=this.input.slice(t,this.pos),++this.pos,r){case 13:10===this.input.charCodeAt(this.pos)&&++this.pos;case 10:e+="\n";break;default:e+=String.fromCharCode(r)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},Lc.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if("{"!==this.input[this.pos+1])break;case"`":return this.finishToken(ll.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":"\n"===this.input[this.pos+1]&&++this.pos;case"\n":case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1}this.raise(this.start,"Unterminated template")},Lc.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return"\n";case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return El(this.readCodePoint());case 116:return"\t";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:10===this.input.charCodeAt(this.pos)&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var r=this.pos-1;this.invalidStringToken(r,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var i=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],s=parseInt(i,8);return s>255&&(i=i.slice(0,-1),s=parseInt(i,8)),this.pos+=i.length-1,t=this.input.charCodeAt(this.pos),"0"===i&&56!==t&&57!==t||!this.strict&&!e||this.invalidStringToken(this.pos-1-i.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(s)}return dl(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},Lc.readHexChar=function(e){var t=this.pos,r=this.readInt(16,e);return null===r&&this.invalidStringToken(t,"Bad character escape sequence"),r},Lc.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,r=this.pos,i=this.options.ecmaVersion>=6;this.pos<this.input.length;){var s=this.fullCharCodeAtPos();if(il(s,i))this.pos+=s<=65535?1:2;else{if(92!==s)break;this.containsEsc=!0,e+=this.input.slice(r,this.pos);var n=this.pos;117!==this.input.charCodeAt(++this.pos)&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var a=this.readCodePoint();(t?rl:il)(a,i)||this.invalidStringToken(n,"Invalid Unicode escape"),e+=El(a),r=this.pos}t=!1}return e+this.input.slice(r,this.pos)},Lc.readWord=function(){var e=this.readWord1(),t=ll.name;return this.keywords.test(e)&&(t=hl[e]),this.finishToken(t,e)},Il.acorn={Parser:Il,version:"8.15.0",defaultOptions:Tl,Position:Al,SourceLocation:Sl,getLineInfo:Fl,Node:rc,TokenType:sl,tokTypes:ll,keywordTypes:hl,TokContext:ql,tokContexts:Wl,isIdentifierChar:il,isIdentifierStart:rl,Token:Bc,isNewLine:dl,lineBreak:cl,lineBreakG:pl,nonASCIIwhitespace:gl};var Uc={};Uc.Program=Uc.BlockStatement=Uc.StaticBlock=function(e,t,r){for(var i=0,s=e.body;i<s.length;i+=1)r(s[i],t,"Statement")},Uc.Statement=Nc,Uc.EmptyStatement=Vc,Uc.ExpressionStatement=Uc.ParenthesizedExpression=Uc.ChainExpression=function(e,t,r){return r(e.expression,t,"Expression")},Uc.IfStatement=function(e,t,r){r(e.test,t,"Expression"),r(e.consequent,t,"Statement"),e.alternate&&r(e.alternate,t,"Statement")},Uc.LabeledStatement=function(e,t,r){return r(e.body,t,"Statement")},Uc.BreakStatement=Uc.ContinueStatement=Vc,Uc.WithStatement=function(e,t,r){r(e.object,t,"Expression"),r(e.body,t,"Statement")},Uc.SwitchStatement=function(e,t,r){r(e.discriminant,t,"Expression");for(var i=0,s=e.cases;i<s.length;i+=1)r(s[i],t)},Uc.SwitchCase=function(e,t,r){e.test&&r(e.test,t,"Expression");for(var i=0,s=e.consequent;i<s.length;i+=1)r(s[i],t,"Statement")},Uc.ReturnStatement=Uc.YieldExpression=Uc.AwaitExpression=function(e,t,r){e.argument&&r(e.argument,t,"Expression")},Uc.ThrowStatement=Uc.SpreadElement=function(e,t,r){return r(e.argument,t,"Expression")},Uc.TryStatement=function(e,t,r){r(e.block,t,"Statement"),e.handler&&r(e.handler,t),e.finalizer&&r(e.finalizer,t,"Statement")},Uc.CatchClause=function(e,t,r){e.param&&r(e.param,t,"Pattern"),r(e.body,t,"Statement")},Uc.WhileStatement=Uc.DoWhileStatement=function(e,t,r){r(e.test,t,"Expression"),r(e.body,t,"Statement")},Uc.ForStatement=function(e,t,r){e.init&&r(e.init,t,"ForInit"),e.test&&r(e.test,t,"Expression"),e.update&&r(e.update,t,"Expression"),r(e.body,t,"Statement")},Uc.ForInStatement=Uc.ForOfStatement=function(e,t,r){r(e.left,t,"ForInit"),r(e.right,t,"Expression"),r(e.body,t,"Statement")},Uc.ForInit=function(e,t,r){"VariableDeclaration"===e.type?r(e,t):r(e,t,"Expression")},Uc.DebuggerStatement=Vc,Uc.FunctionDeclaration=function(e,t,r){return r(e,t,"Function")},Uc.VariableDeclaration=function(e,t,r){for(var i=0,s=e.declarations;i<s.length;i+=1)r(s[i],t)},Uc.VariableDeclarator=function(e,t,r){r(e.id,t,"Pattern"),e.init&&r(e.init,t,"Expression")},Uc.Function=function(e,t,r){e.id&&r(e.id,t,"Pattern");for(var i=0,s=e.params;i<s.length;i+=1)r(s[i],t,"Pattern");r(e.body,t,e.expression?"Expression":"Statement")},Uc.Pattern=function(e,t,r){"Identifier"===e.type?r(e,t,"VariablePattern"):"MemberExpression"===e.type?r(e,t,"MemberPattern"):r(e,t)},Uc.VariablePattern=Vc,Uc.MemberPattern=Nc,Uc.RestElement=function(e,t,r){return r(e.argument,t,"Pattern")},Uc.ArrayPattern=function(e,t,r){for(var i=0,s=e.elements;i<s.length;i+=1){var n=s[i];n&&r(n,t,"Pattern")}},Uc.ObjectPattern=function(e,t,r){for(var i=0,s=e.properties;i<s.length;i+=1){var n=s[i];"Property"===n.type?(n.computed&&r(n.key,t,"Expression"),r(n.value,t,"Pattern")):"RestElement"===n.type&&r(n.argument,t,"Pattern")}},Uc.Expression=Nc,Uc.ThisExpression=Uc.Super=Uc.MetaProperty=Vc,Uc.ArrayExpression=function(e,t,r){for(var i=0,s=e.elements;i<s.length;i+=1){var n=s[i];n&&r(n,t,"Expression")}},Uc.ObjectExpression=function(e,t,r){for(var i=0,s=e.properties;i<s.length;i+=1)r(s[i],t)},Uc.FunctionExpression=Uc.ArrowFunctionExpression=Uc.FunctionDeclaration,Uc.SequenceExpression=function(e,t,r){for(var i=0,s=e.expressions;i<s.length;i+=1)r(s[i],t,"Expression")},Uc.TemplateLiteral=function(e,t,r){for(var i=0,s=e.quasis;i<s.length;i+=1)r(s[i],t);for(var n=0,a=e.expressions;n<a.length;n+=1)r(a[n],t,"Expression")},Uc.TemplateElement=Vc,Uc.UnaryExpression=Uc.UpdateExpression=function(e,t,r){r(e.argument,t,"Expression")},Uc.BinaryExpression=Uc.LogicalExpression=function(e,t,r){r(e.left,t,"Expression"),r(e.right,t,"Expression")},Uc.AssignmentExpression=Uc.AssignmentPattern=function(e,t,r){r(e.left,t,"Pattern"),r(e.right,t,"Expression")},Uc.ConditionalExpression=function(e,t,r){r(e.test,t,"Expression"),r(e.consequent,t,"Expression"),r(e.alternate,t,"Expression")},Uc.NewExpression=Uc.CallExpression=function(e,t,r){if(r(e.callee,t,"Expression"),e.arguments)for(var i=0,s=e.arguments;i<s.length;i+=1)r(s[i],t,"Expression")},Uc.MemberExpression=function(e,t,r){r(e.object,t,"Expression"),e.computed&&r(e.property,t,"Expression")},Uc.ExportNamedDeclaration=Uc.ExportDefaultDeclaration=function(e,t,r){e.declaration&&r(e.declaration,t,"ExportNamedDeclaration"===e.type||e.declaration.id?"Statement":"Expression"),e.source&&r(e.source,t,"Expression")},Uc.ExportAllDeclaration=function(e,t,r){e.exported&&r(e.exported,t),r(e.source,t,"Expression")},Uc.ImportDeclaration=function(e,t,r){for(var i=0,s=e.specifiers;i<s.length;i+=1)r(s[i],t);r(e.source,t,"Expression")},Uc.ImportExpression=function(e,t,r){r(e.source,t,"Expression")},Uc.ImportSpecifier=Uc.ImportDefaultSpecifier=Uc.ImportNamespaceSpecifier=Uc.Identifier=Uc.PrivateIdentifier=Uc.Literal=Vc,Uc.TaggedTemplateExpression=function(e,t,r){r(e.tag,t,"Expression"),r(e.quasi,t,"Expression")},Uc.ClassDeclaration=Uc.ClassExpression=function(e,t,r){return r(e,t,"Class")},Uc.Class=function(e,t,r){e.id&&r(e.id,t,"Pattern"),e.superClass&&r(e.superClass,t,"Expression"),r(e.body,t)},Uc.ClassBody=function(e,t,r){for(var i=0,s=e.body;i<s.length;i+=1)r(s[i],t)},Uc.MethodDefinition=Uc.PropertyDefinition=Uc.Property=function(e,t,r){e.computed&&r(e.key,t,"Expression"),e.value&&r(e.value,t,"Expression")};var zc={},Gc={};!function e(t){var r,i,s,n,a,o;function h(e){var t,r,i={};for(t in e)e.hasOwnProperty(t)&&(r=e[t],i[t]="object"==typeof r&&null!==r?h(r):r);return i}function u(e,t){this.parent=e,this.key=t}function l(e,t,r,i){this.node=e,this.path=t,this.wrap=r,this.ref=i}function c(){}function p(e){return null!=e&&"object"==typeof e&&"string"==typeof e.type}function d(e,t){return(e===r.ObjectExpression||e===r.ObjectPattern)&&"properties"===t}function f(e,t){for(var r=e.length-1;r>=0;--r)if(e[r].node===t)return!0;return!1}function g(e,t){return(new c).traverse(e,t)}function m(e,t){var r;return r=function(e,t){var r,i,s,n;for(i=e.length,s=0;i;)t(e[n=s+(r=i>>>1)])?i=r:(s=n+1,i-=r+1);return s}(t,function(t){return t.range[0]>e.range[0]}),e.extendedRange=[e.range[0],e.range[1]],r!==t.length&&(e.extendedRange[1]=t[r].range[0]),(r-=1)>=0&&(e.extendedRange[0]=t[r].range[1]),e}return r={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ChainExpression:"ChainExpression",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportExpression:"ImportExpression",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MetaProperty:"MetaProperty",MethodDefinition:"MethodDefinition",ModuleSpecifier:"ModuleSpecifier",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",PrivateIdentifier:"PrivateIdentifier",Program:"Program",Property:"Property",PropertyDefinition:"PropertyDefinition",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"},s={AssignmentExpression:["left","right"],AssignmentPattern:["left","right"],ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","body"],AwaitExpression:["argument"],BlockStatement:["body"],BinaryExpression:["left","right"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ChainExpression:["expression"],ClassBody:["body"],ClassDeclaration:["id","superClass","body"],ClassExpression:["id","superClass","body"],ComprehensionBlock:["left","right"],ComprehensionExpression:["blocks","filter","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExportAllDeclaration:["source"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source"],ExportSpecifier:["exported","local"],ExpressionStatement:["expression"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","params","body"],FunctionExpression:["id","params","body"],GeneratorExpression:["blocks","filter","body"],Identifier:[],IfStatement:["test","consequent","alternate"],ImportExpression:["source"],ImportDeclaration:["specifiers","source"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["imported","local"],Literal:[],LabeledStatement:["label","body"],LogicalExpression:["left","right"],MemberExpression:["object","property"],MetaProperty:["meta","property"],MethodDefinition:["key","value"],ModuleSpecifier:[],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],PrivateIdentifier:[],Program:["body"],Property:["key","value"],PropertyDefinition:["key","value"],RestElement:["argument"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],Super:[],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],YieldExpression:["argument"]},i={Break:n={},Skip:a={},Remove:o={}},u.prototype.replace=function(e){this.parent[this.key]=e},u.prototype.remove=function(){return Array.isArray(this.parent)?(this.parent.splice(this.key,1),!0):(this.replace(null),!1)},c.prototype.path=function(){var e,t,r,i,s;function n(e,t){if(Array.isArray(t))for(r=0,i=t.length;r<i;++r)e.push(t[r]);else e.push(t)}if(!this.__current.path)return null;for(s=[],e=2,t=this.__leavelist.length;e<t;++e)n(s,this.__leavelist[e].path);return n(s,this.__current.path),s},c.prototype.type=function(){return this.current().type||this.__current.wrap},c.prototype.parents=function(){var e,t,r;for(r=[],e=1,t=this.__leavelist.length;e<t;++e)r.push(this.__leavelist[e].node);return r},c.prototype.current=function(){return this.__current.node},c.prototype.__execute=function(e,t){var r,i;return i=void 0,r=this.__current,this.__current=t,this.__state=null,e&&(i=e.call(this,t.node,this.__leavelist[this.__leavelist.length-1].node)),this.__current=r,i},c.prototype.notify=function(e){this.__state=e},c.prototype.skip=function(){this.notify(a)},c.prototype.break=function(){this.notify(n)},c.prototype.remove=function(){this.notify(o)},c.prototype.__initialize=function(e,t){this.visitor=t,this.root=e,this.__worklist=[],this.__leavelist=[],this.__current=null,this.__state=null,this.__fallback=null,"iteration"===t.fallback?this.__fallback=Object.keys:"function"==typeof t.fallback&&(this.__fallback=t.fallback),this.__keys=s,t.keys&&(this.__keys=Object.assign(Object.create(this.__keys),t.keys))},c.prototype.traverse=function(e,t){var r,i,s,o,h,u,c,g,m,y,x,v;for(this.__initialize(e,t),v={},r=this.__worklist,i=this.__leavelist,r.push(new l(e,null,null,null)),i.push(new l(null,null,null,null));r.length;)if((s=r.pop())!==v){if(s.node){if(u=this.__execute(t.enter,s),this.__state===n||u===n)return;if(r.push(v),i.push(s),this.__state===a||u===a)continue;if(h=(o=s.node).type||s.wrap,!(y=this.__keys[h])){if(!this.__fallback)throw new Error("Unknown node type "+h+".");y=this.__fallback(o)}for(g=y.length;(g-=1)>=0;)if(x=o[c=y[g]])if(Array.isArray(x)){for(m=x.length;(m-=1)>=0;)if(x[m]&&!f(i,x[m])){if(d(h,y[g]))s=new l(x[m],[c,m],"Property",null);else{if(!p(x[m]))continue;s=new l(x[m],[c,m],null,null)}r.push(s)}}else if(p(x)){if(f(i,x))continue;r.push(new l(x,c,null,null))}}}else if(s=i.pop(),u=this.__execute(t.leave,s),this.__state===n||u===n)return},c.prototype.replace=function(e,t){var r,i,s,h,c,f,g,m,y,x,v,b,_;function w(e){var t,i,s,n;if(e.ref.remove())for(i=e.ref.key,n=e.ref.parent,t=r.length;t--;)if((s=r[t]).ref&&s.ref.parent===n){if(s.ref.key<i)break;--s.ref.key}}for(this.__initialize(e,t),v={},r=this.__worklist,i=this.__leavelist,f=new l(e,null,null,new u(b={root:e},"root")),r.push(f),i.push(f);r.length;)if((f=r.pop())!==v){if(void 0!==(c=this.__execute(t.enter,f))&&c!==n&&c!==a&&c!==o&&(f.ref.replace(c),f.node=c),this.__state!==o&&c!==o||(w(f),f.node=null),this.__state===n||c===n)return b.root;if((s=f.node)&&(r.push(v),i.push(f),this.__state!==a&&c!==a)){if(h=s.type||f.wrap,!(y=this.__keys[h])){if(!this.__fallback)throw new Error("Unknown node type "+h+".");y=this.__fallback(s)}for(g=y.length;(g-=1)>=0;)if(x=s[_=y[g]])if(Array.isArray(x)){for(m=x.length;(m-=1)>=0;)if(x[m]){if(d(h,y[g]))f=new l(x[m],[_,m],"Property",new u(x,m));else{if(!p(x[m]))continue;f=new l(x[m],[_,m],null,new u(x,m))}r.push(f)}}else p(x)&&r.push(new l(x,_,null,new u(s,_)))}}else if(f=i.pop(),void 0!==(c=this.__execute(t.leave,f))&&c!==n&&c!==a&&c!==o&&f.ref.replace(c),this.__state!==o&&c!==o||w(f),this.__state===n||c===n)return b.root;return b.root},t.Syntax=r,t.traverse=g,t.replace=function(e,t){return(new c).replace(e,t)},t.attachComments=function(e,t,r){var s,n,a,o,u=[];if(!e.range)throw new Error("attachComments needs range information");if(!r.length){if(t.length){for(a=0,n=t.length;a<n;a+=1)(s=h(t[a])).extendedRange=[0,e.range[0]],u.push(s);e.leadingComments=u}return e}for(a=0,n=t.length;a<n;a+=1)u.push(m(h(t[a]),r));return o=0,g(e,{enter:function(e){for(var t;o<u.length&&!((t=u[o]).extendedRange[1]>e.range[0]);)t.extendedRange[1]===e.range[0]?(e.leadingComments||(e.leadingComments=[]),e.leadingComments.push(t),u.splice(o,1)):o+=1;return o===u.length?i.Break:u[o].extendedRange[0]>e.range[1]?i.Skip:void 0}}),o=0,g(e,{leave:function(e){for(var t;o<u.length&&(t=u[o],!(e.range[1]<t.extendedRange[0]));)e.range[1]===t.extendedRange[0]?(e.trailingComments||(e.trailingComments=[]),e.trailingComments.push(t),u.splice(o,1)):o+=1;return o===u.length?i.Break:u[o].extendedRange[0]>e.range[1]?i.Skip:void 0}}),e},t.VisitorKeys=s,t.VisitorOption=i,t.Controller=c,t.cloneEnvironment=function(){return e({})},t}(Gc);var jc={},$c={exports:{}};!function(){function e(e){if(null==e)return!1;switch(e.type){case"BlockStatement":case"BreakStatement":case"ContinueStatement":case"DebuggerStatement":case"DoWhileStatement":case"EmptyStatement":case"ExpressionStatement":case"ForInStatement":case"ForStatement":case"IfStatement":case"LabeledStatement":case"ReturnStatement":case"SwitchStatement":case"ThrowStatement":case"TryStatement":case"VariableDeclaration":case"WhileStatement":case"WithStatement":return!0}return!1}function t(e){switch(e.type){case"IfStatement":return null!=e.alternate?e.alternate:e.consequent;case"LabeledStatement":case"ForStatement":case"ForInStatement":case"WhileStatement":case"WithStatement":return e.body}return null}$c.exports={isExpression:function(e){if(null==e)return!1;switch(e.type){case"ArrayExpression":case"AssignmentExpression":case"BinaryExpression":case"CallExpression":case"ConditionalExpression":case"FunctionExpression":case"Identifier":case"Literal":case"LogicalExpression":case"MemberExpression":case"NewExpression":case"ObjectExpression":case"SequenceExpression":case"ThisExpression":case"UnaryExpression":case"UpdateExpression":return!0}return!1},isStatement:e,isIterationStatement:function(e){if(null==e)return!1;switch(e.type){case"DoWhileStatement":case"ForInStatement":case"ForStatement":case"WhileStatement":return!0}return!1},isSourceElement:function(t){return e(t)||null!=t&&"FunctionDeclaration"===t.type},isProblematicIfStatement:function(e){var r;if("IfStatement"!==e.type)return!1;if(null==e.alternate)return!1;r=e.consequent;do{if("IfStatement"===r.type&&null==r.alternate)return!0;r=t(r)}while(r);return!1},trailingStatement:t}}();var Hc=$c.exports,qc={exports:{}};!function(){var e,t,r,i,s,n;function a(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(Math.floor((e-65536)/1024)+55296)+String.fromCharCode((e-65536)%1024+56320)}for(t={NonAsciiIdentifierStart:/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,NonAsciiIdentifierPart:/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/},e={NonAsciiIdentifierStart:/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,NonAsciiIdentifierPart:/[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/},r=[5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279],i=new Array(128),n=0;n<128;++n)i[n]=n>=97&&n<=122||n>=65&&n<=90||36===n||95===n;for(s=new Array(128),n=0;n<128;++n)s[n]=n>=97&&n<=122||n>=65&&n<=90||n>=48&&n<=57||36===n||95===n;qc.exports={isDecimalDigit:function(e){return 48<=e&&e<=57},isHexDigit:function(e){return 48<=e&&e<=57||97<=e&&e<=102||65<=e&&e<=70},isOctalDigit:function(e){return e>=48&&e<=55},isWhiteSpace:function(e){return 32===e||9===e||11===e||12===e||160===e||e>=5760&&r.indexOf(e)>=0},isLineTerminator:function(e){return 10===e||13===e||8232===e||8233===e},isIdentifierStartES5:function(e){return e<128?i[e]:t.NonAsciiIdentifierStart.test(a(e))},isIdentifierPartES5:function(e){return e<128?s[e]:t.NonAsciiIdentifierPart.test(a(e))},isIdentifierStartES6:function(t){return t<128?i[t]:e.NonAsciiIdentifierStart.test(a(t))},isIdentifierPartES6:function(t){return t<128?s[t]:e.NonAsciiIdentifierPart.test(a(t))}}}();var Wc=qc.exports,Xc={exports:{}};!function(){var e=Wc;function t(e,t){return!(!t&&"yield"===e)&&r(e,t)}function r(e,t){if(t&&function(e){switch(e){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"let":return!0;default:return!1}}(e))return!0;switch(e.length){case 2:return"if"===e||"in"===e||"do"===e;case 3:return"var"===e||"for"===e||"new"===e||"try"===e;case 4:return"this"===e||"else"===e||"case"===e||"void"===e||"with"===e||"enum"===e;case 5:return"while"===e||"break"===e||"catch"===e||"throw"===e||"const"===e||"yield"===e||"class"===e||"super"===e;case 6:return"return"===e||"typeof"===e||"delete"===e||"switch"===e||"export"===e||"import"===e;case 7:return"default"===e||"finally"===e||"extends"===e;case 8:return"function"===e||"continue"===e||"debugger"===e;case 10:return"instanceof"===e;default:return!1}}function i(e,r){return"null"===e||"true"===e||"false"===e||t(e,r)}function s(e,t){return"null"===e||"true"===e||"false"===e||r(e,t)}function n(t){var r,i,s;if(0===t.length)return!1;if(s=t.charCodeAt(0),!e.isIdentifierStartES5(s))return!1;for(r=1,i=t.length;r<i;++r)if(s=t.charCodeAt(r),!e.isIdentifierPartES5(s))return!1;return!0}function a(t){var r,i,s,n,a;if(0===t.length)return!1;for(a=e.isIdentifierStartES6,r=0,i=t.length;r<i;++r){if(55296<=(s=t.charCodeAt(r))&&s<=56319){if(++r>=i)return!1;if(!(56320<=(n=t.charCodeAt(r))&&n<=57343))return!1;s=1024*(s-55296)+(n-56320)+65536}if(!a(s))return!1;a=e.isIdentifierPartES6}return!0}Xc.exports={isKeywordES5:t,isKeywordES6:r,isReservedWordES5:i,isReservedWordES6:s,isRestrictedWord:function(e){return"eval"===e||"arguments"===e},isIdentifierNameES5:n,isIdentifierNameES6:a,isIdentifierES5:function(e,t){return n(e)&&!i(e,t)},isIdentifierES6:function(e,t){return a(e)&&!s(e,t)}}}();var Yc=Xc.exports;jc.ast=Hc,jc.code=Wc,jc.keyword=Yc;var Kc,Zc,Jc={},Qc={},ep={},tp={};function rp(){if(Zc)return ep;Zc=1;var e=function(){if(Kc)return tp;Kc=1;var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");return tp.encode=function(t){if(0<=t&&t<e.length)return e[t];throw new TypeError("Must be between 0 and 63: "+t)},tp.decode=function(e){return 65<=e&&e<=90?e-65:97<=e&&e<=122?e-97+26:48<=e&&e<=57?e-48+52:43==e?62:47==e?63:-1},tp}();return ep.encode=function(t){var r,i="",s=function(e){return e<0?1+(-e<<1):0+(e<<1)}(t);do{r=31&s,(s>>>=5)>0&&(r|=32),i+=e.encode(r)}while(s>0);return i},ep.decode=function(t,r,i){var s,n,a,o,h=t.length,u=0,l=0;do{if(r>=h)throw new Error("Expected more digits in base 64 VLQ value.");if(-1===(n=e.decode(t.charCodeAt(r++))))throw new Error("Invalid base64 digit: "+t.charAt(r-1));s=!!(32&n),u+=(n&=31)<<l,l+=5}while(s);i.value=(o=(a=u)>>1,1&~a?o:-o),i.rest=r},ep}var ip,sp={};function np(){return ip||(ip=1,function(e){e.getArg=function(e,t,r){if(t in e)return e[t];if(3===arguments.length)return r;throw new Error('"'+t+'" is a required argument.')};var t=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,r=/^data:.+\,.+$/;function i(e){var r=e.match(t);return r?{scheme:r[1],auth:r[2],host:r[3],port:r[4],path:r[5]}:null}function s(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}function n(t){var r=t,n=i(t);if(n){if(!n.path)return t;r=n.path}for(var a,o=e.isAbsolute(r),h=r.split(/\/+/),u=0,l=h.length-1;l>=0;l--)"."===(a=h[l])?h.splice(l,1):".."===a?u++:u>0&&(""===a?(h.splice(l+1,u),u=0):(h.splice(l,2),u--));return""===(r=h.join("/"))&&(r=o?"/":"."),n?(n.path=r,s(n)):r}function a(e,t){""===e&&(e="."),""===t&&(t=".");var a=i(t),o=i(e);if(o&&(e=o.path||"/"),a&&!a.scheme)return o&&(a.scheme=o.scheme),s(a);if(a||t.match(r))return t;if(o&&!o.host&&!o.path)return o.host=t,s(o);var h="/"===t.charAt(0)?t:n(e.replace(/\/+$/,"")+"/"+t);return o?(o.path=h,s(o)):h}e.urlParse=i,e.urlGenerate=s,e.normalize=n,e.join=a,e.isAbsolute=function(e){return"/"===e.charAt(0)||t.test(e)},e.relative=function(e,t){""===e&&(e="."),e=e.replace(/\/$/,"");for(var r=0;0!==t.indexOf(e+"/");){var i=e.lastIndexOf("/");if(i<0)return t;if((e=e.slice(0,i)).match(/^([^\/]+:\/)?\/*$/))return t;++r}return Array(r+1).join("../")+t.substr(e.length+1)};var o=!("__proto__"in Object.create(null));function h(e){return e}function u(e){if(!e)return!1;var t=e.length;if(t<9)return!1;if(95!==e.charCodeAt(t-1)||95!==e.charCodeAt(t-2)||111!==e.charCodeAt(t-3)||116!==e.charCodeAt(t-4)||111!==e.charCodeAt(t-5)||114!==e.charCodeAt(t-6)||112!==e.charCodeAt(t-7)||95!==e.charCodeAt(t-8)||95!==e.charCodeAt(t-9))return!1;for(var r=t-10;r>=0;r--)if(36!==e.charCodeAt(r))return!1;return!0}function l(e,t){return e===t?0:null===e?1:null===t?-1:e>t?1:-1}e.toSetString=o?h:function(e){return u(e)?"$"+e:e},e.fromSetString=o?h:function(e){return u(e)?e.slice(1):e},e.compareByOriginalPositions=function(e,t,r){var i=l(e.source,t.source);return 0!==i||0!==(i=e.originalLine-t.originalLine)||0!==(i=e.originalColumn-t.originalColumn)||r||0!==(i=e.generatedColumn-t.generatedColumn)||0!==(i=e.generatedLine-t.generatedLine)?i:l(e.name,t.name)},e.compareByGeneratedPositionsDeflated=function(e,t,r){var i=e.generatedLine-t.generatedLine;return 0!==i||0!==(i=e.generatedColumn-t.generatedColumn)||r||0!==(i=l(e.source,t.source))||0!==(i=e.originalLine-t.originalLine)||0!==(i=e.originalColumn-t.originalColumn)?i:l(e.name,t.name)},e.compareByGeneratedPositionsInflated=function(e,t){var r=e.generatedLine-t.generatedLine;return 0!==r||0!==(r=e.generatedColumn-t.generatedColumn)||0!==(r=l(e.source,t.source))||0!==(r=e.originalLine-t.originalLine)||0!==(r=e.originalColumn-t.originalColumn)?r:l(e.name,t.name)},e.parseSourceMapInput=function(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))},e.computeSourceURL=function(e,t,r){if(t=t||"",e&&("/"!==e[e.length-1]&&"/"!==t[0]&&(e+="/"),t=e+t),r){var o=i(r);if(!o)throw new Error("sourceMapURL could not be parsed");if(o.path){var h=o.path.lastIndexOf("/");h>=0&&(o.path=o.path.substring(0,h+1))}t=a(s(o),t)}return n(t)}}(sp)),sp}var ap,op={};function hp(){if(ap)return op;ap=1;var e=np(),t=Object.prototype.hasOwnProperty,r="undefined"!=typeof Map;function i(){this._array=[],this._set=r?new Map:Object.create(null)}return i.fromArray=function(e,t){for(var r=new i,s=0,n=e.length;s<n;s++)r.add(e[s],t);return r},i.prototype.size=function(){return r?this._set.size:Object.getOwnPropertyNames(this._set).length},i.prototype.add=function(i,s){var n=r?i:e.toSetString(i),a=r?this.has(i):t.call(this._set,n),o=this._array.length;a&&!s||this._array.push(i),a||(r?this._set.set(i,o):this._set[n]=o)},i.prototype.has=function(i){if(r)return this._set.has(i);var s=e.toSetString(i);return t.call(this._set,s)},i.prototype.indexOf=function(i){if(r){var s=this._set.get(i);if(s>=0)return s}else{var n=e.toSetString(i);if(t.call(this._set,n))return this._set[n]}throw new Error('"'+i+'" is not in the set.')},i.prototype.at=function(e){if(e>=0&&e<this._array.length)return this._array[e];throw new Error("No element indexed by "+e)},i.prototype.toArray=function(){return this._array.slice()},op.ArraySet=i,op}var up,lp,cp={};function pp(){if(lp)return Qc;lp=1;var e=rp(),t=np(),r=hp().ArraySet,i=function(){if(up)return cp;up=1;var e=np();function t(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}return t.prototype.unsortedForEach=function(e,t){this._array.forEach(e,t)},t.prototype.add=function(t){var r,i,s,n,a,o;i=t,s=(r=this._last).generatedLine,n=i.generatedLine,a=r.generatedColumn,o=i.generatedColumn,n>s||n==s&&o>=a||e.compareByGeneratedPositionsInflated(r,i)<=0?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))},t.prototype.toArray=function(){return this._sorted||(this._array.sort(e.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},cp.MappingList=t,cp}().MappingList;function s(e){e||(e={}),this._file=t.getArg(e,"file",null),this._sourceRoot=t.getArg(e,"sourceRoot",null),this._skipValidation=t.getArg(e,"skipValidation",!1),this._sources=new r,this._names=new r,this._mappings=new i,this._sourcesContents=null}return s.prototype._version=3,s.fromSourceMap=function(e){var r=e.sourceRoot,i=new s({file:e.file,sourceRoot:r});return e.eachMapping(function(e){var s={generated:{line:e.generatedLine,column:e.generatedColumn}};null!=e.source&&(s.source=e.source,null!=r&&(s.source=t.relative(r,s.source)),s.original={line:e.originalLine,column:e.originalColumn},null!=e.name&&(s.name=e.name)),i.addMapping(s)}),e.sources.forEach(function(s){var n=s;null!==r&&(n=t.relative(r,s)),i._sources.has(n)||i._sources.add(n);var a=e.sourceContentFor(s);null!=a&&i.setSourceContent(s,a)}),i},s.prototype.addMapping=function(e){var r=t.getArg(e,"generated"),i=t.getArg(e,"original",null),s=t.getArg(e,"source",null),n=t.getArg(e,"name",null);this._skipValidation||this._validateMapping(r,i,s,n),null!=s&&(s=String(s),this._sources.has(s)||this._sources.add(s)),null!=n&&(n=String(n),this._names.has(n)||this._names.add(n)),this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:null!=i&&i.line,originalColumn:null!=i&&i.column,source:s,name:n})},s.prototype.setSourceContent=function(e,r){var i=e;null!=this._sourceRoot&&(i=t.relative(this._sourceRoot,i)),null!=r?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[t.toSetString(i)]=r):this._sourcesContents&&(delete this._sourcesContents[t.toSetString(i)],0===Object.keys(this._sourcesContents).length&&(this._sourcesContents=null))},s.prototype.applySourceMap=function(e,i,s){var n=i;if(null==i){if(null==e.file)throw new Error('SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map\'s "file" property. Both were omitted.');n=e.file}var a=this._sourceRoot;null!=a&&(n=t.relative(a,n));var o=new r,h=new r;this._mappings.unsortedForEach(function(r){if(r.source===n&&null!=r.originalLine){var i=e.originalPositionFor({line:r.originalLine,column:r.originalColumn});null!=i.source&&(r.source=i.source,null!=s&&(r.source=t.join(s,r.source)),null!=a&&(r.source=t.relative(a,r.source)),r.originalLine=i.line,r.originalColumn=i.column,null!=i.name&&(r.name=i.name))}var u=r.source;null==u||o.has(u)||o.add(u);var l=r.name;null==l||h.has(l)||h.add(l)},this),this._sources=o,this._names=h,e.sources.forEach(function(r){var i=e.sourceContentFor(r);null!=i&&(null!=s&&(r=t.join(s,r)),null!=a&&(r=t.relative(a,r)),this.setSourceContent(r,i))},this)},s.prototype._validateMapping=function(e,t,r,i){if(t&&"number"!=typeof t.line&&"number"!=typeof t.column)throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if((!(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0)||t||r||i)&&!(e&&"line"in e&&"column"in e&&t&&"line"in t&&"column"in t&&e.line>0&&e.column>=0&&t.line>0&&t.column>=0&&r))throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:r,original:t,name:i}))},s.prototype._serializeMappings=function(){for(var r,i,s,n,a=0,o=1,h=0,u=0,l=0,c=0,p="",d=this._mappings.toArray(),f=0,g=d.length;f<g;f++){if(r="",(i=d[f]).generatedLine!==o)for(a=0;i.generatedLine!==o;)r+=";",o++;else if(f>0){if(!t.compareByGeneratedPositionsInflated(i,d[f-1]))continue;r+=","}r+=e.encode(i.generatedColumn-a),a=i.generatedColumn,null!=i.source&&(n=this._sources.indexOf(i.source),r+=e.encode(n-c),c=n,r+=e.encode(i.originalLine-1-u),u=i.originalLine-1,r+=e.encode(i.originalColumn-h),h=i.originalColumn,null!=i.name&&(s=this._names.indexOf(i.name),r+=e.encode(s-l),l=s)),p+=r}return p},s.prototype._generateSourcesContent=function(e,r){return e.map(function(e){if(!this._sourcesContents)return null;null!=r&&(e=t.relative(r,e));var i=t.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,i)?this._sourcesContents[i]:null},this)},s.prototype.toJSON=function(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return null!=this._file&&(e.file=this._file),null!=this._sourceRoot&&(e.sourceRoot=this._sourceRoot),this._sourcesContents&&(e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)),e},s.prototype.toString=function(){return JSON.stringify(this.toJSON())},Qc.SourceMapGenerator=s,Qc}var dp,fp={},gp={};function mp(){return dp||(dp=1,function(e){function t(r,i,s,n,a,o){var h=Math.floor((i-r)/2)+r,u=a(s,n[h],!0);return 0===u?h:u>0?i-h>1?t(h,i,s,n,a,o):o==e.LEAST_UPPER_BOUND?i<n.length?i:-1:h:h-r>1?t(r,h,s,n,a,o):o==e.LEAST_UPPER_BOUND?h:r<0?-1:r}e.GREATEST_LOWER_BOUND=1,e.LEAST_UPPER_BOUND=2,e.search=function(r,i,s,n){if(0===i.length)return-1;var a=t(-1,i.length,r,i,s,n||e.GREATEST_LOWER_BOUND);if(a<0)return-1;for(;a-1>=0&&0===s(i[a],i[a-1],!0);)--a;return a}}(gp)),gp}var yp,xp,vp,bp,_p={},wp={};!function(e){!function(){var t,r,i,s,n,a,o,h,u,l,c,p,d,f,g,m,y,x,v,b,_,w,C,E,D,A;function S(e){return X.Statement.hasOwnProperty(e.type)}a=jc,t=(n=Gc).Syntax,i={"??":(r={Sequence:0,Yield:1,Assignment:1,Conditional:2,ArrowFunction:2,Coalesce:3,LogicalOR:4,LogicalAND:5,BitwiseOR:6,BitwiseXOR:7,BitwiseAND:8,Equality:9,Relational:10,BitwiseSHIFT:11,Additive:12,Multiplicative:13,Exponentiation:14,Await:15,Unary:15,Postfix:16,OptionalChaining:17,Call:18,New:19,TaggedTemplate:20,Member:21,Primary:22}).Coalesce,"||":r.LogicalOR,"&&":r.LogicalAND,"|":r.BitwiseOR,"^":r.BitwiseXOR,"&":r.BitwiseAND,"==":r.Equality,"!=":r.Equality,"===":r.Equality,"!==":r.Equality,is:r.Equality,isnt:r.Equality,"<":r.Relational,">":r.Relational,"<=":r.Relational,">=":r.Relational,in:r.Relational,instanceof:r.Relational,"<<":r.BitwiseSHIFT,">>":r.BitwiseSHIFT,">>>":r.BitwiseSHIFT,"+":r.Additive,"-":r.Additive,"*":r.Multiplicative,"%":r.Multiplicative,"/":r.Multiplicative,"**":r.Exponentiation};var F=32,T=33;function M(e,t){var r="";for(t|=0;t>0;t>>>=1,e+=e)1&t&&(r+=e);return r}function k(e){var t=e.length;return t&&a.code.isLineTerminator(e.charCodeAt(t-1))}function I(e,t){var r;for(r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e}function B(e,t){var r,i;function s(e){return"object"==typeof e&&e instanceof Object&&!(e instanceof RegExp)}for(r in t)t.hasOwnProperty(r)&&(s(i=t[r])?s(e[r])?B(e[r],i):e[r]=B({},i):e[r]=i);return e}function L(e,t){return 8232==(-2&e)?(t?"u":"\\u")+(8232===e?"2028":"2029"):10===e||13===e?(t?"":"\\")+(10===e?"n":"r"):String.fromCharCode(e)}function P(e,t){var r;return 8===e?"\\b":12===e?"\\f":9===e?"\\t":(r=e.toString(16).toUpperCase(),u||e>255?"\\u"+"0000".slice(r.length)+r:0!==e||a.code.isDecimalDigit(t)?11===e?"\\x0B":"\\x"+"00".slice(r.length)+r:"\\0")}function O(e){if(92===e)return"\\\\";if(10===e)return"\\n";if(13===e)return"\\r";if(8232===e)return"\\u2028";if(8233===e)return"\\u2029";throw new Error("Incorrectly classified character")}function R(e){var t,r,i,s="";for(t=0,r=e.length;t<r;++t)i=e[t],s+=Array.isArray(i)?R(i):i;return s}function N(e,t){if(!w)return Array.isArray(e)?R(e):e;if(null==t){if(e instanceof s)return e;t={}}return null==t.loc?new s(null,null,w,e,t.name||null):new s(t.loc.start.line,t.loc.start.column,!0===w?t.loc.source||null:w,e,t.name||null)}function V(){return g||" "}function U(e,t){var r,i,s,n;return 0===(r=N(e).toString()).length?[t]:0===(i=N(t).toString()).length?[e]:(s=r.charCodeAt(r.length-1),n=i.charCodeAt(0),(43===s||45===s)&&s===n||a.code.isIdentifierPartES5(s)&&a.code.isIdentifierPartES5(n)||47===s&&105===n?[e,V(),t]:a.code.isWhiteSpace(s)||a.code.isLineTerminator(s)||a.code.isWhiteSpace(n)||a.code.isLineTerminator(n)?[e,t]:[e,g,t])}function z(e){return[o,e]}function G(e){var t;t=o,e(o+=h),o=t}function j(e,t){if("Line"===e.type){if(k(e.value))return"//"+e.value;var r="//"+e.value;return E||(r+="\n"),r}return b.format.indent.adjustMultilineComment&&/[\n\r]/.test(e.value)?function(e,t){var r,i,s,n,h,u,l,c;for(r=e.split(/\r\n|[\r\n]/),u=Number.MAX_VALUE,i=1,s=r.length;i<s;++i){for(n=r[i],h=0;h<n.length&&a.code.isWhiteSpace(n.charCodeAt(h));)++h;u>h&&(u=h)}for(void 0!==t?(l=o,"*"===r[1][u]&&(t+=" "),o=t):(1&u&&--u,l=o),i=1,s=r.length;i<s;++i)c=N(z(r[i].slice(u))),r[i]=w?c.join(""):c;return o=l,r.join("\n")}("/*"+e.value+"*/",t):"/*"+e.value+"*/"}function $(e,r){var i,s,n,u,l,c,p,d,f,g,m,y;if(e.leadingComments&&e.leadingComments.length>0){if(u=r,E){for(r=[],d=(n=e.leadingComments[0]).extendedRange,f=n.range,(y=((m=C.substring(d[0],f[0])).match(/\n/g)||[]).length)>0?(r.push(M("\n",y)),r.push(z(j(n)))):(r.push(m),r.push(j(n))),g=f,i=1,s=e.leadingComments.length;i<s;i++)f=(n=e.leadingComments[i]).range,y=(C.substring(g[1],f[0]).match(/\n/g)||[]).length,r.push(M("\n",y)),r.push(z(j(n))),g=f;y=(C.substring(f[1],d[1]).match(/\n/g)||[]).length,r.push(M("\n",y))}else for(n=e.leadingComments[0],r=[],x&&e.type===t.Program&&0===e.body.length&&r.push("\n"),r.push(j(n)),k(N(r).toString())||r.push("\n"),i=1,s=e.leadingComments.length;i<s;++i)k(N(p=[j(n=e.leadingComments[i])]).toString())||p.push("\n"),r.push(z(p));r.push(z(u))}if(e.trailingComments)if(E)d=(n=e.trailingComments[0]).extendedRange,f=n.range,(y=((m=C.substring(d[0],f[0])).match(/\n/g)||[]).length)>0?(r.push(M("\n",y)),r.push(z(j(n)))):(r.push(m),r.push(j(n)));else for(l=!k(N(r).toString()),c=M(" ",function(e){var t;for(t=e.length-1;t>=0&&!a.code.isLineTerminator(e.charCodeAt(t));--t);return e.length-1-t}(N([o,r,h]).toString())),i=0,s=e.trailingComments.length;i<s;++i)n=e.trailingComments[i],l?(r=0===i?[r,h]:[r,c]).push(j(n,c)):r=[r,z(j(n))],i===s-1||k(N(r).toString())||(r=[r,"\n"]);return r}function H(e,t,r){var i,s=0;for(i=e;i<t;i++)"\n"===C[i]&&s++;for(i=1;i<s;i++)r.push(f)}function q(e,t,r){return t<r?["(",e,")"]:e}function W(e){var t,r,i;for(t=1,r=(i=e.split(/\r\n|\n/)).length;t<r;t++)i[t]=f+o+i[t];return i}function X(){}function Y(e){return N(e.name,e)}function K(e,t){return e.async?"async"+(t?V():g):""}function Z(e){return e.generator&&!b.moz.starlessGenerator?"*"+g:""}function J(e){var t=e.value,r="";return t.async&&(r+=K(t,!e.computed)),t.generator&&(r+=Z(t)?"*":""),r}function Q(e){var t;if(t=new X,S(e))return t.generateStatement(e,1);if(function(e){return X.Expression.hasOwnProperty(e.type)}(e))return t.generateExpression(e,r.Sequence,7);throw new Error("Unknown node type: "+e.type)}X.prototype.maybeBlock=function(e,r){var i,s,n=this;return s=!b.comment||!e.leadingComments,e.type===t.BlockStatement&&s?[g,this.generateStatement(e,r)]:e.type===t.EmptyStatement&&s?";":(G(function(){i=[f,z(n.generateStatement(e,r))]}),i)},X.prototype.maybeBlockSuffix=function(e,r){var i=k(N(r).toString());return e.type!==t.BlockStatement||b.comment&&e.leadingComments||i?i?[r,o]:[r,f,o]:[r,g]},X.prototype.generatePattern=function(e,r,i){return e.type===t.Identifier?Y(e):this.generateExpression(e,r,i)},X.prototype.generateFunctionParams=function(e){var i,s,n,a;if(a=!1,e.type!==t.ArrowFunctionExpression||e.rest||e.defaults&&0!==e.defaults.length||1!==e.params.length||e.params[0].type!==t.Identifier){for((n=e.type===t.ArrowFunctionExpression?[K(e,!1)]:[]).push("("),e.defaults&&(a=!0),i=0,s=e.params.length;i<s;++i)a&&e.defaults[i]?n.push(this.generateAssignment(e.params[i],e.defaults[i],"=",r.Assignment,7)):n.push(this.generatePattern(e.params[i],r.Assignment,7)),i+1<s&&n.push(","+g);e.rest&&(e.params.length&&n.push(","+g),n.push("..."),n.push(Y(e.rest))),n.push(")")}else n=[K(e,!0),Y(e.params[0])];return n},X.prototype.generateFunctionBody=function(e){var i,s;return i=this.generateFunctionParams(e),e.type===t.ArrowFunctionExpression&&(i.push(g),i.push("=>")),e.expression?(i.push(g),"{"===(s=this.generateExpression(e.body,r.Assignment,7)).toString().charAt(0)&&(s=["(",s,")"]),i.push(s)):i.push(this.maybeBlock(e.body,9)),i},X.prototype.generateIterationForStatement=function(e,i,s){var n=["for"+(i.await?V()+"await":"")+g+"("],a=this;return G(function(){i.left.type===t.VariableDeclaration?G(function(){n.push(i.left.kind+V()),n.push(a.generateStatement(i.left.declarations[0],0))}):n.push(a.generateExpression(i.left,r.Call,7)),n=U(n,e),n=[U(n,a.generateExpression(i.right,r.Assignment,7)),")"]}),n.push(this.maybeBlock(i.body,s)),n},X.prototype.generatePropertyKey=function(e,t){var i=[];return t&&i.push("["),i.push(this.generateExpression(e,r.Assignment,7)),t&&i.push("]"),i},X.prototype.generateAssignment=function(e,t,i,s,n){return r.Assignment<s&&(n|=1),q([this.generateExpression(e,r.Call,n),g+i+g,this.generateExpression(t,r.Assignment,n)],r.Assignment,s)},X.prototype.semicolon=function(e){return!y&&e&F?"":";"},X.Statement={BlockStatement:function(e,t){var r,i,s=["{",f],n=this;return G(function(){var a,o,h,u;for(0===e.body.length&&E&&(r=e.range)[1]-r[0]>2&&("\n"===(i=C.substring(r[0]+1,r[1]-1))[0]&&(s=["{"]),s.push(i)),u=1,8&t&&(u|=16),a=0,o=e.body.length;a<o;++a)E&&(0===a&&(e.body[0].leadingComments&&(r=e.body[0].leadingComments[0].extendedRange,"\n"===(i=C.substring(r[0],r[1]))[0]&&(s=["{"])),e.body[0].leadingComments||H(e.range[0],e.body[0].range[0],s)),a>0&&(e.body[a-1].trailingComments||e.body[a].leadingComments||H(e.body[a-1].range[1],e.body[a].range[0],s))),a===o-1&&(u|=F),h=e.body[a].leadingComments&&E?n.generateStatement(e.body[a],u):z(n.generateStatement(e.body[a],u)),s.push(h),k(N(h).toString())||E&&a<o-1&&e.body[a+1].leadingComments||s.push(f),E&&a===o-1&&(e.body[a].trailingComments||H(e.body[a].range[1],e.range[1],s))}),s.push(z("}")),s},BreakStatement:function(e,t){return e.label?"break "+e.label.name+this.semicolon(t):"break"+this.semicolon(t)},ContinueStatement:function(e,t){return e.label?"continue "+e.label.name+this.semicolon(t):"continue"+this.semicolon(t)},ClassBody:function(e,t){var i=["{",f],s=this;return G(function(t){var n,a;for(n=0,a=e.body.length;n<a;++n)i.push(t),i.push(s.generateExpression(e.body[n],r.Sequence,7)),n+1<a&&i.push(f)}),k(N(i).toString())||i.push(f),i.push(o),i.push("}"),i},ClassDeclaration:function(e,t){var i,s;return i=["class"],e.id&&(i=U(i,this.generateExpression(e.id,r.Sequence,7))),e.superClass&&(s=U("extends",this.generateExpression(e.superClass,r.Unary,7)),i=U(i,s)),i.push(g),i.push(this.generateStatement(e.body,T)),i},DirectiveStatement:function(e,t){return b.raw&&e.raw?e.raw+this.semicolon(t):function(e){var t,r,i,s;for(s="double"===p?'"':"'",t=0,r=e.length;t<r;++t){if(39===(i=e.charCodeAt(t))){s='"';break}if(34===i){s="'";break}92===i&&++t}return s+e+s}(e.directive)+this.semicolon(t)},DoWhileStatement:function(e,t){var i=U("do",this.maybeBlock(e.body,1));return U(i=this.maybeBlockSuffix(e.body,i),["while"+g+"(",this.generateExpression(e.test,r.Sequence,7),")"+this.semicolon(t)])},CatchClause:function(e,t){var i,s=this;return G(function(){var t;e.param?(i=["catch"+g+"(",s.generateExpression(e.param,r.Sequence,7),")"],e.guard&&(t=s.generateExpression(e.guard,r.Sequence,7),i.splice(2,0," if ",t))):i=["catch"]}),i.push(this.maybeBlock(e.body,1)),i},DebuggerStatement:function(e,t){return"debugger"+this.semicolon(t)},EmptyStatement:function(e,t){return";"},ExportDefaultDeclaration:function(e,t){var i,s=["export"];return i=t&F?T:1,s=U(s,"default"),S(e.declaration)?U(s,this.generateStatement(e.declaration,i)):U(s,this.generateExpression(e.declaration,r.Assignment,7)+this.semicolon(t))},ExportNamedDeclaration:function(e,i){var s,n=["export"],a=this;return s=i&F?T:1,e.declaration?U(n,this.generateStatement(e.declaration,s)):(e.specifiers&&(0===e.specifiers.length?n=U(n,"{"+g+"}"):e.specifiers[0].type===t.ExportBatchSpecifier?n=U(n,this.generateExpression(e.specifiers[0],r.Sequence,7)):(n=U(n,"{"),G(function(t){var i,s;for(n.push(f),i=0,s=e.specifiers.length;i<s;++i)n.push(t),n.push(a.generateExpression(e.specifiers[i],r.Sequence,7)),i+1<s&&n.push(","+f)}),k(N(n).toString())||n.push(f),n.push(o+"}")),e.source?n=U(n,["from"+g,this.generateExpression(e.source,r.Sequence,7),this.semicolon(i)]):n.push(this.semicolon(i))),n)},ExportAllDeclaration:function(e,t){return["export"+g,"*"+g,"from"+g,this.generateExpression(e.source,r.Sequence,7),this.semicolon(t)]},ExpressionStatement:function(e,i){var s,n;return 123===(n=N(s=[this.generateExpression(e.expression,r.Sequence,7)]).toString()).charCodeAt(0)||function(e){var t;return"class"===e.slice(0,5)&&(123===(t=e.charCodeAt(5))||a.code.isWhiteSpace(t)||a.code.isLineTerminator(t))}(n)||function(e){var t;return"function"===e.slice(0,8)&&(40===(t=e.charCodeAt(8))||a.code.isWhiteSpace(t)||42===t||a.code.isLineTerminator(t))}(n)||function(e){var t,r,i;if("async"!==e.slice(0,5))return!1;if(!a.code.isWhiteSpace(e.charCodeAt(5)))return!1;for(r=6,i=e.length;r<i&&a.code.isWhiteSpace(e.charCodeAt(r));++r);return r!==i&&"function"===e.slice(r,r+8)&&(40===(t=e.charCodeAt(r+8))||a.code.isWhiteSpace(t)||42===t||a.code.isLineTerminator(t))}(n)||v&&16&i&&e.expression.type===t.Literal&&"string"==typeof e.expression.value?s=["(",s,")"+this.semicolon(i)]:s.push(this.semicolon(i)),s},ImportDeclaration:function(e,i){var s,n,a=this;return 0===e.specifiers.length?["import",g,this.generateExpression(e.source,r.Sequence,7),this.semicolon(i)]:(s=["import"],n=0,e.specifiers[n].type===t.ImportDefaultSpecifier&&(s=U(s,[this.generateExpression(e.specifiers[n],r.Sequence,7)]),++n),e.specifiers[n]&&(0!==n&&s.push(","),e.specifiers[n].type===t.ImportNamespaceSpecifier?s=U(s,[g,this.generateExpression(e.specifiers[n],r.Sequence,7)]):(s.push(g+"{"),e.specifiers.length-n==1?(s.push(g),s.push(this.generateExpression(e.specifiers[n],r.Sequence,7)),s.push(g+"}"+g)):(G(function(t){var i,o;for(s.push(f),i=n,o=e.specifiers.length;i<o;++i)s.push(t),s.push(a.generateExpression(e.specifiers[i],r.Sequence,7)),i+1<o&&s.push(","+f)}),k(N(s).toString())||s.push(f),s.push(o+"}"+g)))),s=U(s,["from"+g,this.generateExpression(e.source,r.Sequence,7),this.semicolon(i)]))},VariableDeclarator:function(e,t){var i=1&t?7:6;return e.init?[this.generateExpression(e.id,r.Assignment,i),g,"=",g,this.generateExpression(e.init,r.Assignment,i)]:this.generatePattern(e.id,r.Assignment,i)},VariableDeclaration:function(e,t){var r,i,s,n,a,o=this;function h(){for(n=e.declarations[0],b.comment&&n.leadingComments?(r.push("\n"),r.push(z(o.generateStatement(n,a)))):(r.push(V()),r.push(o.generateStatement(n,a))),i=1,s=e.declarations.length;i<s;++i)n=e.declarations[i],b.comment&&n.leadingComments?(r.push(","+f),r.push(z(o.generateStatement(n,a)))):(r.push(","+g),r.push(o.generateStatement(n,a)))}return r=[e.kind],a=1&t?1:0,e.declarations.length>1?G(h):h(),r.push(this.semicolon(t)),r},ThrowStatement:function(e,t){return[U("throw",this.generateExpression(e.argument,r.Sequence,7)),this.semicolon(t)]},TryStatement:function(e,t){var r,i,s,n;if(r=["try",this.maybeBlock(e.block,1)],r=this.maybeBlockSuffix(e.block,r),e.handlers)for(i=0,s=e.handlers.length;i<s;++i)r=U(r,this.generateStatement(e.handlers[i],1)),(e.finalizer||i+1!==s)&&(r=this.maybeBlockSuffix(e.handlers[i].body,r));else{for(i=0,s=(n=e.guardedHandlers||[]).length;i<s;++i)r=U(r,this.generateStatement(n[i],1)),(e.finalizer||i+1!==s)&&(r=this.maybeBlockSuffix(n[i].body,r));if(e.handler)if(Array.isArray(e.handler))for(i=0,s=e.handler.length;i<s;++i)r=U(r,this.generateStatement(e.handler[i],1)),(e.finalizer||i+1!==s)&&(r=this.maybeBlockSuffix(e.handler[i].body,r));else r=U(r,this.generateStatement(e.handler,1)),e.finalizer&&(r=this.maybeBlockSuffix(e.handler.body,r))}return e.finalizer&&(r=U(r,["finally",this.maybeBlock(e.finalizer,1)])),r},SwitchStatement:function(e,t){var i,s,n,a,o,h=this;if(G(function(){i=["switch"+g+"(",h.generateExpression(e.discriminant,r.Sequence,7),")"+g+"{"+f]}),e.cases)for(o=1,n=0,a=e.cases.length;n<a;++n)n===a-1&&(o|=F),s=z(this.generateStatement(e.cases[n],o)),i.push(s),k(N(s).toString())||i.push(f);return i.push(z("}")),i},SwitchCase:function(e,i){var s,n,a,o,h,u=this;return G(function(){for(s=e.test?[U("case",u.generateExpression(e.test,r.Sequence,7)),":"]:["default:"],a=0,(o=e.consequent.length)&&e.consequent[0].type===t.BlockStatement&&(n=u.maybeBlock(e.consequent[0],1),s.push(n),a=1),a===o||k(N(s).toString())||s.push(f),h=1;a<o;++a)a===o-1&&i&F&&(h|=F),n=z(u.generateStatement(e.consequent[a],h)),s.push(n),a+1===o||k(N(n).toString())||s.push(f)}),s},IfStatement:function(e,i){var s,n,a=this;return G(function(){s=["if"+g+"(",a.generateExpression(e.test,r.Sequence,7),")"]}),n=1,i&F&&(n|=F),e.alternate?(s.push(this.maybeBlock(e.consequent,1)),s=this.maybeBlockSuffix(e.consequent,s),s=e.alternate.type===t.IfStatement?U(s,["else ",this.generateStatement(e.alternate,n)]):U(s,U("else",this.maybeBlock(e.alternate,n)))):s.push(this.maybeBlock(e.consequent,n)),s},ForStatement:function(e,i){var s,n=this;return G(function(){s=["for"+g+"("],e.init?e.init.type===t.VariableDeclaration?s.push(n.generateStatement(e.init,0)):(s.push(n.generateExpression(e.init,r.Sequence,6)),s.push(";")):s.push(";"),e.test?(s.push(g),s.push(n.generateExpression(e.test,r.Sequence,7)),s.push(";")):s.push(";"),e.update?(s.push(g),s.push(n.generateExpression(e.update,r.Sequence,7)),s.push(")")):s.push(")")}),s.push(this.maybeBlock(e.body,i&F?T:1)),s},ForInStatement:function(e,t){return this.generateIterationForStatement("in",e,t&F?T:1)},ForOfStatement:function(e,t){return this.generateIterationForStatement("of",e,t&F?T:1)},LabeledStatement:function(e,t){return[e.label.name+":",this.maybeBlock(e.body,t&F?T:1)]},Program:function(e,t){var r,i,s,n,a;for(n=e.body.length,r=[x&&n>0?"\n":""],a=17,s=0;s<n;++s)x||s!==n-1||(a|=F),E&&(0===s&&(e.body[0].leadingComments||H(e.range[0],e.body[s].range[0],r)),s>0&&(e.body[s-1].trailingComments||e.body[s].leadingComments||H(e.body[s-1].range[1],e.body[s].range[0],r))),i=z(this.generateStatement(e.body[s],a)),r.push(i),s+1<n&&!k(N(i).toString())&&(E&&e.body[s+1].leadingComments||r.push(f)),E&&s===n-1&&(e.body[s].trailingComments||H(e.body[s].range[1],e.range[1],r));return r},FunctionDeclaration:function(e,t){return[K(e,!0),"function",Z(e)||V(),e.id?Y(e.id):"",this.generateFunctionBody(e)]},ReturnStatement:function(e,t){return e.argument?[U("return",this.generateExpression(e.argument,r.Sequence,7)),this.semicolon(t)]:["return"+this.semicolon(t)]},WhileStatement:function(e,t){var i,s=this;return G(function(){i=["while"+g+"(",s.generateExpression(e.test,r.Sequence,7),")"]}),i.push(this.maybeBlock(e.body,t&F?T:1)),i},WithStatement:function(e,t){var i,s=this;return G(function(){i=["with"+g+"(",s.generateExpression(e.object,r.Sequence,7),")"]}),i.push(this.maybeBlock(e.body,t&F?T:1)),i}},I(X.prototype,X.Statement),X.Expression={SequenceExpression:function(e,t,i){var s,n,a;for(r.Sequence<t&&(i|=1),s=[],n=0,a=e.expressions.length;n<a;++n)s.push(this.generateExpression(e.expressions[n],r.Assignment,i)),n+1<a&&s.push(","+g);return q(s,r.Sequence,t)},AssignmentExpression:function(e,t,r){return this.generateAssignment(e.left,e.right,e.operator,t,r)},ArrowFunctionExpression:function(e,t,i){return q(this.generateFunctionBody(e),r.ArrowFunction,t)},ConditionalExpression:function(e,t,i){return r.Conditional<t&&(i|=1),q([this.generateExpression(e.test,r.Coalesce,i),g+"?"+g,this.generateExpression(e.consequent,r.Assignment,i),g+":"+g,this.generateExpression(e.alternate,r.Assignment,i)],r.Conditional,t)},LogicalExpression:function(e,t,r){return"??"===e.operator&&(r|=64),this.BinaryExpression(e,t,r)},BinaryExpression:function(e,t,s){var n,o,h,u,l,c;return u=i[e.operator],o="**"===e.operator?r.Postfix:u,h="**"===e.operator?u:u+1,u<t&&(s|=1),n=47===(c=(l=this.generateExpression(e.left,o,s)).toString()).charCodeAt(c.length-1)&&a.code.isIdentifierPartES5(e.operator.charCodeAt(0))?[l,V(),e.operator]:U(l,e.operator),l=this.generateExpression(e.right,h,s),"/"===e.operator&&"/"===l.toString().charAt(0)||"<"===e.operator.slice(-1)&&"!--"===l.toString().slice(0,3)?(n.push(V()),n.push(l)):n=U(n,l),"in"!==e.operator||1&s?("||"===e.operator||"&&"===e.operator)&&64&s?["(",n,")"]:q(n,u,t):["(",n,")"]},CallExpression:function(e,t,i){var s,n,a;for(s=[this.generateExpression(e.callee,r.Call,3)],e.optional&&s.push("?."),s.push("("),n=0,a=e.arguments.length;n<a;++n)s.push(this.generateExpression(e.arguments[n],r.Assignment,7)),n+1<a&&s.push(","+g);return s.push(")"),2&i?q(s,r.Call,t):["(",s,")"]},ChainExpression:function(e,t,i){return r.OptionalChaining<t&&(i|=2),q(this.generateExpression(e.expression,r.OptionalChaining,i),r.OptionalChaining,t)},NewExpression:function(e,t,i){var s,n,a,o,h;if(n=e.arguments.length,h=4&i&&!m&&0===n?5:1,s=U("new",this.generateExpression(e.callee,r.New,h)),!(4&i)||m||n>0){for(s.push("("),a=0,o=n;a<o;++a)s.push(this.generateExpression(e.arguments[a],r.Assignment,7)),a+1<o&&s.push(","+g);s.push(")")}return q(s,r.New,t)},MemberExpression:function(e,i,s){var n,o;return n=[this.generateExpression(e.object,r.Call,2&s?3:1)],e.computed?(e.optional&&n.push("?."),n.push("["),n.push(this.generateExpression(e.property,r.Sequence,2&s?7:5)),n.push("]")):(e.optional||e.object.type!==t.Literal||"number"!=typeof e.object.value||(o=N(n).toString()).indexOf(".")<0&&!/[eExX]/.test(o)&&a.code.isDecimalDigit(o.charCodeAt(o.length-1))&&!(o.length>=2&&48===o.charCodeAt(0))&&n.push(" "),n.push(e.optional?"?.":"."),n.push(Y(e.property))),q(n,r.Member,i)},MetaProperty:function(e,t,i){var s;return(s=[]).push("string"==typeof e.meta?e.meta:Y(e.meta)),s.push("."),s.push("string"==typeof e.property?e.property:Y(e.property)),q(s,r.Member,t)},UnaryExpression:function(e,t,i){var s,n,o,h,u;return n=this.generateExpression(e.argument,r.Unary,7),""===g?s=U(e.operator,n):(s=[e.operator],e.operator.length>2?s=U(s,n):(u=(h=N(s).toString()).charCodeAt(h.length-1),o=n.toString().charCodeAt(0),(43===u||45===u)&&u===o||a.code.isIdentifierPartES5(u)&&a.code.isIdentifierPartES5(o)?(s.push(V()),s.push(n)):s.push(n))),q(s,r.Unary,t)},YieldExpression:function(e,t,i){var s;return s=e.delegate?"yield*":"yield",e.argument&&(s=U(s,this.generateExpression(e.argument,r.Yield,7))),q(s,r.Yield,t)},AwaitExpression:function(e,t,i){return q(U(e.all?"await*":"await",this.generateExpression(e.argument,r.Await,7)),r.Await,t)},UpdateExpression:function(e,t,i){return e.prefix?q([e.operator,this.generateExpression(e.argument,r.Unary,7)],r.Unary,t):q([this.generateExpression(e.argument,r.Postfix,7),e.operator],r.Postfix,t)},FunctionExpression:function(e,t,r){var i=[K(e,!0),"function"];return e.id?(i.push(Z(e)||V()),i.push(Y(e.id))):i.push(Z(e)||g),i.push(this.generateFunctionBody(e)),i},ArrayPattern:function(e,t,r){return this.ArrayExpression(e,t,r,!0)},ArrayExpression:function(e,t,i,s){var n,a,h=this;return e.elements.length?(a=!s&&e.elements.length>1,n=["[",a?f:""],G(function(t){var i,s;for(i=0,s=e.elements.length;i<s;++i)e.elements[i]?(n.push(a?t:""),n.push(h.generateExpression(e.elements[i],r.Assignment,7))):(a&&n.push(t),i+1===s&&n.push(",")),i+1<s&&n.push(","+(a?f:g))}),a&&!k(N(n).toString())&&n.push(f),n.push(a?o:""),n.push("]"),n):"[]"},RestElement:function(e,t,r){return"..."+this.generatePattern(e.argument)},ClassExpression:function(e,t,i){var s,n;return s=["class"],e.id&&(s=U(s,this.generateExpression(e.id,r.Sequence,7))),e.superClass&&(n=U("extends",this.generateExpression(e.superClass,r.Unary,7)),s=U(s,n)),s.push(g),s.push(this.generateStatement(e.body,T)),s},MethodDefinition:function(e,t,r){var i,s;return i=e.static?["static"+g]:[],s="get"===e.kind||"set"===e.kind?[U(e.kind,this.generatePropertyKey(e.key,e.computed)),this.generateFunctionBody(e.value)]:[J(e),this.generatePropertyKey(e.key,e.computed),this.generateFunctionBody(e.value)],U(i,s)},Property:function(e,t,i){return"get"===e.kind||"set"===e.kind?[e.kind,V(),this.generatePropertyKey(e.key,e.computed),this.generateFunctionBody(e.value)]:e.shorthand?"AssignmentPattern"===e.value.type?this.AssignmentPattern(e.value,r.Sequence,7):this.generatePropertyKey(e.key,e.computed):e.method?[J(e),this.generatePropertyKey(e.key,e.computed),this.generateFunctionBody(e.value)]:[this.generatePropertyKey(e.key,e.computed),":"+g,this.generateExpression(e.value,r.Assignment,7)]},ObjectExpression:function(e,t,i){var s,n,a,h,u=this;return e.properties.length?(s=e.properties.length>1,G(function(){a=u.generateExpression(e.properties[0],r.Sequence,7)}),s||(h=N(a).toString(),/[\r\n]/g.test(h))?(G(function(t){var i,o;if(n=["{",f,t,a],s)for(n.push(","+f),i=1,o=e.properties.length;i<o;++i)n.push(t),n.push(u.generateExpression(e.properties[i],r.Sequence,7)),i+1<o&&n.push(","+f)}),k(N(n).toString())||n.push(f),n.push(o),n.push("}"),n):["{",g,a,g,"}"]):"{}"},AssignmentPattern:function(e,t,r){return this.generateAssignment(e.left,e.right,"=",t,r)},ObjectPattern:function(e,i,s){var n,a,h,u,l,c=this;if(!e.properties.length)return"{}";if(u=!1,1===e.properties.length)(l=e.properties[0]).type===t.Property&&l.value.type!==t.Identifier&&(u=!0);else for(a=0,h=e.properties.length;a<h;++a)if((l=e.properties[a]).type===t.Property&&!l.shorthand){u=!0;break}return n=["{",u?f:""],G(function(t){var i,s;for(i=0,s=e.properties.length;i<s;++i)n.push(u?t:""),n.push(c.generateExpression(e.properties[i],r.Sequence,7)),i+1<s&&n.push(","+(u?f:g))}),u&&!k(N(n).toString())&&n.push(f),n.push(u?o:""),n.push("}"),n},ThisExpression:function(e,t,r){return"this"},Super:function(e,t,r){return"super"},Identifier:function(e,t,r){return Y(e)},ImportDefaultSpecifier:function(e,t,r){return Y(e.id||e.local)},ImportNamespaceSpecifier:function(e,t,r){var i=["*"],s=e.id||e.local;return s&&i.push(g+"as"+V()+Y(s)),i},ImportSpecifier:function(e,t,r){var i=e.imported,s=[i.name],n=e.local;return n&&n.name!==i.name&&s.push(V()+"as"+V()+Y(n)),s},ExportSpecifier:function(e,t,r){var i=e.local,s=[i.name],n=e.exported;return n&&n.name!==i.name&&s.push(V()+"as"+V()+Y(n)),s},Literal:function(e,r,i){var s;if(e.hasOwnProperty("raw")&&_&&b.raw)try{if((s=_(e.raw).body[0].expression).type===t.Literal&&s.value===e.value)return e.raw}catch(e){}return e.regex?"/"+e.regex.pattern+"/"+e.regex.flags:"bigint"==typeof e.value?e.value.toString()+"n":e.bigint?e.bigint+"n":null===e.value?"null":"string"==typeof e.value?function(e){var t,r,i,s,n,o="",h=0,l=0;for(t=0,r=e.length;t<r;++t){if(39===(i=e.charCodeAt(t)))++h;else if(34===i)++l;else if(47===i&&u)o+="\\";else{if(a.code.isLineTerminator(i)||92===i){o+=O(i);continue}if(!a.code.isIdentifierPartES5(i)&&(u&&i<32||!u&&!d&&(i<32||i>126))){o+=P(i,e.charCodeAt(t+1));continue}}o+=String.fromCharCode(i)}if(n=(s=!("double"===p||"auto"===p&&l<h))?"'":'"',!(s?h:l))return n+o+n;for(e=o,o=n,t=0,r=e.length;t<r;++t)(39===(i=e.charCodeAt(t))&&s||34===i&&!s)&&(o+="\\"),o+=String.fromCharCode(i);return o+n}(e.value):"number"==typeof e.value?function(e){var t,r,i,s,n;if(e!=e)throw new Error("Numeric literal whose value is NaN");if(e<0||0===e&&1/e<0)throw new Error("Numeric literal whose value is negative");if(e===1/0)return u?"null":l?"1e400":"1e+400";if(t=""+e,!l||t.length<3)return t;for(r=t.indexOf("."),u||48!==t.charCodeAt(0)||1!==r||(r=0,t=t.slice(1)),i=t,t=t.replace("e+","e"),s=0,(n=i.indexOf("e"))>0&&(s=+i.slice(n+1),i=i.slice(0,n)),r>=0&&(s-=i.length-r-1,i=+(i.slice(0,r)+i.slice(r+1))+""),n=0;48===i.charCodeAt(i.length+n-1);)--n;return 0!==n&&(s-=n,i=i.slice(0,n)),0!==s&&(i+="e"+s),(i.length<t.length||c&&e>1e12&&Math.floor(e)===e&&(i="0x"+e.toString(16)).length<t.length)&&+i===e&&(t=i),t}(e.value):"boolean"==typeof e.value?e.value?"true":"false":function(e){var t,r,i,s,n,a,o,h;if(r=e.toString(),e.source){if(!(t=r.match(/\/([^/]*)$/)))return r;for(i=t[1],r="",o=!1,h=!1,s=0,n=e.source.length;s<n;++s)a=e.source.charCodeAt(s),h?(r+=L(a,h),h=!1):(o?93===a&&(o=!1):47===a?r+="\\":91===a&&(o=!0),r+=L(a,h),h=92===a);return"/"+r+"/"+i}return r}(e.value)},GeneratorExpression:function(e,t,r){return this.ComprehensionExpression(e,t,r)},ComprehensionExpression:function(e,i,s){var n,a,o,h,u=this;return n=e.type===t.GeneratorExpression?["("]:["["],b.moz.comprehensionExpressionStartsWithAssignment&&(h=this.generateExpression(e.body,r.Assignment,7),n.push(h)),e.blocks&&G(function(){for(a=0,o=e.blocks.length;a<o;++a)h=u.generateExpression(e.blocks[a],r.Sequence,7),a>0||b.moz.comprehensionExpressionStartsWithAssignment?n=U(n,h):n.push(h)}),e.filter&&(n=U(n,"if"+g),h=this.generateExpression(e.filter,r.Sequence,7),n=U(n,["(",h,")"])),b.moz.comprehensionExpressionStartsWithAssignment||(h=this.generateExpression(e.body,r.Assignment,7),n=U(n,h)),n.push(e.type===t.GeneratorExpression?")":"]"),n},ComprehensionBlock:function(e,i,s){var n;return n=U(n=e.left.type===t.VariableDeclaration?[e.left.kind,V(),this.generateStatement(e.left.declarations[0],0)]:this.generateExpression(e.left,r.Call,7),e.of?"of":"in"),n=U(n,this.generateExpression(e.right,r.Sequence,7)),["for"+g+"(",n,")"]},SpreadElement:function(e,t,i){return["...",this.generateExpression(e.argument,r.Assignment,7)]},TaggedTemplateExpression:function(e,t,i){var s=3;return 2&i||(s=1),q([this.generateExpression(e.tag,r.Call,s),this.generateExpression(e.quasi,r.Primary,4)],r.TaggedTemplate,t)},TemplateElement:function(e,t,r){return e.value.raw},TemplateLiteral:function(e,t,i){var s,n,a;for(s=["`"],n=0,a=e.quasis.length;n<a;++n)s.push(this.generateExpression(e.quasis[n],r.Primary,7)),n+1<a&&(s.push("${"+g),s.push(this.generateExpression(e.expressions[n],r.Sequence,7)),s.push(g+"}"));return s.push("`"),s},ModuleSpecifier:function(e,t,r){return this.Literal(e,t,r)},ImportExpression:function(e,t,i){return q(["import(",this.generateExpression(e.source,r.Assignment,7),")"],r.Call,t)}},I(X.prototype,X.Expression),X.prototype.generateExpression=function(e,i,s){var n,a;return a=e.type||t.Property,b.verbatim&&e.hasOwnProperty(b.verbatim)?function(e,t){var i;return N("string"==typeof(i=e[b.verbatim])?q(W(i),r.Sequence,t):q(W(i.content),null!=i.precedence?i.precedence:r.Sequence,t),e)}(e,i):(n=this[a](e,i,s),b.comment&&(n=$(e,n)),N(n,e))},X.prototype.generateStatement=function(e,r){var i,s;return i=this[e.type](e,r),b.comment&&(i=$(e,i)),s=N(i).toString(),e.type!==t.Program||x||""!==f||"\n"!==s.charAt(s.length-1)||(i=w?N(i).replaceRight(/\s+$/,""):s.replace(/\s+$/,"")),N(i,e)},D={indent:{style:"",base:0},renumber:!0,hexadecimal:!0,quotes:"auto",escapeless:!0,compact:!0,parentheses:!1,semicolons:!1},A={indent:{style:" ",base:0,adjustMultilineComment:!1},newline:"\n",space:" ",json:!1,renumber:!1,hexadecimal:!1,quotes:"single",escapeless:!1,compact:!1,parentheses:!0,semicolons:!0,safeConcatenation:!1,preserveBlankLines:!1},e.version="2.1.0",e.generate=function(t,r){var i,n,a={indent:null,base:null,parse:null,comment:!1,format:{indent:{style:" ",base:0,adjustMultilineComment:!1},newline:"\n",space:" ",json:!1,renumber:!1,hexadecimal:!1,quotes:"single",escapeless:!1,compact:!1,parentheses:!0,semicolons:!0,safeConcatenation:!1,preserveBlankLines:!1},moz:{comprehensionExpressionStartsWithAssignment:!1,starlessGenerator:!1},sourceMap:null,sourceMapRoot:null,sourceMapWithCode:!1,directive:!1,raw:!0,verbatim:null,sourceCode:null};return null!=r?("string"==typeof r.indent&&(a.format.indent.style=r.indent),"number"==typeof r.base&&(a.format.indent.base=r.base),r=B(a,r),h=r.format.indent.style,o="string"==typeof r.base?r.base:M(h,r.format.indent.base)):(h=(r=a).format.indent.style,o=M(h,r.format.indent.base)),u=r.format.json,l=r.format.renumber,c=!u&&r.format.hexadecimal,p=u?"double":r.format.quotes,d=r.format.escapeless,f=r.format.newline,g=r.format.space,r.format.compact&&(f=g=h=o=""),m=r.format.parentheses,y=r.format.semicolons,x=r.format.safeConcatenation,v=r.directive,_=u?null:r.parse,w=r.sourceMap,C=r.sourceCode,E=r.format.preserveBlankLines&&null!==C,b=r,w&&(s=e.browser?Ps.sourceMap.SourceNode:(bp||(bp=1,Jc.SourceMapGenerator=pp().SourceMapGenerator,Jc.SourceMapConsumer=function(){if(xp)return fp;xp=1;var e=np(),t=mp(),r=hp().ArraySet,i=rp(),s=function(){if(yp)return _p;function e(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function t(r,i,s,n){if(s<n){var a=s-1;e(r,(l=s,c=n,Math.round(l+Math.random()*(c-l))),n);for(var o=r[n],h=s;h<n;h++)i(r[h],o)<=0&&e(r,a+=1,h);e(r,a+1,h);var u=a+1;t(r,i,s,u-1),t(r,i,u+1,n)}var l,c}return yp=1,_p.quickSort=function(e,r){t(e,r,0,e.length-1)},_p}().quickSort;function n(t,r){var i=t;return"string"==typeof t&&(i=e.parseSourceMapInput(t)),null!=i.sections?new h(i,r):new a(i,r)}function a(t,i){var s=t;"string"==typeof t&&(s=e.parseSourceMapInput(t));var n=e.getArg(s,"version"),a=e.getArg(s,"sources"),o=e.getArg(s,"names",[]),h=e.getArg(s,"sourceRoot",null),u=e.getArg(s,"sourcesContent",null),l=e.getArg(s,"mappings"),c=e.getArg(s,"file",null);if(n!=this._version)throw new Error("Unsupported version: "+n);h&&(h=e.normalize(h)),a=a.map(String).map(e.normalize).map(function(t){return h&&e.isAbsolute(h)&&e.isAbsolute(t)?e.relative(h,t):t}),this._names=r.fromArray(o.map(String),!0),this._sources=r.fromArray(a,!0),this._absoluteSources=this._sources.toArray().map(function(t){return e.computeSourceURL(h,t,i)}),this.sourceRoot=h,this.sourcesContent=u,this._mappings=l,this._sourceMapURL=i,this.file=c}function o(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}function h(t,i){var s=t;"string"==typeof t&&(s=e.parseSourceMapInput(t));var a=e.getArg(s,"version"),o=e.getArg(s,"sections");if(a!=this._version)throw new Error("Unsupported version: "+a);this._sources=new r,this._names=new r;var h={line:-1,column:0};this._sections=o.map(function(t){if(t.url)throw new Error("Support for url field in sections not implemented.");var r=e.getArg(t,"offset"),s=e.getArg(r,"line"),a=e.getArg(r,"column");if(s<h.line||s===h.line&&a<h.column)throw new Error("Section offsets must be ordered and non-overlapping.");return h=r,{generatedOffset:{generatedLine:s+1,generatedColumn:a+1},consumer:new n(e.getArg(t,"map"),i)}})}return n.fromSourceMap=function(e,t){return a.fromSourceMap(e,t)},n.prototype._version=3,n.prototype.__generatedMappings=null,Object.defineProperty(n.prototype,"_generatedMappings",{configurable:!0,enumerable:!0,get:function(){return this.__generatedMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__generatedMappings}}),n.prototype.__originalMappings=null,Object.defineProperty(n.prototype,"_originalMappings",{configurable:!0,enumerable:!0,get:function(){return this.__originalMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__originalMappings}}),n.prototype._charIsMappingSeparator=function(e,t){var r=e.charAt(t);return";"===r||","===r},n.prototype._parseMappings=function(e,t){throw new Error("Subclasses must implement _parseMappings")},n.GENERATED_ORDER=1,n.ORIGINAL_ORDER=2,n.GREATEST_LOWER_BOUND=1,n.LEAST_UPPER_BOUND=2,n.prototype.eachMapping=function(t,r,i){var s,a=r||null;switch(i||n.GENERATED_ORDER){case n.GENERATED_ORDER:s=this._generatedMappings;break;case n.ORIGINAL_ORDER:s=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var o=this.sourceRoot;s.map(function(t){var r=null===t.source?null:this._sources.at(t.source);return{source:r=e.computeSourceURL(o,r,this._sourceMapURL),generatedLine:t.generatedLine,generatedColumn:t.generatedColumn,originalLine:t.originalLine,originalColumn:t.originalColumn,name:null===t.name?null:this._names.at(t.name)}},this).forEach(t,a)},n.prototype.allGeneratedPositionsFor=function(r){var i=e.getArg(r,"line"),s={source:e.getArg(r,"source"),originalLine:i,originalColumn:e.getArg(r,"column",0)};if(s.source=this._findSourceIndex(s.source),s.source<0)return[];var n=[],a=this._findMapping(s,this._originalMappings,"originalLine","originalColumn",e.compareByOriginalPositions,t.LEAST_UPPER_BOUND);if(a>=0){var o=this._originalMappings[a];if(void 0===r.column)for(var h=o.originalLine;o&&o.originalLine===h;)n.push({line:e.getArg(o,"generatedLine",null),column:e.getArg(o,"generatedColumn",null),lastColumn:e.getArg(o,"lastGeneratedColumn",null)}),o=this._originalMappings[++a];else for(var u=o.originalColumn;o&&o.originalLine===i&&o.originalColumn==u;)n.push({line:e.getArg(o,"generatedLine",null),column:e.getArg(o,"generatedColumn",null),lastColumn:e.getArg(o,"lastGeneratedColumn",null)}),o=this._originalMappings[++a]}return n},fp.SourceMapConsumer=n,a.prototype=Object.create(n.prototype),a.prototype.consumer=n,a.prototype._findSourceIndex=function(t){var r,i=t;if(null!=this.sourceRoot&&(i=e.relative(this.sourceRoot,i)),this._sources.has(i))return this._sources.indexOf(i);for(r=0;r<this._absoluteSources.length;++r)if(this._absoluteSources[r]==t)return r;return-1},a.fromSourceMap=function(t,i){var n=Object.create(a.prototype),h=n._names=r.fromArray(t._names.toArray(),!0),u=n._sources=r.fromArray(t._sources.toArray(),!0);n.sourceRoot=t._sourceRoot,n.sourcesContent=t._generateSourcesContent(n._sources.toArray(),n.sourceRoot),n.file=t._file,n._sourceMapURL=i,n._absoluteSources=n._sources.toArray().map(function(t){return e.computeSourceURL(n.sourceRoot,t,i)});for(var l=t._mappings.toArray().slice(),c=n.__generatedMappings=[],p=n.__originalMappings=[],d=0,f=l.length;d<f;d++){var g=l[d],m=new o;m.generatedLine=g.generatedLine,m.generatedColumn=g.generatedColumn,g.source&&(m.source=u.indexOf(g.source),m.originalLine=g.originalLine,m.originalColumn=g.originalColumn,g.name&&(m.name=h.indexOf(g.name)),p.push(m)),c.push(m)}return s(n.__originalMappings,e.compareByOriginalPositions),n},a.prototype._version=3,Object.defineProperty(a.prototype,"sources",{get:function(){return this._absoluteSources.slice()}}),a.prototype._parseMappings=function(t,r){for(var n,a,h,u,l,c=1,p=0,d=0,f=0,g=0,m=0,y=t.length,x=0,v={},b={},_=[],w=[];x<y;)if(";"===t.charAt(x))c++,x++,p=0;else if(","===t.charAt(x))x++;else{for((n=new o).generatedLine=c,u=x;u<y&&!this._charIsMappingSeparator(t,u);u++);if(h=v[a=t.slice(x,u)])x+=a.length;else{for(h=[];x<u;)i.decode(t,x,b),l=b.value,x=b.rest,h.push(l);if(2===h.length)throw new Error("Found a source, but no line and column");if(3===h.length)throw new Error("Found a source and line, but no column");v[a]=h}n.generatedColumn=p+h[0],p=n.generatedColumn,h.length>1&&(n.source=g+h[1],g+=h[1],n.originalLine=d+h[2],d=n.originalLine,n.originalLine+=1,n.originalColumn=f+h[3],f=n.originalColumn,h.length>4&&(n.name=m+h[4],m+=h[4])),w.push(n),"number"==typeof n.originalLine&&_.push(n)}s(w,e.compareByGeneratedPositionsDeflated),this.__generatedMappings=w,s(_,e.compareByOriginalPositions),this.__originalMappings=_},a.prototype._findMapping=function(e,r,i,s,n,a){if(e[i]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+e[i]);if(e[s]<0)throw new TypeError("Column must be greater than or equal to 0, got "+e[s]);return t.search(e,r,n,a)},a.prototype.computeColumnSpans=function(){for(var e=0;e<this._generatedMappings.length;++e){var t=this._generatedMappings[e];if(e+1<this._generatedMappings.length){var r=this._generatedMappings[e+1];if(t.generatedLine===r.generatedLine){t.lastGeneratedColumn=r.generatedColumn-1;continue}}t.lastGeneratedColumn=1/0}},a.prototype.originalPositionFor=function(t){var r={generatedLine:e.getArg(t,"line"),generatedColumn:e.getArg(t,"column")},i=this._findMapping(r,this._generatedMappings,"generatedLine","generatedColumn",e.compareByGeneratedPositionsDeflated,e.getArg(t,"bias",n.GREATEST_LOWER_BOUND));if(i>=0){var s=this._generatedMappings[i];if(s.generatedLine===r.generatedLine){var a=e.getArg(s,"source",null);null!==a&&(a=this._sources.at(a),a=e.computeSourceURL(this.sourceRoot,a,this._sourceMapURL));var o=e.getArg(s,"name",null);return null!==o&&(o=this._names.at(o)),{source:a,line:e.getArg(s,"originalLine",null),column:e.getArg(s,"originalColumn",null),name:o}}}return{source:null,line:null,column:null,name:null}},a.prototype.hasContentsOfAllSources=function(){return!!this.sourcesContent&&this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(e){return null==e})},a.prototype.sourceContentFor=function(t,r){if(!this.sourcesContent)return null;var i=this._findSourceIndex(t);if(i>=0)return this.sourcesContent[i];var s,n=t;if(null!=this.sourceRoot&&(n=e.relative(this.sourceRoot,n)),null!=this.sourceRoot&&(s=e.urlParse(this.sourceRoot))){var a=n.replace(/^file:\/\//,"");if("file"==s.scheme&&this._sources.has(a))return this.sourcesContent[this._sources.indexOf(a)];if((!s.path||"/"==s.path)&&this._sources.has("/"+n))return this.sourcesContent[this._sources.indexOf("/"+n)]}if(r)return null;throw new Error('"'+n+'" is not in the SourceMap.')},a.prototype.generatedPositionFor=function(t){var r=e.getArg(t,"source");if((r=this._findSourceIndex(r))<0)return{line:null,column:null,lastColumn:null};var i={source:r,originalLine:e.getArg(t,"line"),originalColumn:e.getArg(t,"column")},s=this._findMapping(i,this._originalMappings,"originalLine","originalColumn",e.compareByOriginalPositions,e.getArg(t,"bias",n.GREATEST_LOWER_BOUND));if(s>=0){var a=this._originalMappings[s];if(a.source===i.source)return{line:e.getArg(a,"generatedLine",null),column:e.getArg(a,"generatedColumn",null),lastColumn:e.getArg(a,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},fp.BasicSourceMapConsumer=a,h.prototype=Object.create(n.prototype),h.prototype.constructor=n,h.prototype._version=3,Object.defineProperty(h.prototype,"sources",{get:function(){for(var e=[],t=0;t<this._sections.length;t++)for(var r=0;r<this._sections[t].consumer.sources.length;r++)e.push(this._sections[t].consumer.sources[r]);return e}}),h.prototype.originalPositionFor=function(r){var i={generatedLine:e.getArg(r,"line"),generatedColumn:e.getArg(r,"column")},s=t.search(i,this._sections,function(e,t){return e.generatedLine-t.generatedOffset.generatedLine||e.generatedColumn-t.generatedOffset.generatedColumn}),n=this._sections[s];return n?n.consumer.originalPositionFor({line:i.generatedLine-(n.generatedOffset.generatedLine-1),column:i.generatedColumn-(n.generatedOffset.generatedLine===i.generatedLine?n.generatedOffset.generatedColumn-1:0),bias:r.bias}):{source:null,line:null,column:null,name:null}},h.prototype.hasContentsOfAllSources=function(){return this._sections.every(function(e){return e.consumer.hasContentsOfAllSources()})},h.prototype.sourceContentFor=function(e,t){for(var r=0;r<this._sections.length;r++){var i=this._sections[r].consumer.sourceContentFor(e,!0);if(i)return i}if(t)return null;throw new Error('"'+e+'" is not in the SourceMap.')},h.prototype.generatedPositionFor=function(t){for(var r=0;r<this._sections.length;r++){var i=this._sections[r];if(-1!==i.consumer._findSourceIndex(e.getArg(t,"source"))){var s=i.consumer.generatedPositionFor(t);if(s)return{line:s.line+(i.generatedOffset.generatedLine-1),column:s.column+(i.generatedOffset.generatedLine===s.line?i.generatedOffset.generatedColumn-1:0)}}}return{line:null,column:null}},h.prototype._parseMappings=function(t,r){this.__generatedMappings=[],this.__originalMappings=[];for(var i=0;i<this._sections.length;i++)for(var n=this._sections[i],a=n.consumer._generatedMappings,o=0;o<a.length;o++){var h=a[o],u=n.consumer._sources.at(h.source);u=e.computeSourceURL(n.consumer.sourceRoot,u,this._sourceMapURL),this._sources.add(u),u=this._sources.indexOf(u);var l=null;h.name&&(l=n.consumer._names.at(h.name),this._names.add(l),l=this._names.indexOf(l));var c={source:u,generatedLine:h.generatedLine+(n.generatedOffset.generatedLine-1),generatedColumn:h.generatedColumn+(n.generatedOffset.generatedLine===h.generatedLine?n.generatedOffset.generatedColumn-1:0),originalLine:h.originalLine,originalColumn:h.originalColumn,name:l};this.__generatedMappings.push(c),"number"==typeof c.originalLine&&this.__originalMappings.push(c)}s(this.__generatedMappings,e.compareByGeneratedPositionsDeflated),s(this.__originalMappings,e.compareByOriginalPositions)},fp.IndexedSourceMapConsumer=h,fp}().SourceMapConsumer,Jc.SourceNode=function(){if(vp)return wp;vp=1;var e=pp().SourceMapGenerator,t=np(),r=/(\r?\n)/,i="$$$isSourceNode$$$";function s(e,t,r,s,n){this.children=[],this.sourceContents={},this.line=null==e?null:e,this.column=null==t?null:t,this.source=null==r?null:r,this.name=null==n?null:n,this[i]=!0,null!=s&&this.add(s)}return s.fromStringWithSourceMap=function(e,i,n){var a=new s,o=e.split(r),h=0,u=function(){return e()+(e()||"");function e(){return h<o.length?o[h++]:void 0}},l=1,c=0,p=null;return i.eachMapping(function(e){if(null!==p){if(!(l<e.generatedLine)){var t=(r=o[h]||"").substr(0,e.generatedColumn-c);return o[h]=r.substr(e.generatedColumn-c),c=e.generatedColumn,d(p,t),void(p=e)}d(p,u()),l++,c=0}for(;l<e.generatedLine;)a.add(u()),l++;if(c<e.generatedColumn){var r=o[h]||"";a.add(r.substr(0,e.generatedColumn)),o[h]=r.substr(e.generatedColumn),c=e.generatedColumn}p=e},this),h<o.length&&(p&&d(p,u()),a.add(o.splice(h).join(""))),i.sources.forEach(function(e){var r=i.sourceContentFor(e);null!=r&&(null!=n&&(e=t.join(n,e)),a.setSourceContent(e,r))}),a;function d(e,r){if(null===e||void 0===e.source)a.add(r);else{var i=n?t.join(n,e.source):e.source;a.add(new s(e.originalLine,e.originalColumn,i,r,e.name))}}},s.prototype.add=function(e){if(Array.isArray(e))e.forEach(function(e){this.add(e)},this);else{if(!e[i]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);e&&this.children.push(e)}return this},s.prototype.prepend=function(e){if(Array.isArray(e))for(var t=e.length-1;t>=0;t--)this.prepend(e[t]);else{if(!e[i]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);this.children.unshift(e)}return this},s.prototype.walk=function(e){for(var t,r=0,s=this.children.length;r<s;r++)(t=this.children[r])[i]?t.walk(e):""!==t&&e(t,{source:this.source,line:this.line,column:this.column,name:this.name})},s.prototype.join=function(e){var t,r,i=this.children.length;if(i>0){for(t=[],r=0;r<i-1;r++)t.push(this.children[r]),t.push(e);t.push(this.children[r]),this.children=t}return this},s.prototype.replaceRight=function(e,t){var r=this.children[this.children.length-1];return r[i]?r.replaceRight(e,t):"string"==typeof r?this.children[this.children.length-1]=r.replace(e,t):this.children.push("".replace(e,t)),this},s.prototype.setSourceContent=function(e,r){this.sourceContents[t.toSetString(e)]=r},s.prototype.walkSourceContents=function(e){for(var r=0,s=this.children.length;r<s;r++)this.children[r][i]&&this.children[r].walkSourceContents(e);var n=Object.keys(this.sourceContents);for(r=0,s=n.length;r<s;r++)e(t.fromSetString(n[r]),this.sourceContents[n[r]])},s.prototype.toString=function(){var e="";return this.walk(function(t){e+=t}),e},s.prototype.toStringWithSourceMap=function(t){var r={code:"",line:1,column:0},i=new e(t),s=!1,n=null,a=null,o=null,h=null;return this.walk(function(e,t){r.code+=e,null!==t.source&&null!==t.line&&null!==t.column?(n===t.source&&a===t.line&&o===t.column&&h===t.name||i.addMapping({source:t.source,original:{line:t.line,column:t.column},generated:{line:r.line,column:r.column},name:t.name}),n=t.source,a=t.line,o=t.column,h=t.name,s=!0):s&&(i.addMapping({generated:{line:r.line,column:r.column}}),n=null,s=!1);for(var u=0,l=e.length;u<l;u++)10===e.charCodeAt(u)?(r.line++,r.column=0,u+1===l?(n=null,s=!1):s&&i.addMapping({source:t.source,original:{line:t.line,column:t.column},generated:{line:r.line,column:r.column},name:t.name})):r.column++}),this.walkSourceContents(function(e,t){i.setSourceContent(e,t)}),{code:r.code,map:i}},wp.SourceNode=s,wp}().SourceNode),Jc).SourceNode),i=Q(t),w?(n=i.toStringWithSourceMap({file:r.file,sourceRoot:r.sourceMapRoot}),r.sourceContent&&n.map.setSourceContent(r.sourceMap,r.sourceContent),r.sourceMapWithCode?n:n.map.toString()):(n={code:i.toString(),map:null},r.sourceMapWithCode?n:n.code)},e.attachComments=n.attachComments,e.Precedence=B({},r),e.browser=!1,e.FORMAT_MINIFY=D,e.FORMAT_DEFAULTS=A}()}(zc);var Cp=Os(zc);let Ep=0,Dp=0;function Ap(e){switch(e){case"+":return"add";case"-":return"sub";case"*":return"mult";case"/":return"div";case"%":return"mod";case"==":case"===":return"equalTo";case"!=":case"!==":return"notEqual";case">":return"greaterThan";case">=":return"greaterEqual";case"<":return"lessThan";case"<=":return"lessEqual";case"&&":return"and";case"||":return"or"}}function Sp(e){return"CallExpression"===e.type&&("Identifier"===e.callee?.type&&e.callee?.name.startsWith("uniform")||"MemberExpression"===e.callee?.type&&e.callee?.property.name.startsWith("uniform"))}function Fp(e){return"VariableDeclaration"===e.type&&e.declarations.some(e=>"CallExpression"===e.init?.type&&("MemberExpression"===e.init?.callee?.type&&"Identifier"===e.init?.callee?.object?.type&&"__p5"===e.init?.callee?.object?.name&&("strandsFor"===e.init?.callee?.property?.name||"strandsIf"===e.init?.callee?.property?.name)||"Identifier"===e.init?.callee?.type&&("__p5.strandsFor"===e.init?.callee?.name||"__p5.strandsIf"===e.init?.callee?.name)))}function Tp(e){return!(!e||"string"!=typeof e)&&[["x","y","z","w"],["r","g","b","a"],["s","t","p","q"]].some(t=>[...e].every(e=>t.includes(e)))}function Mp(e){const t=[];let r=e;for(;"MemberExpression"===r.type;){if(r.computed)return null;const e=r.property.name||r.property.value;if(Tp(e)){r=r.object;break}t.unshift(e),r=r.object}return"Identifier"!==r.type?null:(t.unshift(r.name),t.join("."))}function kp(e,t){const r=e=>{if(e&&"object"==typeof e){if("MemberExpression"===e.type){if(Tp(e.property.name||e.property.value))return void r(e.object);const i=Mp(e);if(i&&t.has(i))return void Object.assign(e,{type:"Identifier",name:t.get(i)})}if("Identifier"===e.type&&t.has(e.name)&&(e.name=t.get(e.name)),"AssignmentExpression"===e.type){let r=null;"Identifier"===e.left.type?r=e.left.name:"MemberExpression"===e.left.type&&(r=Mp(e.left)),r&&t.has(r)&&("Literal"===e.right.type||"ArrayExpression"===e.right.type)&&(e.right={type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsNode"},arguments:[e.right]})}for(const t in e)if(e.hasOwnProperty(t)&&"parent"!==t){if("MemberExpression"===e.type&&"property"===t&&!e.computed)continue;Array.isArray(e[t])?e[t].forEach(r):"object"==typeof e[t]&&r(e[t])}}};r(e)}const Ip={UnaryExpression(e,t,r){if(r.some(Sp))return;const i=Xa[e.operator],s=e=>{e.type="CallExpression",e.callee={type:"Identifier",name:`__p5.${i}`},e.arguments=[e.argument]};if("MemberExpression"===e.type){const t=e.argument.property.name;let r=[["x","y","z","w"],["r","g","b","a"],["s","t","p","q"]].some(e=>[...t].every(t=>e.includes(t)))&&"MemberExpression"===e.argument.type;r?(e.type="MemberExpression",e.object={type:"CallExpression",callee:{type:"Identifier",name:`__p5.${i}`},arguments:[e.argument.object]},e.property={type:"Identifier",name:t}):s(e)}else s(e);delete e.argument,delete e.operator},BreakStatement(e,t,r){r.some(Sp)||(e.callee={type:"Identifier",name:"__p5.break"},e.arguments=[],e.type="CallExpression")},VariableDeclarator(e,t,r){if(!r.some(Sp)){if(Sp(e.init)&&(0===e.init.arguments.length||"Literal"!==e.init.arguments[0].type||"string"!=typeof e.init.arguments[0].value)){const t={type:"Literal",value:e.id.name};e.init.arguments.unshift(t)}if(function(e){return"CallExpression"===e?.type&&("Identifier"===e.callee?.type&&(e.callee?.name.startsWith("varying")||e.callee?.name.startsWith("shared"))||"MemberExpression"===e.callee?.type&&(e.callee?.property.name.startsWith("varying")||e.callee?.property.name.startsWith("shared")))}(e.init))if(0===e.init.arguments.length||"Literal"!==e.init.arguments[0].type||"string"!=typeof e.init.arguments[0].value){const r={type:"Literal",value:e.id.name};e.init.arguments.unshift(r),t.varyings[e.id.name]=r}else t.varyings[e.id.name]=e.init.arguments[0]}},Identifier(e,t,r){r.some(Sp)||t.varyings[e.name]&&!r.some(t=>"AssignmentExpression"===t.type&&t.left===e)&&(e.type="CallExpression",e.callee={type:"MemberExpression",object:{type:"Identifier",name:e.name},property:{type:"Identifier",name:"getValue"}},e.arguments=[])},ArrayExpression(e,t,r){if(r.some(Sp))return;const i=JSON.parse(JSON.stringify(e));e.type="CallExpression",e.callee={type:"Identifier",name:"__p5.strandsNode"},e.arguments=[i]},AssignmentExpression(e,t,r){if(r.some(Sp))return;const i=["Literal","ArrayExpression","Identifier"];if("="!==e.operator){const t=Ap(e.operator.replace("=","")),r={type:"CallExpression",callee:{type:"MemberExpression",object:i.includes(e.left.type)?{type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsNode"},arguments:[e.left]}:e.left,property:{type:"Identifier",name:t}},arguments:[e.right]};e.operator="=",e.right=r}if(t.varyings[e.left.name])e.type="ExpressionStatement",e.expression={type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:e.left.name},property:{type:"Identifier",name:"bridge"}},arguments:[e.right]};else if("MemberExpression"===e.left.type){let r=null;if("Identifier"===e.left.object.type&&t.varyings[e.left.object.name]?r=e.left.object.name:"CallExpression"===e.left.object.type&&"MemberExpression"===e.left.object.callee?.type&&"getValue"===e.left.object.callee.property?.name&&"Identifier"===e.left.object.callee.object?.type&&t.varyings[e.left.object.callee.object.name]&&(r=e.left.object.callee.object.name),r){const t=e.left.property.name;e.type="ExpressionStatement",e.expression={type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:r},property:{type:"Identifier",name:"bridgeSwizzle"}},arguments:[{type:"Literal",value:t},e.right]}}}},BinaryExpression(e,t,r){if(!r.some(Sp)){if(["Literal","ArrayExpression","Identifier"].includes(e.left.type)){const t={type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsNode"},arguments:[e.left]};e.left=t}e.type="CallExpression",e.callee={type:"MemberExpression",object:e.left,property:{type:"Identifier",name:Ap(e.operator)}},e.arguments=[e.right]}},LogicalExpression(e,t,r){if(!r.some(Sp)){if(["Literal","ArrayExpression","Identifier"].includes(e.left.type)){const t={type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsNode"},arguments:[e.left]};e.left=t}e.type="CallExpression",e.callee={type:"MemberExpression",object:e.left,property:{type:"Identifier",name:Ap(e.operator)}},e.arguments=[e.right]}},IfStatement(e,t,r){if(r.some(Sp))return;const i=e.test,s={type:"ArrowFunctionExpression",params:[],body:"BlockStatement"===e.consequent.type?e.consequent:{type:"BlockStatement",body:[e.consequent]}};let n,a={type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsIf"},arguments:[i,s]};n=e.alternate?{type:"ArrowFunctionExpression",params:[],body:"BlockStatement"===e.alternate.type?e.alternate:{type:"BlockStatement",body:[e.alternate]}}:{type:"ArrowFunctionExpression",params:[],body:{type:"BlockStatement",body:[]}},a={type:"CallExpression",callee:{type:"MemberExpression",object:a,property:{type:"Identifier",name:"Else"}},arguments:[n]};const o=new Set,h=e=>{const t=new Set;Rc(e,{VariableDeclarator(e,r){r.some(Fp)||"Identifier"===e.id.type&&t.add(e.id.name)}}),Rc(e,{AssignmentExpression(e,r){if(r.some(Fp))return;const i=e.left;if("Identifier"===i.type)t.has(i.name)||o.add(i.name);else if("MemberExpression"===i.type){const e=Mp(i);if(e){const r=e.split(".")[0];t.has(r)||o.add(e)}}}})};if(h(s.body),h(n.body),o.size>0){const t=(e,t)=>{if("BlockStatement"===e.type){const r=new Map,i=[];for(const e of t){const t=e.split("."),s=`__copy_${t.join("_")}_${Ep++}`;r.set(e,s);let n={type:"Identifier",name:t[0]};for(let e=1;e<t.length;e++)n={type:"MemberExpression",object:n,property:{type:"Identifier",name:t[e]},computed:!1};i.push({type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:s},init:{type:"CallExpression",callee:{type:"MemberExpression",object:n,property:{type:"Identifier",name:"copy"},computed:!1},arguments:[]}}],kind:"let"})}e.body.forEach(e=>kp(e,r)),e.body.unshift(...i);const s={type:"ObjectExpression",properties:Array.from(t).map(e=>({type:"Property",key:{type:"Literal",value:e},value:{type:"Identifier",name:r.get(e)},kind:"init",computed:!1,shorthand:!1}))};e.body.push({type:"ReturnStatement",argument:s})}};t(s.body,o),t(n.body,o);const r="__block_"+Ep++,i=[];for(const e of o){const t=e.split(".");let r={type:"Identifier",name:t[0]};for(let e=1;e<t.length;e++)r={type:"MemberExpression",object:r,property:{type:"Identifier",name:t[e]},computed:!1};let s={type:"Identifier",name:t[0]};for(let e=1;e<t.length;e++)s={type:"MemberExpression",object:s,property:{type:"Identifier",name:t[e]},computed:!1};i.push({type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:r,right:{type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsNode"},arguments:[s]}}})}i.push({type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:r},init:a}],kind:"const"});for(const e of o){const t=e.split(".");let s={type:"Identifier",name:t[0]};for(let e=1;e<t.length;e++)s={type:"MemberExpression",object:s,property:{type:"Identifier",name:t[e]},computed:!1};const n={type:"MemberExpression",object:{type:"Identifier",name:r},property:{type:"Literal",value:e},computed:!0};i.push({type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:s,right:n}})}e.type="BlockStatement",e.body=i}else e.type="ExpressionStatement",e.expression=a;delete e.test,delete e.consequent,delete e.alternate},UpdateExpression(e,t,r){if(r.some(Sp))return;let i;if("++"===e.operator)i="+";else{if("--"!==e.operator)return;i="-"}const s={type:"AssignmentExpression",operator:"=",left:e.argument,right:{type:"BinaryExpression",operator:i,left:e.argument,right:{type:"Literal",value:1}}};Object.assign(e,s),delete e.prefix,this.BinaryExpression(e.right,t,[...r,e]),this.AssignmentExpression(e,t,r)},ForStatement(e,t,r){if(r.some(Sp))return;const i="loopVar"+Dp++;let s;if(e.init&&"VariableDeclaration"===e.init.type){let t=e.init.declarations[0].init;t={type:"ExpressionStatement",expression:t}.expression,s={type:"ArrowFunctionExpression",params:[],body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:t}]}}}else s={type:"ArrowFunctionExpression",params:[],body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:{type:"Literal",value:0}}]}};let n=e.test||{type:"Literal",value:!0};if("VariableDeclaration"===e.init?.type){const t=e.init.declarations[0].id.name;n=this.replaceIdentifierReferences(n,t,i)}n={type:"ExpressionStatement",expression:n}.expression;const a={type:"ArrowFunctionExpression",params:[{type:"Identifier",name:i}],body:n};let o;if(e.update){let t=e.update;if("VariableDeclaration"===e.init?.type){const r=e.init.declarations[0].id.name;t=this.replaceIdentifierReferences(t,r,i)}t={type:"ExpressionStatement",expression:t}.expression,o={type:"ArrowFunctionExpression",params:[{type:"Identifier",name:i}],body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:t}]}}}else o={type:"ArrowFunctionExpression",params:[{type:"Identifier",name:i}],body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:{type:"Identifier",name:i}}]}};let h="BlockStatement"===e.body.type?e.body:{type:"BlockStatement",body:[e.body]};if("VariableDeclaration"===e.init?.type){const t=e.init.declarations[0].id.name;h=this.replaceIdentifierReferences(h,t,i)}const u={type:"ArrowFunctionExpression",params:[{type:"Identifier",name:i},{type:"Identifier",name:"vars"}],body:h},l=new Set,c=new Set;if(Rc(u.body,{VariableDeclarator(e,t){t.some(Fp)||"Identifier"===e.id.type&&c.add(e.id.name)}}),Rc(u.body,{AssignmentExpression(e,t){if(t.some(Fp))return;const r=e.left;if("Identifier"===r.type)c.has(r.name)||l.add(r.name);else if("MemberExpression"===r.type){const e=Mp(r);if(e){const t=e.split(".")[0];c.has(t)||l.add(e)}}}}),l.size>0){const t=(e,t)=>{if("BlockStatement"===e.type){const r=new Map,i=[];for(const e of t){const t=e.split("."),s=`__copy_${t.join("_")}_${Ep++}`;r.set(e,s);let n={type:"Identifier",name:"vars"};for(const e of t)n={type:"MemberExpression",object:n,property:{type:"Identifier",name:e},computed:!1};i.push({type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:s},init:{type:"CallExpression",callee:{type:"MemberExpression",object:n,property:{type:"Identifier",name:"copy"},computed:!1},arguments:[]}}],kind:"let"})}e.body.forEach(e=>kp(e,r)),e.body.unshift(...i);const s={type:"ObjectExpression",properties:Array.from(t).map(e=>({type:"Property",key:{type:"Literal",value:e},value:{type:"Identifier",name:r.get(e)},kind:"init",computed:!1,shorthand:!1}))};e.body.push({type:"ReturnStatement",argument:s})}};t(u.body,l);const r="__block_"+Ep++,i=[],n={type:"ObjectExpression",properties:Array.from(l).map(e=>{const t=e.split(".");let r={type:"Identifier",name:t[0]};for(let e=1;e<t.length;e++)r={type:"MemberExpression",object:r,property:{type:"Identifier",name:t[e]},computed:!1};return{type:"Property",key:{type:"Literal",value:e},value:{type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsNode"},arguments:[r]},kind:"init",computed:!1,shorthand:!1}})},h={type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsFor"},arguments:[s,a,o,u,n]};i.push({type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:r},init:h}],kind:"const"});for(const e of l){const t=e.split(".");let s={type:"Identifier",name:t[0]};for(let e=1;e<t.length;e++)s={type:"MemberExpression",object:s,property:{type:"Identifier",name:t[e]},computed:!1};let n={type:"Identifier",name:r};for(const e of t)n={type:"MemberExpression",object:n,property:{type:"Identifier",name:e},computed:!1};i.push({type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:s,right:n}})}e.type="BlockStatement",e.body=i}else e.type="ExpressionStatement",e.expression={type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsFor"},arguments:[s,a,o,u,{type:"ObjectExpression",properties:[]}]};delete e.init,delete e.test,delete e.update},replaceIdentifierReferences(e,t,r){if(!e||"object"!=typeof e)return e;const i=e=>{if(!e||"object"!=typeof e)return e;if("Identifier"===e.type&&e.name===t)return{...e,name:r};const s={...e};for(const t in e)e.hasOwnProperty(t)&&"parent"!==t&&(Array.isArray(e[t])?s[t]=e[t].map(i):"object"==typeof e[t]&&(s[t]=i(e[t])));return s};return i(e)}};function Bp(e,t,r){const i=t.filter(e=>null!==e.value.id);if(0===i.length)throw new Error(`No valid inputs for phi node for variable ${r}`);let s=i.map(t=>to(e.dag,t.value.id)).find(e=>e.dimension)??to(e.dag,i[0].value.id);const n=s.dimension,a=s.baseType,o={nodeType:wa.PHI,dimension:n,baseType:a,dependsOn:t.map(e=>e.value.id).filter(e=>null!==e),phiBlocks:t.map(e=>e.blockId)},h=Qa(e.dag,o);return ho(e.cfg,e.cfg.currentBlock,h),{id:h,dimension:n,baseType:a}}class Lp{constructor(e,t,r){this.branches=[{condition:t,branchCallback:r,blockType:Ya.IF_BODY}],this.ctx=e}ElseIf(e,t){return this.branches.push({condition:e,branchCallback:t,blockType:Ya.IF_BODY}),this}Else(e=()=>({})){this.branches.push({condition:null,branchCallback:e,blockType:Ya.IF_BODY});const t=function(e,t){const r=e.cfg,i=t.branches,s=ao(r,Ya.MERGE),n=[],a=[],o={},h={},u=ao(r,Ya.BRANCH);oo(r,r.currentBlock,u),oo(r,u,s);let l=u;for(let t=0;t<i.length;t++){const{condition:o,branchCallback:u,blockType:c}=i[t];if(null!==o){const e=ao(r,Ya.IF_COND);oo(r,l,e),io(r,e),r.blockConditions[e]=o.id,l=e,so(r)}else{const e=ao(r,Ya.ELSE_COND);oo(r,l,e),l=e}const p=ao(r,Ya.SCOPE_START);oo(r,l,p);const d=ao(r,c);oo(r,p,d),io(r,d);const f=u();for(const t in f)f[t]=e.p5.strandsNode(f[t]);for(const e in f)h[e]?h[e].push({value:f[e],blockId:d}):h[e]=[{value:f[e],blockId:d}];n.push(f);const g=ao(r,Ya.DEFAULT);oo(r,r.currentBlock,g),a.push(g),so(r);const m=ao(r,Ya.SCOPE_END);oo(r,g,m),oo(r,m,s),l=p}no(r,u);for(const t in h)o[t]=Bp(e,h[t],t);so(r);for(let t=0;t<n.length;t++){const i=n[t],s=a[t];no(r,s);for(const t in i)if(o[t]){const n=o[t].id,a=i[t].id,h={nodeType:wa.ASSIGNMENT,dependsOn:[n,a],phiBlocks:[]};ho(r,s,Qa(e.dag,h))}so(r)}return io(r,s),o}(this.ctx,this),r={};for(const[e,i]of Object.entries(t))r[e]=co(i.id,i.dimension,this.ctx);return r}}class Pp{constructor(e,t,r,i,s,n){this.strandsContext=e,this.initialCb=t,this.conditionCb=r,this.updateCb=i,this.bodyCb=s,this.initialVars=n}build(){const e=this.strandsContext.cfg,t=ao(e,Ya.MERGE),r=ao(e,Ya.BRANCH);oo(e,e.currentBlock,r),oo(e,r,t);const{initialVar:i,phiNode:s}=this.initializeLoopVariable(e,r);io(e,e.currentBlock);const n=co(s.id,s.dimension,this.strandsContext),a=this.conditionCb(n),o=this.updateCb(n);so(e),this.loopIsBounded(i,a,o)?this.buildBoundedLoop(e,r,t,i,s,a,o):this.buildUnboundedLoop(e,r,t,i,s,a,o);const h=this.phiNodesForBody;no(e,r);for(const[e,t]of Object.entries(this.bodyResults))if("loopVar"!==e&&h[e]){const r=h[e].id,i=to(this.strandsContext.dag,r);i.dependsOn.length>1&&(i.dependsOn[1]=t.id),i.phiInputs&&i.phiInputs.length>1&&(i.phiInputs[1].value=t)}so(e),no(e,r);for(const[t,i]of Object.entries(this.initialVars))if("loopVar"!==t&&h[t]){const s=h[t].id,n=i.id,a=eo({nodeType:wa.ASSIGNMENT,dependsOn:[s,n],phiBlocks:[]});ho(e,r,Qa(this.strandsContext.dag,a))}so(e),no(e,this.finalBodyBlock);for(const[t,r]of Object.entries(this.bodyResults))if("loopVar"!==t&&h[t]){const i=h[t].id,s=r.id,n=eo({nodeType:wa.ASSIGNMENT,dependsOn:[i,s],phiBlocks:[]}),a=Qa(this.strandsContext.dag,n);ho(e,this.finalBodyBlock,a)}so(e);const u={};for(const[e,t]of Object.entries(h))u[e]=co(t.id,t.dimension,this.strandsContext);return io(e,t),u}buildBoundedLoop(e,t,r,i,s,n,a){const o=ao(e,Ya.FOR);if(oo(e,t,o),io(e,o),i){const t=eo({nodeType:wa.ASSIGNMENT,dependsOn:[s.id,i.id],phiBlocks:[]});ho(e,o,Qa(this.strandsContext.dag,t))}const h=eo({nodeType:wa.STATEMENT,statementType:Fa,dependsOn:[n.id],phiBlocks:[]});ho(e,o,Qa(this.strandsContext.dag,h));const u=eo({nodeType:wa.ASSIGNMENT,dependsOn:[s.id,a.id],phiBlocks:[]});ho(e,o,Qa(this.strandsContext.dag,u)),so(e);const l=e.blockInstructions[o]||[],c=i?3:2;if(l.length!==c)throw new Error(`FOR block must have exactly ${c} statements, got ${l.length}`);const p=ao(e,Ya.SCOPE_START);oo(e,o,p);const d=ao(e,Ya.DEFAULT);this.bodyBlock=d,oo(e,p,d),this.executeBodyCallback(e,t,d,s);const f=ao(e,Ya.SCOPE_END);oo(e,d,f),oo(e,f,r)}buildUnboundedLoop(e,t,r,i,s,n,a){const o=ao(e,Ya.FOR);if(oo(e,t,o),io(e,o),i){const t=eo({nodeType:wa.ASSIGNMENT,dependsOn:[s.id,i.id],phiBlocks:[]});ho(e,o,Qa(this.strandsContext.dag,t))}else{const t=eo({nodeType:wa.STATEMENT,statementType:Ta,dependsOn:[],phiBlocks:[]});ho(e,o,Qa(this.strandsContext.dag,t))}const h=eo({nodeType:wa.STATEMENT,statementType:Ta,dependsOn:[],phiBlocks:[]});ho(e,o,Qa(this.strandsContext.dag,h));const u=eo({nodeType:wa.STATEMENT,statementType:Ta,dependsOn:[],phiBlocks:[]});ho(e,o,Qa(this.strandsContext.dag,u)),so(e);const l=ao(e,Ya.SCOPE_START);oo(e,o,l);const c=ao(e,Ya.DEFAULT);oo(e,l,c),io(e,c);const p=n,d=this.createLogicalNotNode(p),f=ao(e,Ya.IF_COND);oo(e,c,f),e.blockConditions[f]=d.id;const g=ao(e,Ya.SCOPE_START);oo(e,f,g);const m=ao(e,Ya.DEFAULT);oo(e,g,m),io(e,m);const y=eo({nodeType:wa.STATEMENT,statementType:Aa,dependsOn:[],phiBlocks:[]});ho(e,m,Qa(this.strandsContext.dag,y)),so(e);const x=ao(e,Ya.SCOPE_END);oo(e,m,x),oo(e,x,r),so(e);const v=ao(e,Ya.DEFAULT);this.bodyBlock=v,oo(e,c,v),this.executeBodyCallback(e,t,v,s);const b=ao(e,Ya.DEFAULT);oo(e,v,b),io(e,b);const _=eo({nodeType:wa.ASSIGNMENT,dependsOn:[s.id,a.id],phiBlocks:[]});ho(e,b,Qa(this.strandsContext.dag,_)),so(e);const w=ao(e,Ya.SCOPE_END);oo(e,b,w),oo(e,w,r),oo(e,c,r)}initializeLoopVariable(e,t){io(e,t);let r=this.initialCb();if(!(r instanceof lo)){const{id:e,dimension:t}=_o(this.strandsContext,{baseType:Ma,dimension:1},r);r=co(e,t,this.strandsContext)}const i=Bp(this.strandsContext,[{value:r,blockId:t},{value:r,blockId:t}],"loopVar");return so(e),{initialVar:r,phiNode:i}}createLogicalNotNode(e){const t=eo({nodeType:wa.OPERATION,opCode:100,baseType:Ia,dimension:1,dependsOn:[e.id],phiBlocks:[],usedBy:[]});return co(Qa(this.strandsContext.dag,t),1,this.strandsContext)}executeBodyCallback(e,t,r,i){io(e,r);const s={},n={};no(e,t);for(const[e,i]of Object.entries(this.initialVars))if("loopVar"!==e){const a=Bp(this.strandsContext,[{value:i,blockId:t},{value:i,blockId:r}],e);n[e]=a,s[e]=co(a.id,a.dimension,this.strandsContext)}so(e);const a=co(i.id,i.dimension,this.strandsContext);this.bodyResults=this.bodyCb(a,s)||{};for(const e in this.bodyResults)this.bodyResults[e]=this.strandsContext.p5.strandsNode(this.bodyResults[e]);this.phiNodesForBody=n,this.finalBodyBlock=e.currentBlock,so(e)}loopIsBounded(e,t,r){if(!t)return!1;const i=to(this.strandsContext.dag,t.id);if(i.nodeType!==wa.OPERATION)return!1;if(!i.dependsOn||2!==i.dependsOn.length)return!1;const s=co(i.dependsOn[0],1,this.strandsContext),n=co(i.dependsOn[1],1,this.strandsContext),a=this.nodeUsesOnlyLiterals(s),o=this.nodeUsesOnlyLiterals(n);return a||o}nodeUsesOnlyLiterals(e){const t=to(this.strandsContext.dag,e.id);switch(t.nodeType){case wa.LITERAL:return!0;case wa.VARIABLE:case wa.PHI:return!1;case wa.OPERATION:if(t.dependsOn)for(const e of t.dependsOn){const t=co(e,1,this.strandsContext);if(!this.nodeUsesOnlyLiterals(t))return!1}return!0;default:return!1}}}const Op={width:{typeInfo:Na.float1,get:e=>e.width},height:{typeInfo:Na.float1,get:e=>e.height},mouseX:{typeInfo:Na.float1,get:e=>e.mouseX},mouseY:{typeInfo:Na.float1,get:e=>e.mouseY},pmouseX:{typeInfo:Na.float1,get:e=>e.pmouseX},pmouseY:{typeInfo:Na.float1,get:e=>e.pmouseY},winMouseX:{typeInfo:Na.float1,get:e=>e.winMouseX},winMouseY:{typeInfo:Na.float1,get:e=>e.winMouseY},pwinMouseX:{typeInfo:Na.float1,get:e=>e.pwinMouseX},pwinMouseY:{typeInfo:Na.float1,get:e=>e.pwinMouseY},frameCount:{typeInfo:Na.float1,get:e=>e.frameCount},deltaTime:{typeInfo:Na.float1,get:e=>e.deltaTime},displayWidth:{typeInfo:Na.float1,get:e=>e.displayWidth},displayHeight:{typeInfo:Na.float1,get:e=>e.displayHeight},windowWidth:{typeInfo:Na.float1,get:e=>e.windowWidth},windowHeight:{typeInfo:Na.float1,get:e=>e.windowHeight},mouseIsPressed:{typeInfo:Na.bool1,get:e=>e.mouseIsPressed}};function Rp(e,t){const r=Op[t];if(!r)return null;const i=function(e){return e._builtinGlobals&&e._builtinGlobals.dag===e.dag||(e._builtinGlobals={dag:e.dag,nodes:new Map,uniformsAdded:new Set}),e._builtinGlobals}(e),s=`_p5_global_${t}`,n=i.nodes.get(s);if(n)return n;i.uniformsAdded.has(s)||(i.uniformsAdded.add(s),e.uniforms.push({name:s,typeInfo:r.typeInfo,defaultValue:()=>{const t=e.renderer?._pInst||e.p5?.instance;return t?r.get(t):void 0}}));const{id:a,dimension:o}=go(e,r.typeInfo,s),h=co(a,o,e);return h._originalBuiltinName=t,i.nodes.set(s,h),h}function Np(e,t){const r=[],i=e.dag;for(const s of t)if(Ua(s.type)){const t=Va(s),{id:n,dimension:a}=xo(e,t,s.name,[]),o=co(n,a,e).withStructProperties(t.properties.map(e=>e.name));for(let r=0;r<t.properties.length;r++){const n=t.properties[r];Object.defineProperty(o,n.name,{get(){const n=to(i,i.dependsOn[o.id][r]);return co(n.id,n.dimension,e,n=>{const a=i.dependsOn[o.id].slice();a[r]=n;const h=xo(e,t,s.name,a);o.id=h.id})},set(a){const h=[...i.dependsOn[o.id]];let u;u=a instanceof lo?a.id:_o(e,n.dataType,a).id,h[r]=u;const l=xo(e,t,s.name,h);o.id=l.id}})}r.push(o)}else{if("sampler"===s.type.typeName)continue;if(!s.type.dataType)throw new Error(`Missing dataType for parameter ${s.name} of type ${s.type.typeName}`);const t=s.type.dataType,{id:i,dimension:n}=go(e,t,s.name),a=co(i,n,e);r.push(a)}return r}function Vp(e,t,r,i){if(!(r instanceof lo))return _o(e,t,r).id;const s=e.dag;let n=r.id;const a=s.baseTypes[n],o=s.dimensions[n];return o!==t.dimension?1!==o?Za("type error",`You have returned a vector with ${o} components in ${i} when a ${t.baseType+t.dimension} was expected!`):n=_o(e,t,r).id:a!==t.baseType&&(n=_o(e,t,r).id),n}function Up(e,t){function r(t,r,{active:i=!1,renderer:s=null,baseShader:n=null}={}){t.dag=Ja(),t.cfg={blockTypes:[],incomingEdges:[],outgoingEdges:[],blockInstructions:[],nextID:0,blockStack:[],blockOrder:[],blockConditions:{},currentBlock:-1},t.uniforms=[],t.vertexDeclarations=new Set,t.fragmentDeclarations=new Set,t.hooks=[],t.globalAssignments=[],t.backend=r,t.active=i,t.renderer=s,t.baseShader=n,t.previousFES=e.disableFriendlyErrors,t.windowOverrides={},t.fnOverrides={},i&&(e.disableFriendlyErrors=!0),t.p5=e}t._runStrandsInGlobalMode=!1;const i={};r(i),function(e,t,r){for(const{name:t,arity:i,opCode:s}of qa)"binary"===i&&(lo.prototype[t]=function(...e){const{id:t,dimension:i}=yo(r,this,e,s);return co(t,i,r)}),"unary"===i&&(e[t]=function(e){const{id:t,dimension:i}=mo(r,e,s);return co(t,i,r)});t.discard=function(){Eo(r,Da)},t.break=function(){Eo(r,Aa)},e.break=t.break,t.instanceID=function(){const e=go(r,{baseType:ka,dimension:1},r.backend.instanceIdReference());return co(e.id,e.dimension,r)},e.strandsIf=function(e,t){return new Lp(r,e,t)},t.strandsIf=e.strandsIf,e.strandsFor=function(e,t,i,s,n){return new Pp(r,e,t,i,s,n).build()},t.strandsFor=e.strandsFor,e.strandsEarlyReturn=function(t){const{dag:i,cfg:s}=r;if(!r.activeHook)throw new Error("strandsEarlyReturn can only be used inside a hook callback");const n=t instanceof lo?t:e.strandsNode(t),a=ao(s,Ya.DEFAULT);oo(s,s.currentBlock,a),io(s,a);const o=Qa(i,eo({nodeType:wa.STATEMENT,statementType:Sa,dependsOn:[n.id]}));return ho(s,s.currentBlock,o),r.activeHook.earlyReturns.push({earlyReturnID:o,valueNode:n}),so(s),n},t.strandsEarlyReturn=e.strandsEarlyReturn,e.strandsNode=function(...e){if(1===e.length&&e[0]instanceof lo)return e[0];e.length>4&&Za("type error","It looks like you've tried to construct a p5.strands node implicitly, with more than 4 components. This is currently not supported.");const{id:t,dimension:i}=_o(r,{baseType:Ma,dimension:null},e.flat());return co(t,i,r)};for(const[i,s]of Object.entries(po))if(s[0].isp5Function){const e=t[i];t[i]=function(...t){if(r.active){const{id:e,dimension:s}=Co(r,i,t);return co(e,s,r)}return e.apply(this,t)}}else t[i]=function(...t){if(r.active){const{id:e,dimension:s}=Co(r,i,t);return co(e,s,r)}e._friendlyError(`It looks like you've called ${i} outside of a shader's modify() function.`)};t.getTexture=function(...t){if(r.active){const{id:e,dimension:i}=r.backend.createGetTextureCall(r,t);return co(e,i,r)}e._friendlyError("It looks like you've called getTexture outside of a shader's modify() function.")};const i=t.texture;t.texture=function(...e){return r.active?this.getTexture(...e):i.apply(this,e)};const s=t.noise,n=t.noiseDetail;r._noiseOctaves=null,r._noiseAmpFalloff=null,t.noiseDetail=function(e,t=.5){if(!r.active)return n.apply(this,arguments);r._noiseOctaves=e,r._noiseAmpFalloff=t},t.noise=function(...i){if(!r.active)return s.apply(this,i);const n=this._renderer.getNoiseShaderSnippet();r.vertexDeclarations.add(n),r.fragmentDeclarations.add(n);const a=i.flat().map(t=>e.strandsNode(t));let o;3===a.length?o=[t.vec3(a[0],a[1],a[2])]:2===a.length?o=[t.vec3(a[0],a[1],0)]:1===a.length&&a[0].dimension<=3?o=3===a[0].dimension?a:2===a[0].dimension?[t.vec3(a[0],0)]:[t.vec3(a[0],0,0)]:e._friendlyError(`It looks like you've called noise() with ${i.length} arguments. It only supports 1D to 3D input.`);const h=null!==r._noiseOctaves?r._noiseOctaves:t._getNoiseOctaves(),u=null!==r._noiseAmpFalloff?r._noiseAmpFalloff:t._getNoiseAmpFalloff();o.push(h),o.push(u);const{id:l,dimension:c}=Co(r,"noise",o,{overloads:[{params:[Na.float3,Na.int1,Na.float1],returnType:Na.float1}]});return co(l,c,r)};for(const i in Na){if(i===La||"sampler"===i)continue;const s=Na[i],n=[];let a;/^[ib]vec/.test(s.fnName)?(a=s.fnName.slice(0,2).toUpperCase()+s.fnName.slice(2).toLowerCase(),n.push(a.replace("Vec","Vector"))):(a=s.fnName.charAt(0).toUpperCase()+s.fnName.slice(1),"Sampler2D"===a?n.push("Texture"):/^vec/.test(s.fnName)&&n.push(a.replace("Vec","Vector"))),t[`uniform${a}`]=function(e,t){const{id:i,dimension:n}=go(r,s,e);return r.uniforms.push({name:e,typeInfo:s,defaultValue:t}),co(i,n,r)},t[`shared${a}`]=function(e){const{id:t,dimension:i}=go(r,s,e);return r.sharedVariables||(r.sharedVariables=new Map),r.sharedVariables.set(e,{typeInfo:s,usedInVertex:!1,usedInFragment:!1,declared:!1}),co(t,i,r)},t[`varying${a}`]=t[`shared${a}`];for(const e of n)t[`uniform${e}`]=t[`uniform${a}`],t[`varying${e}`]=t[`varying${a}`],t[`shared${e}`]=t[`shared${a}`];const o=t[s.fnName];t[s.fnName]=function(...t){if(r.active){if(1===t.length&&t[0].dimension&&t[0].dimension===s.dimension){const{id:e,dimension:i}=Co(r,s.fnName,t,{overloads:[{params:[t[0].typeInfo()],returnType:s}]});return co(e,i,r)}{!(s.dimension>1&&1===t.length)||Array.isArray(t[0])||t[0]instanceof lo&&t[0].dimension>1||s.baseType!==Ma&&s.baseType!==ka&&s.baseType!==Ia||(t=Array(s.dimension).fill(t[0]));const{id:e,dimension:i}=_o(r,s,t);return co(e,i,r)}}if(o)return o.apply(this,t);e._friendlyError(`It looks like you've called ${s.fnName} outside of a shader's modify() function.`)}}}(e,t,i);const s=e.Shader.prototype.modify;e.Shader.prototype.modify=function(n,a={}){try{if(n instanceof Function||"string"==typeof n){r(i,this._renderer.strandsBackend,{active:!0,renderer:this._renderer,baseShader:this}),function(e,t,r){!function(e){if(!e._builtinGlobalsAccessorsInstalled){for(const t of Object.keys(Op)){const r=Op[t];Object.defineProperty(window,t,{get:()=>{if(e.active)return Rp(e,t);const i=e.renderer?._pInst||e.p5?.instance;return r.get(i)}})}e._builtinGlobalsAccessorsInstalled=!0}}(e);const i={...Object.fromEntries(Object.entries(r.hooks.vertex).map(([e,t])=>[e,{...t,shaderContext:"vertex"}])),...Object.fromEntries(Object.entries(r.hooks.fragment).map(([e,t])=>[e,{...t,shaderContext:"fragment"}]))},s=Object.keys(i).map(e=>r.hookTypes(e)),{cfg:n,dag:a}=e;for(const o of s){const h=function(e){const t=l();h._result=e(...t)??h._result,c()};let u;function l(){e.activeHook=h,u=ao(n,Ya.FUNCTION),oo(n,n.currentBlock,u),io(n,u);const t=Np(e,o.parameters),r=o.parameters.filter(e=>e.type.properties).length;let i=-1;1===r&&(i=o.parameters.findIndex(e=>e.type.properties));for(let e=0;e<t.length;e++)if(e===i){for(const e of t[i].structProperties||[])Object.defineProperty(h,e,{get:()=>t[i][e],set(r){t[i][e]=r},enumerable:!0});o.returnType?.typeName===o.parameters[i].type.typeName&&h.set(t[i])}else h[o.parameters[e].name]=t[e];return t}function c(){const t=h._result;e.activeHook=void 0;const r=o.returnType;let s=null;const l=t=>{if(Ua(r)){const i=Va(r);if(t instanceof lo){const r=to(e.dag,t.id);r.baseType!==i.typeName&&Za("type error",`You have returned a ${t.baseType} from ${o.name} when a ${i.typeName} was expected.`);const s=r.dependsOn.slice();for(let n=0;n<i.properties.length;n++){const h=i.properties[n].dataType,u=co(r.dependsOn[n],a.dependsOn[t.id],e);s[n]=Vp(e,h,u,o.name)}return a.dependsOn[t.id]=s,t.id}{const s=i.properties,n=[];for(let i=0;i<s.length;i++){const a=s[i],h=t[a.name];void 0===h&&Za("type error",`You've returned an incomplete struct from ${o.name}.\nExpected: { ${r.properties.map(e=>e.name).join(", ")} }\nReceived: { ${Object.keys(t).join(", ")} }\nAll of the properties are required!`);const u=a.dataType,l=Vp(e,u,h,o.name);n.push(l)}return wo(e,i,n).id}}{if(!r.dataType)throw new Error(`Missing dataType for return type ${r.typeName}`);const i=r.dataType;return Vp(e,i,t,o.name)}};for(const{valueNode:e,earlyReturnID:t}of h.earlyReturns){const r=l(e);a.dependsOn[t]=[r]}s=t?l(t):void 0;const c=`${o.returnType.typeName} ${o.name}`,p=i[c];e.hooks.push({hookType:o,entryBlockID:u,rootNodeID:s,shaderContext:p?.shaderContext}),so(n)}h.set=function(e){h._result=e},h.begin=l,h.end=c;const p=[o.name];e.baseShader?.hooks?.hookAliases?.[o.name]&&p.push(...e.baseShader.hooks.hookAliases[o.name]);const d=/^get([A-Z0-9]\w*)$/.exec(o.name);if(d){const f=d[1][0].toLowerCase()+d[1].slice(1);t[f]||p.push(f)}for(const g of p)e.windowOverrides[g]=window[g],e.fnOverrides[g]=t[g],window[g]=h,t[g]=h;h.earlyReturns=[]}}(i,t,this);const o={srcLocations:!1};let h;{const t="string"==typeof n?`(${n})`:`(${n.toString()})`;h=function(e,t,r,i){Ep=0,Dp=0;const s=function(e,t){return Il.parse(e,t)}(t,{ecmaVersion:2021,locations:r}),n={...Ip};delete n.IfStatement,delete n.ForStatement,Rc(s,n,void 0,{varyings:{}}),function(e,t,r){var i=r?function(e){var t=Object.create(Uc);for(var r in e)t[r]=e[r];return t}(r):void 0;!function e(t,r,s){i[s||t.type](t,r,e)}(e,{varyings:{},inControlFlow:0},void 0)}(s,0,{IfStatement(e,t,r){t.inControlFlow++,e.test&&r(e.test,t),e.consequent&&r(e.consequent,t),e.alternate&&r(e.alternate,t),Ip.IfStatement(e,t,[]),t.inControlFlow--},ForStatement(e,t,r){t.inControlFlow++,e.init&&r(e.init,t),e.test&&r(e.test,t),e.update&&r(e.update,t),e.body&&r(e.body,t),Ip.ForStatement(e,t,[]),t.inControlFlow--},ReturnStatement(e,t,r){t.inControlFlow&&(e.type="ExpressionStatement",e.expression={type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsEarlyReturn"},arguments:e.argument?[e.argument]:[]},delete e.argument)}});const a=Cp.generate(s),o=Object.keys(i),h=/\(?\s*(?:function)?\s*\w*\s*\(([^)]*)\)\s*(?:=>)?\s*{((?:.|\n)*)}\s*;?\s*\)?/.exec(a);if(!h)throw console.log(a),new Error("Could not parse p5.strands function!");const u=h[1].split(/,\s*/).filter(e=>!!e.trim());let l,c;u.length>0?(c=u,l=[i]):(c=o,l=o.map(e=>i[e]));const p=h[2];try{const t=new Function("__p5",...c,p);return()=>t(e,...l)}catch(e){throw console.error(e),console.log(c),console.log(p),new Error("Error transpiling p5.strands callback!")}}(e,t,o.srcLocations,a)}const u=ao(i.cfg,Ya.GLOBAL);io(i.cfg,u),i.renderer?._pInst?._runStrandsInGlobalMode?function(e,r){if(e._isGlobal)return r();const i={};for(const r of Object.getOwnPropertyNames(t)){const s=Object.getOwnPropertyDescriptor(t,r);s&&!s.get&&"function"==typeof t[r]&&(i[r]=window[r],window[r]=t[r].bind(e))}try{r()}finally{for(const e in i)window[e]=i[e]}}(i.renderer._pInst,h):h(),so(i.cfg);const l=function(e){const{cfg:t,backend:r,vertexDeclarations:i,fragmentDeclarations:s}=e,n={uniforms:{},varyingVariables:[]};for(const{name:t,typeInfo:i,defaultValue:s}of e.uniforms){const e=r.generateHookUniformKey(t,i);null!==e&&(n.uniforms[e]=s)}r.addTextureBindingsToDeclarations&&r.addTextureBindingsToDeclarations(e);for(const{hookType:i,rootNodeID:s,entryBlockID:a,shaderContext:o}of e.hooks){const h={indent:1,codeLines:[],write(e){this.codeLines.push(" ".repeat(this.indent)+e)},tempNames:{},declarations:[],nextTempID:0,visitedNodes:new Set,shaderContext:o,strandsContext:e},u=uo(t.outgoingEdges,a);for(const t of u)r.generateBlock(t,e,h);for(const t of e.globalAssignments)h.visitedNodes.has(t)||(r.generateAssignment(h,e.dag,t),h.visitedNodes.add(t));e.globalAssignments=[];const l=r.hookEntry(i);let c;if(i.returnType.properties)c=Va(i.returnType);else{if(!i.returnType.dataType)throw new Error(`Missing dataType for return type ${i.returnType.typeName}`);c=i.returnType.dataType}s&&r.generateReturnStatement(e,h,s,c),n[`${i.returnType.typeName} ${i.name}`]=[l,...h.codeLines,"}"].join("\n")}if(e.sharedVariables)for(const[t,a]of e.sharedVariables)a.usedInVertex&&a.usedInFragment?n.varyingVariables.push(r.generateVaryingVariable(t,a.typeInfo)):a.usedInVertex?i.add(r.generateLocalDeclaration(t,a.typeInfo)):a.usedInFragment&&s.add(r.generateLocalDeclaration(t,a.typeInfo));return n.vertexDeclarations=[...i].join("\n"),n.fragmentDeclarations=[...s].join("\n"),n}(i);return s.call(this,l)}return s.call(this,n)}finally{!function(r){r.dag=Ja(),r.cfg={blockTypes:[],incomingEdges:[],outgoingEdges:[],blockInstructions:[],nextID:0,blockStack:[],blockOrder:[],blockConditions:{},currentBlock:-1},r.uniforms=[],r.vertexDeclarations=new Set,r.fragmentDeclarations=new Set,r.hooks=[],r.globalAssignments=[],r.active=!1,e.disableFriendlyErrors=r.previousFES;for(const e in r.windowOverrides)window[e]=r.windowOverrides[e];for(const e in r.fnOverrides)t[e]=r.fnOverrides[e]}(i)}}}function zp(e){return zp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},zp(e)}function Gp(e){var t=function(e){if("object"!=zp(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=zp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==zp(t)?t:t+""}function jp(e,t,r){return(t=Gp(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function $p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?Object(arguments[t]):{},i=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&i.push.apply(i,Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})),i.forEach(function(t){jp(e,t,r[t])})}return e}function Hp(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function qp(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,Gp(i.key),i)}}function Wp(e,t,r){return t&&qp(e.prototype,t),r&&qp(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Xp(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Yp(e,t){if(t&&("object"==zp(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Xp(e)}function Kp(e){return Kp=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Kp(e)}function Zp(e,t){return Zp=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Zp(e,t)}function Jp(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Zp(e,t)}void 0!==p5&&p5.registerAddon(Up);var Qp={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){console&&console[e]&&console[e].apply(console,t)}},ed=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Hp(this,e),this.init(t,r)}return Wp(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||Qp,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,r,i){return i&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(r).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,$p({},{prefix:"".concat(this.prefix,":").concat(t,":")},this.options))}}]),e}(),td=new ed,rd=function(){function e(){Hp(this,e),this.observers={}}return Wp(e,[{key:"on",value:function(e,t){var r=this;return e.split(" ").forEach(function(e){r.observers[e]=r.observers[e]||[],r.observers[e].push(t)}),this}},{key:"off",value:function(e,t){this.observers[e]&&(t?this.observers[e]=this.observers[e].filter(function(e){return e!==t}):delete this.observers[e])}},{key:"emit",value:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];this.observers[e]&&[].concat(this.observers[e]).forEach(function(e){e.apply(void 0,r)}),this.observers["*"]&&[].concat(this.observers["*"]).forEach(function(t){t.apply(t,[e].concat(r))})}}]),e}();function id(){var e,t,r=new Promise(function(r,i){e=r,t=i});return r.resolve=e,r.reject=t,r}function sd(e){return null==e?"":""+e}function nd(e,t,r){function i(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function s(){return!e||"string"==typeof e}for(var n="string"!=typeof t?[].concat(t):t.split(".");n.length>1;){if(s())return{};var a=i(n.shift());!e[a]&&r&&(e[a]=new r),e=Object.prototype.hasOwnProperty.call(e,a)?e[a]:{}}return s()?{}:{obj:e,k:i(n.shift())}}function ad(e,t,r){var i=nd(e,t,Object);i.obj[i.k]=r}function od(e,t){var r=nd(e,t),i=r.obj,s=r.k;if(i)return i[s]}function hd(e,t,r){var i=od(e,r);return void 0!==i?i:od(t,r)}function ud(e,t,r){for(var i in t)"__proto__"!==i&&"constructor"!==i&&(i in e?"string"==typeof e[i]||e[i]instanceof String||"string"==typeof t[i]||t[i]instanceof String?r&&(e[i]=t[i]):ud(e[i],t[i],r):e[i]=t[i]);return e}function ld(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var cd={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function pd(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,function(e){return cd[e]}):e}var dd="undefined"!=typeof window&&window.navigator&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,fd=function(e){function t(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return Hp(this,t),r=Yp(this,Kp(t).call(this)),dd&&rd.call(Xp(r)),r.data=e||{},r.options=i,void 0===r.options.keySeparator&&(r.options.keySeparator="."),r}return Jp(t,e),Wp(t,[{key:"addNamespaces",value:function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},s=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,n=[e,t];return r&&"string"!=typeof r&&(n=n.concat(r)),r&&"string"==typeof r&&(n=n.concat(s?r.split(s):r)),e.indexOf(".")>-1&&(n=e.split(".")),od(this.data,n)}},{key:"addResource",value:function(e,t,r,i){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},n=this.options.keySeparator;void 0===n&&(n=".");var a=[e,t];r&&(a=a.concat(n?r.split(n):r)),e.indexOf(".")>-1&&(i=t,t=(a=e.split("."))[1]),this.addNamespaces(t),ad(this.data,a,i),s.silent||this.emit("added",e,t,r,i)}},{key:"addResources",value:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var s in r)"string"!=typeof r[s]&&"[object Array]"!==Object.prototype.toString.apply(r[s])||this.addResource(e,t,s,r[s],{silent:!0});i.silent||this.emit("added",e,t,r)}},{key:"addResourceBundle",value:function(e,t,r,i,s){var n=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},a=[e,t];e.indexOf(".")>-1&&(i=r,r=t,t=(a=e.split("."))[1]),this.addNamespaces(t);var o=od(this.data,a)||{};i?ud(o,r,s):o=$p({},o,r),ad(this.data,a,o),n.silent||this.emit("added",e,t,r)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?$p({},{},this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"toJSON",value:function(){return this.data}}]),t}(rd),gd={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,r,i,s){var n=this;return e.forEach(function(e){n.processors[e]&&(t=n.processors[e].process(t,r,i,s))}),t}},md={},yd=function(e){function t(e){var r,i,s,n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Hp(this,t),r=Yp(this,Kp(t).call(this)),dd&&rd.call(Xp(r)),i=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],s=e,n=Xp(r),i.forEach(function(e){s[e]&&(n[e]=s[e])}),r.options=a,void 0===r.options.keySeparator&&(r.options.keySeparator="."),r.logger=td.create("translator"),r}return Jp(t,e),Wp(t,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}},r=this.resolve(e,t);return r&&void 0!==r.res}},{key:"extractFromKey",value:function(e,t){var r=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===r&&(r=":");var i=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,s=t.ns||this.options.defaultNS;if(r&&e.indexOf(r)>-1){var n=e.match(this.interpolator.nestingRegexp);if(n&&n.length>0)return{key:e,namespaces:s};var a=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(a[0])>-1)&&(s=a.shift()),e=a.join(i)}return"string"==typeof s&&(s=[s]),{key:e,namespaces:s}}},{key:"translate",value:function(e,r,i){var s=this;if("object"!==zp(r)&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),r||(r={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var n=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,a=this.extractFromKey(e[e.length-1],r),o=a.key,h=a.namespaces,u=h[h.length-1],l=r.lng||this.language,c=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(l&&"cimode"===l.toLowerCase()){if(c){var p=r.nsSeparator||this.options.nsSeparator;return u+p+o}return o}var d=this.resolve(e,r),f=d&&d.res,g=d&&d.usedKey||o,m=d&&d.exactUsedKey||o,y=Object.prototype.toString.apply(f),x=void 0!==r.joinArrays?r.joinArrays:this.options.joinArrays,v=!this.i18nFormat||this.i18nFormat.handleAsObject;if(v&&f&&"string"!=typeof f&&"boolean"!=typeof f&&"number"!=typeof f&&["[object Number]","[object Function]","[object RegExp]"].indexOf(y)<0&&("string"!=typeof x||"[object Array]"!==y)){if(!r.returnObjects&&!this.options.returnObjects)return this.logger.warn("accessing an object - but returnObjects options is not enabled!"),this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,f,r):"key '".concat(o," (").concat(this.language,")' returned an object instead of string.");if(n){var b="[object Array]"===y,_=b?[]:{},w=b?m:g;for(var C in f)if(Object.prototype.hasOwnProperty.call(f,C)){var E="".concat(w).concat(n).concat(C);_[C]=this.translate(E,$p({},r,{joinArrays:!1,ns:h})),_[C]===E&&(_[C]=f[C])}f=_}}else if(v&&"string"==typeof x&&"[object Array]"===y)(f=f.join(x))&&(f=this.extendTranslation(f,e,r,i));else{var D=!1,A=!1,S=void 0!==r.count&&"string"!=typeof r.count,F=t.hasDefaultValue(r),T=S?this.pluralResolver.getSuffix(l,r.count):"",M=r["defaultValue".concat(T)]||r.defaultValue;!this.isValidLookup(f)&&F&&(D=!0,f=M),this.isValidLookup(f)||(A=!0,f=o);var k=F&&M!==f&&this.options.updateMissing;if(A||D||k){if(this.logger.log(k?"updateKey":"missingKey",l,u,o,k?M:f),n){var I=this.resolve(o,$p({},r,{keySeparator:!1}));I&&I.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var B=[],L=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if("fallback"===this.options.saveMissingTo&&L&&L[0])for(var P=0;P<L.length;P++)B.push(L[P]);else"all"===this.options.saveMissingTo?B=this.languageUtils.toResolveHierarchy(r.lng||this.language):B.push(r.lng||this.language);var O=function(e,t,i){s.options.missingKeyHandler?s.options.missingKeyHandler(e,u,t,k?i:f,k,r):s.backendConnector&&s.backendConnector.saveMissing&&s.backendConnector.saveMissing(e,u,t,k?i:f,k,r),s.emit("missingKey",e,u,t,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&S?B.forEach(function(e){s.pluralResolver.getSuffixes(e).forEach(function(t){O([e],o+t,r["defaultValue".concat(t)]||M)})}):O(B,o,M))}f=this.extendTranslation(f,e,r,d,i),A&&f===o&&this.options.appendNamespaceToMissingKey&&(f="".concat(u,":").concat(o)),A&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(f))}return f}},{key:"extendTranslation",value:function(e,t,r,i,s){var n=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,r,i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init($p({},r,{interpolation:$p({},this.options.interpolation,r.interpolation)}));var a,o=r.interpolation&&r.interpolation.skipOnVariables||this.options.interpolation.skipOnVariables;if(o){var h=e.match(this.interpolator.nestingRegexp);a=h&&h.length}var u=r.replace&&"string"!=typeof r.replace?r.replace:r;if(this.options.interpolation.defaultVariables&&(u=$p({},this.options.interpolation.defaultVariables,u)),e=this.interpolator.interpolate(e,u,r.lng||this.language,r),o){var l=e.match(this.interpolator.nestingRegexp);a<(l&&l.length)&&(r.nest=!1)}!1!==r.nest&&(e=this.interpolator.nest(e,function(){for(var e=arguments.length,i=new Array(e),a=0;a<e;a++)i[a]=arguments[a];return s&&s[0]===i[0]&&!r.context?(n.logger.warn("It seems you are nesting recursively key: ".concat(i[0]," in key: ").concat(t[0])),null):n.translate.apply(n,i.concat([t]))},r)),r.interpolation&&this.interpolator.reset()}var c=r.postProcess||this.options.postProcess,p="string"==typeof c?[c]:c;return null!=e&&p&&p.length&&!1!==r.applyPostProcessor&&(e=gd.handle(p,e,t,this.options&&this.options.postProcessPassResolved?$p({i18nResolved:i},r):r,this)),e}},{key:"resolve",value:function(e){var t,r,i,s,n,a=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach(function(e){if(!a.isValidLookup(t)){var h=a.extractFromKey(e,o),u=h.key;r=u;var l=h.namespaces;a.options.fallbackNS&&(l=l.concat(a.options.fallbackNS));var c=void 0!==o.count&&"string"!=typeof o.count,p=void 0!==o.context&&"string"==typeof o.context&&""!==o.context,d=o.lngs?o.lngs:a.languageUtils.toResolveHierarchy(o.lng||a.language,o.fallbackLng);l.forEach(function(e){a.isValidLookup(t)||(n=e,!md["".concat(d[0],"-").concat(e)]&&a.utils&&a.utils.hasLoadedNamespace&&!a.utils.hasLoadedNamespace(n)&&(md["".concat(d[0],"-").concat(e)]=!0,a.logger.warn('key "'.concat(r,'" for languages "').concat(d.join(", "),'" won\'t get resolved as namespace "').concat(n,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),d.forEach(function(r){if(!a.isValidLookup(t)){s=r;var n,h,l=u,d=[l];for(a.i18nFormat&&a.i18nFormat.addLookupKeys?a.i18nFormat.addLookupKeys(d,u,r,e,o):(c&&(n=a.pluralResolver.getSuffix(r,o.count)),c&&p&&d.push(l+n),p&&d.push(l+="".concat(a.options.contextSeparator).concat(o.context)),c&&d.push(l+=n));h=d.pop();)a.isValidLookup(t)||(i=h,t=a.getResource(r,e,h,o))}}))})}}),{res:t,usedKey:r,exactUsedKey:i,usedLng:s,usedNS:n}}},{key:"isValidLookup",value:function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,r,i):this.resourceStore.getResource(e,t,r,i)}}],[{key:"hasDefaultValue",value:function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&"defaultValue"===t.substring(0,12)&&void 0!==e[t])return!0;return!1}}]),t}(rd);function xd(e){return e.charAt(0).toUpperCase()+e.slice(1)}var vd=function(){function e(t){Hp(this,e),this.options=t,this.whitelist=this.options.supportedLngs||!1,this.supportedLngs=this.options.supportedLngs||!1,this.logger=td.create("languageUtils")}return Wp(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],r=e.split("-");return this.options.lowerCaseLng?r=r.map(function(e){return e.toLowerCase()}):2===r.length?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),t.indexOf(r[1].toLowerCase())>-1&&(r[1]=xd(r[1].toLowerCase()))):3===r.length&&(r[0]=r[0].toLowerCase(),2===r[1].length&&(r[1]=r[1].toUpperCase()),"sgn"!==r[0]&&2===r[2].length&&(r[2]=r[2].toUpperCase()),t.indexOf(r[1].toLowerCase())>-1&&(r[1]=xd(r[1].toLowerCase())),t.indexOf(r[2].toLowerCase())>-1&&(r[2]=xd(r[2].toLowerCase()))),r.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isWhitelisted",value:function(e){return this.logger.deprecate("languageUtils.isWhitelisted",'function "isWhitelisted" will be renamed to "isSupportedCode" in the next major - please make sure to rename it\'s usage asap.'),this.isSupportedCode(e)}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,r=this;return e?(e.forEach(function(e){if(!t){var i=r.formatLanguageCode(e);r.options.supportedLngs&&!r.isSupportedCode(i)||(t=i)}}),!t&&this.options.supportedLngs&&e.forEach(function(e){if(!t){var i=r.getLanguagePartFromCode(e);if(r.isSupportedCode(i))return t=i;t=r.options.supportedLngs.find(function(e){if(0===e.indexOf(i))return e})}}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var r=e[t];return r||(r=e[this.getScriptPartFromCode(t)]),r||(r=e[this.formatLanguageCode(t)]),r||(r=e[this.getLanguagePartFromCode(t)]),r||(r=e.default),r||[]}},{key:"toResolveHierarchy",value:function(e,t){var r=this,i=this.getFallbackCodes(t||this.options.fallbackLng||[],e),s=[],n=function(e){e&&(r.isSupportedCode(e)?s.push(e):r.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&n(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&n(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&n(this.getLanguagePartFromCode(e))):"string"==typeof e&&n(this.formatLanguageCode(e)),i.forEach(function(e){s.indexOf(e)<0&&n(r.formatLanguageCode(e))}),s}}]),e}(),bd=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","kk","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],_d={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1&&e%100!=11?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},wd=function(){function e(t){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Hp(this,e),this.languageUtils=t,this.options=i,this.logger=td.create("pluralResolver"),this.rules=(r={},bd.forEach(function(e){e.lngs.forEach(function(t){r[t]={numbers:e.nr,plurals:_d[e.fc]}})}),r)}return Wp(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=this.getRule(e);return t&&t.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){return this.getSuffixes(e).map(function(e){return t+e})}},{key:"getSuffixes",value:function(e){var t=this,r=this.getRule(e);return r?r.numbers.map(function(r){return t.getSuffix(e,r)}):[]}},{key:"getSuffix",value:function(e,t){var r=this,i=this.getRule(e);if(i){var s=i.noAbs?i.plurals(t):i.plurals(Math.abs(t)),n=i.numbers[s];this.options.simplifyPluralSuffix&&2===i.numbers.length&&1===i.numbers[0]&&(2===n?n="plural":1===n&&(n=""));var a=function(){return r.options.prepend&&n.toString()?r.options.prepend+n.toString():n.toString()};return"v1"===this.options.compatibilityJSON?1===n?"":"number"==typeof n?"_plural_".concat(n.toString()):a():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===i.numbers.length&&1===i.numbers[0]?a():this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString()}return this.logger.warn("no plural rule found for: ".concat(e)),""}}]),e}(),Cd=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Hp(this,e),this.logger=td.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return Wp(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:pd,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?ld(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?ld(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?ld(t.nestingPrefix):t.nestingPrefixEscaped||ld("$t("),this.nestingSuffix=t.nestingSuffix?ld(t.nestingSuffix):t.nestingSuffixEscaped||ld(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(t,"g");var r="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(r,"g")}},{key:"interpolate",value:function(e,t,r,i){var s,n,a,o=this,h=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function u(e){return e.replace(/\$/g,"$$$$")}var l=function(e){if(e.indexOf(o.formatSeparator)<0){var s=hd(t,h,e);return o.alwaysFormat?o.format(s,void 0,r):s}var n=e.split(o.formatSeparator),a=n.shift().trim(),u=n.join(o.formatSeparator).trim();return o.format(hd(t,h,a),u,r,i)};this.resetRegExp();var c=i&&i.missingInterpolationHandler||this.options.missingInterpolationHandler,p=i&&i.interpolation&&i.interpolation.skipOnVariables||this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return u(e)}},{regex:this.regexp,safeValue:function(e){return o.escapeValue?u(o.escape(e)):u(e)}}].forEach(function(t){for(a=0;s=t.regex.exec(e);){if(void 0===(n=l(s[1].trim())))if("function"==typeof c){var r=c(e,s,i);n="string"==typeof r?r:""}else{if(p){n=s[0];continue}o.logger.warn("missed to pass in variable ".concat(s[1]," for interpolating ").concat(e)),n=""}else"string"==typeof n||o.useRawValueToEscape||(n=sd(n));if(e=e.replace(s[0],t.safeValue(n)),t.regex.lastIndex=0,++a>=o.maxReplaces)break}}),e}},{key:"nest",value:function(e,t){var r,i,s=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=$p({},n);function o(e,t){var r=this.nestingOptionsSeparator;if(e.indexOf(r)<0)return e;var i=e.split(new RegExp("".concat(r,"[ ]*{"))),s="{".concat(i[1]);e=i[0],s=(s=this.interpolate(s,a)).replace(/'/g,'"');try{a=JSON.parse(s),t&&(a=$p({},t,a))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(r).concat(s)}return delete a.defaultValue,e}for(a.applyPostProcessor=!1,delete a.defaultValue;r=this.nestingRegexp.exec(e);){var h=[],u=!1;if(r[0].includes(this.formatSeparator)&&!/{.*}/.test(r[1])){var l=r[1].split(this.formatSeparator).map(function(e){return e.trim()});r[1]=l.shift(),h=l,u=!0}if((i=t(o.call(this,r[1].trim(),a),a))&&r[0]===e&&"string"!=typeof i)return i;"string"!=typeof i&&(i=sd(i)),i||(this.logger.warn("missed to resolve ".concat(r[1]," for nesting ").concat(e)),i=""),u&&(i=h.reduce(function(e,t){return s.format(e,t,n.lng,n)},i.trim())),e=e.replace(r[0],i),this.regexp.lastIndex=0}return e}}]),e}(),Ed=function(e){function t(e,r,i){var s,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return Hp(this,t),s=Yp(this,Kp(t).call(this)),dd&&rd.call(Xp(s)),s.backend=e,s.store=r,s.services=i,s.languageUtils=i.languageUtils,s.options=n,s.logger=td.create("backendConnector"),s.state={},s.queue=[],s.backend&&s.backend.init&&s.backend.init(i,n.backend,n),s}return Jp(t,e),Wp(t,[{key:"queueLoad",value:function(e,t,r,i){var s=this,n=[],a=[],o=[],h=[];return e.forEach(function(e){var i=!0;t.forEach(function(t){var o="".concat(e,"|").concat(t);!r.reload&&s.store.hasResourceBundle(e,t)?s.state[o]=2:s.state[o]<0||(1===s.state[o]?a.indexOf(o)<0&&a.push(o):(s.state[o]=1,i=!1,a.indexOf(o)<0&&a.push(o),n.indexOf(o)<0&&n.push(o),h.indexOf(t)<0&&h.push(t)))}),i||o.push(e)}),(n.length||a.length)&&this.queue.push({pending:a,loaded:{},errors:[],callback:i}),{toLoad:n,pending:a,toLoadLanguages:o,toLoadNamespaces:h}}},{key:"loaded",value:function(e,t,r){var i=e.split("|"),s=i[0],n=i[1];t&&this.emit("failedLoading",s,n,t),r&&this.store.addResourceBundle(s,n,r),this.state[e]=t?-1:2;var a={};this.queue.forEach(function(r){!function(e,t,r){var i=nd(e,t,Object),s=i.obj,n=i.k;s[n]=s[n]||[],s[n].push(r)}(r.loaded,[s],n),function(e,t){for(var r=e.indexOf(t);-1!==r;)e.splice(r,1),r=e.indexOf(t)}(r.pending,e),t&&r.errors.push(t),0!==r.pending.length||r.done||(Object.keys(r.loaded).forEach(function(e){a[e]||(a[e]=[]),r.loaded[e].length&&r.loaded[e].forEach(function(t){a[e].indexOf(t)<0&&a[e].push(t)})}),r.done=!0,r.errors.length?r.callback(r.errors):r.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(function(e){return!e.done})}},{key:"read",value:function(e,t,r){var i=this,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:350,a=arguments.length>5?arguments[5]:void 0;return e.length?this.backend[r](e,t,function(o,h){o&&h&&s<5?setTimeout(function(){i.read.call(i,e,t,r,s+1,2*n,a)},n):a(o,h)}):a(null,{})}},{key:"prepareLoading",value:function(e,t){var r=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var n=this.queueLoad(e,t,i,s);if(!n.toLoad.length)return n.pending.length||s(),null;n.toLoad.forEach(function(e){r.loadOne(e)})}},{key:"load",value:function(e,t,r){this.prepareLoading(e,t,{},r)}},{key:"reload",value:function(e,t,r){this.prepareLoading(e,t,{reload:!0},r)}},{key:"loadOne",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=e.split("|"),s=i[0],n=i[1];this.read(s,n,"read",void 0,void 0,function(i,a){i&&t.logger.warn("".concat(r,"loading namespace ").concat(n," for language ").concat(s," failed"),i),!i&&a&&t.logger.log("".concat(r,"loaded namespace ").concat(n," for language ").concat(s),a),t.loaded(e,i,a)})}},{key:"saveMissing",value:function(e,t,r,i,s){var n=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t)?this.logger.warn('did not save key "'.concat(r,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"):null!=r&&""!==r&&(this.backend&&this.backend.create&&this.backend.create(e,t,r,i,null,$p({},n,{isUpdate:s})),e&&e[0]&&this.store.addResource(e[0],t,r,i))}}]),t}(rd);function Dd(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.whitelist&&(e.whitelist&&e.whitelist.indexOf("cimode")<0&&(e.whitelist=e.whitelist.concat(["cimode"])),e.supportedLngs=e.whitelist),e.nonExplicitWhitelist&&(e.nonExplicitSupportedLngs=e.nonExplicitWhitelist),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function Ad(){}var Sd,Fd=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;if(Hp(this,t),e=Yp(this,Kp(t).call(this)),dd&&rd.call(Xp(e)),e.options=Dd(r),e.services={},e.logger=td,e.modules={external:[]},i&&!e.isInitialized&&!r.isClone){if(!e.options.initImmediate)return e.init(r,i),Yp(e,Xp(e));setTimeout(function(){e.init(r,i)},0)}return e}return Jp(t,e),Wp(t,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;function i(e){return e?"function"==typeof e?new e:e:null}if("function"==typeof t&&(r=t,t={}),t.whitelist&&!t.supportedLngs&&this.logger.deprecate("whitelist",'option "whitelist" will be renamed to "supportedLngs" in the next major - please make sure to rename this option asap.'),t.nonExplicitWhitelist&&!t.nonExplicitSupportedLngs&&this.logger.deprecate("whitelist",'options "nonExplicitWhitelist" will be renamed to "nonExplicitSupportedLngs" in the next major - please make sure to rename this option asap.'),this.options=$p({},{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,whitelist:!1,nonExplicitWhitelist:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===zp(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===zp(e[2])||"object"===zp(e[3])){var r=e[3]||e[2];Object.keys(r).forEach(function(e){t[e]=r[e]})}return t},interpolation:{escapeValue:!0,format:function(e,t,r,i){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!1}},this.options,Dd(t)),this.format=this.options.interpolation.format,r||(r=Ad),!this.options.isClone){this.modules.logger?td.init(i(this.modules.logger),this.options):td.init(null,this.options);var s=new vd(this.options);this.store=new fd(this.options.resources,this.options);var n=this.services;n.logger=td,n.resourceStore=this.store,n.languageUtils=s,n.pluralResolver=new wd(s,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),n.interpolator=new Cd(this.options),n.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},n.backendConnector=new Ed(i(this.modules.backend),n.resourceStore,n,this.options),n.backendConnector.on("*",function(t){for(var r=arguments.length,i=new Array(r>1?r-1:0),s=1;s<r;s++)i[s-1]=arguments[s];e.emit.apply(e,[t].concat(i))}),this.modules.languageDetector&&(n.languageDetector=i(this.modules.languageDetector),n.languageDetector.init(n,this.options.detection,this.options)),this.modules.i18nFormat&&(n.i18nFormat=i(this.modules.i18nFormat),n.i18nFormat.init&&n.i18nFormat.init(this)),this.translator=new yd(this.services,this.options),this.translator.on("*",function(t){for(var r=arguments.length,i=new Array(r>1?r-1:0),s=1;s<r;s++)i[s-1]=arguments[s];e.emit.apply(e,[t].concat(i))}),this.modules.external.forEach(function(t){t.init&&t.init(e)})}if(this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var a=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);a.length>0&&"dev"!==a[0]&&(this.options.lng=a[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(function(t){e[t]=function(){var r;return(r=e.store)[t].apply(r,arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(function(t){e[t]=function(){var r;return(r=e.store)[t].apply(r,arguments),e}});var o=id(),h=function(){var t=function(t,i){e.isInitialized&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),o.resolve(i),r(t,i)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?h():setTimeout(h,0),o}},{key:"loadResources",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ad,i="string"==typeof e?e:this.language;if("function"==typeof e&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i&&"cimode"===i.toLowerCase())return r();var s=[],n=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach(function(e){s.indexOf(e)<0&&s.push(e)})};i?n(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(function(e){return n(e)}),this.options.preload&&this.options.preload.forEach(function(e){return n(e)}),this.services.backendConnector.load(s,this.options.ns,r)}else r(null)}},{key:"reloadResources",value:function(e,t,r){var i=id();return e||(e=this.languages),t||(t=this.options.ns),r||(r=Ad),this.services.backendConnector.reload(e,t,function(e){i.resolve(),r(e)}),i}},{key:"use",value:function(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&gd.addPostProcessor(e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"changeLanguage",value:function(e,t){var r=this;this.isLanguageChangingTo=e;var i=id();this.emit("languageChanging",e);var s=function(e){var s="string"==typeof e?e:r.services.languageUtils.getBestMatchFromCodes(e);s&&(r.language||(r.language=s,r.languages=r.services.languageUtils.toResolveHierarchy(s)),r.translator.language||r.translator.changeLanguage(s),r.services.languageDetector&&r.services.languageDetector.cacheUserLanguage(s)),r.loadResources(s,function(e){!function(e,s){s?(r.language=s,r.languages=r.services.languageUtils.toResolveHierarchy(s),r.translator.changeLanguage(s),r.isLanguageChangingTo=void 0,r.emit("languageChanged",s),r.logger.log("languageChanged",s)):r.isLanguageChangingTo=void 0,i.resolve(function(){return r.t.apply(r,arguments)}),t&&t(e,function(){return r.t.apply(r,arguments)})}(e,s)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(s):s(e):s(this.services.languageDetector.detect()),i}},{key:"getFixedT",value:function(e,t){var r=this,i=function e(t,i){var s;if("object"!==zp(i)){for(var n=arguments.length,a=new Array(n>2?n-2:0),o=2;o<n;o++)a[o-2]=arguments[o];s=r.options.overloadTranslationOptionHandler([t,i].concat(a))}else s=$p({},i);return s.lng=s.lng||e.lng,s.lngs=s.lngs||e.lngs,s.ns=s.ns||e.ns,r.t(t,s)};return"string"==typeof e?i.lng=e:i.lngs=e,i.ns=t,i}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var i=this.languages[0],s=!!this.options&&this.options.fallbackLng,n=this.languages[this.languages.length-1];if("cimode"===i.toLowerCase())return!0;var a=function(e,r){var i=t.services.backendConnector.state["".concat(e,"|").concat(r)];return-1===i||2===i};if(r.precheck){var o=r.precheck(this,a);if(void 0!==o)return o}return!!this.hasResourceBundle(i,e)||!this.services.backendConnector.backend||!(!a(i,e)||s&&!a(n,e))}},{key:"loadNamespaces",value:function(e,t){var r=this,i=id();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach(function(e){r.options.ns.indexOf(e)<0&&r.options.ns.push(e)}),this.loadResources(function(e){i.resolve(),t&&t(e)}),i):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var r=id();"string"==typeof e&&(e=[e]);var i=this.options.preload||[],s=e.filter(function(e){return i.indexOf(e)<0});return s.length?(this.options.preload=i.concat(s),this.loadResources(function(e){r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){return e||(e=this.languages&&this.languages.length>0?this.languages[0]:this.language),e?["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam"].indexOf(this.services.languageUtils.getLanguagePartFromCode(e))>=0?"rtl":"ltr":"rtl"}},{key:"createInstance",value:function(){return new t(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}},{key:"cloneInstance",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ad,s=$p({},this.options,r,{isClone:!0}),n=new t(s);return["store","services","language"].forEach(function(t){n[t]=e[t]}),n.services=$p({},this.services),n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n.translator=new yd(n.services,n.options),n.translator.on("*",function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];n.emit.apply(n,[e].concat(r))}),n.init(s,i),n.translator.options=n.options,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}}]),t}(rd),Td=(new Fd,[]),Md=Td.forEach,kd=Td.slice,Id={name:"cookie",lookup:function(e){var t;if(e.lookupCookie&&"undefined"!=typeof document){var r=function(e){for(var t=e+"=",r=document.cookie.split(";"),i=0;i<r.length;i++){for(var s=r[i];" "===s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return s.substring(t.length,s.length)}return null}(e.lookupCookie);r&&(t=r)}return t},cacheUserLanguage:function(e,t){t.lookupCookie&&"undefined"!=typeof document&&function(e,t,r,i){var s,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{path:"/"};if(r){var a=new Date;a.setTime(a.getTime()+60*r*1e3),s="; expires="+a.toUTCString()}else s="";i=i?"domain="+i+";":"",n=Object.keys(n).reduce(function(e,t){return e+";"+t.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})+"="+n[t]},""),document.cookie=e+"="+encodeURIComponent(t)+s+";"+i+n}(t.lookupCookie,e,t.cookieMinutes,t.cookieDomain,t.cookieOptions)}},Bd={name:"querystring",lookup:function(e){var t;if("undefined"!=typeof window)for(var r=window.location.search.substring(1).split("&"),i=0;i<r.length;i++){var s=r[i].indexOf("=");s>0&&r[i].substring(0,s)===e.lookupQuerystring&&(t=r[i].substring(s+1))}return t}};try{Sd="undefined"!==window&&null!==window.localStorage;var Ld="i18next.translate.boo";window.localStorage.setItem(Ld,"foo"),window.localStorage.removeItem(Ld)}catch(e){Sd=!1}var Pd,Od={name:"localStorage",lookup:function(e){var t;if(e.lookupLocalStorage&&Sd){var r=window.localStorage.getItem(e.lookupLocalStorage);r&&(t=r)}return t},cacheUserLanguage:function(e,t){t.lookupLocalStorage&&Sd&&window.localStorage.setItem(t.lookupLocalStorage,e)}};try{Pd="undefined"!==window&&null!==window.sessionStorage;var Rd="i18next.translate.boo";window.sessionStorage.setItem(Rd,"foo"),window.sessionStorage.removeItem(Rd)}catch(e){Pd=!1}var Nd={name:"sessionStorage",lookup:function(e){var t;if(e.lookupsessionStorage&&Pd){var r=window.sessionStorage.getItem(e.lookupsessionStorage);r&&(t=r)}return t},cacheUserLanguage:function(e,t){t.lookupsessionStorage&&Pd&&window.sessionStorage.setItem(t.lookupsessionStorage,e)}},Vd={name:"navigator",lookup:function(e){var t=[];if("undefined"!=typeof navigator){if(navigator.languages)for(var r=0;r<navigator.languages.length;r++)t.push(navigator.languages[r]);navigator.userLanguage&&t.push(navigator.userLanguage),navigator.language&&t.push(navigator.language)}return t.length>0?t:void 0}},Ud={name:"htmlTag",lookup:function(e){var t,r=e.htmlTag||("undefined"!=typeof document?document.documentElement:null);return r&&"function"==typeof r.getAttribute&&(t=r.getAttribute("lang")),t}},zd={name:"path",lookup:function(e){var t;if("undefined"!=typeof window){var r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(r instanceof Array)if("number"==typeof e.lookupFromPathIndex){if("string"!=typeof r[e.lookupFromPathIndex])return;t=r[e.lookupFromPathIndex].replace("/","")}else t=r[0].replace("/","")}return t}},Gd={name:"subdomain",lookup:function(e){var t;if("undefined"!=typeof window){var r=window.location.href.match(/(?:http[s]*\:\/\/)*(.*?)\.(?=[^\/]*\..{2,5})/gi);r instanceof Array&&(t="number"==typeof e.lookupFromSubdomainIndex?r[e.lookupFromSubdomainIndex].replace("http://","").replace("https://","").replace(".",""):r[0].replace("http://","").replace("https://","").replace(".",""))}return t}},jd=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Hp(this,e),this.type="languageDetector",this.detectors={},this.init(t,r)}return Wp(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.services=e,this.options=function(e){return Md.call(kd.call(arguments,1),function(t){if(t)for(var r in t)void 0===e[r]&&(e[r]=t[r])}),e}(t,this.options||{},{order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],checkWhitelist:!0,checkForSimilarInWhitelist:!1}),this.options.checkForSimilarInWhitelist&&(this.options.checkWhitelist=!0),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=r,this.addDetector(Id),this.addDetector(Bd),this.addDetector(Od),this.addDetector(Nd),this.addDetector(Vd),this.addDetector(Ud),this.addDetector(zd),this.addDetector(Gd)}},{key:"addDetector",value:function(e){this.detectors[e.name]=e}},{key:"detect",value:function(e){var t=this;e||(e=this.options.order);var r,i=[];if(e.forEach(function(e){if(t.detectors[e]){var r=t.detectors[e].lookup(t.options);r&&"string"==typeof r&&(r=[r]),r&&(i=i.concat(r))}}),i.forEach(function(e){if(!r){var i=t.services.languageUtils.formatLanguageCode(e);t.options.checkWhitelist&&!t.services.languageUtils.isWhitelisted(i)||(r=i),!r&&t.options.checkForSimilarInWhitelist&&(r=t.getSimilarInWhitelist(i))}}),!r){var s=this.i18nOptions.fallbackLng;"string"==typeof s&&(s=[s]),s||(s=[]),r="[object Array]"===Object.prototype.toString.apply(s)?s[0]:s[0]||s.default&&s.default[0]}return r}},{key:"cacheUserLanguage",value:function(e,t){var r=this;t||(t=this.options.caches),t&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||t.forEach(function(t){r.detectors[t]&&r.detectors[t].cacheUserLanguage(e,r.options)}))}},{key:"getSimilarInWhitelist",value:function(e){var t=this;if(this.i18nOptions.whitelist){if(e.includes("-")){var r=e.split("-")[0],i=this.services.languageUtils.formatLanguageCode(r);if(this.services.languageUtils.isWhitelisted(i))return i;e=i}var s=this.i18nOptions.whitelist.find(function(r){var i=t.services.languageUtils.formatLanguageCode(r);if(i.startsWith(e))return i});return s||void 0}}}]),e}();jd.type="languageDetector";const $d=Promise.resolve();return function(e){e.registerAddon(Fs),e.registerAddon(Ts),e.registerAddon(Ms),e.registerAddon(ks),e.registerAddon(xs)}(Po),function(e){e.registerAddon(Oo),e.registerAddon(Ro),e.registerAddon(No),e.registerAddon(Vo),e.registerAddon(zo)}(Po),function(e){e.registerAddon(Mi),e.registerAddon(vi),e.registerAddon(Is)}(Po),function(e){e._friendlyError=()=>{},e._checkForUserDefinedFunctions=()=>{},e._fesErrorMonitor=()=>{}}(Po),function(e){e.registerAddon(Go)}(Po),function(e){e.registerAddon(jo),e.registerAddon(Oi),e.registerAddon(As),e.registerAddon(Li)}(Po),function(e){e.registerAddon($o),e.registerAddon(Ho),e.registerAddon(qo)}(Po),function(e){e.registerAddon(Ns),e.registerAddon(on),e.registerAddon(Hi),e.registerAddon(hn),e.registerAddon(Yn),e.registerAddon(ia)}(Po),function(e){e.registerAddon($s),e.registerAddon(Xo),e.registerAddon(Ko),e.registerAddon(Ii)}(Po),function(e){e.registerAddon(Zo),e.registerAddon(Jo),e.registerAddon(Qo),e.registerAddon(Qn),e.registerAddon(eh),e.registerAddon(Yi)}(Po),function(e){e.registerAddon(th),e.registerAddon(rh),e.registerAddon(ih)}(Po),function(e){e.registerAddon($n),e.registerAddon(Hu),e.registerAddon(Hn),e.registerAddon(sh),e.registerAddon(qn),e.registerAddon(ah),e.registerAddon(Jn),e.registerAddon(Uu),e.registerAddon(Fn),e.registerAddon(wn),e.registerAddon(gn),e.registerAddon(vn),e.registerAddon(En),e.registerAddon(ya),e.registerAddon(yn),e.registerAddon(ia)}(Po),function(e){e.registerAddon(Nn),e.registerAddon(Nu)}(Po),Po.registerAddon(Yn),Po.registerAddon(Up),Promise.all([new Promise((e,t)=>{"complete"===document.readyState?e():window.addEventListener("load",e,!1)}),$d]).then(()=>{if(void 0===window._setupDone){if(!window.mocha){const e=new Event("p5Ready");window.dispatchEvent(e),(window.setup&&"function"==typeof window.setup||window.draw&&"function"==typeof window.draw)&&!Po.instance&&new Po}}else console.warn("p5.js seems to have been imported multiple times. Please remove the duplicate import")}),Po}();
|