@vgai/editor 0.2.0
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/LICENSE +661 -0
- package/README.md +35 -0
- package/dist/a/b/c/test-nested.json +1 -0
- package/dist/assets/CCDIKSolver-Dz-ysxZF.js +1 -0
- package/dist/assets/SelectionBox-BXsv_6aH.js +1 -0
- package/dist/assets/browser-project-scripts-DOru4L1x.js +2 -0
- package/dist/assets/browserAll-CEkWYlFk.js +1 -0
- package/dist/assets/collision-world-DniMB0qq.glb +0 -0
- package/dist/assets/create-runtime-DYIWr3va.js +1 -0
- package/dist/assets/data-asset-Bb9sIM7i.js +5 -0
- package/dist/assets/esbuild-BHljloGq.wasm +0 -0
- package/dist/assets/fake-three-BMTQ9rl_.js +1 -0
- package/dist/assets/game-8SDZPPgH.js +1 -0
- package/dist/assets/game-BI111o5f.js +10 -0
- package/dist/assets/game-CevorxyV.js +1 -0
- package/dist/assets/game-Di1H0gFj.js +1 -0
- package/dist/assets/game-Di7XlywD.js +1 -0
- package/dist/assets/game-DjnCaw8R.js +1 -0
- package/dist/assets/game-Q9A0aXSV.js +1 -0
- package/dist/assets/game-pt_1lQLv.js +1 -0
- package/dist/assets/game-source-CvidN7AB.js +1 -0
- package/dist/assets/game-xsOho_wg.js +83 -0
- package/dist/assets/index-Bp5cecD6.js +12 -0
- package/dist/assets/index-CPVV6pjw.js +1 -0
- package/dist/assets/index-CpOnYyeD.js +213 -0
- package/dist/assets/index-Cs8xwv3e.js +1 -0
- package/dist/assets/index-DL7RcQ0n.js +27 -0
- package/dist/assets/index-Dr8H_6Rl.js +1 -0
- package/dist/assets/index-_bCaipUk.js +13650 -0
- package/dist/assets/ingest-siblings-Dz8eEqrV.js +1 -0
- package/dist/assets/mount-manifest-Bhk0ohsl.js +1 -0
- package/dist/assets/recast-navigation.wasm-compat-CvP4UGK6.js +1 -0
- package/dist/assets/scene-query-BivAHhJu.js +1 -0
- package/dist/assets/stats.module--VATS4Kh.js +1 -0
- package/dist/assets/webworkerAll-BLrH0F6F.js +1 -0
- package/dist/assets/xstate-animation-binding-1NGLmw6y.js +1 -0
- package/dist/assets/xstate.esm-BgUD33nl.js +3 -0
- package/dist/index.html +37 -0
- package/dist/ingest/racing-game/UPSTREAM.md +68 -0
- package/dist/ingest/racing-game/a/Inter-Black.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-Black.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-BlackItalic.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-BlackItalic.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-Bold.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-Bold.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-BoldItalic.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-BoldItalic.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-ExtraBold.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-ExtraBold.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-ExtraBoldItalic.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-ExtraBoldItalic.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-ExtraLight.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-ExtraLight.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-ExtraLightItalic.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-ExtraLightItalic.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-Italic.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-Italic.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-Light.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-Light.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-LightItalic.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-LightItalic.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-Medium.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-Medium.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-MediumItalic.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-MediumItalic.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-Regular.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-Regular.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-SemiBold.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-SemiBold.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-SemiBoldItalic.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-SemiBoldItalic.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-Thin.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-Thin.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-ThinItalic.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-ThinItalic.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-italic.var.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-roman.var.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter.var.woff2 +0 -0
- package/dist/ingest/racing-game/a/index.css +1 -0
- package/dist/ingest/racing-game/images/bronze.png +0 -0
- package/dist/ingest/racing-game/images/gold.png +0 -0
- package/dist/ingest/racing-game/images/silver.png +0 -0
- package/dist/ingest/racing-game/index.html +15 -0
- package/dist/ingest/racing-game/models/chassis-draco.glb +0 -0
- package/dist/ingest/racing-game/models/track-draco.glb +0 -0
- package/dist/ingest/racing-game/models/wheel-draco.glb +0 -0
- package/dist/ingest/racing-game/rg-entry.js +1 -0
- package/dist/ingest/racing-game/sounds/accelerate.mp3 +0 -0
- package/dist/ingest/racing-game/sounds/boost.mp3 +0 -0
- package/dist/ingest/racing-game/sounds/crash.mp3 +0 -0
- package/dist/ingest/racing-game/sounds/engine.mp3 +0 -0
- package/dist/ingest/racing-game/sounds/honk.mp3 +0 -0
- package/dist/ingest/racing-game/sounds/tire-brake.mp3 +0 -0
- package/dist/ingest/racing-game/sounds/train.mp3 +0 -0
- package/dist/ingest/racing-game/sounds/water.mp3 +0 -0
- package/dist/ingest/racing-game/textures/cursor.svg +3 -0
- package/dist/ingest/racing-game/textures/dikhololo_night_1k.hdr +0 -0
- package/dist/ingest/racing-game/textures/heightmap_1024.png +0 -0
- package/dist/ingest/racing-game/textures/mask.svg +11 -0
- package/dist/ingest/racing-game/textures/no_sound.png +0 -0
- package/dist/ingest/racing-game/three-r139.module.js +50617 -0
- package/dist/ingest/racing-game/vendor.js +179 -0
- package/dist/ingest/racing-game/vgai.game.json +20 -0
- package/dist/ingest/simcity/UPSTREAM.md +65 -0
- package/dist/ingest/simcity/favicon.ico +0 -0
- package/dist/ingest/simcity/fonts/Bebas-Regular.otf +0 -0
- package/dist/ingest/simcity/fonts/Digitalt.otf +0 -0
- package/dist/ingest/simcity/fonts/Stanberry.ttf +0 -0
- package/dist/ingest/simcity/icons/bulldozer-color.png +0 -0
- package/dist/ingest/simcity/icons/bulldozer.png +0 -0
- package/dist/ingest/simcity/icons/calendar.png +0 -0
- package/dist/ingest/simcity/icons/factory-color.png +0 -0
- package/dist/ingest/simcity/icons/factory.png +0 -0
- package/dist/ingest/simcity/icons/house-color.png +0 -0
- package/dist/ingest/simcity/icons/house.png +0 -0
- package/dist/ingest/simcity/icons/job.png +0 -0
- package/dist/ingest/simcity/icons/office.png +0 -0
- package/dist/ingest/simcity/icons/pause-color.png +0 -0
- package/dist/ingest/simcity/icons/pause.png +0 -0
- package/dist/ingest/simcity/icons/person.png +0 -0
- package/dist/ingest/simcity/icons/play-color.png +0 -0
- package/dist/ingest/simcity/icons/play.png +0 -0
- package/dist/ingest/simcity/icons/power-color.png +0 -0
- package/dist/ingest/simcity/icons/power-line-color.png +0 -0
- package/dist/ingest/simcity/icons/power.png +0 -0
- package/dist/ingest/simcity/icons/road-color.png +0 -0
- package/dist/ingest/simcity/icons/road.png +0 -0
- package/dist/ingest/simcity/icons/select-color.png +0 -0
- package/dist/ingest/simcity/icons/select.png +0 -0
- package/dist/ingest/simcity/icons/store-color.png +0 -0
- package/dist/ingest/simcity/index.html +94 -0
- package/dist/ingest/simcity/index.js +58 -0
- package/dist/ingest/simcity/main.css +233 -0
- package/dist/ingest/simcity/models/armored-truck.glb +0 -0
- package/dist/ingest/simcity/models/building-block-4floor-corner.glb +0 -0
- package/dist/ingest/simcity/models/building-block-4floor-short.glb +0 -0
- package/dist/ingest/simcity/models/building-block-5floor.glb +0 -0
- package/dist/ingest/simcity/models/building-burger-joint.glb +0 -0
- package/dist/ingest/simcity/models/building-cafe.glb +0 -0
- package/dist/ingest/simcity/models/building-casino.glb +0 -0
- package/dist/ingest/simcity/models/building-cinema.glb +0 -0
- package/dist/ingest/simcity/models/building-house-block-big.glb +0 -0
- package/dist/ingest/simcity/models/building-house-family-large.glb +0 -0
- package/dist/ingest/simcity/models/building-house-family-small.glb +0 -0
- package/dist/ingest/simcity/models/building-office-balcony.glb +0 -0
- package/dist/ingest/simcity/models/building-office-big.glb +0 -0
- package/dist/ingest/simcity/models/building-office-pyramid.glb +0 -0
- package/dist/ingest/simcity/models/building-office-tall.glb +0 -0
- package/dist/ingest/simcity/models/building-office.glb +0 -0
- package/dist/ingest/simcity/models/building-restaurant.glb +0 -0
- package/dist/ingest/simcity/models/building-skyscraper.glb +0 -0
- package/dist/ingest/simcity/models/car-ambulance-pickup.glb +0 -0
- package/dist/ingest/simcity/models/car-baywatch.glb +0 -0
- package/dist/ingest/simcity/models/car-hippie-van.glb +0 -0
- package/dist/ingest/simcity/models/car-passenger-race.glb +0 -0
- package/dist/ingest/simcity/models/car-passenger.glb +0 -0
- package/dist/ingest/simcity/models/car-police.glb +0 -0
- package/dist/ingest/simcity/models/car-taxi.glb +0 -0
- package/dist/ingest/simcity/models/car-tow-truck.glb +0 -0
- package/dist/ingest/simcity/models/car-truck-dump.glb +0 -0
- package/dist/ingest/simcity/models/car-veteran.glb +0 -0
- package/dist/ingest/simcity/models/construction-small.glb +0 -0
- package/dist/ingest/simcity/models/data-center.glb +0 -0
- package/dist/ingest/simcity/models/industry-factory-old.glb +0 -0
- package/dist/ingest/simcity/models/industry-factory.glb +0 -0
- package/dist/ingest/simcity/models/industry-refinery.glb +0 -0
- package/dist/ingest/simcity/models/industry-warehouse.glb +0 -0
- package/dist/ingest/simcity/models/power_line_pole_modified.glb +0 -0
- package/dist/ingest/simcity/models/tile-plain_grass.glb +0 -0
- package/dist/ingest/simcity/models/tile-road-curve.glb +0 -0
- package/dist/ingest/simcity/models/tile-road-end.glb +0 -0
- package/dist/ingest/simcity/models/tile-road-intersection-t.glb +0 -0
- package/dist/ingest/simcity/models/tile-road-intersection.glb +0 -0
- package/dist/ingest/simcity/models/tile-road-straight.glb +0 -0
- package/dist/ingest/simcity/models/truck.glb +0 -0
- package/dist/ingest/simcity/statusIcons/no-power.png +0 -0
- package/dist/ingest/simcity/statusIcons/no-road-access.png +0 -0
- package/dist/ingest/simcity/textures/base.png +0 -0
- package/dist/ingest/simcity/textures/grid.png +0 -0
- package/dist/ingest/simcity/textures/specular.png +0 -0
- package/dist/ingest/simcity/three-r155.module.js +51466 -0
- package/dist/ingest/simcity/vgai.game.json +20 -0
- package/dist/ingest/tanks/UPSTREAM.md +69 -0
- package/dist/ingest/tanks/index.html +214 -0
- package/dist/ingest/tanks/models/pixelTank.fbx +0 -0
- package/dist/ingest/tanks/tanks-entry.js +92 -0
- package/dist/ingest/tanks/three-r170.module.js +54571 -0
- package/dist/ingest/tanks/vgai.game.json +20 -0
- package/dist/inputmaps/default.inputmap.json +41 -0
- package/dist/jsm/libs/draco/gltf/draco_decoder.js +33 -0
- package/dist/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/dist/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -0
- package/dist/scenes/untitled.vscn.json +29 -0
- package/dist/textures/waternormals.jpg +0 -0
- package/dist-server/packaged.mjs +18155 -0
- package/package.json +36 -0
- package/server/asset-library-routes.ts +833 -0
- package/server/canonical-path.ts +50 -0
- package/server/cloud-asset-catalog.ts +101 -0
- package/server/dev.ts +350 -0
- package/server/editor-server.ts +1537 -0
- package/server/editor-sse.ts +73 -0
- package/server/game-globals-shadow.ts +58 -0
- package/server/local-asset-catalog.ts +163 -0
- package/server/packaged.ts +571 -0
- package/server/prod.ts +75 -0
- package/server/project-optimize-deps-entries.ts +149 -0
- package/server/project-view.ts +65 -0
- package/server/server-utils.ts +430 -0
- package/server/session-registry.ts +93 -0
- package/src/EditorContext.tsx +87 -0
- package/src/achieved-tier.ts +126 -0
- package/src/action-registry.ts +268 -0
- package/src/adapter-resolver.ts +1858 -0
- package/src/asset-events.ts +100 -0
- package/src/authoring/active-adapter.ts +98 -0
- package/src/authoring/active-systems.ts +50 -0
- package/src/authoring/boundary-authoring-adapter.ts +178 -0
- package/src/authoring/composite-authoring-adapter.ts +891 -0
- package/src/authoring/design-time-layers.ts +776 -0
- package/src/authoring/edit-mode-authoring.ts +643 -0
- package/src/authoring/embed-only-adapter.ts +57 -0
- package/src/authoring/ephemeral-persistence.ts +26 -0
- package/src/authoring/eyedropper-session.ts +69 -0
- package/src/authoring/first-party-hierarchy-menu.ts +74 -0
- package/src/authoring/first-party-inspector/AddSectionMenu.tsx +118 -0
- package/src/authoring/first-party-inspector/EnvironmentSection.tsx +550 -0
- package/src/authoring/first-party-inspector/HeaderSection.tsx +329 -0
- package/src/authoring/first-party-inspector/is-first-party-selection.ts +44 -0
- package/src/authoring/first-party-inspector/register.tsx +108 -0
- package/src/authoring/ingest-authoring-adapter.ts +475 -0
- package/src/authoring/ingest-capture.ts +94 -0
- package/src/authoring/ingest-game-adapter.ts +291 -0
- package/src/authoring/ingest-iframe-adapter.ts +38 -0
- package/src/authoring/ingest-iframe-reachable-adapter.ts +401 -0
- package/src/authoring/ingest-overlay.ts +193 -0
- package/src/authoring/layered-pick.ts +87 -0
- package/src/authoring/mount-failure-report.ts +112 -0
- package/src/authoring/overlay-report.ts +52 -0
- package/src/authoring/project-scenes.ts +111 -0
- package/src/authoring/react-dom-authoring-adapter.ts +795 -0
- package/src/authoring/react-inspector-section.tsx +1041 -0
- package/src/authoring/react-world-authoring-adapter.ts +2400 -0
- package/src/authoring/root-activation.ts +61 -0
- package/src/authoring/scene-ui-layer.ts +485 -0
- package/src/authoring/story-overlay.ts +48 -0
- package/src/authoring/ui-authoring-adapter.ts +325 -0
- package/src/authoring/ui-hierarchy-menu.ts +40 -0
- package/src/authoring/ui-inspector-sections.tsx +156 -0
- package/src/authoring/undo-timeline.ts +145 -0
- package/src/authoring/vgai-scene-authoring-adapter.ts +746 -0
- package/src/authoring/viewport-pick-context.ts +31 -0
- package/src/authoring/viewport-raycast.ts +80 -0
- package/src/authoring/world-overlay.ts +76 -0
- package/src/authoring/world-pan-state.ts +115 -0
- package/src/authoring/world-session-state.ts +102 -0
- package/src/authoring/world2d-authoring-adapter.ts +313 -0
- package/src/browser-external-watch.ts +98 -0
- package/src/browser-play-entry.ts +112 -0
- package/src/browser-project-scripts.ts +112 -0
- package/src/browser-transpile.ts +246 -0
- package/src/browser-watch-reload.ts +100 -0
- package/src/command-listener.ts +326 -0
- package/src/components/AlignToolbar.tsx +189 -0
- package/src/components/AppRoot.tsx +73 -0
- package/src/components/AssetBrowser.tsx +502 -0
- package/src/components/BottomPanel.tsx +326 -0
- package/src/components/BuildPanel.tsx +455 -0
- package/src/components/CameraInfo.tsx +56 -0
- package/src/components/CommandPalette.tsx +265 -0
- package/src/components/ConsolePanel.tsx +272 -0
- package/src/components/DataPanel.tsx +1268 -0
- package/src/components/DefaultEditorLayout.tsx +509 -0
- package/src/components/FolderTree.tsx +179 -0
- package/src/components/GameHierarchy.tsx +1349 -0
- package/src/components/Inspector.tsx +671 -0
- package/src/components/InspectorToolSection.tsx +74 -0
- package/src/components/MountFailureBanner.tsx +110 -0
- package/src/components/NetworkSection.tsx +109 -0
- package/src/components/OnlineAssetBrowser.tsx +448 -0
- package/src/components/OverlayReportBanner.tsx +122 -0
- package/src/components/PlayBar.tsx +356 -0
- package/src/components/PrefabSaveDialog.tsx +201 -0
- package/src/components/ProjectHeader.tsx +174 -0
- package/src/components/ProjectScreen.tsx +1004 -0
- package/src/components/RightPanel.tsx +166 -0
- package/src/components/RootActivateDialog.tsx +105 -0
- package/src/components/SaveDialog.tsx +197 -0
- package/src/components/SaveStatus.tsx +69 -0
- package/src/components/StatsOverlay.tsx +35 -0
- package/src/components/ToolHost.tsx +80 -0
- package/src/components/Toolbar.tsx +307 -0
- package/src/components/ViewportOverlay.tsx +234 -0
- package/src/components/ViewportPanel.tsx +369 -0
- package/src/components/WorldContextMenu.tsx +257 -0
- package/src/components/WorldSelectionOverlay.tsx +2003 -0
- package/src/components/WorldTextEditor.tsx +86 -0
- package/src/components/asset-viewers/AssetViewer.tsx +38 -0
- package/src/components/asset-viewers/AudioViewer.tsx +149 -0
- package/src/components/asset-viewers/GenericJsonViewer.tsx +77 -0
- package/src/components/asset-viewers/ImageViewer.tsx +65 -0
- package/src/components/asset-viewers/InputMapViewer.tsx +206 -0
- package/src/components/asset-viewers/ModelViewer.tsx +180 -0
- package/src/components/asset-viewers/OnlineAssetDetail.tsx +236 -0
- package/src/components/data-csv.ts +301 -0
- package/src/components/entity-name-commit.ts +18 -0
- package/src/components/inspector-property-grouping.ts +65 -0
- package/src/components/inspector-widgets/AlignmentGrid.tsx +188 -0
- package/src/components/inspector-widgets/BorderEditor.tsx +305 -0
- package/src/components/inspector-widgets/ColorPicker.tsx +548 -0
- package/src/components/inspector-widgets/FilterEditor.tsx +108 -0
- package/src/components/inspector-widgets/FontPicker.tsx +196 -0
- package/src/components/inspector-widgets/GradientEditor.tsx +277 -0
- package/src/components/inspector-widgets/ScrubbableInput.tsx +152 -0
- package/src/components/inspector-widgets/ShadowEditor.tsx +332 -0
- package/src/components/inspector-widgets/color-utils.ts +202 -0
- package/src/components/inspector-widgets/gallery-main.tsx +167 -0
- package/src/components/inspector-widgets/index.ts +22 -0
- package/src/components/inspector-widgets/shared.tsx +135 -0
- package/src/components/inspectors/AnimationSection.tsx +143 -0
- package/src/components/inspectors/AudioSection.tsx +215 -0
- package/src/components/inspectors/BoneAttachmentSection.tsx +82 -0
- package/src/components/inspectors/CameraSection.tsx +105 -0
- package/src/components/inspectors/ComponentsSection.tsx +358 -0
- package/src/components/inspectors/JointsSection.tsx +255 -0
- package/src/components/inspectors/LightSection.tsx +116 -0
- package/src/components/inspectors/MaterialSection.tsx +1189 -0
- package/src/components/inspectors/MeshSection.tsx +99 -0
- package/src/components/inspectors/NavigationSection.tsx +58 -0
- package/src/components/inspectors/ParticleSection.tsx +681 -0
- package/src/components/inspectors/PhysicsSection.tsx +326 -0
- package/src/components/inspectors/PostProcessingSection.tsx +1290 -0
- package/src/components/inspectors/RenderingSection.tsx +109 -0
- package/src/components/inspectors/ShadowSection.tsx +84 -0
- package/src/components/inspectors/SplineSection.tsx +191 -0
- package/src/components/inspectors/TransformSection.tsx +191 -0
- package/src/components/inspectors/json-schema-fields.ts +281 -0
- package/src/components/inspectors/multi-edit-utils.ts +49 -0
- package/src/components/inspectors/zod-fields.ts +184 -0
- package/src/components/primitives/ColorInput.tsx +109 -0
- package/src/components/primitives/JsonInput.tsx +98 -0
- package/src/components/primitives/NumberInput.tsx +164 -0
- package/src/components/primitives/Panel.tsx +68 -0
- package/src/components/primitives/SectionHeader.tsx +45 -0
- package/src/components/primitives/Tooltip.tsx +82 -0
- package/src/components/primitives/Vec3Input.tsx +62 -0
- package/src/components/world-overlay-gestures.ts +1438 -0
- package/src/doctor/data-checks.ts +285 -0
- package/src/doctor/report.ts +386 -0
- package/src/editor-api.ts +700 -0
- package/src/editor-console.ts +194 -0
- package/src/editor-hotkeys.ts +441 -0
- package/src/editor-layers.ts +2 -0
- package/src/editor-mode.ts +28 -0
- package/src/editor-store.ts +2225 -0
- package/src/editor-viewport.ts +1924 -0
- package/src/entity-factory.ts +221 -0
- package/src/game-globals-prelude.ts +27 -0
- package/src/gated-globals.ts +131 -0
- package/src/generated/setup-by-example.generated.ts +53 -0
- package/src/gizmo-registry.ts +608 -0
- package/src/handle-system.ts +221 -0
- package/src/hierarchy-menu-registry.ts +70 -0
- package/src/hierarchy-rows.ts +73 -0
- package/src/hosted-example.ts +160 -0
- package/src/hotkeys.ts +142 -0
- package/src/ingest/discovery-react.ts +132 -0
- package/src/ingest/discovery.ts +205 -0
- package/src/ingest/discovery2d.ts +204 -0
- package/src/ingest/esm-entry-resolution.ts +102 -0
- package/src/ingest/games/bloom-composer/game.js +99 -0
- package/src/ingest/games/bloom-composer/vgai.game.json +21 -0
- package/src/ingest/games/embed-bundle/embed.html +10 -0
- package/src/ingest/games/embed-bundle/vgai.game.json +21 -0
- package/src/ingest/games/games-fps/assets/collision-world.glb +0 -0
- package/src/ingest/games/games-fps/game.js +479 -0
- package/src/ingest/games/games-fps/vgai.game.json +24 -0
- package/src/ingest/games/iframe-reachable/game-source.js +58 -0
- package/src/ingest/games/iframe-reachable/vgai.game.json +21 -0
- package/src/ingest/games/interactive-cubes/game.js +139 -0
- package/src/ingest/games/interactive-cubes/vgai.game.json +21 -0
- package/src/ingest/games/mismatched-three/fake-three.js +38 -0
- package/src/ingest/games/mismatched-three/game.js +10 -0
- package/src/ingest/games/mismatched-three/vgai.game.json +22 -0
- package/src/ingest/games/own-three-bundled/game.js +43 -0
- package/src/ingest/games/own-three-bundled/vgai.game.json +21 -0
- package/src/ingest/games/pointerlock-maze/game.js +288 -0
- package/src/ingest/games/pointerlock-maze/vgai.game.json +22 -0
- package/src/ingest/games-2d/_fixtures/first-party-scene.scn2d.json +124 -0
- package/src/ingest/games-2d/bubbo-bubbo/vgai.game.json +25 -0
- package/src/ingest/games-2d/bunnymark/game.ts +88 -0
- package/src/ingest/games-2d/bunnymark/vgai.game.json +21 -0
- package/src/ingest/games-2d/flappy/game.ts +148 -0
- package/src/ingest/games-2d/flappy/vgai.game.json +21 -0
- package/src/ingest/games-2d/flappy-pixi/vgai.game.json +25 -0
- package/src/ingest/games-2d/puzzling-potions/vgai.game.json +25 -0
- package/src/ingest/games-2d/tilemap-camera/game.ts +115 -0
- package/src/ingest/games-2d/tilemap-camera/vgai.game.json +21 -0
- package/src/ingest/games-react/react-rpg/entry.tsx +185 -0
- package/src/ingest/games-react/react-rpg/shims.d.ts +26 -0
- package/src/ingest/games-react/react-rpg/src/ui/game-state.tsx +129 -0
- package/src/ingest/games-react/react-rpg/vgai.game.json +21 -0
- package/src/ingest/host-namespace-registry.ts +196 -0
- package/src/ingest/types.ts +127 -0
- package/src/ingest-hierarchy-rows.ts +207 -0
- package/src/ingest-mode.ts +2092 -0
- package/src/ingest-siblings.ts +466 -0
- package/src/initial-scene.ts +194 -0
- package/src/inspector-section-registry.ts +117 -0
- package/src/interactive-edit-scope.ts +34 -0
- package/src/main.tsx +23 -0
- package/src/manifest-project.ts +43 -0
- package/src/model-thumbnail.ts +156 -0
- package/src/module-mode.ts +513 -0
- package/src/navmesh-handler.ts +94 -0
- package/src/packaged-runtime.ts +49 -0
- package/src/play-mode.ts +1148 -0
- package/src/playground/main.ts +206 -0
- package/src/project-manager.ts +173 -0
- package/src/scene-diff.ts +112 -0
- package/src/scene-serializer.ts +144 -0
- package/src/scene-sync.ts +587 -0
- package/src/scene-ui-mode/active-scene-ui.ts +58 -0
- package/src/scene-ui-mode/scene-ui-palette-panel.tsx +152 -0
- package/src/scene-ui-mode/scene-ui-timeline-tab.tsx +29 -0
- package/src/scene-ui-mode/ui-prefab-dialog-host.tsx +74 -0
- package/src/scene-ui-mode/ui-prefab-hierarchy-menu.ts +49 -0
- package/src/scene-ui-mode/ui-prefab-io.ts +76 -0
- package/src/script-loader.ts +143 -0
- package/src/storage/fsa-storage.ts +55 -0
- package/src/storage/handle-storage.ts +150 -0
- package/src/storage/handle-store.ts +116 -0
- package/src/storage/http-storage.ts +137 -0
- package/src/storage/index.ts +147 -0
- package/src/storage/mem-storage.ts +135 -0
- package/src/storage/opfs-storage.ts +25 -0
- package/src/storage/paths.ts +26 -0
- package/src/storage/seed.ts +106 -0
- package/src/storage/types.ts +110 -0
- package/src/tool-loader.ts +291 -0
- package/src/ui-editor/inspector.tsx +563 -0
- package/src/ui-editor/node-ops.ts +266 -0
- package/src/ui-editor/overlay.tsx +380 -0
- package/src/ui-editor/palette.tsx +114 -0
- package/src/ui-editor/react-store.ts +78 -0
- package/src/ui-editor/timeline-panel.tsx +443 -0
- package/src/ui-editor/ui-edit-store.ts +552 -0
- package/src/ui-editor/ui-prefab.ts +95 -0
- package/src/ui-source/inspect.ts +544 -0
- package/src/ui-source/oid-transform.ts +133 -0
- package/src/ui-source/source-write-backend.ts +203 -0
- package/src/ui-source/tailwind-map.ts +174 -0
- package/src/ui-source/writer.ts +1175 -0
- package/src/widgets/index.ts +73 -0
- package/template/.claude/skills/editor/SKILL.md +252 -0
- package/template/CLAUDE.md +512 -0
- package/template/LICENSE +30 -0
- package/template/emit-schemas.ts +42 -0
- package/template/index.html +17 -0
- package/template/package.json +53 -0
- package/template/project.json +9 -0
- package/template/public/audio/ambient-arena.wav +0 -0
- package/template/public/audio/ambient-music.wav +0 -0
- package/template/public/audio/ambient-nature.wav +0 -0
- package/template/public/audio/ambient-wind.wav +0 -0
- package/template/public/inputmaps/default.inputmap.json +41 -0
- package/template/public/jsm/libs/draco/gltf/draco_decoder.js +33 -0
- package/template/public/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/template/public/jsm/libs/draco/gltf/draco_encoder.js +33 -0
- package/template/public/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -0
- package/template/public/scenes/default.vscn.json +43 -0
- package/template/public/scenes/untitled.vscn.json +29 -0
- package/template/public/textures/waternormals.jpg +0 -0
- package/template/server/colyseus-setup.ts +85 -0
- package/template/server/main.ts +34 -0
- package/template/server/rooms/arena-room.ts +420 -0
- package/template/server/rooms/game-room.ts +162 -0
- package/template/server/rooms.ts +15 -0
- package/template/server/tsconfig.json +19 -0
- package/template/src/data/README.md +40 -0
- package/template/src/data/assets.ts +31 -0
- package/template/src/data/tuning.data.json +5 -0
- package/template/src/data/tuning.schema.json +21 -0
- package/template/src/data/tuning.schema.ts +34 -0
- package/template/src/data/tuning.ts +24 -0
- package/template/src/main.ts +157 -0
- package/template/src/scripts/components/data-spinner.ts +45 -0
- package/template/src/scripts/components/scene-camera.ts +40 -0
- package/template/src/scripts/main.ts +94 -0
- package/template/src/scripts/registry.ts +46 -0
- package/template/src/tools/README.md +14 -0
- package/template/src/tools/example.tool.tsx +91 -0
- package/template/src/tools/spin.tool.tsx +101 -0
- package/template/src/ui/Button.tsx +27 -0
- package/template/src/ui/DefaultHud.tsx +40 -0
- package/template/src/ui/KeyHint.tsx +25 -0
- package/template/src/ui/Panel.tsx +52 -0
- package/template/src/ui/RebindPanel.tsx +129 -0
- package/template/src/ui/Slider.tsx +28 -0
- package/template/src/ui/StatusDot.tsx +22 -0
- package/template/src/ui/Toggle.tsx +19 -0
- package/template/src/ui/game-state.tsx +37 -0
- package/template/src/ui/index.ts +7 -0
- package/template/src/ui/mount-default-hud.tsx +19 -0
- package/template/src/ui/mount-ui.ts +15 -0
- package/template/tsconfig.json +36 -0
- package/template/validate-asset-content.ts +78 -0
- package/template/validate-manifest.ts +55 -0
- package/template/validate-scenes.ts +211 -0
- package/template/vgai.game.json +21 -0
- package/template/vite.config.ts +128 -0
- package/vite-plugin-example-assets.ts +60 -0
- package/vite-plugin-game-globals.ts +46 -0
- package/vite-plugin-game-static.ts +71 -0
- package/vite-plugin-project-game-static.ts +84 -0
- package/vite-plugin-react-game-static.ts +98 -0
- package/vite-plugin-react-world-provider.ts +81 -0
- package/vite-plugin-react-world-runtime.ts +76 -0
- package/vite-plugin-ui-oid.ts +561 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
function hh(s,t,e={}){const n=e.phase??"animation",r=s.subscribe(n,a=>{t.seconds=a.currentTime});let i=!1;return{dispose(){i||(i=!0,r.dispose())}}}const sr="15.1.22",Vs=(s,t,e)=>({endTime:t,insertTime:e,type:"exponentialRampToValue",value:s}),Fs=(s,t,e)=>({endTime:t,insertTime:e,type:"linearRampToValue",value:s}),Un=(s,t)=>({startTime:t,type:"setValue",value:s}),rr=(s,t,e)=>({duration:e,startTime:t,type:"setValueCurve",values:s}),ir=(s,t,{startTime:e,target:n,timeConstant:r})=>n+(t-n)*Math.exp((e-s)/r),ve=s=>s.type==="exponentialRampToValue",cn=s=>s.type==="linearRampToValue",Jt=s=>ve(s)||cn(s),ts=s=>s.type==="setValue",Gt=s=>s.type==="setValueCurve",un=(s,t,e,n)=>{const r=s[t];return r===void 0?n:Jt(r)||ts(r)?r.value:Gt(r)?r.values[r.values.length-1]:ir(e,un(s,t-1,r.startTime,n),r)},Ws=(s,t,e,n,r)=>e===void 0?[n.insertTime,r]:Jt(e)?[e.endTime,e.value]:ts(e)?[e.startTime,e.value]:Gt(e)?[e.startTime+e.duration,e.values[e.values.length-1]]:[e.startTime,un(s,t-1,e.startTime,r)],Gn=s=>s.type==="cancelAndHold",zn=s=>s.type==="cancelScheduledValues",Qt=s=>Gn(s)||zn(s)?s.cancelTime:ve(s)||cn(s)?s.endTime:s.startTime,qs=(s,t,e,{endTime:n,value:r})=>e===r?r:0<e&&0<r||e<0&&r<0?e*(r/e)**((s-t)/(n-t)):s<n?e:r,Ls=(s,t,e,{endTime:n,value:r})=>e+(s-t)/(n-t)*(r-e),or=(s,t)=>{const e=Math.floor(t);if(e===t)return s[e];const n=Math.ceil(t);return(1-(t-e))*s[e]+(1-(n-t))*s[n]},mi=(s,{duration:t,startTime:e,values:n})=>{const r=(s-e)/t*(n.length-1);return or(n,r)},_i=(s,t,e)=>{const n=s.length,r=Math.max(1,Math.floor(e/t*n))+1,i=s instanceof Float32Array?new Float32Array(r):s.slice(0,r);for(let a=0;a<r;a+=1){const c=a/(r-1)*e/t*(n-1);i[a]=or(s,c)}return i},en=s=>s.type==="setTarget";class gi{constructor(t){this._automationEvents=[],this._currenTime=0,this._defaultValue=t}[Symbol.iterator](){return this._automationEvents[Symbol.iterator]()}add(t){const e=Qt(t);if(Gn(t)||zn(t)){const n=this._automationEvents.findIndex(i=>zn(t)&&Gt(i)?i.startTime+i.duration>=e:Qt(i)>=e),r=this._automationEvents[n];if(n!==-1&&(this._automationEvents=this._automationEvents.slice(0,n)),Gn(t)){const i=this._automationEvents[this._automationEvents.length-1];if(r!==void 0&&Jt(r)){if(i!==void 0&&en(i))throw new Error("The internal list is malformed.");const a=i===void 0?r.insertTime:Gt(i)?i.startTime+i.duration:Qt(i),o=i===void 0?this._defaultValue:Gt(i)?i.values[i.values.length-1]:i.value,c=ve(r)?qs(e,a,o,r):Ls(e,a,o,r),u=ve(r)?Vs(c,e,this._currenTime):Fs(c,e,this._currenTime);this._automationEvents.push(u)}if(i!==void 0&&en(i)&&this._automationEvents.push(Un(this.getValue(e),e)),i!==void 0&&Gt(i)&&i.startTime+i.duration>e){const a=e-i.startTime;this._automationEvents[this._automationEvents.length-1]=rr(_i(i.values,i.duration,a),i.startTime,a)}}}else{const n=this._automationEvents.findIndex(a=>Qt(a)>e),r=n===-1?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[n-1];if(r!==void 0&&Gt(r)&&Qt(r)+r.duration>e)return!1;const i=ve(t)?Vs(t.value,t.endTime,this._currenTime):cn(t)?Fs(t.value,e,this._currenTime):t;if(n===-1)this._automationEvents.push(i);else{if(Gt(t)&&e+t.duration>Qt(this._automationEvents[n]))return!1;this._automationEvents.splice(n,0,i)}}return!0}flush(t){const e=this._automationEvents.findIndex(n=>Qt(n)>t);if(e>1){const n=this._automationEvents.slice(e-1),r=n[0];en(r)&&n.unshift(Un(un(this._automationEvents,e-2,r.startTime,this._defaultValue),r.startTime)),this._automationEvents=n}}getValue(t){if(this._automationEvents.length===0)return this._defaultValue;const e=this._automationEvents.findIndex(a=>Qt(a)>t),n=this._automationEvents[e],r=(e===-1?this._automationEvents.length:e)-1,i=this._automationEvents[r];if(i!==void 0&&en(i)&&(n===void 0||!Jt(n)||n.insertTime>t))return ir(t,un(this._automationEvents,r-1,i.startTime,this._defaultValue),i);if(i!==void 0&&ts(i)&&(n===void 0||!Jt(n)))return i.value;if(i!==void 0&&Gt(i)&&(n===void 0||!Jt(n)||i.startTime+i.duration>t))return t<i.startTime+i.duration?mi(t,i):i.values[i.values.length-1];if(i!==void 0&&Jt(i)&&(n===void 0||!Jt(n)))return i.value;if(n!==void 0&&ve(n)){const[a,o]=Ws(this._automationEvents,r,i,n,this._defaultValue);return qs(t,a,o,n)}if(n!==void 0&&cn(n)){const[a,o]=Ws(this._automationEvents,r,i,n,this._defaultValue);return Ls(t,a,o,n)}return this._defaultValue}}const vi=s=>({cancelTime:s,type:"cancelAndHold"}),yi=s=>({cancelTime:s,type:"cancelScheduledValues"}),Ti=(s,t)=>({endTime:t,type:"exponentialRampToValue",value:s}),wi=(s,t)=>({endTime:t,type:"linearRampToValue",value:s}),bi=(s,t,e)=>({startTime:t,target:s,timeConstant:e,type:"setTarget"}),Ci=()=>new DOMException("","AbortError"),Si=s=>(t,e,[n,r,i],a)=>{s(t[r],[e,n,i],o=>o[0]===e&&o[1]===n,a)},Ai=s=>(t,e,n)=>{const r=[];for(let i=0;i<n.numberOfInputs;i+=1)r.push(new Set);s.set(t,{activeInputs:r,outputs:new Set,passiveInputs:new WeakMap,renderer:e})},ki=s=>(t,e)=>{s.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:e})},Ce=new WeakSet,ar=new WeakMap,es=new WeakMap,cr=new WeakMap,ns=new WeakMap,wn=new WeakMap,ur=new WeakMap,$n=new WeakMap,Zn=new WeakMap,Xn=new WeakMap,lr={construct(){return lr}},xi=s=>{try{const t=new Proxy(s,lr);new t}catch{return!1}return!0},Bs=/^import(?:(?:[\s]+[\w]+|(?:[\s]+[\w]+[\s]*,)?[\s]*\{[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?(?:[\s]*,[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?)*[\s]*}|(?:[\s]+[\w]+[\s]*,)?[\s]*\*[\s]+as[\s]+[\w]+)[\s]+from)?(?:[\s]*)("([^"\\]|\\.)+"|'([^'\\]|\\.)+')(?:[\s]*);?/,js=(s,t)=>{const e=[];let n=s.replace(/^[\s]+/,""),r=n.match(Bs);for(;r!==null;){const i=r[1].slice(1,-1),a=r[0].replace(/([\s]+)?;?$/,"").replace(i,new URL(i,t).toString());e.push(a),n=n.slice(r[0].length).replace(/^[\s]+/,""),r=n.match(Bs)}return[e.join(";"),n]},Us=s=>{if(s!==void 0&&!Array.isArray(s))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},Gs=s=>{if(!xi(s))throw new TypeError("The given value for processorCtor should be a constructor.");if(s.prototype===null||typeof s.prototype!="object")throw new TypeError("The given value for processorCtor should have a prototype.")},Ni=(s,t,e,n,r,i,a,o,c,u,l,h,p)=>{let f=0;return(d,m,_={credentials:"omit"})=>{const v=l.get(d);if(v!==void 0&&v.has(m))return Promise.resolve();const b=u.get(d);if(b!==void 0){const g=b.get(m);if(g!==void 0)return g}const C=i(d),A=C.audioWorklet===void 0?r(m).then(([g,T])=>{const[w,y]=js(g,T),N=`${w};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${y}
|
|
2
|
+
})})(window,'_AWGS')`;return e(N)}).then(()=>{const g=p._AWGS.pop();if(g===void 0)throw new SyntaxError;n(C.currentTime,C.sampleRate,()=>g(class{},void 0,(T,w)=>{if(T.trim()==="")throw t();const y=Zn.get(C);if(y!==void 0){if(y.has(T))throw t();Gs(w),Us(w.parameterDescriptors),y.set(T,w)}else Gs(w),Us(w.parameterDescriptors),Zn.set(C,new Map([[T,w]]))},C.sampleRate,void 0,void 0))}):Promise.all([r(m),Promise.resolve(s(h,h))]).then(([[g,T],w])=>{const y=f+1;f=y;const[N,x]=js(g,T),E=`${N};((AudioWorkletProcessor,registerProcessor)=>{${x}
|
|
3
|
+
})(${w?"AudioWorkletProcessor":"class extends AudioWorkletProcessor {__b=new WeakSet();constructor(){super();(p=>p.postMessage=(q=>(m,t)=>q.call(p,m,t?t.filter(u=>!this.__b.has(u)):t))(p.postMessage))(this.port)}}"},(n,p)=>registerProcessor(n,class extends p{${w?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${w?"":"i.forEach(this.__c);o.forEach(this.__c);this.__c(Object.values(p));"}return super.process(i.map(j=>j.some(k=>k.length===0)?[]:j),o,p)}}));registerProcessor('__sac${y}',class extends AudioWorkletProcessor{process(){return !1}})`,P=new Blob([E],{type:"application/javascript; charset=utf-8"}),M=URL.createObjectURL(P);return C.audioWorklet.addModule(M,_).then(()=>{if(o(C))return C;const D=a(C);return D.audioWorklet.addModule(M,_).then(()=>D)}).then(D=>{if(c===null)throw new SyntaxError;try{new c(D,`__sac${y}`)}catch{throw new SyntaxError}}).finally(()=>URL.revokeObjectURL(M))});return b===void 0?u.set(d,new Map([[m,A]])):b.set(m,A),A.then(()=>{const g=l.get(d);g===void 0?l.set(d,new Set([m])):g.add(m)}).finally(()=>{const g=u.get(d);g!==void 0&&g.delete(m)}),A}},Vt=(s,t)=>{const e=s.get(t);if(e===void 0)throw new Error("A value with the given key could not be found.");return e},bn=(s,t)=>{const e=Array.from(s).filter(t);if(e.length>1)throw Error("More than one element was found.");if(e.length===0)throw Error("No element was found.");const[n]=e;return s.delete(n),n},hr=(s,t,e,n)=>{const r=Vt(s,t),i=bn(r,a=>a[0]===e&&a[1]===n);return r.size===0&&s.delete(t),i},Ue=s=>Vt(ur,s),Se=s=>{if(Ce.has(s))throw new Error("The AudioNode is already stored.");Ce.add(s),Ue(s).forEach(t=>t(!0))},dr=s=>"port"in s,Ge=s=>{if(!Ce.has(s))throw new Error("The AudioNode is not stored.");Ce.delete(s),Ue(s).forEach(t=>t(!1))},Yn=(s,t)=>{!dr(s)&&t.every(e=>e.size===0)&&Ge(s)},Oi=(s,t,e,n,r,i,a,o,c,u,l,h,p)=>{const f=new WeakMap;return(d,m,_,v,b)=>{const{activeInputs:C,passiveInputs:A}=i(m),{outputs:g}=i(d),T=o(d),w=y=>{const N=c(m),x=c(d);if(y){const k=hr(A,d,_,v);s(C,d,k,!1),!b&&!h(d)&&e(x,N,_,v),p(m)&&Se(m)}else{const k=n(C,d,_,v);t(A,v,k,!1),!b&&!h(d)&&r(x,N,_,v);const S=a(m);if(S===0)l(m)&&Yn(m,C);else{const I=f.get(m);I!==void 0&&clearTimeout(I),f.set(m,setTimeout(()=>{l(m)&&Yn(m,C)},S*1e3))}}};return u(g,[m,_,v],y=>y[0]===m&&y[1]===_&&y[2]===v,!0)?(T.add(w),l(d)?s(C,d,[_,v,w],!0):t(A,v,[d,_,w],!0),!0):!1}},Ei=s=>(t,e,[n,r,i],a)=>{const o=t.get(n);o===void 0?t.set(n,new Set([[r,e,i]])):s(o,[r,e,i],c=>c[0]===r&&c[1]===e,a)},Ii=s=>(t,e)=>{const n=s(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});e.connect(n).connect(t.destination);const r=()=>{e.removeEventListener("ended",r),e.disconnect(n),n.disconnect()};e.addEventListener("ended",r)},Mi=s=>(t,e)=>{s(t).add(e)},Di={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},Ri=(s,t,e,n,r,i)=>class extends s{constructor(o,c){const u=r(o),l={...Di,...c},h=n(u,l),p=i(u)?t():null;super(o,!1,h,p),this._nativeAnalyserNode=h}get fftSize(){return this._nativeAnalyserNode.fftSize}set fftSize(o){this._nativeAnalyserNode.fftSize=o}get frequencyBinCount(){return this._nativeAnalyserNode.frequencyBinCount}get maxDecibels(){return this._nativeAnalyserNode.maxDecibels}set maxDecibels(o){const c=this._nativeAnalyserNode.maxDecibels;if(this._nativeAnalyserNode.maxDecibels=o,!(o>this._nativeAnalyserNode.minDecibels))throw this._nativeAnalyserNode.maxDecibels=c,e()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(o){const c=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=o,!(this._nativeAnalyserNode.maxDecibels>o))throw this._nativeAnalyserNode.minDecibels=c,e()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(o){this._nativeAnalyserNode.smoothingTimeConstant=o}getByteFrequencyData(o){this._nativeAnalyserNode.getByteFrequencyData(o)}getByteTimeDomainData(o){this._nativeAnalyserNode.getByteTimeDomainData(o)}getFloatFrequencyData(o){this._nativeAnalyserNode.getFloatFrequencyData(o)}getFloatTimeDomainData(o){this._nativeAnalyserNode.getFloatTimeDomainData(o)}},_t=(s,t)=>s.context===t,Pi=(s,t,e)=>()=>{const n=new WeakMap,r=async(i,a)=>{let o=t(i);if(!_t(o,a)){const u={channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,fftSize:o.fftSize,maxDecibels:o.maxDecibels,minDecibels:o.minDecibels,smoothingTimeConstant:o.smoothingTimeConstant};o=s(a,u)}return n.set(a,o),await e(i,a,o),o};return{render(i,a){const o=n.get(a);return o!==void 0?Promise.resolve(o):r(i,a)}}},ln=s=>{try{s.copyToChannel(new Float32Array(1),0,-1)}catch{return!1}return!0},Bt=()=>new DOMException("","IndexSizeError"),ss=s=>{s.getChannelData=(t=>e=>{try{return t.call(s,e)}catch(n){throw n.code===12?Bt():n}})(s.getChannelData)},Vi={numberOfChannels:1},Fi=(s,t,e,n,r,i,a,o)=>{let c=null;return class pr{constructor(l){if(r===null)throw new Error("Missing the native OfflineAudioContext constructor.");const{length:h,numberOfChannels:p,sampleRate:f}={...Vi,...l};c===null&&(c=new r(1,1,44100));const d=n!==null&&t(i,i)?new n({length:h,numberOfChannels:p,sampleRate:f}):c.createBuffer(p,h,f);if(d.numberOfChannels===0)throw e();return typeof d.copyFromChannel!="function"?(a(d),ss(d)):t(ln,()=>ln(d))||o(d),s.add(d),d}static[Symbol.hasInstance](l){return l!==null&&typeof l=="object"&&Object.getPrototypeOf(l)===pr.prototype||s.has(l)}}},wt=-34028234663852886e22,vt=-wt,zt=s=>Ce.has(s),Wi={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},qi=(s,t,e,n,r,i,a,o)=>class extends s{constructor(u,l){const h=i(u),p={...Wi,...l},f=r(h,p),d=a(h),m=d?t():null;super(u,!1,f,m),this._audioBufferSourceNodeRenderer=m,this._isBufferNullified=!1,this._isBufferSet=p.buffer!==null,this._nativeAudioBufferSourceNode=f,this._onended=null,this._playbackRate=e(this,d,f.playbackRate,vt,wt)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(u){if(this._nativeAudioBufferSourceNode.buffer=u,u!==null){if(this._isBufferSet)throw n();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(u){this._nativeAudioBufferSourceNode.loop=u}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(u){this._nativeAudioBufferSourceNode.loopEnd=u}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(u){this._nativeAudioBufferSourceNode.loopStart=u}get onended(){return this._onended}set onended(u){const l=typeof u=="function"?o(this,u):null;this._nativeAudioBufferSourceNode.onended=l;const h=this._nativeAudioBufferSourceNode.onended;this._onended=h!==null&&h===l?u:h}get playbackRate(){return this._playbackRate}start(u=0,l=0,h){if(this._nativeAudioBufferSourceNode.start(u,l,h),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.start=h===void 0?[u,l]:[u,l,h]),this.context.state!=="closed"){Se(this);const p=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",p),zt(this)&&Ge(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",p)}}stop(u=0){this._nativeAudioBufferSourceNode.stop(u),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=u)}},Li=(s,t,e,n,r)=>()=>{const i=new WeakMap;let a=null,o=null;const c=async(u,l)=>{let h=e(u);const p=_t(h,l);if(!p){const f={buffer:h.buffer,channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,loop:h.loop,loopEnd:h.loopEnd,loopStart:h.loopStart,playbackRate:h.playbackRate.value};h=t(l,f),a!==null&&h.start(...a),o!==null&&h.stop(o)}return i.set(l,h),p?await s(l,u.playbackRate,h.playbackRate):await n(l,u.playbackRate,h.playbackRate),await r(u,l,h),h};return{set start(u){a=u},set stop(u){o=u},render(u,l){const h=i.get(l);return h!==void 0?Promise.resolve(h):c(u,l)}}},Bi=s=>"playbackRate"in s,ji=s=>"frequency"in s&&"gain"in s,Ui=s=>"offset"in s,Gi=s=>!("frequency"in s)&&"gain"in s,zi=s=>"detune"in s&&"frequency"in s&&!("gain"in s),$i=s=>"pan"in s,yt=s=>Vt(ar,s),ze=s=>Vt(cr,s),Hn=(s,t)=>{const{activeInputs:e}=yt(s);e.forEach(r=>r.forEach(([i])=>{t.includes(s)||Hn(i,[...t,s])}));const n=Bi(s)?[s.playbackRate]:dr(s)?Array.from(s.parameters.values()):ji(s)?[s.Q,s.detune,s.frequency,s.gain]:Ui(s)?[s.offset]:Gi(s)?[s.gain]:zi(s)?[s.detune,s.frequency]:$i(s)?[s.pan]:[];for(const r of n){const i=ze(r);i!==void 0&&i.activeInputs.forEach(([a])=>Hn(a,t))}zt(s)&&Ge(s)},fr=s=>{Hn(s.destination,[])},Zi=s=>s===void 0||typeof s=="number"||typeof s=="string"&&(s==="balanced"||s==="interactive"||s==="playback"),Xi=(s,t,e,n,r,i,a,o,c)=>class extends s{constructor(l={}){if(c===null)throw new Error("Missing the native AudioContext constructor.");let h;try{h=new c(l)}catch(d){throw d.code===12&&d.message==="sampleRate is not in range"?e():d}if(h===null)throw n();if(!Zi(l.latencyHint))throw new TypeError(`The provided value '${l.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(l.sampleRate!==void 0&&h.sampleRate!==l.sampleRate)throw e();super(h,2);const{latencyHint:p}=l,{sampleRate:f}=h;if(this._baseLatency=typeof h.baseLatency=="number"?h.baseLatency:p==="balanced"?512/f:p==="interactive"||p===void 0?256/f:p==="playback"?1024/f:Math.max(2,Math.min(128,Math.round(p*f/128)))*128/f,this._nativeAudioContext=h,c.name==="webkitAudioContext"?(this._nativeGainNode=h.createGain(),this._nativeOscillatorNode=h.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(h.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,h.state==="running"){this._state="suspended";const d=()=>{this._state==="suspended"&&(this._state=null),h.removeEventListener("statechange",d)};h.addEventListener("statechange",d)}}get baseLatency(){return this._baseLatency}get state(){return this._state!==null?this._state:this._nativeAudioContext.state}close(){return this.state==="closed"?this._nativeAudioContext.close().then(()=>{throw t()}):(this._state==="suspended"&&(this._state=null),this._nativeAudioContext.close().then(()=>{this._nativeGainNode!==null&&this._nativeOscillatorNode!==null&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),fr(this)}))}createMediaElementSource(l){return new r(this,{mediaElement:l})}createMediaStreamDestination(){return new i(this)}createMediaStreamSource(l){return new a(this,{mediaStream:l})}createMediaStreamTrackSource(l){return new o(this,{mediaStreamTrack:l})}resume(){return this._state==="suspended"?new Promise((l,h)=>{const p=()=>{this._nativeAudioContext.removeEventListener("statechange",p),this._nativeAudioContext.state==="running"?l():this.resume().then(l,h)};this._nativeAudioContext.addEventListener("statechange",p)}):this._nativeAudioContext.resume().catch(l=>{throw l===void 0||l.code===15?t():l})}suspend(){return this._nativeAudioContext.suspend().catch(l=>{throw l===void 0?t():l})}},Yi=(s,t,e,n,r,i,a,o)=>class extends s{constructor(u,l){const h=i(u),p=a(h),f=r(h,l,p),d=p?t(o):null;super(u,!1,f,d),this._isNodeOfNativeOfflineAudioContext=p,this._nativeAudioDestinationNode=f}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(u){if(this._isNodeOfNativeOfflineAudioContext)throw n();if(u>this._nativeAudioDestinationNode.maxChannelCount)throw e();this._nativeAudioDestinationNode.channelCount=u}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(u){if(this._isNodeOfNativeOfflineAudioContext)throw n();this._nativeAudioDestinationNode.channelCountMode=u}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}},Hi=s=>{const t=new WeakMap,e=async(n,r)=>{const i=r.destination;return t.set(r,i),await s(n,r,i),i};return{render(n,r){const i=t.get(r);return i!==void 0?Promise.resolve(i):e(n,r)}}},Qi=(s,t,e,n,r,i,a,o)=>(c,u)=>{const l=u.listener,h=()=>{const g=new Float32Array(1),T=t(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),w=a(u);let y=!1,N=[0,0,-1,0,1,0],x=[0,0,0];const k=()=>{if(y)return;y=!0;const P=n(u,256,9,0);P.onaudioprocess=({inputBuffer:M})=>{const D=[i(M,g,0),i(M,g,1),i(M,g,2),i(M,g,3),i(M,g,4),i(M,g,5)];D.some((V,q)=>V!==N[q])&&(l.setOrientation(...D),N=D);const j=[i(M,g,6),i(M,g,7),i(M,g,8)];j.some((V,q)=>V!==x[q])&&(l.setPosition(...j),x=j)},T.connect(P)},S=P=>M=>{M!==N[P]&&(N[P]=M,l.setOrientation(...N))},I=P=>M=>{M!==x[P]&&(x[P]=M,l.setPosition(...x))},E=(P,M,D)=>{const j=e(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:M});j.connect(T,0,P),j.start(),Object.defineProperty(j.offset,"defaultValue",{get(){return M}});const V=s({context:c},w,j.offset,vt,wt);return o(V,"value",q=>()=>q.call(V),q=>W=>{try{q.call(V,W)}catch(Z){if(Z.code!==9)throw Z}k(),w&&D(W)}),V.cancelAndHoldAtTime=(q=>w?()=>{throw r()}:(...W)=>{const Z=q.apply(V,W);return k(),Z})(V.cancelAndHoldAtTime),V.cancelScheduledValues=(q=>w?()=>{throw r()}:(...W)=>{const Z=q.apply(V,W);return k(),Z})(V.cancelScheduledValues),V.exponentialRampToValueAtTime=(q=>w?()=>{throw r()}:(...W)=>{const Z=q.apply(V,W);return k(),Z})(V.exponentialRampToValueAtTime),V.linearRampToValueAtTime=(q=>w?()=>{throw r()}:(...W)=>{const Z=q.apply(V,W);return k(),Z})(V.linearRampToValueAtTime),V.setTargetAtTime=(q=>w?()=>{throw r()}:(...W)=>{const Z=q.apply(V,W);return k(),Z})(V.setTargetAtTime),V.setValueAtTime=(q=>w?()=>{throw r()}:(...W)=>{const Z=q.apply(V,W);return k(),Z})(V.setValueAtTime),V.setValueCurveAtTime=(q=>w?()=>{throw r()}:(...W)=>{const Z=q.apply(V,W);return k(),Z})(V.setValueCurveAtTime),V};return{forwardX:E(0,0,S(0)),forwardY:E(1,0,S(1)),forwardZ:E(2,-1,S(2)),positionX:E(6,0,I(0)),positionY:E(7,0,I(1)),positionZ:E(8,0,I(2)),upX:E(3,0,S(3)),upY:E(4,1,S(4)),upZ:E(5,0,S(5))}},{forwardX:p,forwardY:f,forwardZ:d,positionX:m,positionY:_,positionZ:v,upX:b,upY:C,upZ:A}=l.forwardX===void 0?h():l;return{get forwardX(){return p},get forwardY(){return f},get forwardZ(){return d},get positionX(){return m},get positionY(){return _},get positionZ(){return v},get upX(){return b},get upY(){return C},get upZ(){return A}}},hn=s=>"context"in s,$e=s=>hn(s[0]),de=(s,t,e,n)=>{for(const r of s)if(e(r)){if(n)return!1;throw Error("The set contains at least one similar element.")}return s.add(t),!0},zs=(s,t,[e,n],r)=>{de(s,[t,e,n],i=>i[0]===t&&i[1]===e,r)},$s=(s,[t,e,n],r)=>{const i=s.get(t);i===void 0?s.set(t,new Set([[e,n]])):de(i,[e,n],a=>a[0]===e,r)},Ie=s=>"inputs"in s,dn=(s,t,e,n)=>{if(Ie(t)){const r=t.inputs[n];return s.connect(r,e,0),[r,e,0]}return s.connect(t,e,n),[t,e,n]},mr=(s,t,e)=>{for(const n of s)if(n[0]===t&&n[1]===e)return s.delete(n),n;return null},Ji=(s,t,e)=>bn(s,n=>n[0]===t&&n[1]===e),_r=(s,t)=>{if(!Ue(s).delete(t))throw new Error("Missing the expected event listener.")},gr=(s,t,e)=>{const n=Vt(s,t),r=bn(n,i=>i[0]===e);return n.size===0&&s.delete(t),r},pn=(s,t,e,n)=>{Ie(t)?s.disconnect(t.inputs[n],e,0):s.disconnect(t,e,n)},J=s=>Vt(es,s),Le=s=>Vt(ns,s),ue=s=>$n.has(s),on=s=>!Ce.has(s),Zs=(s,t)=>new Promise(e=>{if(t!==null)e(!0);else{const n=s.createScriptProcessor(256,1,1),r=s.createGain(),i=s.createBuffer(1,2,44100),a=i.getChannelData(0);a[0]=1,a[1]=1;const o=s.createBufferSource();o.buffer=i,o.loop=!0,o.connect(n).connect(s.destination),o.connect(r),o.disconnect(r),n.onaudioprocess=c=>{const u=c.inputBuffer.getChannelData(0);Array.prototype.some.call(u,l=>l===1)?e(!0):e(!1),o.stop(),n.onaudioprocess=null,o.disconnect(n),n.disconnect(s.destination)},o.start()}}),jn=(s,t)=>{const e=new Map;for(const n of s)for(const r of n){const i=e.get(r);e.set(r,i===void 0?1:i+1)}e.forEach((n,r)=>t(r,n))},fn=s=>"context"in s,Ki=s=>{const t=new Map;s.connect=(e=>(n,r=0,i=0)=>{const a=fn(n)?e(n,r,i):e(n,r),o=t.get(n);return o===void 0?t.set(n,[{input:i,output:r}]):o.every(c=>c.input!==i||c.output!==r)&&o.push({input:i,output:r}),a})(s.connect.bind(s)),s.disconnect=(e=>(n,r,i)=>{if(e.apply(s),n===void 0)t.clear();else if(typeof n=="number")for(const[a,o]of t){const c=o.filter(u=>u.output!==n);c.length===0?t.delete(a):t.set(a,c)}else if(t.has(n))if(r===void 0)t.delete(n);else{const a=t.get(n);if(a!==void 0){const o=a.filter(c=>c.output!==r&&(c.input!==i||i===void 0));o.length===0?t.delete(n):t.set(n,o)}}for(const[a,o]of t)o.forEach(c=>{fn(a)?s.connect(a,c.output,c.input):s.connect(a,c.output)})})(s.disconnect)},to=(s,t,e,n)=>{const{activeInputs:r,passiveInputs:i}=ze(t),{outputs:a}=yt(s),o=Ue(s),c=u=>{const l=J(s),h=Le(t);if(u){const p=gr(i,s,e);zs(r,s,p,!1),!n&&!ue(s)&&l.connect(h,e)}else{const p=Ji(r,s,e);$s(i,p,!1),!n&&!ue(s)&&l.disconnect(h,e)}};return de(a,[t,e],u=>u[0]===t&&u[1]===e,!0)?(o.add(c),zt(s)?zs(r,s,[e,c],!0):$s(i,[s,e,c],!0),!0):!1},eo=(s,t,e,n)=>{const{activeInputs:r,passiveInputs:i}=yt(t),a=mr(r[n],s,e);return a===null?[hr(i,s,e,n)[2],!1]:[a[2],!0]},no=(s,t,e)=>{const{activeInputs:n,passiveInputs:r}=ze(t),i=mr(n,s,e);return i===null?[gr(r,s,e)[1],!1]:[i[2],!0]},rs=(s,t,e,n,r)=>{const[i,a]=eo(s,e,n,r);if(i!==null&&(_r(s,i),a&&!t&&!ue(s)&&pn(J(s),J(e),n,r)),zt(e)){const{activeInputs:o}=yt(e);Yn(e,o)}},is=(s,t,e,n)=>{const[r,i]=no(s,e,n);r!==null&&(_r(s,r),i&&!t&&!ue(s)&&J(s).disconnect(Le(e),n))},so=(s,t)=>{const e=yt(s),n=[];for(const r of e.outputs)$e(r)?rs(s,t,...r):is(s,t,...r),n.push(r[0]);return e.outputs.clear(),n},ro=(s,t,e)=>{const n=yt(s),r=[];for(const i of n.outputs)i[1]===e&&($e(i)?rs(s,t,...i):is(s,t,...i),r.push(i[0]),n.outputs.delete(i));return r},io=(s,t,e,n,r)=>{const i=yt(s);return Array.from(i.outputs).filter(a=>a[0]===e&&(n===void 0||a[1]===n)&&(r===void 0||a[2]===r)).map(a=>($e(a)?rs(s,t,...a):is(s,t,...a),i.outputs.delete(a),a[0]))},oo=(s,t,e,n,r,i,a,o,c,u,l,h,p,f,d,m)=>class extends u{constructor(v,b,C,A){super(C),this._context=v,this._nativeAudioNode=C;const g=l(v);h(g)&&e(Zs,()=>Zs(g,m))!==!0&&Ki(C),es.set(this,C),ur.set(this,new Set),v.state!=="closed"&&b&&Se(this),s(this,A,C)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(v){this._nativeAudioNode.channelCount=v}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(v){this._nativeAudioNode.channelCountMode=v}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(v){this._nativeAudioNode.channelInterpretation=v}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(v,b=0,C=0){if(b<0||b>=this._nativeAudioNode.numberOfOutputs)throw r();const A=l(this._context),g=d(A);if(p(v)||f(v))throw i();if(hn(v)){const y=J(v);try{const x=dn(this._nativeAudioNode,y,b,C),k=on(this);(g||k)&&this._nativeAudioNode.disconnect(...x),this.context.state!=="closed"&&!k&&on(v)&&Se(v)}catch(x){throw x.code===12?i():x}if(t(this,v,b,C,g)){const x=c([this],v);jn(x,n(g))}return v}const T=Le(v);if(T.name==="playbackRate"&&T.maxValue===1024)throw a();try{this._nativeAudioNode.connect(T,b),(g||on(this))&&this._nativeAudioNode.disconnect(T,b)}catch(y){throw y.code===12?i():y}if(to(this,v,b,g)){const y=c([this],v);jn(y,n(g))}}disconnect(v,b,C){let A;const g=l(this._context),T=d(g);if(v===void 0)A=so(this,T);else if(typeof v=="number"){if(v<0||v>=this.numberOfOutputs)throw r();A=ro(this,T,v)}else{if(b!==void 0&&(b<0||b>=this.numberOfOutputs)||hn(v)&&C!==void 0&&(C<0||C>=v.numberOfInputs))throw r();if(A=io(this,T,v,b,C),A.length===0)throw i()}for(const w of A){const y=c([this],w);jn(y,o)}}},ao=(s,t,e,n,r,i,a,o,c,u,l,h,p)=>(f,d,m,_=null,v=null)=>{const b=m.value,C=new gi(b),A=d?n(C):null,g={get defaultValue(){return b},get maxValue(){return _===null?m.maxValue:_},get minValue(){return v===null?m.minValue:v},get value(){return m.value},set value(T){m.value=T,g.setValueAtTime(T,f.context.currentTime)},cancelAndHoldAtTime(T){if(typeof m.cancelAndHoldAtTime=="function")A===null&&C.flush(f.context.currentTime),C.add(r(T)),m.cancelAndHoldAtTime(T);else{const w=Array.from(C).pop();A===null&&C.flush(f.context.currentTime),C.add(r(T));const y=Array.from(C).pop();m.cancelScheduledValues(T),w!==y&&y!==void 0&&(y.type==="exponentialRampToValue"?m.exponentialRampToValueAtTime(y.value,y.endTime):y.type==="linearRampToValue"?m.linearRampToValueAtTime(y.value,y.endTime):y.type==="setValue"?m.setValueAtTime(y.value,y.startTime):y.type==="setValueCurve"&&m.setValueCurveAtTime(y.values,y.startTime,y.duration))}return g},cancelScheduledValues(T){return A===null&&C.flush(f.context.currentTime),C.add(i(T)),m.cancelScheduledValues(T),g},exponentialRampToValueAtTime(T,w){if(T===0)throw new RangeError;if(!Number.isFinite(w)||w<0)throw new RangeError;const y=f.context.currentTime;return A===null&&C.flush(y),Array.from(C).length===0&&(C.add(u(b,y)),m.setValueAtTime(b,y)),C.add(a(T,w)),m.exponentialRampToValueAtTime(T,w),g},linearRampToValueAtTime(T,w){const y=f.context.currentTime;return A===null&&C.flush(y),Array.from(C).length===0&&(C.add(u(b,y)),m.setValueAtTime(b,y)),C.add(o(T,w)),m.linearRampToValueAtTime(T,w),g},setTargetAtTime(T,w,y){return A===null&&C.flush(f.context.currentTime),C.add(c(T,w,y)),m.setTargetAtTime(T,w,y),g},setValueAtTime(T,w){return A===null&&C.flush(f.context.currentTime),C.add(u(T,w)),m.setValueAtTime(T,w),g},setValueCurveAtTime(T,w,y){const N=T instanceof Float32Array?T:new Float32Array(T);if(h!==null&&h.name==="webkitAudioContext"){const x=w+y,k=f.context.sampleRate,S=Math.ceil(w*k),I=Math.floor(x*k),E=I-S,P=new Float32Array(E);for(let D=0;D<E;D+=1){const j=(N.length-1)/y*((S+D)/k-w),V=Math.floor(j),q=Math.ceil(j);P[D]=V===q?N[V]:(1-(j-V))*N[V]+(1-(q-j))*N[q]}A===null&&C.flush(f.context.currentTime),C.add(l(P,w,y)),m.setValueCurveAtTime(P,w,y);const M=I/k;M<x&&p(g,P[P.length-1],M),p(g,N[N.length-1],x)}else A===null&&C.flush(f.context.currentTime),C.add(l(N,w,y)),m.setValueCurveAtTime(N,w,y);return g}};return e.set(g,m),t.set(g,f),s(g,A),g},co=s=>({replay(t){for(const e of s)if(e.type==="exponentialRampToValue"){const{endTime:n,value:r}=e;t.exponentialRampToValueAtTime(r,n)}else if(e.type==="linearRampToValue"){const{endTime:n,value:r}=e;t.linearRampToValueAtTime(r,n)}else if(e.type==="setTarget"){const{startTime:n,target:r,timeConstant:i}=e;t.setTargetAtTime(r,n,i)}else if(e.type==="setValue"){const{startTime:n,value:r}=e;t.setValueAtTime(r,n)}else if(e.type==="setValueCurve"){const{duration:n,startTime:r,values:i}=e;t.setValueCurveAtTime(i,r,n)}else throw new Error("Can't apply an unknown automation.")}});class vr{constructor(t){this._map=new Map(t)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(t,e=null){return this._map.forEach((n,r)=>t.call(e,n,r,this))}get(t){return this._map.get(t)}has(t){return this._map.has(t)}keys(){return this._map.keys()}values(){return this._map.values()}}const uo={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},lo=(s,t,e,n,r,i,a,o,c,u,l,h,p,f)=>class extends t{constructor(m,_,v){var b;const C=o(m),A=c(C),g=l({...uo,...v});p(g);const T=Zn.get(C),w=T?.get(_),y=A||C.state!=="closed"?C:(b=a(C))!==null&&b!==void 0?b:C,N=r(y,A?null:m.baseLatency,u,_,w,g),x=A?n(_,g,w):null;super(m,!0,N,x);const k=[];N.parameters.forEach((I,E)=>{const P=e(this,A,I);k.push([E,P])}),this._nativeAudioWorkletNode=N,this._onprocessorerror=null,this._parameters=new vr(k),A&&s(C,this);const{activeInputs:S}=i(this);h(N,S)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(m){const _=typeof m=="function"?f(this,m):null;this._nativeAudioWorkletNode.onprocessorerror=_;const v=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=v!==null&&v===_?m:v}get parameters(){return this._parameters===null?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}};function mn(s,t,e,n,r){if(typeof s.copyFromChannel=="function")t[e].byteLength===0&&(t[e]=new Float32Array(128)),s.copyFromChannel(t[e],n,r);else{const i=s.getChannelData(n);if(t[e].byteLength===0)t[e]=i.slice(r,r+128);else{const a=new Float32Array(i.buffer,r*Float32Array.BYTES_PER_ELEMENT,128);t[e].set(a)}}}const yr=(s,t,e,n,r)=>{typeof s.copyToChannel=="function"?t[e].byteLength!==0&&s.copyToChannel(t[e],n,r):t[e].byteLength!==0&&s.getChannelData(n).set(t[e],r)},_n=(s,t)=>{const e=[];for(let n=0;n<s;n+=1){const r=[],i=typeof t=="number"?t:t[n];for(let a=0;a<i;a+=1)r.push(new Float32Array(128));e.push(r)}return e},ho=(s,t)=>{const e=Vt(Xn,s),n=J(t);return Vt(e,n)},po=async(s,t,e,n,r,i,a)=>{const o=t===null?Math.ceil(s.context.length/128)*128:t.length,c=n.channelCount*n.numberOfInputs,u=r.reduce((_,v)=>_+v,0),l=u===0?null:e.createBuffer(u,o,e.sampleRate);if(i===void 0)throw new Error("Missing the processor constructor.");const h=yt(s),p=await ho(e,s),f=_n(n.numberOfInputs,n.channelCount),d=_n(n.numberOfOutputs,r),m=Array.from(s.parameters.keys()).reduce((_,v)=>({..._,[v]:new Float32Array(128)}),{});for(let _=0;_<o;_+=128){if(n.numberOfInputs>0&&t!==null)for(let v=0;v<n.numberOfInputs;v+=1)for(let b=0;b<n.channelCount;b+=1)mn(t,f[v],b,b,_);i.parameterDescriptors!==void 0&&t!==null&&i.parameterDescriptors.forEach(({name:v},b)=>{mn(t,m,v,c+b,_)});for(let v=0;v<n.numberOfInputs;v+=1)for(let b=0;b<r[v];b+=1)d[v][b].byteLength===0&&(d[v][b]=new Float32Array(128));try{const v=f.map((C,A)=>h.activeInputs[A].size===0?[]:C),b=a(_/e.sampleRate,e.sampleRate,()=>p.process(v,d,m));if(l!==null)for(let C=0,A=0;C<n.numberOfOutputs;C+=1){for(let g=0;g<r[C];g+=1)yr(l,d[C],g,A+g,_);A+=r[C]}if(!b)break}catch(v){s.dispatchEvent(new ErrorEvent("processorerror",{colno:v.colno,filename:v.filename,lineno:v.lineno,message:v.message}));break}}return l},fo=(s,t,e,n,r,i,a,o,c,u,l,h,p,f,d,m)=>(_,v,b)=>{const C=new WeakMap;let A=null;const g=async(T,w)=>{let y=l(T),N=null;const x=_t(y,w),k=Array.isArray(v.outputChannelCount)?v.outputChannelCount:Array.from(v.outputChannelCount);if(h===null){const S=k.reduce((M,D)=>M+D,0),I=r(w,{channelCount:Math.max(1,S),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,S)}),E=[];for(let M=0;M<T.numberOfOutputs;M+=1)E.push(n(w,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:k[M]}));const P=a(w,{channelCount:v.channelCount,channelCountMode:v.channelCountMode,channelInterpretation:v.channelInterpretation,gain:1});P.connect=t.bind(null,E),P.disconnect=c.bind(null,E),N=[I,E,P]}else x||(y=new h(w,_));if(C.set(w,N===null?y:N[2]),N!==null){if(A===null){if(b===void 0)throw new Error("Missing the processor constructor.");if(p===null)throw new Error("Missing the native OfflineAudioContext constructor.");const D=T.channelCount*T.numberOfInputs,j=b.parameterDescriptors===void 0?0:b.parameterDescriptors.length,V=D+j;A=po(T,V===0?null:await(async()=>{const W=new p(V,Math.ceil(T.context.length/128)*128,w.sampleRate),Z=[],At=[];for(let K=0;K<v.numberOfInputs;K+=1)Z.push(a(W,{channelCount:v.channelCount,channelCountMode:v.channelCountMode,channelInterpretation:v.channelInterpretation,gain:1})),At.push(r(W,{channelCount:v.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:v.channelCount}));const kt=await Promise.all(Array.from(T.parameters.values()).map(async K=>{const gt=i(W,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:K.value});return await f(W,K,gt.offset),gt})),G=n(W,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,D+j)});for(let K=0;K<v.numberOfInputs;K+=1){Z[K].connect(At[K]);for(let gt=0;gt<v.channelCount;gt+=1)At[K].connect(G,gt,K*v.channelCount+gt)}for(const[K,gt]of kt.entries())gt.connect(G,0,D+K),gt.start(0);return G.connect(W.destination),await Promise.all(Z.map(K=>d(T,W,K))),m(W)})(),w,v,k,b,u)}const S=await A,I=e(w,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[E,P,M]=N;S!==null&&(I.buffer=S,I.start(0)),I.connect(E);for(let D=0,j=0;D<T.numberOfOutputs;D+=1){const V=P[D];for(let q=0;q<k[D];q+=1)E.connect(V,j+q,q);j+=k[D]}return M}if(x)for(const[S,I]of T.parameters.entries())await s(w,I,y.parameters.get(S));else for(const[S,I]of T.parameters.entries())await f(w,I,y.parameters.get(S));return await d(T,w,y),y};return{render(T,w){o(w,T);const y=C.get(w);return y!==void 0?Promise.resolve(y):g(T,w)}}},mo=(s,t,e,n,r,i,a,o,c,u,l,h,p,f,d,m,_,v,b,C)=>class extends d{constructor(g,T){super(g,T),this._nativeContext=g,this._audioWorklet=s===void 0?void 0:{addModule:(w,y)=>s(this,w,y)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new t(this)}createBiquadFilter(){return new r(this)}createBuffer(g,T,w){return new e({length:T,numberOfChannels:g,sampleRate:w})}createBufferSource(){return new n(this)}createChannelMerger(g=6){return new i(this,{numberOfInputs:g})}createChannelSplitter(g=6){return new a(this,{numberOfOutputs:g})}createConstantSource(){return new o(this)}createConvolver(){return new c(this)}createDelay(g=1){return new l(this,{maxDelayTime:g})}createDynamicsCompressor(){return new h(this)}createGain(){return new p(this)}createIIRFilter(g,T){return new f(this,{feedback:T,feedforward:g})}createOscillator(){return new m(this)}createPanner(){return new _(this)}createPeriodicWave(g,T,w={disableNormalization:!1}){return new v(this,{...w,imag:T,real:g})}createStereoPanner(){return new b(this)}createWaveShaper(){return new C(this)}decodeAudioData(g,T,w){return u(this._nativeContext,g).then(y=>(typeof T=="function"&&T(y),y),y=>{throw typeof w=="function"&&w(y),y})}},_o={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},go=(s,t,e,n,r,i,a,o)=>class extends s{constructor(u,l){const h=i(u),p={..._o,...l},f=r(h,p),d=a(h),m=d?e():null;super(u,!1,f,m),this._Q=t(this,d,f.Q,vt,wt),this._detune=t(this,d,f.detune,1200*Math.log2(vt),-1200*Math.log2(vt)),this._frequency=t(this,d,f.frequency,u.sampleRate/2,0),this._gain=t(this,d,f.gain,40*Math.log10(vt),wt),this._nativeBiquadFilterNode=f,o(this,1)}get detune(){return this._detune}get frequency(){return this._frequency}get gain(){return this._gain}get Q(){return this._Q}get type(){return this._nativeBiquadFilterNode.type}set type(u){this._nativeBiquadFilterNode.type=u}getFrequencyResponse(u,l,h){try{this._nativeBiquadFilterNode.getFrequencyResponse(u,l,h)}catch(p){throw p.code===11?n():p}if(u.length!==l.length||l.length!==h.length)throw n()}},vo=(s,t,e,n,r)=>()=>{const i=new WeakMap,a=async(o,c)=>{let u=e(o);const l=_t(u,c);if(!l){const h={Q:u.Q.value,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,detune:u.detune.value,frequency:u.frequency.value,gain:u.gain.value,type:u.type};u=t(c,h)}return i.set(c,u),l?(await s(c,o.Q,u.Q),await s(c,o.detune,u.detune),await s(c,o.frequency,u.frequency),await s(c,o.gain,u.gain)):(await n(c,o.Q,u.Q),await n(c,o.detune,u.detune),await n(c,o.frequency,u.frequency),await n(c,o.gain,u.gain)),await r(o,c,u),u};return{render(o,c){const u=i.get(c);return u!==void 0?Promise.resolve(u):a(o,c)}}},yo=(s,t)=>(e,n)=>{const r=t.get(e);if(r!==void 0)return r;const i=s.get(e);if(i!==void 0)return i;try{const a=n();return a instanceof Promise?(s.set(e,a),a.catch(()=>!1).then(o=>(s.delete(e),t.set(e,o),o))):(t.set(e,a),a)}catch{return t.set(e,!1),!1}},To={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},wo=(s,t,e,n,r)=>class extends s{constructor(a,o){const c=n(a),u={...To,...o},l=e(c,u),h=r(c)?t():null;super(a,!1,l,h)}},bo=(s,t,e)=>()=>{const n=new WeakMap,r=async(i,a)=>{let o=t(i);if(!_t(o,a)){const u={channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,numberOfInputs:o.numberOfInputs};o=s(a,u)}return n.set(a,o),await e(i,a,o),o};return{render(i,a){const o=n.get(a);return o!==void 0?Promise.resolve(o):r(i,a)}}},Co={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},So=(s,t,e,n,r,i)=>class extends s{constructor(o,c){const u=n(o),l=i({...Co,...c}),h=e(u,l),p=r(u)?t():null;super(o,!1,h,p)}},Ao=(s,t,e)=>()=>{const n=new WeakMap,r=async(i,a)=>{let o=t(i);if(!_t(o,a)){const u={channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,numberOfOutputs:o.numberOfOutputs};o=s(a,u)}return n.set(a,o),await e(i,a,o),o};return{render(i,a){const o=n.get(a);return o!==void 0?Promise.resolve(o):r(i,a)}}},ko=s=>(t,e,n)=>s(e,t,n),xo=s=>(t,e,n=0,r=0)=>{const i=t[n];if(i===void 0)throw s();return fn(e)?i.connect(e,0,r):i.connect(e,0)},No=s=>(t,e)=>{const n=s(t,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),r=t.createBuffer(1,2,44100);return n.buffer=r,n.loop=!0,n.connect(e),n.start(),()=>{n.stop(),n.disconnect(e)}},Oo={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},Eo=(s,t,e,n,r,i,a)=>class extends s{constructor(c,u){const l=r(c),h={...Oo,...u},p=n(l,h),f=i(l),d=f?e():null;super(c,!1,p,d),this._constantSourceNodeRenderer=d,this._nativeConstantSourceNode=p,this._offset=t(this,f,p.offset,vt,wt),this._onended=null}get offset(){return this._offset}get onended(){return this._onended}set onended(c){const u=typeof c=="function"?a(this,c):null;this._nativeConstantSourceNode.onended=u;const l=this._nativeConstantSourceNode.onended;this._onended=l!==null&&l===u?c:l}start(c=0){if(this._nativeConstantSourceNode.start(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.start=c),this.context.state!=="closed"){Se(this);const u=()=>{this._nativeConstantSourceNode.removeEventListener("ended",u),zt(this)&&Ge(this)};this._nativeConstantSourceNode.addEventListener("ended",u)}}stop(c=0){this._nativeConstantSourceNode.stop(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.stop=c)}},Io=(s,t,e,n,r)=>()=>{const i=new WeakMap;let a=null,o=null;const c=async(u,l)=>{let h=e(u);const p=_t(h,l);if(!p){const f={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,offset:h.offset.value};h=t(l,f),a!==null&&h.start(a),o!==null&&h.stop(o)}return i.set(l,h),p?await s(l,u.offset,h.offset):await n(l,u.offset,h.offset),await r(u,l,h),h};return{set start(u){a=u},set stop(u){o=u},render(u,l){const h=i.get(l);return h!==void 0?Promise.resolve(h):c(u,l)}}},Mo=s=>t=>(s[0]=t,s[0]),Do={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},Ro=(s,t,e,n,r,i)=>class extends s{constructor(o,c){const u=n(o),l={...Do,...c},h=e(u,l),f=r(u)?t():null;super(o,!1,h,f),this._isBufferNullified=!1,this._nativeConvolverNode=h,l.buffer!==null&&i(this,l.buffer.duration)}get buffer(){return this._isBufferNullified?null:this._nativeConvolverNode.buffer}set buffer(o){if(this._nativeConvolverNode.buffer=o,o===null&&this._nativeConvolverNode.buffer!==null){const c=this._nativeConvolverNode.context;this._nativeConvolverNode.buffer=c.createBuffer(1,1,c.sampleRate),this._isBufferNullified=!0,i(this,0)}else this._isBufferNullified=!1,i(this,this._nativeConvolverNode.buffer===null?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(o){this._nativeConvolverNode.normalize=o}},Po=(s,t,e)=>()=>{const n=new WeakMap,r=async(i,a)=>{let o=t(i);if(!_t(o,a)){const u={buffer:o.buffer,channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,disableNormalization:!o.normalize};o=s(a,u)}return n.set(a,o),Ie(o)?await e(i,a,o.inputs[0]):await e(i,a,o),o};return{render(i,a){const o=n.get(a);return o!==void 0?Promise.resolve(o):r(i,a)}}},Vo=(s,t)=>(e,n,r)=>{if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new t(e,n,r)}catch(i){throw i.name==="SyntaxError"?s():i}},Fo=()=>new DOMException("","DataCloneError"),Xs=s=>{const{port1:t,port2:e}=new MessageChannel;return new Promise(n=>{const r=()=>{e.onmessage=null,t.close(),e.close(),n()};e.onmessage=()=>r();try{t.postMessage(s,[s])}catch{}finally{r()}})},Wo=(s,t,e,n,r,i,a,o,c,u,l)=>(h,p)=>{const f=a(h)?h:i(h);if(r.has(p)){const d=e();return Promise.reject(d)}try{r.add(p)}catch{}return t(c,()=>c(f))?f.decodeAudioData(p).then(d=>(Xs(p).catch(()=>{}),t(o,()=>o(d))||l(d),s.add(d),d)):new Promise((d,m)=>{const _=async()=>{try{await Xs(p)}catch{}},v=b=>{m(b),_()};try{f.decodeAudioData(p,b=>{typeof b.copyFromChannel!="function"&&(u(b),ss(b)),s.add(b),_().then(()=>d(b))},b=>{v(b===null?n():b)})}catch(b){v(b)}})},qo=(s,t,e,n,r,i,a,o)=>(c,u)=>{const l=t.get(c);if(l===void 0)throw new Error("Missing the expected cycle count.");const h=i(c.context),p=o(h);if(l===u){if(t.delete(c),!p&&a(c)){const f=n(c),{outputs:d}=e(c);for(const m of d)if($e(m)){const _=n(m[0]);s(f,_,m[1],m[2])}else{const _=r(m[0]);f.connect(_,m[1])}}}else t.set(c,l-u)},Lo={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},Bo=(s,t,e,n,r,i,a)=>class extends s{constructor(c,u){const l=r(c),h={...Lo,...u},p=n(l,h),f=i(l),d=f?e(h.maxDelayTime):null;super(c,!1,p,d),this._delayTime=t(this,f,p.delayTime),a(this,h.maxDelayTime)}get delayTime(){return this._delayTime}},jo=(s,t,e,n,r)=>i=>{const a=new WeakMap,o=async(c,u)=>{let l=e(c);const h=_t(l,u);if(!h){const p={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,delayTime:l.delayTime.value,maxDelayTime:i};l=t(u,p)}return a.set(u,l),h?await s(u,c.delayTime,l.delayTime):await n(u,c.delayTime,l.delayTime),await r(c,u,l),l};return{render(c,u){const l=a.get(u);return l!==void 0?Promise.resolve(l):o(c,u)}}},Uo=s=>(t,e,n,r)=>s(t[r],i=>i[0]===e&&i[1]===n),Go=s=>(t,e)=>{s(t).delete(e)},zo=s=>"delayTime"in s,$o=(s,t,e)=>function n(r,i){const a=hn(i)?i:e(s,i);if(zo(a))return[];if(r[0]===a)return[r];if(r.includes(a))return[];const{outputs:o}=t(a);return Array.from(o).map(c=>n([...r,a],c[0])).reduce((c,u)=>c.concat(u),[])},nn=(s,t,e)=>{const n=t[e];if(n===void 0)throw s();return n},Zo=s=>(t,e=void 0,n=void 0,r=0)=>e===void 0?t.forEach(i=>i.disconnect()):typeof e=="number"?nn(s,t,e).disconnect():fn(e)?n===void 0?t.forEach(i=>i.disconnect(e)):r===void 0?nn(s,t,n).disconnect(e,0):nn(s,t,n).disconnect(e,0,r):n===void 0?t.forEach(i=>i.disconnect(e)):nn(s,t,n).disconnect(e,0),Xo={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},Yo=(s,t,e,n,r,i,a,o)=>class extends s{constructor(u,l){const h=i(u),p={...Xo,...l},f=n(h,p),d=a(h),m=d?e():null;super(u,!1,f,m),this._attack=t(this,d,f.attack),this._knee=t(this,d,f.knee),this._nativeDynamicsCompressorNode=f,this._ratio=t(this,d,f.ratio),this._release=t(this,d,f.release),this._threshold=t(this,d,f.threshold),o(this,.006)}get attack(){return this._attack}get channelCount(){return this._nativeDynamicsCompressorNode.channelCount}set channelCount(u){const l=this._nativeDynamicsCompressorNode.channelCount;if(this._nativeDynamicsCompressorNode.channelCount=u,u>2)throw this._nativeDynamicsCompressorNode.channelCount=l,r()}get channelCountMode(){return this._nativeDynamicsCompressorNode.channelCountMode}set channelCountMode(u){const l=this._nativeDynamicsCompressorNode.channelCountMode;if(this._nativeDynamicsCompressorNode.channelCountMode=u,u==="max")throw this._nativeDynamicsCompressorNode.channelCountMode=l,r()}get knee(){return this._knee}get ratio(){return this._ratio}get reduction(){return typeof this._nativeDynamicsCompressorNode.reduction.value=="number"?this._nativeDynamicsCompressorNode.reduction.value:this._nativeDynamicsCompressorNode.reduction}get release(){return this._release}get threshold(){return this._threshold}},Ho=(s,t,e,n,r)=>()=>{const i=new WeakMap,a=async(o,c)=>{let u=e(o);const l=_t(u,c);if(!l){const h={attack:u.attack.value,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,knee:u.knee.value,ratio:u.ratio.value,release:u.release.value,threshold:u.threshold.value};u=t(c,h)}return i.set(c,u),l?(await s(c,o.attack,u.attack),await s(c,o.knee,u.knee),await s(c,o.ratio,u.ratio),await s(c,o.release,u.release),await s(c,o.threshold,u.threshold)):(await n(c,o.attack,u.attack),await n(c,o.knee,u.knee),await n(c,o.ratio,u.ratio),await n(c,o.release,u.release),await n(c,o.threshold,u.threshold)),await r(o,c,u),u};return{render(o,c){const u=i.get(c);return u!==void 0?Promise.resolve(u):a(o,c)}}},Qo=()=>new DOMException("","EncodingError"),Jo=s=>t=>new Promise((e,n)=>{if(s===null){n(new SyntaxError);return}const r=s.document.head;if(r===null)n(new SyntaxError);else{const i=s.document.createElement("script"),a=new Blob([t],{type:"application/javascript"}),o=URL.createObjectURL(a),c=s.onerror,u=()=>{s.onerror=c,URL.revokeObjectURL(o)};s.onerror=(l,h,p,f,d)=>{if(h===o||h===s.location.href&&p===1&&f===1)return u(),n(d),!1;if(c!==null)return c(l,h,p,f,d)},i.onerror=()=>{u(),n(new SyntaxError)},i.onload=()=>{u(),e()},i.src=o,i.type="module",r.appendChild(i)}}),Ko=s=>class{constructor(e){this._nativeEventTarget=e,this._listeners=new WeakMap}addEventListener(e,n,r){if(n!==null){let i=this._listeners.get(n);i===void 0&&(i=s(this,n),typeof n=="function"&&this._listeners.set(n,i)),this._nativeEventTarget.addEventListener(e,i,r)}}dispatchEvent(e){return this._nativeEventTarget.dispatchEvent(e)}removeEventListener(e,n,r){const i=n===null?void 0:this._listeners.get(n);this._nativeEventTarget.removeEventListener(e,i===void 0?null:i,r)}},ta=s=>(t,e,n)=>{Object.defineProperties(s,{currentFrame:{configurable:!0,get(){return Math.round(t*e)}},currentTime:{configurable:!0,get(){return t}}});try{return n()}finally{s!==null&&(delete s.currentFrame,delete s.currentTime)}},ea=s=>async t=>{try{const e=await fetch(t);if(e.ok)return[await e.text(),e.url]}catch{}throw s()},na={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},sa=(s,t,e,n,r,i)=>class extends s{constructor(o,c){const u=r(o),l={...na,...c},h=n(u,l),p=i(u),f=p?e():null;super(o,!1,h,f),this._gain=t(this,p,h.gain,vt,wt)}get gain(){return this._gain}},ra=(s,t,e,n,r)=>()=>{const i=new WeakMap,a=async(o,c)=>{let u=e(o);const l=_t(u,c);if(!l){const h={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,gain:u.gain.value};u=t(c,h)}return i.set(c,u),l?await s(c,o.gain,u.gain):await n(c,o.gain,u.gain),await r(o,c,u),u};return{render(o,c){const u=i.get(c);return u!==void 0?Promise.resolve(u):a(o,c)}}},ia=(s,t)=>e=>t(s,e),oa=s=>t=>{const e=s(t);if(e.renderer===null)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return e.renderer},aa=s=>t=>{var e;return(e=s.get(t))!==null&&e!==void 0?e:0},ca=s=>t=>{const e=s(t);if(e.renderer===null)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return e.renderer},ua=s=>t=>s.get(t),dt=()=>new DOMException("","InvalidStateError"),la=s=>t=>{const e=s.get(t);if(e===void 0)throw dt();return e},ha=(s,t)=>e=>{let n=s.get(e);if(n!==void 0)return n;if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");return n=new t(1,1,44100),s.set(e,n),n},da=s=>t=>{const e=s.get(t);if(e===void 0)throw new Error("The context has no set of AudioWorkletNodes.");return e},Cn=()=>new DOMException("","InvalidAccessError"),pa=s=>{s.getFrequencyResponse=(t=>(e,n,r)=>{if(e.length!==n.length||n.length!==r.length)throw Cn();return t.call(s,e,n,r)})(s.getFrequencyResponse)},fa={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},ma=(s,t,e,n,r,i)=>class extends s{constructor(o,c){const u=n(o),l=r(u),h={...fa,...c},p=t(u,l?null:o.baseLatency,h),f=l?e(h.feedback,h.feedforward):null;super(o,!1,p,f),pa(p),this._nativeIIRFilterNode=p,i(this,1)}getFrequencyResponse(o,c,u){return this._nativeIIRFilterNode.getFrequencyResponse(o,c,u)}},Tr=(s,t,e,n,r,i,a,o,c,u,l)=>{const h=u.length;let p=o;for(let f=0;f<h;f+=1){let d=e[0]*u[f];for(let m=1;m<r;m+=1){const _=p-m&c-1;d+=e[m]*i[_],d-=s[m]*a[_]}for(let m=r;m<n;m+=1)d+=e[m]*i[p-m&c-1];for(let m=r;m<t;m+=1)d-=s[m]*a[p-m&c-1];i[p]=u[f],a[p]=d,p=p+1&c-1,l[f]=d}return p},_a=(s,t,e,n)=>{const r=e instanceof Float64Array?e:new Float64Array(e),i=n instanceof Float64Array?n:new Float64Array(n),a=r.length,o=i.length,c=Math.min(a,o);if(r[0]!==1){for(let d=0;d<a;d+=1)i[d]/=r[0];for(let d=1;d<o;d+=1)r[d]/=r[0]}const u=32,l=new Float32Array(u),h=new Float32Array(u),p=t.createBuffer(s.numberOfChannels,s.length,s.sampleRate),f=s.numberOfChannels;for(let d=0;d<f;d+=1){const m=s.getChannelData(d),_=p.getChannelData(d);l.fill(0),h.fill(0),Tr(r,a,i,o,c,l,h,0,u,m,_)}return p},ga=(s,t,e,n,r)=>(i,a)=>{const o=new WeakMap;let c=null;const u=async(l,h)=>{let p=null,f=t(l);const d=_t(f,h);if(h.createIIRFilter===void 0?p=s(h,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):d||(f=h.createIIRFilter(a,i)),o.set(h,p===null?f:p),p!==null){if(c===null){if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");const _=new e(l.context.destination.channelCount,l.context.length,h.sampleRate);c=(async()=>{await n(l,_,_.destination);const v=await r(_);return _a(v,h,i,a)})()}const m=await c;return p.buffer=m,p.start(0),p}return await n(l,h,f),f};return{render(l,h){const p=o.get(h);return p!==void 0?Promise.resolve(p):u(l,h)}}},va=(s,t,e,n,r,i)=>a=>(o,c)=>{const u=s.get(o);if(u===void 0){if(!a&&i(o)){const l=n(o),{outputs:h}=e(o);for(const p of h)if($e(p)){const f=n(p[0]);t(l,f,p[1],p[2])}else{const f=r(p[0]);l.disconnect(f,p[1])}}s.set(o,c)}else s.set(o,u+c)},ya=(s,t)=>e=>{const n=s.get(e);return t(n)||t(e)},Ta=(s,t)=>e=>s.has(e)||t(e),wa=(s,t)=>e=>s.has(e)||t(e),ba=(s,t)=>e=>{const n=s.get(e);return t(n)||t(e)},Ca=s=>t=>s!==null&&t instanceof s,Sa=s=>t=>s!==null&&typeof s.AudioNode=="function"&&t instanceof s.AudioNode,Aa=s=>t=>s!==null&&typeof s.AudioParam=="function"&&t instanceof s.AudioParam,ka=(s,t)=>e=>s(e)||t(e),xa=s=>t=>s!==null&&t instanceof s,Na=s=>s!==null&&s.isSecureContext,Oa=(s,t,e,n)=>class extends s{constructor(i,a){const o=e(i),c=t(o,a);if(n(o))throw TypeError();super(i,!0,c,null),this._nativeMediaElementAudioSourceNode=c}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}},Ea={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},Ia=(s,t,e,n)=>class extends s{constructor(i,a){const o=e(i);if(n(o))throw new TypeError;const c={...Ea,...a},u=t(o,c);super(i,!1,u,null),this._nativeMediaStreamAudioDestinationNode=u}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}},Ma=(s,t,e,n)=>class extends s{constructor(i,a){const o=e(i),c=t(o,a);if(n(o))throw new TypeError;super(i,!0,c,null),this._nativeMediaStreamAudioSourceNode=c}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}},Da=(s,t,e)=>class extends s{constructor(r,i){const a=e(r),o=t(a,i);super(r,!0,o,null)}},Ra=(s,t,e,n,r,i)=>class extends e{constructor(o,c){super(o),this._nativeContext=o,wn.set(this,o),n(o)&&r.set(o,new Set),this._destination=new s(this,c),this._listener=t(this,o),this._onstatechange=null}get currentTime(){return this._nativeContext.currentTime}get destination(){return this._destination}get listener(){return this._listener}get onstatechange(){return this._onstatechange}set onstatechange(o){const c=typeof o=="function"?i(this,o):null;this._nativeContext.onstatechange=c;const u=this._nativeContext.onstatechange;this._onstatechange=u!==null&&u===c?o:u}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}},Be=s=>{const t=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{const e=s.decodeAudioData(t.buffer,()=>{});return e===void 0?!1:(e.catch(()=>{}),!0)}catch{}return!1},Pa=(s,t)=>(e,n,r)=>{const i=new Set;return e.connect=(a=>(o,c=0,u=0)=>{const l=i.size===0;if(t(o))return a.call(e,o,c,u),s(i,[o,c,u],h=>h[0]===o&&h[1]===c&&h[2]===u,!0),l&&n(),o;a.call(e,o,c),s(i,[o,c],h=>h[0]===o&&h[1]===c,!0),l&&n()})(e.connect),e.disconnect=(a=>(o,c,u)=>{const l=i.size>0;if(o===void 0)a.apply(e),i.clear();else if(typeof o=="number"){a.call(e,o);for(const p of i)p[1]===o&&i.delete(p)}else{t(o)?a.call(e,o,c,u):a.call(e,o,c);for(const p of i)p[0]===o&&(c===void 0||p[1]===c)&&(u===void 0||p[2]===u)&&i.delete(p)}const h=i.size===0;l&&h&&r()})(e.disconnect),e},tt=(s,t,e)=>{const n=t[e];n!==void 0&&n!==s[e]&&(s[e]=n)},ht=(s,t)=>{tt(s,t,"channelCount"),tt(s,t,"channelCountMode"),tt(s,t,"channelInterpretation")},Ys=s=>typeof s.getFloatTimeDomainData=="function",Va=s=>{s.getFloatTimeDomainData=t=>{const e=new Uint8Array(t.length);s.getByteTimeDomainData(e);const n=Math.max(e.length,s.fftSize);for(let r=0;r<n;r+=1)t[r]=(e[r]-128)*.0078125;return t}},Fa=(s,t)=>(e,n)=>{const r=e.createAnalyser();if(ht(r,n),!(n.maxDecibels>n.minDecibels))throw t();return tt(r,n,"fftSize"),tt(r,n,"maxDecibels"),tt(r,n,"minDecibels"),tt(r,n,"smoothingTimeConstant"),s(Ys,()=>Ys(r))||Va(r),r},Wa=s=>s===null?null:s.hasOwnProperty("AudioBuffer")?s.AudioBuffer:null,rt=(s,t,e)=>{const n=t[e];n!==void 0&&n!==s[e].value&&(s[e].value=n)},qa=s=>{s.start=(t=>{let e=!1;return(n=0,r=0,i)=>{if(e)throw dt();t.call(s,n,r,i),e=!0}})(s.start)},os=s=>{s.start=(t=>(e=0,n=0,r)=>{if(typeof r=="number"&&r<0||n<0||e<0)throw new RangeError("The parameters can't be negative.");t.call(s,e,n,r)})(s.start)},as=s=>{s.stop=(t=>(e=0)=>{if(e<0)throw new RangeError("The parameter can't be negative.");t.call(s,e)})(s.stop)},La=(s,t,e,n,r,i,a,o,c,u,l)=>(h,p)=>{const f=h.createBufferSource();return ht(f,p),rt(f,p,"playbackRate"),tt(f,p,"buffer"),tt(f,p,"loop"),tt(f,p,"loopEnd"),tt(f,p,"loopStart"),t(e,()=>e(h))||qa(f),t(n,()=>n(h))||c(f),t(r,()=>r(h))||u(f,h),t(i,()=>i(h))||os(f),t(a,()=>a(h))||l(f,h),t(o,()=>o(h))||as(f),s(h,f),f},Ba=s=>s===null?null:s.hasOwnProperty("AudioContext")?s.AudioContext:s.hasOwnProperty("webkitAudioContext")?s.webkitAudioContext:null,ja=(s,t)=>(e,n,r)=>{const i=e.destination;if(i.channelCount!==n)try{i.channelCount=n}catch{}r&&i.channelCountMode!=="explicit"&&(i.channelCountMode="explicit"),i.maxChannelCount===0&&Object.defineProperty(i,"maxChannelCount",{value:n});const a=s(e,{channelCount:n,channelCountMode:i.channelCountMode,channelInterpretation:i.channelInterpretation,gain:1});return t(a,"channelCount",o=>()=>o.call(a),o=>c=>{o.call(a,c);try{i.channelCount=c}catch(u){if(c>i.maxChannelCount)throw u}}),t(a,"channelCountMode",o=>()=>o.call(a),o=>c=>{o.call(a,c),i.channelCountMode=c}),t(a,"channelInterpretation",o=>()=>o.call(a),o=>c=>{o.call(a,c),i.channelInterpretation=c}),Object.defineProperty(a,"maxChannelCount",{get:()=>i.maxChannelCount}),a.connect(i),a},Ua=s=>s===null?null:s.hasOwnProperty("AudioWorkletNode")?s.AudioWorkletNode:null,Ga=s=>{const{port1:t}=new MessageChannel;try{t.postMessage(s)}finally{t.close()}},za=(s,t,e,n,r)=>(i,a,o,c,u,l)=>{if(o!==null)try{const h=new o(i,c,l),p=new Map;let f=null;if(Object.defineProperties(h,{channelCount:{get:()=>l.channelCount,set:()=>{throw s()}},channelCountMode:{get:()=>"explicit",set:()=>{throw s()}},onprocessorerror:{get:()=>f,set:d=>{typeof f=="function"&&h.removeEventListener("processorerror",f),f=typeof d=="function"?d:null,typeof f=="function"&&h.addEventListener("processorerror",f)}}}),h.addEventListener=(d=>(...m)=>{if(m[0]==="processorerror"){const _=typeof m[1]=="function"?m[1]:typeof m[1]=="object"&&m[1]!==null&&typeof m[1].handleEvent=="function"?m[1].handleEvent:null;if(_!==null){const v=p.get(m[1]);v!==void 0?m[1]=v:(m[1]=b=>{b.type==="error"?(Object.defineProperties(b,{type:{value:"processorerror"}}),_(b)):_(new ErrorEvent(m[0],{...b}))},p.set(_,m[1]))}}return d.call(h,"error",m[1],m[2]),d.call(h,...m)})(h.addEventListener),h.removeEventListener=(d=>(...m)=>{if(m[0]==="processorerror"){const _=p.get(m[1]);_!==void 0&&(p.delete(m[1]),m[1]=_)}return d.call(h,"error",m[1],m[2]),d.call(h,m[0],m[1],m[2])})(h.removeEventListener),l.numberOfOutputs!==0){const d=e(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return h.connect(d).connect(i.destination),r(h,()=>d.disconnect(),()=>d.connect(i.destination))}return h}catch(h){throw h.code===11?n():h}if(u===void 0)throw n();return Ga(l),t(i,a,u,l)},wr=(s,t)=>s===null?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(s*t))))),$a=s=>new Promise((t,e)=>{const{port1:n,port2:r}=new MessageChannel;n.onmessage=({data:i})=>{n.close(),r.close(),t(i)},n.onmessageerror=({data:i})=>{n.close(),r.close(),e(i)},r.postMessage(s)}),Za=async(s,t)=>{const e=await $a(t);return new s(e)},Xa=(s,t,e,n)=>{let r=Xn.get(s);r===void 0&&(r=new WeakMap,Xn.set(s,r));const i=Za(e,n);return r.set(t,i),i},Ya=(s,t,e,n,r,i,a,o,c,u,l,h,p)=>(f,d,m,_)=>{if(_.numberOfInputs===0&&_.numberOfOutputs===0)throw c();const v=Array.isArray(_.outputChannelCount)?_.outputChannelCount:Array.from(_.outputChannelCount);if(v.some(O=>O<1))throw c();if(v.length!==_.numberOfOutputs)throw t();if(_.channelCountMode!=="explicit")throw c();const b=_.channelCount*_.numberOfInputs,C=v.reduce((O,F)=>O+F,0),A=m.parameterDescriptors===void 0?0:m.parameterDescriptors.length;if(b+A>6||C>6)throw c();const g=new MessageChannel,T=[],w=[];for(let O=0;O<_.numberOfInputs;O+=1)T.push(a(f,{channelCount:_.channelCount,channelCountMode:_.channelCountMode,channelInterpretation:_.channelInterpretation,gain:1})),w.push(r(f,{channelCount:_.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:_.channelCount}));const y=[];if(m.parameterDescriptors!==void 0)for(const{defaultValue:O,maxValue:F,minValue:lt,name:et}of m.parameterDescriptors){const $=i(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:_.parameterData[et]!==void 0?_.parameterData[et]:O===void 0?0:O});Object.defineProperties($.offset,{defaultValue:{get:()=>O===void 0?0:O},maxValue:{get:()=>F===void 0?vt:F},minValue:{get:()=>lt===void 0?wt:lt}}),y.push($)}const N=n(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,b+A)}),x=wr(d,f.sampleRate),k=o(f,x,b+A,Math.max(1,C)),S=r(f,{channelCount:Math.max(1,C),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,C)}),I=[];for(let O=0;O<_.numberOfOutputs;O+=1)I.push(n(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:v[O]}));for(let O=0;O<_.numberOfInputs;O+=1){T[O].connect(w[O]);for(let F=0;F<_.channelCount;F+=1)w[O].connect(N,F,O*_.channelCount+F)}const E=new vr(m.parameterDescriptors===void 0?[]:m.parameterDescriptors.map(({name:O},F)=>{const lt=y[F];return lt.connect(N,0,b+F),lt.start(0),[O,lt.offset]}));N.connect(k);let P=_.channelInterpretation,M=null;const D=_.numberOfOutputs===0?[k]:I,j={get bufferSize(){return x},get channelCount(){return _.channelCount},set channelCount(O){throw e()},get channelCountMode(){return _.channelCountMode},set channelCountMode(O){throw e()},get channelInterpretation(){return P},set channelInterpretation(O){for(const F of T)F.channelInterpretation=O;P=O},get context(){return k.context},get inputs(){return T},get numberOfInputs(){return _.numberOfInputs},get numberOfOutputs(){return _.numberOfOutputs},get onprocessorerror(){return M},set onprocessorerror(O){typeof M=="function"&&j.removeEventListener("processorerror",M),M=typeof O=="function"?O:null,typeof M=="function"&&j.addEventListener("processorerror",M)},get parameters(){return E},get port(){return g.port2},addEventListener(...O){return k.addEventListener(O[0],O[1],O[2])},connect:s.bind(null,D),disconnect:u.bind(null,D),dispatchEvent(...O){return k.dispatchEvent(O[0])},removeEventListener(...O){return k.removeEventListener(O[0],O[1],O[2])}},V=new Map;g.port1.addEventListener=(O=>(...F)=>{if(F[0]==="message"){const lt=typeof F[1]=="function"?F[1]:typeof F[1]=="object"&&F[1]!==null&&typeof F[1].handleEvent=="function"?F[1].handleEvent:null;if(lt!==null){const et=V.get(F[1]);et!==void 0?F[1]=et:(F[1]=$=>{l(f.currentTime,f.sampleRate,()=>lt($))},V.set(lt,F[1]))}}return O.call(g.port1,F[0],F[1],F[2])})(g.port1.addEventListener),g.port1.removeEventListener=(O=>(...F)=>{if(F[0]==="message"){const lt=V.get(F[1]);lt!==void 0&&(V.delete(F[1]),F[1]=lt)}return O.call(g.port1,F[0],F[1],F[2])})(g.port1.removeEventListener);let q=null;Object.defineProperty(g.port1,"onmessage",{get:()=>q,set:O=>{typeof q=="function"&&g.port1.removeEventListener("message",q),q=typeof O=="function"?O:null,typeof q=="function"&&(g.port1.addEventListener("message",q),g.port1.start())}}),m.prototype.port=g.port1;let W=null;Xa(f,j,m,_).then(O=>W=O);const At=_n(_.numberOfInputs,_.channelCount),kt=_n(_.numberOfOutputs,v),G=m.parameterDescriptors===void 0?[]:m.parameterDescriptors.reduce((O,{name:F})=>({...O,[F]:new Float32Array(128)}),{});let K=!0;const gt=()=>{_.numberOfOutputs>0&&k.disconnect(S);for(let O=0,F=0;O<_.numberOfOutputs;O+=1){const lt=I[O];for(let et=0;et<v[O];et+=1)S.disconnect(lt,F+et,et);F+=v[O]}},R=new Map;k.onaudioprocess=({inputBuffer:O,outputBuffer:F})=>{if(W!==null){const lt=h(j);for(let et=0;et<x;et+=128){for(let $=0;$<_.numberOfInputs;$+=1)for(let st=0;st<_.channelCount;st+=1)mn(O,At[$],st,st,et);m.parameterDescriptors!==void 0&&m.parameterDescriptors.forEach(({name:$},st)=>{mn(O,G,$,b+st,et)});for(let $=0;$<_.numberOfInputs;$+=1)for(let st=0;st<v[$];st+=1)kt[$][st].byteLength===0&&(kt[$][st]=new Float32Array(128));try{const $=At.map((Ot,Ht)=>{if(lt[Ht].size>0)return R.set(Ht,x/128),Ot;const Bn=R.get(Ht);return Bn===void 0?[]:(Ot.every(pi=>pi.every(fi=>fi===0))&&(Bn===1?R.delete(Ht):R.set(Ht,Bn-1)),Ot)});K=l(f.currentTime+et/f.sampleRate,f.sampleRate,()=>W.process($,kt,G));for(let Ot=0,Ht=0;Ot<_.numberOfOutputs;Ot+=1){for(let We=0;We<v[Ot];We+=1)yr(F,kt[Ot],We,Ht+We,et);Ht+=v[Ot]}}catch($){K=!1,j.dispatchEvent(new ErrorEvent("processorerror",{colno:$.colno,filename:$.filename,lineno:$.lineno,message:$.message}))}if(!K){for(let $=0;$<_.numberOfInputs;$+=1){T[$].disconnect(w[$]);for(let st=0;st<_.channelCount;st+=1)w[et].disconnect(N,st,$*_.channelCount+st)}if(m.parameterDescriptors!==void 0){const $=m.parameterDescriptors.length;for(let st=0;st<$;st+=1){const Ot=y[st];Ot.disconnect(N,0,b+st),Ot.stop()}}N.disconnect(k),k.onaudioprocess=null,ie?gt():_e();break}}}};let ie=!1;const oe=a(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),me=()=>k.connect(oe).connect(f.destination),_e=()=>{k.disconnect(oe),oe.disconnect()},hi=()=>{if(K){_e(),_.numberOfOutputs>0&&k.connect(S);for(let O=0,F=0;O<_.numberOfOutputs;O+=1){const lt=I[O];for(let et=0;et<v[O];et+=1)S.connect(lt,F+et,et);F+=v[O]}}ie=!0},di=()=>{K&&(me(),gt()),ie=!1};return me(),p(j,hi,di)},br=(s,t)=>{const e=s.createBiquadFilter();return ht(e,t),rt(e,t,"Q"),rt(e,t,"detune"),rt(e,t,"frequency"),rt(e,t,"gain"),tt(e,t,"type"),e},Ha=(s,t)=>(e,n)=>{const r=e.createChannelMerger(n.numberOfInputs);return s!==null&&s.name==="webkitAudioContext"&&t(e,r),ht(r,n),r},Qa=s=>{const t=s.numberOfOutputs;Object.defineProperty(s,"channelCount",{get:()=>t,set:e=>{if(e!==t)throw dt()}}),Object.defineProperty(s,"channelCountMode",{get:()=>"explicit",set:e=>{if(e!=="explicit")throw dt()}}),Object.defineProperty(s,"channelInterpretation",{get:()=>"discrete",set:e=>{if(e!=="discrete")throw dt()}})},Ze=(s,t)=>{const e=s.createChannelSplitter(t.numberOfOutputs);return ht(e,t),Qa(e),e},Ja=(s,t,e,n,r)=>(i,a)=>{if(i.createConstantSource===void 0)return e(i,a);const o=i.createConstantSource();return ht(o,a),rt(o,a,"offset"),t(n,()=>n(i))||os(o),t(r,()=>r(i))||as(o),s(i,o),o},Me=(s,t)=>(s.connect=t.connect.bind(t),s.disconnect=t.disconnect.bind(t),s),Ka=(s,t,e,n)=>(r,{offset:i,...a})=>{const o=r.createBuffer(1,2,44100),c=t(r,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),u=e(r,{...a,gain:i}),l=o.getChannelData(0);l[0]=1,l[1]=1,c.buffer=o,c.loop=!0;const h={get bufferSize(){},get channelCount(){return u.channelCount},set channelCount(d){u.channelCount=d},get channelCountMode(){return u.channelCountMode},set channelCountMode(d){u.channelCountMode=d},get channelInterpretation(){return u.channelInterpretation},set channelInterpretation(d){u.channelInterpretation=d},get context(){return u.context},get inputs(){return[]},get numberOfInputs(){return c.numberOfInputs},get numberOfOutputs(){return u.numberOfOutputs},get offset(){return u.gain},get onended(){return c.onended},set onended(d){c.onended=d},addEventListener(...d){return c.addEventListener(d[0],d[1],d[2])},dispatchEvent(...d){return c.dispatchEvent(d[0])},removeEventListener(...d){return c.removeEventListener(d[0],d[1],d[2])},start(d=0){c.start.call(c,d)},stop(d=0){c.stop.call(c,d)}},p=()=>c.connect(u),f=()=>c.disconnect(u);return s(r,c),n(Me(h,u),p,f)},tc=(s,t)=>(e,n)=>{const r=e.createConvolver();if(ht(r,n),n.disableNormalization===r.normalize&&(r.normalize=!n.disableNormalization),tt(r,n,"buffer"),n.channelCount>2||(t(r,"channelCount",i=>()=>i.call(r),i=>a=>{if(a>2)throw s();return i.call(r,a)}),n.channelCountMode==="max"))throw s();return t(r,"channelCountMode",i=>()=>i.call(r),i=>a=>{if(a==="max")throw s();return i.call(r,a)}),r},Cr=(s,t)=>{const e=s.createDelay(t.maxDelayTime);return ht(e,t),rt(e,t,"delayTime"),e},ec=s=>(t,e)=>{const n=t.createDynamicsCompressor();if(ht(n,e),e.channelCount>2||e.channelCountMode==="max")throw s();return rt(n,e,"attack"),rt(n,e,"knee"),rt(n,e,"ratio"),rt(n,e,"release"),rt(n,e,"threshold"),n},St=(s,t)=>{const e=s.createGain();return ht(e,t),rt(e,t,"gain"),e},nc=s=>(t,e,n)=>{if(t.createIIRFilter===void 0)return s(t,e,n);const r=t.createIIRFilter(n.feedforward,n.feedback);return ht(r,n),r};function sc(s,t){const e=t[0]*t[0]+t[1]*t[1];return[(s[0]*t[0]+s[1]*t[1])/e,(s[1]*t[0]-s[0]*t[1])/e]}function rc(s,t){return[s[0]*t[0]-s[1]*t[1],s[0]*t[1]+s[1]*t[0]]}function Hs(s,t){let e=[0,0];for(let n=s.length-1;n>=0;n-=1)e=rc(e,t),e[0]+=s[n];return e}const ic=(s,t,e,n)=>(r,i,{channelCount:a,channelCountMode:o,channelInterpretation:c,feedback:u,feedforward:l})=>{const h=wr(i,r.sampleRate),p=u instanceof Float64Array?u:new Float64Array(u),f=l instanceof Float64Array?l:new Float64Array(l),d=p.length,m=f.length,_=Math.min(d,m);if(d===0||d>20)throw n();if(p[0]===0)throw t();if(m===0||m>20)throw n();if(f[0]===0)throw t();if(p[0]!==1){for(let y=0;y<m;y+=1)f[y]/=p[0];for(let y=1;y<d;y+=1)p[y]/=p[0]}const v=e(r,h,a,a);v.channelCount=a,v.channelCountMode=o,v.channelInterpretation=c;const b=32,C=[],A=[],g=[];for(let y=0;y<a;y+=1){C.push(0);const N=new Float32Array(b),x=new Float32Array(b);N.fill(0),x.fill(0),A.push(N),g.push(x)}v.onaudioprocess=y=>{const N=y.inputBuffer,x=y.outputBuffer,k=N.numberOfChannels;for(let S=0;S<k;S+=1){const I=N.getChannelData(S),E=x.getChannelData(S);C[S]=Tr(p,d,f,m,_,A[S],g[S],C[S],b,I,E)}};const T=r.sampleRate/2;return Me({get bufferSize(){return h},get channelCount(){return v.channelCount},set channelCount(y){v.channelCount=y},get channelCountMode(){return v.channelCountMode},set channelCountMode(y){v.channelCountMode=y},get channelInterpretation(){return v.channelInterpretation},set channelInterpretation(y){v.channelInterpretation=y},get context(){return v.context},get inputs(){return[v]},get numberOfInputs(){return v.numberOfInputs},get numberOfOutputs(){return v.numberOfOutputs},addEventListener(...y){return v.addEventListener(y[0],y[1],y[2])},dispatchEvent(...y){return v.dispatchEvent(y[0])},getFrequencyResponse(y,N,x){if(y.length!==N.length||N.length!==x.length)throw s();const k=y.length;for(let S=0;S<k;S+=1){const I=-Math.PI*(y[S]/T),E=[Math.cos(I),Math.sin(I)],P=Hs(f,E),M=Hs(p,E),D=sc(P,M);N[S]=Math.sqrt(D[0]*D[0]+D[1]*D[1]),x[S]=Math.atan2(D[1],D[0])}},removeEventListener(...y){return v.removeEventListener(y[0],y[1],y[2])}},v)},oc=(s,t)=>s.createMediaElementSource(t.mediaElement),ac=(s,t)=>{const e=s.createMediaStreamDestination();return ht(e,t),e.numberOfOutputs===1&&Object.defineProperty(e,"numberOfOutputs",{get:()=>0}),e},cc=(s,{mediaStream:t})=>{const e=t.getAudioTracks();e.sort((i,a)=>i.id<a.id?-1:i.id>a.id?1:0);const n=e.slice(0,1),r=s.createMediaStreamSource(new MediaStream(n));return Object.defineProperty(r,"mediaStream",{value:t}),r},uc=(s,t)=>(e,{mediaStreamTrack:n})=>{if(typeof e.createMediaStreamTrackSource=="function")return e.createMediaStreamTrackSource(n);const r=new MediaStream([n]),i=e.createMediaStreamSource(r);if(n.kind!=="audio")throw s();if(t(e))throw new TypeError;return i},lc=s=>s===null?null:s.hasOwnProperty("OfflineAudioContext")?s.OfflineAudioContext:s.hasOwnProperty("webkitOfflineAudioContext")?s.webkitOfflineAudioContext:null,hc=(s,t,e,n,r,i)=>(a,o)=>{const c=a.createOscillator();return ht(c,o),rt(c,o,"detune"),rt(c,o,"frequency"),o.periodicWave!==void 0?c.setPeriodicWave(o.periodicWave):tt(c,o,"type"),t(e,()=>e(a))||os(c),t(n,()=>n(a))||i(c,a),t(r,()=>r(a))||as(c),s(a,c),c},dc=s=>(t,e)=>{const n=t.createPanner();return n.orientationX===void 0?s(t,e):(ht(n,e),rt(n,e,"orientationX"),rt(n,e,"orientationY"),rt(n,e,"orientationZ"),rt(n,e,"positionX"),rt(n,e,"positionY"),rt(n,e,"positionZ"),tt(n,e,"coneInnerAngle"),tt(n,e,"coneOuterAngle"),tt(n,e,"coneOuterGain"),tt(n,e,"distanceModel"),tt(n,e,"maxDistance"),tt(n,e,"panningModel"),tt(n,e,"refDistance"),tt(n,e,"rolloffFactor"),n)},pc=(s,t,e,n,r,i,a,o,c,u)=>(l,{coneInnerAngle:h,coneOuterAngle:p,coneOuterGain:f,distanceModel:d,maxDistance:m,orientationX:_,orientationY:v,orientationZ:b,panningModel:C,positionX:A,positionY:g,positionZ:T,refDistance:w,rolloffFactor:y,...N})=>{const x=l.createPanner();if(N.channelCount>2||N.channelCountMode==="max")throw a();ht(x,N);const k={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},S=e(l,{...k,channelInterpretation:"speakers",numberOfInputs:6}),I=n(l,{...N,gain:1}),E=n(l,{...k,gain:1}),P=n(l,{...k,gain:0}),M=n(l,{...k,gain:0}),D=n(l,{...k,gain:0}),j=n(l,{...k,gain:0}),V=n(l,{...k,gain:0}),q=r(l,256,6,1),W=i(l,{...k,curve:new Float32Array([1,1]),oversample:"none"});let Z=[_,v,b],At=[A,g,T];const kt=new Float32Array(1);q.onaudioprocess=({inputBuffer:R})=>{const ie=[c(R,kt,0),c(R,kt,1),c(R,kt,2)];ie.some((me,_e)=>me!==Z[_e])&&(x.setOrientation(...ie),Z=ie);const oe=[c(R,kt,3),c(R,kt,4),c(R,kt,5)];oe.some((me,_e)=>me!==At[_e])&&(x.setPosition(...oe),At=oe)},Object.defineProperty(P.gain,"defaultValue",{get:()=>0}),Object.defineProperty(M.gain,"defaultValue",{get:()=>0}),Object.defineProperty(D.gain,"defaultValue",{get:()=>0}),Object.defineProperty(j.gain,"defaultValue",{get:()=>0}),Object.defineProperty(V.gain,"defaultValue",{get:()=>0});const G={get bufferSize(){},get channelCount(){return x.channelCount},set channelCount(R){if(R>2)throw a();I.channelCount=R,x.channelCount=R},get channelCountMode(){return x.channelCountMode},set channelCountMode(R){if(R==="max")throw a();I.channelCountMode=R,x.channelCountMode=R},get channelInterpretation(){return x.channelInterpretation},set channelInterpretation(R){I.channelInterpretation=R,x.channelInterpretation=R},get coneInnerAngle(){return x.coneInnerAngle},set coneInnerAngle(R){x.coneInnerAngle=R},get coneOuterAngle(){return x.coneOuterAngle},set coneOuterAngle(R){x.coneOuterAngle=R},get coneOuterGain(){return x.coneOuterGain},set coneOuterGain(R){if(R<0||R>1)throw t();x.coneOuterGain=R},get context(){return x.context},get distanceModel(){return x.distanceModel},set distanceModel(R){x.distanceModel=R},get inputs(){return[I]},get maxDistance(){return x.maxDistance},set maxDistance(R){if(R<0)throw new RangeError;x.maxDistance=R},get numberOfInputs(){return x.numberOfInputs},get numberOfOutputs(){return x.numberOfOutputs},get orientationX(){return E.gain},get orientationY(){return P.gain},get orientationZ(){return M.gain},get panningModel(){return x.panningModel},set panningModel(R){x.panningModel=R},get positionX(){return D.gain},get positionY(){return j.gain},get positionZ(){return V.gain},get refDistance(){return x.refDistance},set refDistance(R){if(R<0)throw new RangeError;x.refDistance=R},get rolloffFactor(){return x.rolloffFactor},set rolloffFactor(R){if(R<0)throw new RangeError;x.rolloffFactor=R},addEventListener(...R){return I.addEventListener(R[0],R[1],R[2])},dispatchEvent(...R){return I.dispatchEvent(R[0])},removeEventListener(...R){return I.removeEventListener(R[0],R[1],R[2])}};h!==G.coneInnerAngle&&(G.coneInnerAngle=h),p!==G.coneOuterAngle&&(G.coneOuterAngle=p),f!==G.coneOuterGain&&(G.coneOuterGain=f),d!==G.distanceModel&&(G.distanceModel=d),m!==G.maxDistance&&(G.maxDistance=m),_!==G.orientationX.value&&(G.orientationX.value=_),v!==G.orientationY.value&&(G.orientationY.value=v),b!==G.orientationZ.value&&(G.orientationZ.value=b),C!==G.panningModel&&(G.panningModel=C),A!==G.positionX.value&&(G.positionX.value=A),g!==G.positionY.value&&(G.positionY.value=g),T!==G.positionZ.value&&(G.positionZ.value=T),w!==G.refDistance&&(G.refDistance=w),y!==G.rolloffFactor&&(G.rolloffFactor=y),(Z[0]!==1||Z[1]!==0||Z[2]!==0)&&x.setOrientation(...Z),(At[0]!==0||At[1]!==0||At[2]!==0)&&x.setPosition(...At);const K=()=>{I.connect(x),s(I,W,0,0),W.connect(E).connect(S,0,0),W.connect(P).connect(S,0,1),W.connect(M).connect(S,0,2),W.connect(D).connect(S,0,3),W.connect(j).connect(S,0,4),W.connect(V).connect(S,0,5),S.connect(q).connect(l.destination)},gt=()=>{I.disconnect(x),o(I,W,0,0),W.disconnect(E),E.disconnect(S),W.disconnect(P),P.disconnect(S),W.disconnect(M),M.disconnect(S),W.disconnect(D),D.disconnect(S),W.disconnect(j),j.disconnect(S),W.disconnect(V),V.disconnect(S),S.disconnect(q),q.disconnect(l.destination)};return u(Me(G,x),K,gt)},fc=s=>(t,{disableNormalization:e,imag:n,real:r})=>{const i=n instanceof Float32Array?n:new Float32Array(n),a=r instanceof Float32Array?r:new Float32Array(r),o=t.createPeriodicWave(a,i,{disableNormalization:e});if(Array.from(n).length<2)throw s();return o},Xe=(s,t,e,n)=>s.createScriptProcessor(t,e,n),mc=(s,t)=>(e,n)=>{const r=n.channelCountMode;if(r==="clamped-max")throw t();if(e.createStereoPanner===void 0)return s(e,n);const i=e.createStereoPanner();return ht(i,n),rt(i,n,"pan"),Object.defineProperty(i,"channelCountMode",{get:()=>r,set:a=>{if(a!==r)throw t()}}),i},_c=(s,t,e,n,r,i)=>{const o=new Float32Array([1,1]),c=Math.PI/2,u={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},l={...u,oversample:"none"},h=(d,m,_,v)=>{const b=new Float32Array(16385),C=new Float32Array(16385);for(let N=0;N<16385;N+=1){const x=N/16384*c;b[N]=Math.cos(x),C[N]=Math.sin(x)}const A=e(d,{...u,gain:0}),g=n(d,{...l,curve:b}),T=n(d,{...l,curve:o}),w=e(d,{...u,gain:0}),y=n(d,{...l,curve:C});return{connectGraph(){m.connect(A),m.connect(T.inputs===void 0?T:T.inputs[0]),m.connect(w),T.connect(_),_.connect(g.inputs===void 0?g:g.inputs[0]),_.connect(y.inputs===void 0?y:y.inputs[0]),g.connect(A.gain),y.connect(w.gain),A.connect(v,0,0),w.connect(v,0,1)},disconnectGraph(){m.disconnect(A),m.disconnect(T.inputs===void 0?T:T.inputs[0]),m.disconnect(w),T.disconnect(_),_.disconnect(g.inputs===void 0?g:g.inputs[0]),_.disconnect(y.inputs===void 0?y:y.inputs[0]),g.disconnect(A.gain),y.disconnect(w.gain),A.disconnect(v,0,0),w.disconnect(v,0,1)}}},p=(d,m,_,v)=>{const b=new Float32Array(16385),C=new Float32Array(16385),A=new Float32Array(16385),g=new Float32Array(16385),T=Math.floor(16385/2);for(let D=0;D<16385;D+=1)if(D>T){const j=(D-T)/(16384-T)*c;b[D]=Math.cos(j),C[D]=Math.sin(j),A[D]=0,g[D]=1}else{const j=D/(16384-T)*c;b[D]=1,C[D]=0,A[D]=Math.cos(j),g[D]=Math.sin(j)}const w=t(d,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),y=e(d,{...u,gain:0}),N=n(d,{...l,curve:b}),x=e(d,{...u,gain:0}),k=n(d,{...l,curve:C}),S=n(d,{...l,curve:o}),I=e(d,{...u,gain:0}),E=n(d,{...l,curve:A}),P=e(d,{...u,gain:0}),M=n(d,{...l,curve:g});return{connectGraph(){m.connect(w),m.connect(S.inputs===void 0?S:S.inputs[0]),w.connect(y,0),w.connect(x,0),w.connect(I,1),w.connect(P,1),S.connect(_),_.connect(N.inputs===void 0?N:N.inputs[0]),_.connect(k.inputs===void 0?k:k.inputs[0]),_.connect(E.inputs===void 0?E:E.inputs[0]),_.connect(M.inputs===void 0?M:M.inputs[0]),N.connect(y.gain),k.connect(x.gain),E.connect(I.gain),M.connect(P.gain),y.connect(v,0,0),I.connect(v,0,0),x.connect(v,0,1),P.connect(v,0,1)},disconnectGraph(){m.disconnect(w),m.disconnect(S.inputs===void 0?S:S.inputs[0]),w.disconnect(y,0),w.disconnect(x,0),w.disconnect(I,1),w.disconnect(P,1),S.disconnect(_),_.disconnect(N.inputs===void 0?N:N.inputs[0]),_.disconnect(k.inputs===void 0?k:k.inputs[0]),_.disconnect(E.inputs===void 0?E:E.inputs[0]),_.disconnect(M.inputs===void 0?M:M.inputs[0]),N.disconnect(y.gain),k.disconnect(x.gain),E.disconnect(I.gain),M.disconnect(P.gain),y.disconnect(v,0,0),I.disconnect(v,0,0),x.disconnect(v,0,1),P.disconnect(v,0,1)}}},f=(d,m,_,v,b)=>{if(m===1)return h(d,_,v,b);if(m===2)return p(d,_,v,b);throw r()};return(d,{channelCount:m,channelCountMode:_,pan:v,...b})=>{if(_==="max")throw r();const C=s(d,{...b,channelCount:1,channelCountMode:_,numberOfInputs:2}),A=e(d,{...b,channelCount:m,channelCountMode:_,gain:1}),g=e(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:v});let{connectGraph:T,disconnectGraph:w}=f(d,m,A,g,C);Object.defineProperty(g.gain,"defaultValue",{get:()=>0}),Object.defineProperty(g.gain,"maxValue",{get:()=>1}),Object.defineProperty(g.gain,"minValue",{get:()=>-1});const y={get bufferSize(){},get channelCount(){return A.channelCount},set channelCount(S){A.channelCount!==S&&(N&&w(),{connectGraph:T,disconnectGraph:w}=f(d,S,A,g,C),N&&T()),A.channelCount=S},get channelCountMode(){return A.channelCountMode},set channelCountMode(S){if(S==="clamped-max"||S==="max")throw r();A.channelCountMode=S},get channelInterpretation(){return A.channelInterpretation},set channelInterpretation(S){A.channelInterpretation=S},get context(){return A.context},get inputs(){return[A]},get numberOfInputs(){return A.numberOfInputs},get numberOfOutputs(){return A.numberOfOutputs},get pan(){return g.gain},addEventListener(...S){return A.addEventListener(S[0],S[1],S[2])},dispatchEvent(...S){return A.dispatchEvent(S[0])},removeEventListener(...S){return A.removeEventListener(S[0],S[1],S[2])}};let N=!1;const x=()=>{T(),N=!0},k=()=>{w(),N=!1};return i(Me(y,C),x,k)}},gc=(s,t,e,n,r,i,a)=>(o,c)=>{const u=o.createWaveShaper();if(i!==null&&i.name==="webkitAudioContext"&&o.createGain().gain.automationRate===void 0)return e(o,c);ht(u,c);const l=c.curve===null||c.curve instanceof Float32Array?c.curve:new Float32Array(c.curve);if(l!==null&&l.length<2)throw t();tt(u,{curve:l},"curve"),tt(u,c,"oversample");let h=null,p=!1;return a(u,"curve",m=>()=>m.call(u),m=>_=>(m.call(u,_),p&&(n(_)&&h===null?h=s(o,u):!n(_)&&h!==null&&(h(),h=null)),_)),r(u,()=>{p=!0,n(u.curve)&&(h=s(o,u))},()=>{p=!1,h!==null&&(h(),h=null)})},vc=(s,t,e,n,r)=>(i,{curve:a,oversample:o,...c})=>{const u=i.createWaveShaper(),l=i.createWaveShaper();ht(u,c),ht(l,c);const h=e(i,{...c,gain:1}),p=e(i,{...c,gain:-1}),f=e(i,{...c,gain:1}),d=e(i,{...c,gain:-1});let m=null,_=!1,v=null;const b={get bufferSize(){},get channelCount(){return u.channelCount},set channelCount(g){h.channelCount=g,p.channelCount=g,u.channelCount=g,f.channelCount=g,l.channelCount=g,d.channelCount=g},get channelCountMode(){return u.channelCountMode},set channelCountMode(g){h.channelCountMode=g,p.channelCountMode=g,u.channelCountMode=g,f.channelCountMode=g,l.channelCountMode=g,d.channelCountMode=g},get channelInterpretation(){return u.channelInterpretation},set channelInterpretation(g){h.channelInterpretation=g,p.channelInterpretation=g,u.channelInterpretation=g,f.channelInterpretation=g,l.channelInterpretation=g,d.channelInterpretation=g},get context(){return u.context},get curve(){return v},set curve(g){if(g!==null&&g.length<2)throw t();if(g===null)u.curve=g,l.curve=g;else{const T=g.length,w=new Float32Array(T+2-T%2),y=new Float32Array(T+2-T%2);w[0]=g[0],y[0]=-g[T-1];const N=Math.ceil((T+1)/2),x=(T+1)/2-1;for(let k=1;k<N;k+=1){const S=k/N*x,I=Math.floor(S),E=Math.ceil(S);w[k]=I===E?g[I]:(1-(S-I))*g[I]+(1-(E-S))*g[E],y[k]=I===E?-g[T-1-I]:-((1-(S-I))*g[T-1-I])-(1-(E-S))*g[T-1-E]}w[N]=T%2===1?g[N-1]:(g[N-2]+g[N-1])/2,u.curve=w,l.curve=y}v=g,_&&(n(v)&&m===null?m=s(i,h):m!==null&&(m(),m=null))},get inputs(){return[h]},get numberOfInputs(){return u.numberOfInputs},get numberOfOutputs(){return u.numberOfOutputs},get oversample(){return u.oversample},set oversample(g){u.oversample=g,l.oversample=g},addEventListener(...g){return h.addEventListener(g[0],g[1],g[2])},dispatchEvent(...g){return h.dispatchEvent(g[0])},removeEventListener(...g){return h.removeEventListener(g[0],g[1],g[2])}};a!==null&&(b.curve=a instanceof Float32Array?a:new Float32Array(a)),o!==b.oversample&&(b.oversample=o);const C=()=>{h.connect(u).connect(f),h.connect(p).connect(l).connect(d).connect(f),_=!0,n(v)&&(m=s(i,h))},A=()=>{h.disconnect(u),u.disconnect(f),h.disconnect(p),p.disconnect(l),l.disconnect(d),d.disconnect(f),_=!1,m!==null&&(m(),m=null)};return r(Me(b,f),C,A)},Tt=()=>new DOMException("","NotSupportedError"),yc={numberOfChannels:1},Tc=(s,t,e,n,r)=>class extends s{constructor(a,o,c){let u;if(typeof a=="number"&&o!==void 0&&c!==void 0)u={length:o,numberOfChannels:a,sampleRate:c};else if(typeof a=="object")u=a;else throw new Error("The given parameters are not valid.");const{length:l,numberOfChannels:h,sampleRate:p}={...yc,...u},f=n(h,l,p);t(Be,()=>Be(f))||f.addEventListener("statechange",(()=>{let d=0;const m=_=>{this._state==="running"&&(d>0?(f.removeEventListener("statechange",m),_.stopImmediatePropagation(),this._waitForThePromiseToSettle(_)):d+=1)};return m})()),super(f,h),this._length=l,this._nativeOfflineAudioContext=f,this._state=null}get length(){return this._nativeOfflineAudioContext.length===void 0?this._length:this._nativeOfflineAudioContext.length}get state(){return this._state===null?this._nativeOfflineAudioContext.state:this._state}startRendering(){return this._state==="running"?Promise.reject(e()):(this._state="running",r(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,fr(this)}))}_waitForThePromiseToSettle(a){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(a):setTimeout(()=>this._waitForThePromiseToSettle(a))}},wc={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},bc=(s,t,e,n,r,i,a)=>class extends s{constructor(c,u){const l=r(c),h={...wc,...u},p=e(l,h),f=i(l),d=f?n():null,m=c.sampleRate/2;super(c,!1,p,d),this._detune=t(this,f,p.detune,153600,-153600),this._frequency=t(this,f,p.frequency,m,-m),this._nativeOscillatorNode=p,this._onended=null,this._oscillatorNodeRenderer=d,this._oscillatorNodeRenderer!==null&&h.periodicWave!==void 0&&(this._oscillatorNodeRenderer.periodicWave=h.periodicWave)}get detune(){return this._detune}get frequency(){return this._frequency}get onended(){return this._onended}set onended(c){const u=typeof c=="function"?a(this,c):null;this._nativeOscillatorNode.onended=u;const l=this._nativeOscillatorNode.onended;this._onended=l!==null&&l===u?c:l}get type(){return this._nativeOscillatorNode.type}set type(c){this._nativeOscillatorNode.type=c,this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=null)}setPeriodicWave(c){this._nativeOscillatorNode.setPeriodicWave(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=c)}start(c=0){if(this._nativeOscillatorNode.start(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.start=c),this.context.state!=="closed"){Se(this);const u=()=>{this._nativeOscillatorNode.removeEventListener("ended",u),zt(this)&&Ge(this)};this._nativeOscillatorNode.addEventListener("ended",u)}}stop(c=0){this._nativeOscillatorNode.stop(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.stop=c)}},Cc=(s,t,e,n,r)=>()=>{const i=new WeakMap;let a=null,o=null,c=null;const u=async(l,h)=>{let p=e(l);const f=_t(p,h);if(!f){const d={channelCount:p.channelCount,channelCountMode:p.channelCountMode,channelInterpretation:p.channelInterpretation,detune:p.detune.value,frequency:p.frequency.value,periodicWave:a===null?void 0:a,type:p.type};p=t(h,d),o!==null&&p.start(o),c!==null&&p.stop(c)}return i.set(h,p),f?(await s(h,l.detune,p.detune),await s(h,l.frequency,p.frequency)):(await n(h,l.detune,p.detune),await n(h,l.frequency,p.frequency)),await r(l,h,p),p};return{set periodicWave(l){a=l},set start(l){o=l},set stop(l){c=l},render(l,h){const p=i.get(h);return p!==void 0?Promise.resolve(p):u(l,h)}}},Sc={channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0,distanceModel:"inverse",maxDistance:1e4,orientationX:1,orientationY:0,orientationZ:0,panningModel:"equalpower",positionX:0,positionY:0,positionZ:0,refDistance:1,rolloffFactor:1},Ac=(s,t,e,n,r,i,a)=>class extends s{constructor(c,u){const l=r(c),h={...Sc,...u},p=e(l,h),f=i(l),d=f?n():null;super(c,!1,p,d),this._nativePannerNode=p,this._orientationX=t(this,f,p.orientationX,vt,wt),this._orientationY=t(this,f,p.orientationY,vt,wt),this._orientationZ=t(this,f,p.orientationZ,vt,wt),this._positionX=t(this,f,p.positionX,vt,wt),this._positionY=t(this,f,p.positionY,vt,wt),this._positionZ=t(this,f,p.positionZ,vt,wt),a(this,1)}get coneInnerAngle(){return this._nativePannerNode.coneInnerAngle}set coneInnerAngle(c){this._nativePannerNode.coneInnerAngle=c}get coneOuterAngle(){return this._nativePannerNode.coneOuterAngle}set coneOuterAngle(c){this._nativePannerNode.coneOuterAngle=c}get coneOuterGain(){return this._nativePannerNode.coneOuterGain}set coneOuterGain(c){this._nativePannerNode.coneOuterGain=c}get distanceModel(){return this._nativePannerNode.distanceModel}set distanceModel(c){this._nativePannerNode.distanceModel=c}get maxDistance(){return this._nativePannerNode.maxDistance}set maxDistance(c){this._nativePannerNode.maxDistance=c}get orientationX(){return this._orientationX}get orientationY(){return this._orientationY}get orientationZ(){return this._orientationZ}get panningModel(){return this._nativePannerNode.panningModel}set panningModel(c){this._nativePannerNode.panningModel=c}get positionX(){return this._positionX}get positionY(){return this._positionY}get positionZ(){return this._positionZ}get refDistance(){return this._nativePannerNode.refDistance}set refDistance(c){this._nativePannerNode.refDistance=c}get rolloffFactor(){return this._nativePannerNode.rolloffFactor}set rolloffFactor(c){this._nativePannerNode.rolloffFactor=c}},kc=(s,t,e,n,r,i,a,o,c,u)=>()=>{const l=new WeakMap;let h=null;const p=async(f,d)=>{let m=null,_=i(f);const v={channelCount:_.channelCount,channelCountMode:_.channelCountMode,channelInterpretation:_.channelInterpretation},b={...v,coneInnerAngle:_.coneInnerAngle,coneOuterAngle:_.coneOuterAngle,coneOuterGain:_.coneOuterGain,distanceModel:_.distanceModel,maxDistance:_.maxDistance,panningModel:_.panningModel,refDistance:_.refDistance,rolloffFactor:_.rolloffFactor},C=_t(_,d);if("bufferSize"in _)m=n(d,{...v,gain:1});else if(!C){const A={...b,orientationX:_.orientationX.value,orientationY:_.orientationY.value,orientationZ:_.orientationZ.value,positionX:_.positionX.value,positionY:_.positionY.value,positionZ:_.positionZ.value};_=r(d,A)}if(l.set(d,m===null?_:m),m!==null){if(h===null){if(a===null)throw new Error("Missing the native OfflineAudioContext constructor.");const k=new a(6,f.context.length,d.sampleRate),S=t(k,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});S.connect(k.destination),h=(async()=>{const I=await Promise.all([f.orientationX,f.orientationY,f.orientationZ,f.positionX,f.positionY,f.positionZ].map(async(E,P)=>{const M=e(k,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:P===0?1:0});return await o(k,E,M.offset),M}));for(let E=0;E<6;E+=1)I[E].connect(S,0,E),I[E].start(0);return u(k)})()}const A=await h,g=n(d,{...v,gain:1});await c(f,d,g);const T=[];for(let k=0;k<A.numberOfChannels;k+=1)T.push(A.getChannelData(k));let w=[T[0][0],T[1][0],T[2][0]],y=[T[3][0],T[4][0],T[5][0]],N=n(d,{...v,gain:1}),x=r(d,{...b,orientationX:w[0],orientationY:w[1],orientationZ:w[2],positionX:y[0],positionY:y[1],positionZ:y[2]});g.connect(N).connect(x.inputs[0]),x.connect(m);for(let k=128;k<A.length;k+=128){const S=[T[0][k],T[1][k],T[2][k]],I=[T[3][k],T[4][k],T[5][k]];if(S.some((E,P)=>E!==w[P])||I.some((E,P)=>E!==y[P])){w=S,y=I;const E=k/d.sampleRate;N.gain.setValueAtTime(0,E),N=n(d,{...v,gain:0}),x=r(d,{...b,orientationX:w[0],orientationY:w[1],orientationZ:w[2],positionX:y[0],positionY:y[1],positionZ:y[2]}),N.gain.setValueAtTime(1,E),g.connect(N).connect(x.inputs[0]),x.connect(m)}}return m}return C?(await s(d,f.orientationX,_.orientationX),await s(d,f.orientationY,_.orientationY),await s(d,f.orientationZ,_.orientationZ),await s(d,f.positionX,_.positionX),await s(d,f.positionY,_.positionY),await s(d,f.positionZ,_.positionZ)):(await o(d,f.orientationX,_.orientationX),await o(d,f.orientationY,_.orientationY),await o(d,f.orientationZ,_.orientationZ),await o(d,f.positionX,_.positionX),await o(d,f.positionY,_.positionY),await o(d,f.positionZ,_.positionZ)),Ie(_)?await c(f,d,_.inputs[0]):await c(f,d,_),_};return{render(f,d){const m=l.get(d);return m!==void 0?Promise.resolve(m):p(f,d)}}},xc={disableNormalization:!1},Nc=(s,t,e,n)=>class Sr{constructor(i,a){const o=t(i),c=n({...xc,...a}),u=s(o,c);return e.add(u),u}static[Symbol.hasInstance](i){return i!==null&&typeof i=="object"&&Object.getPrototypeOf(i)===Sr.prototype||e.has(i)}},Oc=(s,t)=>(e,n,r)=>(s(n).replay(r),t(n,e,r)),Ec=(s,t,e)=>async(n,r,i)=>{const a=s(n);await Promise.all(a.activeInputs.map((o,c)=>Array.from(o).map(async([u,l])=>{const p=await t(u).render(u,r),f=n.context.destination;!e(u)&&(n!==f||!e(n))&&p.connect(i,l,c)})).reduce((o,c)=>[...o,...c],[]))},Ic=(s,t,e)=>async(n,r,i)=>{const a=t(n);await Promise.all(Array.from(a.activeInputs).map(async([o,c])=>{const l=await s(o).render(o,r);e(o)||l.connect(i,c)}))},Mc=(s,t,e,n)=>r=>s(Be,()=>Be(r))?Promise.resolve(s(n,n)).then(i=>{if(!i){const a=e(r,512,0,1);r.oncomplete=()=>{a.onaudioprocess=null,a.disconnect()},a.onaudioprocess=()=>r.currentTime,a.connect(r.destination)}return r.startRendering()}):new Promise(i=>{const a=t(r,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});r.oncomplete=o=>{a.disconnect(),i(o.renderedBuffer)},a.connect(r.destination),r.startRendering()}),Dc=s=>(t,e)=>{s.set(t,e)},Rc=s=>(t,e)=>s.set(t,e),Pc=(s,t,e,n,r,i,a,o)=>(c,u)=>e(c).render(c,u).then(()=>Promise.all(Array.from(n(u)).map(l=>e(l).render(l,u)))).then(()=>r(u)).then(l=>(typeof l.copyFromChannel!="function"?(a(l),ss(l)):t(i,()=>i(l))||o(l),s.add(l),l)),Vc={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},Fc=(s,t,e,n,r,i)=>class extends s{constructor(o,c){const u=r(o),l={...Vc,...c},h=e(u,l),p=i(u),f=p?n():null;super(o,!1,h,f),this._pan=t(this,p,h.pan)}get pan(){return this._pan}},Wc=(s,t,e,n,r)=>()=>{const i=new WeakMap,a=async(o,c)=>{let u=e(o);const l=_t(u,c);if(!l){const h={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,pan:u.pan.value};u=t(c,h)}return i.set(c,u),l?await s(c,o.pan,u.pan):await n(c,o.pan,u.pan),Ie(u)?await r(o,c,u.inputs[0]):await r(o,c,u),u};return{render(o,c){const u=i.get(c);return u!==void 0?Promise.resolve(u):a(o,c)}}},qc=s=>()=>{if(s===null)return!1;try{new s({length:1,sampleRate:44100})}catch{return!1}return!0},Lc=(s,t)=>async()=>{if(s===null)return!0;if(t===null)return!1;const e=new Blob(['class A extends AudioWorkletProcessor{process(i){this.port.postMessage(i,[i[0][0].buffer])}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),n=new t(1,128,44100),r=URL.createObjectURL(e);let i=!1,a=!1;try{await n.audioWorklet.addModule(r);const o=new s(n,"a",{numberOfOutputs:0}),c=n.createOscillator();o.port.onmessage=()=>i=!0,o.onprocessorerror=()=>a=!0,c.connect(o),c.start(0),await n.startRendering(),await new Promise(u=>setTimeout(u))}catch{}finally{URL.revokeObjectURL(r)}return i&&!a},Bc=(s,t)=>()=>{if(t===null)return Promise.resolve(!1);const e=new t(1,1,44100),n=s(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise(r=>{e.oncomplete=()=>{n.disconnect(),r(e.currentTime!==0)},e.startRendering()})},jc=()=>new DOMException("","UnknownError"),Uc={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},Gc=(s,t,e,n,r,i,a)=>class extends s{constructor(c,u){const l=r(c),h={...Uc,...u},p=e(l,h),d=i(l)?n():null;super(c,!0,p,d),this._isCurveNullified=!1,this._nativeWaveShaperNode=p,a(this,1)}get curve(){return this._isCurveNullified?null:this._nativeWaveShaperNode.curve}set curve(c){if(c===null)this._isCurveNullified=!0,this._nativeWaveShaperNode.curve=new Float32Array([0,0]);else{if(c.length<2)throw t();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=c}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(c){this._nativeWaveShaperNode.oversample=c}},zc=(s,t,e)=>()=>{const n=new WeakMap,r=async(i,a)=>{let o=t(i);if(!_t(o,a)){const u={channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,curve:o.curve,oversample:o.oversample};o=s(a,u)}return n.set(a,o),Ie(o)?await e(i,a,o.inputs[0]):await e(i,a,o),o};return{render(i,a){const o=n.get(a);return o!==void 0?Promise.resolve(o):r(i,a)}}},$c=()=>typeof window>"u"?null:window,Zc=(s,t)=>e=>{e.copyFromChannel=(n,r,i=0)=>{const a=s(i),o=s(r);if(o>=e.numberOfChannels)throw t();const c=e.length,u=e.getChannelData(o),l=n.length;for(let h=a<0?-a:0;h+a<c&&h<l;h+=1)n[h]=u[h+a]},e.copyToChannel=(n,r,i=0)=>{const a=s(i),o=s(r);if(o>=e.numberOfChannels)throw t();const c=e.length,u=e.getChannelData(o),l=n.length;for(let h=a<0?-a:0;h+a<c&&h<l;h+=1)u[h+a]=n[h]}},Xc=s=>t=>{t.copyFromChannel=(e=>(n,r,i=0)=>{const a=s(i),o=s(r);if(a<t.length)return e.call(t,n,o,a)})(t.copyFromChannel),t.copyToChannel=(e=>(n,r,i=0)=>{const a=s(i),o=s(r);if(a<t.length)return e.call(t,n,o,a)})(t.copyToChannel)},Yc=s=>(t,e)=>{const n=e.createBuffer(1,1,44100);t.buffer===null&&(t.buffer=n),s(t,"buffer",r=>()=>{const i=r.call(t);return i===n?null:i},r=>i=>r.call(t,i===null?n:i))},Hc=(s,t)=>(e,n)=>{n.channelCount=1,n.channelCountMode="explicit",Object.defineProperty(n,"channelCount",{get:()=>1,set:()=>{throw s()}}),Object.defineProperty(n,"channelCountMode",{get:()=>"explicit",set:()=>{throw s()}});const r=e.createBufferSource();t(n,()=>{const o=n.numberOfInputs;for(let c=0;c<o;c+=1)r.connect(n,0,c)},()=>r.disconnect(n))},Ar=(s,t,e)=>s.copyFromChannel===void 0?s.getChannelData(e)[0]:(s.copyFromChannel(t,e),t[0]),kr=s=>{if(s===null)return!1;const t=s.length;return t%2!==0?s[Math.floor(t/2)]!==0:s[t/2-1]+s[t/2]!==0},Ye=(s,t,e,n)=>{let r=s;for(;!r.hasOwnProperty(t);)r=Object.getPrototypeOf(r);const{get:i,set:a}=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(s,t,{get:e(i),set:n(a)})},Qc=s=>({...s,outputChannelCount:s.outputChannelCount!==void 0?s.outputChannelCount:s.numberOfInputs===1&&s.numberOfOutputs===1?[s.channelCount]:Array.from({length:s.numberOfOutputs},()=>1)}),Jc=s=>({...s,channelCount:s.numberOfOutputs}),Kc=s=>{const{imag:t,real:e}=s;return t===void 0?e===void 0?{...s,imag:[0,0],real:[0,0]}:{...s,imag:Array.from(e,()=>0),real:e}:e===void 0?{...s,imag:t,real:Array.from(t,()=>0)}:{...s,imag:t,real:e}},xr=(s,t,e)=>{try{s.setValueAtTime(t,e)}catch(n){if(n.code!==9)throw n;xr(s,t,e+1e-7)}},tu=s=>{const t=s.createBufferSource();t.start();try{t.start()}catch{return!0}return!1},eu=s=>{const t=s.createBufferSource(),e=s.createBuffer(1,1,44100);t.buffer=e;try{t.start(0,1)}catch{return!1}return!0},nu=s=>{const t=s.createBufferSource();t.start();try{t.stop()}catch{return!1}return!0},cs=s=>{const t=s.createOscillator();try{t.start(-1)}catch(e){return e instanceof RangeError}return!1},Nr=s=>{const t=s.createBuffer(1,1,44100),e=s.createBufferSource();e.buffer=t,e.start(),e.stop();try{return e.stop(),!0}catch{return!1}},us=s=>{const t=s.createOscillator();try{t.stop(-1)}catch(e){return e instanceof RangeError}return!1},su=s=>{const{port1:t,port2:e}=new MessageChannel;try{t.postMessage(s)}finally{t.close(),e.close()}},ru=s=>{s.start=(t=>(e=0,n=0,r)=>{const i=s.buffer,a=i===null?n:Math.min(i.duration,n);i!==null&&a>i.duration-.5/s.context.sampleRate?t.call(s,e,0,0):t.call(s,e,a,r)})(s.start)},Or=(s,t)=>{const e=t.createGain();s.connect(e);const n=(r=>()=>{r.call(s,e),s.removeEventListener("ended",n)})(s.disconnect);s.addEventListener("ended",n),Me(s,e),s.stop=(r=>{let i=!1;return(a=0)=>{if(i)try{r.call(s,a)}catch{e.gain.setValueAtTime(0,a)}else r.call(s,a),i=!0}})(s.stop)},De=(s,t)=>e=>{const n={value:s};return Object.defineProperties(e,{currentTarget:n,target:n}),typeof t=="function"?t.call(s,e):t.handleEvent.call(s,e)},iu=Si(de),ou=Ei(de),au=Uo(bn),Er=new WeakMap,cu=aa(Er),Ft=yo(new Map,new WeakMap),Lt=$c(),Ir=Fa(Ft,Bt),ls=oa(yt),ft=Ec(yt,ls,ue),uu=Pi(Ir,J,ft),H=la(wn),Zt=lc(Lt),Y=xa(Zt),Mr=new WeakMap,Dr=Ko(De),He=Ba(Lt),hs=Ca(He),ds=Sa(Lt),Rr=Aa(Lt),je=Ua(Lt),at=oo(Ai(ar),Oi(iu,ou,dn,au,pn,yt,cu,Ue,J,de,zt,ue,on),Ft,va($n,pn,yt,J,Le,zt),Bt,Cn,Tt,qo(dn,$n,yt,J,Le,H,zt,Y),$o(Mr,yt,Vt),Dr,H,hs,ds,Rr,Y,je),lu=Ri(at,uu,Bt,Ir,H,Y),ps=new WeakSet,Qs=Wa(Lt),Pr=Mo(new Uint32Array(1)),fs=Zc(Pr,Bt),ms=Xc(Pr),Vr=Fi(ps,Ft,Tt,Qs,Zt,qc(Qs),fs,ms),Sn=Ii(St),Fr=Ic(ls,ze,ue),jt=ko(Fr),Re=La(Sn,Ft,tu,eu,nu,cs,Nr,us,ru,Yc(Ye),Or),Ut=Oc(ca(ze),Fr),hu=Li(jt,Re,J,Ut,ft),Wt=ao(ki(cr),Mr,ns,co,vi,yi,Ti,wi,bi,Un,rr,He,xr),du=qi(at,hu,Wt,dt,Re,H,Y,De),pu=Yi(at,Hi,Bt,dt,ja(St,Ye),H,Y,ft),fu=vo(jt,br,J,Ut,ft),pe=Rc(Er),mu=go(at,Wt,fu,Cn,br,H,Y,pe),ne=Pa(de,ds),_u=Hc(dt,ne),se=Ha(He,_u),gu=bo(se,J,ft),vu=wo(at,gu,se,H,Y),yu=Ao(Ze,J,ft),Tu=So(at,yu,Ze,H,Y,Jc),wu=Ka(Sn,Re,St,ne),Pe=Ja(Sn,Ft,wu,cs,us),bu=Io(jt,Pe,J,Ut,ft),Cu=Eo(at,Wt,bu,Pe,H,Y,De),Wr=tc(Tt,Ye),Su=Po(Wr,J,ft),Au=Ro(at,Su,Wr,H,Y,pe),ku=jo(jt,Cr,J,Ut,ft),xu=Bo(at,Wt,ku,Cr,H,Y,pe),qr=ec(Tt),Nu=Ho(jt,qr,J,Ut,ft),Ou=Yo(at,Wt,Nu,qr,Tt,H,Y,pe),Eu=ra(jt,St,J,Ut,ft),Iu=sa(at,Wt,Eu,St,H,Y),Mu=ic(Cn,dt,Xe,Tt),An=Mc(Ft,St,Xe,Bc(St,Zt)),Du=ga(Re,J,Zt,ft,An),Ru=nc(Mu),Pu=ma(at,Ru,Du,H,Y,pe),Vu=Qi(Wt,se,Pe,Xe,Tt,Ar,Y,Ye),Lr=new WeakMap,Fu=Ra(pu,Vu,Dr,Y,Lr,De),Br=hc(Sn,Ft,cs,Nr,us,Or),Wu=Cc(jt,Br,J,Ut,ft),qu=bc(at,Wt,Br,Wu,H,Y,De),jr=No(Re),Lu=vc(jr,dt,St,kr,ne),kn=gc(jr,dt,Lu,kr,ne,He,Ye),Bu=pc(dn,dt,se,St,Xe,kn,Tt,pn,Ar,ne),Ur=dc(Bu),ju=kc(jt,se,Pe,St,Ur,J,Zt,Ut,ft,An),Uu=Ac(at,Wt,Ur,ju,H,Y,pe),Gu=fc(Bt),zu=Nc(Gu,H,new WeakSet,Kc),$u=_c(se,Ze,St,kn,Tt,ne),Gr=mc($u,Tt),Zu=Wc(jt,Gr,J,Ut,ft),Xu=Fc(at,Wt,Gr,Zu,H,Y),Yu=zc(kn,J,ft),Hu=Gc(at,dt,kn,Yu,H,Y,pe),zr=Na(Lt),_s=ta(Lt),$r=new WeakMap,Qu=ha($r,Zt),Ju=zr?Ni(Ft,Tt,Jo(Lt),_s,ea(Ci),H,Qu,Y,je,new WeakMap,new WeakMap,Lc(je,Zt),Lt):void 0,Ku=ka(hs,Y),tl=Wo(ps,Ft,Fo,Qo,new WeakSet,H,Ku,ln,Be,fs,ms),Zr=mo(Ju,lu,Vr,du,mu,vu,Tu,Cu,Au,tl,xu,Ou,Iu,Pu,Fu,qu,Uu,zu,Xu,Hu),el=Oa(at,oc,H,Y),nl=Ia(at,ac,H,Y),sl=Ma(at,cc,H,Y),rl=uc(dt,Y),il=Da(at,rl,H),ol=Xi(Zr,dt,Tt,jc,el,nl,sl,il,He),gs=da(Lr),al=Mi(gs),Xr=xo(Bt),cl=Go(gs),Yr=Zo(Bt),Hr=new WeakMap,ul=ia(Hr,Vt),ll=Ya(Xr,Bt,dt,se,Ze,Pe,St,Xe,Tt,Yr,_s,ul,ne),hl=za(dt,ll,St,Tt,ne),dl=fo(jt,Xr,Re,se,Ze,Pe,St,cl,Yr,_s,J,je,Zt,Ut,ft,An),pl=ua($r),fl=Dc(Hr),Js=zr?lo(al,at,Wt,dl,hl,yt,pl,H,Y,je,Qc,fl,su,De):void 0,ml=Vo(Tt,Zt),_l=Pc(ps,Ft,ls,gs,An,ln,fs,ms),gl=Tc(Zr,Ft,dt,ml,_l),vl=ya(wn,hs),yl=Ta(es,ds),Tl=wa(ns,Rr),wl=ba(wn,Y);function It(s){return s===void 0}function z(s){return s!==void 0}function bl(s){return typeof s=="function"}function le(s){return typeof s=="number"}function ce(s){return Object.prototype.toString.call(s)==="[object Object]"&&s.constructor===Object}function Cl(s){return typeof s=="boolean"}function Pt(s){return Array.isArray(s)}function $t(s){return typeof s=="string"}function sn(s){return $t(s)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(s)}function B(s,t){if(!s)throw new Error(t)}function te(s,t,e=1/0){if(!(t<=s&&s<=e))throw new RangeError(`Value must be within [${t}, ${e}], got: ${s}`)}function Qr(s){!s.isOffline&&s.state!=="running"&&vs('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}let Jr=!1,Ks=!1;function tr(s){Jr=s}function Sl(s){It(s)&&Jr&&!Ks&&(Ks=!0,vs("Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"))}let Kr=console;function Al(...s){Kr.log(...s)}function vs(...s){Kr.warn(...s)}function kl(s){return new ol(s)}function xl(s,t,e){return new gl(s,t,e)}const xt=typeof self=="object"?self:null,Nl=xt&&(xt.hasOwnProperty("AudioContext")||xt.hasOwnProperty("webkitAudioContext"));function Ol(s,t,e){return B(z(Js),"AudioWorkletNode only works in a secure context (https or localhost)"),new(s instanceof xt?.BaseAudioContext?xt?.AudioWorkletNode:Js)(s,t,e)}function qt(s,t,e,n){var r=arguments.length,i=r<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,t,e,n);else for(var o=s.length-1;o>=0;o--)(a=s[o])&&(i=(r<3?a(i):r>3?a(t,e,i):a(t,e))||i);return r>3&&i&&Object.defineProperty(t,e,i),i}function ot(s,t,e,n){function r(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function o(l){try{u(n.next(l))}catch(h){a(h)}}function c(l){try{u(n.throw(l))}catch(h){a(h)}}function u(l){l.done?i(l.value):r(l.value).then(o,c)}u((n=n.apply(s,t||[])).next())})}class El{constructor(t,e,n,r){this._callback=t,this._type=e,this._minimumUpdateInterval=Math.max(128/(r||44100),.001),this.updateInterval=n,this._createClock()}_createWorker(){const t=new Blob([`
|
|
4
|
+
// the initial timeout time
|
|
5
|
+
let timeoutTime = ${(this._updateInterval*1e3).toFixed(1)};
|
|
6
|
+
// onmessage callback
|
|
7
|
+
self.onmessage = function(msg){
|
|
8
|
+
timeoutTime = parseInt(msg.data);
|
|
9
|
+
};
|
|
10
|
+
// the tick function which posts a message
|
|
11
|
+
// and schedules a new tick
|
|
12
|
+
function tick(){
|
|
13
|
+
setTimeout(tick, timeoutTime);
|
|
14
|
+
self.postMessage('tick');
|
|
15
|
+
}
|
|
16
|
+
// call tick initially
|
|
17
|
+
tick();
|
|
18
|
+
`],{type:"text/javascript"}),e=URL.createObjectURL(t),n=new Worker(e);n.onmessage=this._callback.bind(this),this._worker=n}_createTimeout(){this._timeout=setTimeout(()=>{this._createTimeout(),this._callback()},this._updateInterval*1e3)}_createClock(){if(this._type==="worker")try{this._createWorker()}catch{this._type="timeout",this._createClock()}else this._type==="timeout"&&this._createTimeout()}_disposeClock(){this._timeout&&clearTimeout(this._timeout),this._worker&&(this._worker.terminate(),this._worker.onmessage=null)}get updateInterval(){return this._updateInterval}set updateInterval(t){var e;this._updateInterval=Math.max(t,this._minimumUpdateInterval),this._type==="worker"&&((e=this._worker)===null||e===void 0||e.postMessage(this._updateInterval*1e3))}get type(){return this._type}set type(t){this._disposeClock(),this._type=t,this._createClock()}dispose(){this._disposeClock()}}function he(s){return Tl(s)}function Kt(s){return yl(s)}function an(s){return wl(s)}function ge(s){return vl(s)}function Il(s){return s instanceof Vr}function Ml(s,t){return s==="value"||he(t)||Kt(t)||Il(t)}function we(s,...t){if(!t.length)return s;const e=t.shift();if(ce(s)&&ce(e))for(const n in e)Ml(n,e[n])?s[n]=e[n]:ce(e[n])?(s[n]||Object.assign(s,{[n]:{}}),we(s[n],e[n])):Object.assign(s,{[n]:e[n]});return we(s,...t)}function Dl(s,t){return s.length===t.length&&s.every((e,n)=>t[n]===e)}function L(s,t,e=[],n){const r={},i=Array.from(t);if(ce(i[0])&&n&&!Reflect.has(i[0],n)&&(Object.keys(i[0]).some(o=>Reflect.has(s,o))||(we(r,{[n]:i[0]}),e.splice(e.indexOf(n),1),i.shift())),i.length===1&&ce(i[0]))we(r,i[0]);else for(let a=0;a<e.length;a++)z(i[a])&&(r[e[a]]=i[a]);return we(s,r)}function Rl(s){return s.constructor.getDefaults()}function be(s,t){return It(s)?t:s}function er(s,t){return t.forEach(e=>{Reflect.has(s,e)&&delete s[e]}),s}/**
|
|
19
|
+
* Tone.js
|
|
20
|
+
* @author Yotam Mann
|
|
21
|
+
* @license http://opensource.org/licenses/MIT MIT License
|
|
22
|
+
* @copyright 2014-2024 Yotam Mann
|
|
23
|
+
*/class Xt{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...t){(this.debug||xt&&this.toString()===xt.TONE_DEBUG_CLASS)&&Al(this,...t)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}}Xt.version=sr;const ys=1e-6;function Ae(s,t){return s>t+ys}function Qn(s,t){return Ae(s,t)||Dt(s,t)}function gn(s,t){return s+ys<t}function Dt(s,t){return Math.abs(s-t)<ys}function Pl(s,t,e){return Math.max(Math.min(s,e),t)}class Mt extends Xt{constructor(){super(),this.name="Timeline",this._timeline=[];const t=L(Mt.getDefaults(),arguments,["memory"]);this.memory=t.memory,this.increasing=t.increasing}static getDefaults(){return{memory:1/0,increasing:!1}}get length(){return this._timeline.length}add(t){if(B(Reflect.has(t,"time"),"Timeline: events must have a time attribute"),t.time=t.time.valueOf(),this.increasing&&this.length){const e=this._timeline[this.length-1];B(Qn(t.time,e.time),"The time must be greater than or equal to the last scheduled time"),this._timeline.push(t)}else{const e=this._search(t.time);this._timeline.splice(e+1,0,t)}if(this.length>this.memory){const e=this.length-this.memory;this._timeline.splice(0,e)}return this}remove(t){const e=this._timeline.indexOf(t);return e!==-1&&this._timeline.splice(e,1),this}get(t,e="time"){const n=this._search(t,e);return n!==-1?this._timeline[n]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(t,e="time"){const n=this._search(t,e);return n+1<this._timeline.length?this._timeline[n+1]:null}getBefore(t){const e=this._timeline.length;if(e>0&&this._timeline[e-1].time<t)return this._timeline[e-1];const n=this._search(t);return n-1>=0?this._timeline[n-1]:null}cancel(t){if(this._timeline.length>1){let e=this._search(t);if(e>=0)if(Dt(this._timeline[e].time,t)){for(let n=e;n>=0&&Dt(this._timeline[n].time,t);n--)e=n;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else this._timeline.length===1&&Qn(this._timeline[0].time,t)&&(this._timeline=[]);return this}cancelBefore(t){const e=this._search(t);return e>=0&&(this._timeline=this._timeline.slice(e+1)),this}previousEvent(t){const e=this._timeline.indexOf(t);return e>0?this._timeline[e-1]:null}_search(t,e="time"){if(this._timeline.length===0)return-1;let n=0;const r=this._timeline.length;let i=r;if(r>0&&this._timeline[r-1][e]<=t)return r-1;for(;n<i;){let a=Math.floor(n+(i-n)/2);const o=this._timeline[a],c=this._timeline[a+1];if(Dt(o[e],t)){for(let u=a;u<this._timeline.length;u++){const l=this._timeline[u];if(Dt(l[e],t))a=u;else break}return a}else{if(gn(o[e],t)&&Ae(c[e],t))return a;Ae(o[e],t)?i=a:n=a+1}}return-1}_iterate(t,e=0,n=this._timeline.length-1){this._timeline.slice(e,n+1).forEach(t)}forEach(t){return this._iterate(t),this}forEachBefore(t,e){const n=this._search(t);return n!==-1&&this._iterate(e,0,n),this}forEachAfter(t,e){const n=this._search(t);return this._iterate(e,n+1),this}forEachBetween(t,e,n){let r=this._search(t),i=this._search(e);return r!==-1&&i!==-1?(this._timeline[r].time!==t&&(r+=1),this._timeline[i].time===e&&(i-=1),this._iterate(n,r,i)):r===-1&&this._iterate(n,0,i),this}forEachFrom(t,e){let n=this._search(t);for(;n>=0&&this._timeline[n].time>=t;)n--;return this._iterate(e,n+1),this}forEachAtTime(t,e){const n=this._search(t);if(n!==-1&&Dt(this._timeline[n].time,t)){let r=n;for(let i=n;i>=0&&Dt(this._timeline[i].time,t);i--)r=i;this._iterate(i=>{e(i)},r,n)}return this}dispose(){return super.dispose(),this._timeline=[],this}}const ti=[];function xn(s){ti.push(s)}function Vl(s){ti.forEach(t=>t(s))}const ei=[];function Nn(s){ei.push(s)}function Fl(s){ei.forEach(t=>t(s))}class Qe extends Xt{constructor(){super(...arguments),this.name="Emitter"}on(t,e){return t.split(/\W+/).forEach(r=>{It(this._events)&&(this._events={}),this._events.hasOwnProperty(r)||(this._events[r]=[]),this._events[r].push(e)}),this}once(t,e){const n=(...r)=>{e(...r),this.off(t,n)};return this.on(t,n),this}off(t,e){return t.split(/\W+/).forEach(r=>{if(It(this._events)&&(this._events={}),this._events.hasOwnProperty(r))if(It(e))this._events[r]=[];else{const i=this._events[r];for(let a=i.length-1;a>=0;a--)i[a]===e&&i.splice(a,1)}}),this}emit(t,...e){if(this._events&&this._events.hasOwnProperty(t)){const n=this._events[t].slice(0);for(let r=0,i=n.length;r<i;r++)n[r].apply(this,e)}return this}static mixin(t){["on","once","off","emit"].forEach(e=>{const n=Object.getOwnPropertyDescriptor(Qe.prototype,e);Object.defineProperty(t.prototype,e,n)})}dispose(){return super.dispose(),this._events=void 0,this}}class ni extends Qe{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}}class Je extends ni{constructor(){var t,e;super(),this.name="Context",this._constants=new Map,this._timeouts=new Mt,this._timeoutIds=0,this._initialized=!1,this._closeStarted=!1,this.isOffline=!1,this._workletPromise=null;const n=L(Je.getDefaults(),arguments,["context"]);n.context?(this._context=n.context,this._latencyHint=((t=arguments[0])===null||t===void 0?void 0:t.latencyHint)||""):(this._context=kl({latencyHint:n.latencyHint}),this._latencyHint=n.latencyHint),this._ticker=new El(this.emit.bind(this,"tick"),n.clockSource,n.updateInterval,this._context.sampleRate),this.on("tick",this._timeoutLoop.bind(this)),this._context.onstatechange=()=>{this.emit("statechange",this.state)},this[!((e=arguments[0])===null||e===void 0)&&e.hasOwnProperty("updateInterval")?"_lookAhead":"lookAhead"]=n.lookAhead}static getDefaults(){return{clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.05}}initialize(){return this._initialized||(Vl(this),this._initialized=!0),this}createAnalyser(){return this._context.createAnalyser()}createOscillator(){return this._context.createOscillator()}createBufferSource(){return this._context.createBufferSource()}createBiquadFilter(){return this._context.createBiquadFilter()}createBuffer(t,e,n){return this._context.createBuffer(t,e,n)}createChannelMerger(t){return this._context.createChannelMerger(t)}createChannelSplitter(t){return this._context.createChannelSplitter(t)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(t){return this._context.createDelay(t)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(t,e){return this._context.createIIRFilter(t,e)}createPanner(){return this._context.createPanner()}createPeriodicWave(t,e,n){return this._context.createPeriodicWave(t,e,n)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(t){return B(ge(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamSource(t)}createMediaElementSource(t){return B(ge(this._context),"Not available if OfflineAudioContext"),this._context.createMediaElementSource(t)}createMediaStreamDestination(){return B(ge(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamDestination()}decodeAudioData(t){return this._context.decodeAudioData(t)}get currentTime(){return this._context.currentTime}get state(){return this._context.state}get sampleRate(){return this._context.sampleRate}get listener(){return this.initialize(),this._listener}set listener(t){B(!this._initialized,"The listener cannot be set after initialization."),this._listener=t}get transport(){return this.initialize(),this._transport}set transport(t){B(!this._initialized,"The transport cannot be set after initialization."),this._transport=t}get draw(){return this.initialize(),this._draw}set draw(t){B(!this._initialized,"Draw cannot be set after initialization."),this._draw=t}get destination(){return this.initialize(),this._destination}set destination(t){B(!this._initialized,"The destination cannot be set after initialization."),this._destination=t}createAudioWorkletNode(t,e){return Ol(this.rawContext,t,e)}addAudioWorkletModule(t){return ot(this,void 0,void 0,function*(){B(z(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)"),this._workletPromise||(this._workletPromise=this.rawContext.audioWorklet.addModule(t)),yield this._workletPromise})}workletsAreReady(){return ot(this,void 0,void 0,function*(){(yield this._workletPromise)?this._workletPromise:Promise.resolve()})}get updateInterval(){return this._ticker.updateInterval}set updateInterval(t){this._ticker.updateInterval=t}get clockSource(){return this._ticker.type}set clockSource(t){this._ticker.type=t}get lookAhead(){return this._lookAhead}set lookAhead(t){this._lookAhead=t,this.updateInterval=t?t/2:.01}get latencyHint(){return this._latencyHint}get rawContext(){return this._context}now(){return this._context.currentTime+this._lookAhead}immediate(){return this._context.currentTime}resume(){return ge(this._context)?this._context.resume():Promise.resolve()}close(){return ot(this,void 0,void 0,function*(){ge(this._context)&&this.state!=="closed"&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&Fl(this)})}getConstant(t){if(this._constants.has(t))return this._constants.get(t);{const e=this._context.createBuffer(1,128,this._context.sampleRate),n=e.getChannelData(0);for(let i=0;i<n.length;i++)n[i]=t;const r=this._context.createBufferSource();return r.channelCount=1,r.channelCountMode="explicit",r.buffer=e,r.loop=!0,r.start(0),this._constants.set(t,r),r}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map(t=>this._constants[t].disconnect()),this.close(),this}_timeoutLoop(){const t=this.now();this._timeouts.forEachBefore(t,e=>{e.callback(),this._timeouts.remove(e)})}setTimeout(t,e){this._timeoutIds++;const n=this.now();return this._timeouts.add({callback:t,id:this._timeoutIds,time:n+e}),this._timeoutIds}clearTimeout(t){return this._timeouts.forEach(e=>{e.id===t&&this._timeouts.remove(e)}),this}clearInterval(t){return this.clearTimeout(t)}setInterval(t,e){const n=++this._timeoutIds,r=()=>{const i=this.now();this._timeouts.add({callback:()=>{t(),r()},id:n,time:i+e})};return r(),n}}class Wl extends ni{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(t,e,n){return{}}createChannelMerger(t){return{}}createChannelSplitter(t){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(t){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(t,e){return{}}createPanner(){return{}}createPeriodicWave(t,e,n){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(t){return{}}createMediaElementSource(t){return{}}createMediaStreamDestination(){return{}}decodeAudioData(t){return Promise.resolve({})}createAudioWorkletNode(t,e){return{}}get rawContext(){return{}}addAudioWorkletModule(t){return ot(this,void 0,void 0,function*(){return Promise.resolve()})}resume(){return Promise.resolve()}setTimeout(t,e){return 0}clearTimeout(t){return this}setInterval(t,e){return 0}clearInterval(t){return this}getConstant(t){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(t){}get destination(){return{}}set destination(t){}now(){return 0}immediate(){return 0}}function it(s,t){Pt(t)?t.forEach(e=>it(s,e)):Object.defineProperty(s,t,{enumerable:!0,writable:!1})}function si(s,t){Pt(t)?t.forEach(e=>si(s,e)):Object.defineProperty(s,t,{writable:!0})}const X=()=>{};class Q extends Xt{constructor(){super(),this.name="ToneAudioBuffer",this.onload=X;const t=L(Q.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=t.reverse,this.onload=t.onload,$t(t.url)?this.load(t.url).catch(t.onerror):t.url&&this.set(t.url)}static getDefaults(){return{onerror:X,onload:X,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:bt().sampleRate}set(t){return t instanceof Q?t.loaded?this._buffer=t.get():t.onload=()=>{this.set(t),this.onload(this)}:this._buffer=t,this._reversed&&this._reverse(),this}get(){return this._buffer}load(t){return ot(this,void 0,void 0,function*(){const e=Q.load(t).then(n=>{this.set(n),this.onload(this)});Q.downloads.push(e);try{yield e}finally{const n=Q.downloads.indexOf(e);Q.downloads.splice(n,1)}return this})}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(t){const e=Pt(t)&&t[0].length>0,n=e?t.length:1,r=e?t[0].length:t.length,i=bt(),a=i.createBuffer(n,r,i.sampleRate),o=!e&&n===1?[t]:t;for(let c=0;c<n;c++)a.copyToChannel(o[c],c);return this._buffer=a,this}toMono(t){if(le(t))this.fromArray(this.toArray(t));else{let e=new Float32Array(this.length);const n=this.numberOfChannels;for(let r=0;r<n;r++){const i=this.toArray(r);for(let a=0;a<i.length;a++)e[a]+=i[a]}e=e.map(r=>r/n),this.fromArray(e)}return this}toArray(t){if(le(t))return this.getChannelData(t);if(this.numberOfChannels===1)return this.toArray(0);{const e=[];for(let n=0;n<this.numberOfChannels;n++)e[n]=this.getChannelData(n);return e}}getChannelData(t){return this._buffer?this._buffer.getChannelData(t):new Float32Array(0)}slice(t,e=this.duration){B(this.loaded,"Buffer is not loaded");const n=Math.floor(t*this.sampleRate),r=Math.floor(e*this.sampleRate);B(n<r,"The start time must be less than the end time");const i=r-n,a=bt().createBuffer(this.numberOfChannels,i,this.sampleRate);for(let o=0;o<this.numberOfChannels;o++)a.copyToChannel(this.getChannelData(o).subarray(n,r),o);return new Q(a)}_reverse(){if(this.loaded)for(let t=0;t<this.numberOfChannels;t++)this.getChannelData(t).reverse();return this}get loaded(){return this.length>0}get duration(){return this._buffer?this._buffer.duration:0}get length(){return this._buffer?this._buffer.length:0}get numberOfChannels(){return this._buffer?this._buffer.numberOfChannels:0}get reverse(){return this._reversed}set reverse(t){this._reversed!==t&&(this._reversed=t,this._reverse())}static fromArray(t){return new Q().fromArray(t)}static fromUrl(t){return ot(this,void 0,void 0,function*(){return yield new Q().load(t)})}static load(t){return ot(this,void 0,void 0,function*(){const e=Q.baseUrl===""||Q.baseUrl.endsWith("/")?Q.baseUrl:Q.baseUrl+"/",n=yield fetch(e+t);if(!n.ok)throw new Error(`could not load url: ${t}`);const r=yield n.arrayBuffer();return yield bt().decodeAudioData(r)})}static supportsType(t){const e=t.split("."),n=e[e.length-1];return document.createElement("audio").canPlayType("audio/"+n)!==""}static loaded(){return ot(this,void 0,void 0,function*(){for(yield Promise.resolve();Q.downloads.length;)yield Q.downloads[0]})}}Q.baseUrl="";Q.downloads=[];class On extends Je{constructor(){super({clockSource:"offline",context:an(arguments[0])?arguments[0]:xl(arguments[0],arguments[1]*arguments[2],arguments[2]),lookAhead:0,updateInterval:an(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this.isOffline=!0,this._duration=an(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(t){return ot(this,void 0,void 0,function*(){let e=0;for(;this._duration-this._currentTime>=0;){this.emit("tick"),this._currentTime+=128/this.sampleRate,e++;const n=Math.floor(this.sampleRate/128);t&&e%n===0&&(yield new Promise(r=>setTimeout(r,1)))}})}render(){return ot(this,arguments,void 0,function*(t=!0){yield this.workletsAreReady(),yield this._renderClock(t);const e=yield this._context.startRendering();return new Q(e)})}close(){return Promise.resolve()}}const ri=new Wl;let ae=ri;function bt(){return ae===ri&&Nl&&vn(new Je),ae}function vn(s,t=!1){t&&ae.dispose(),ge(s)?ae=new Je(s):an(s)?ae=new On(s):ae=s}function ql(){return ae.resume()}if(xt&&!xt.TONE_SILENCE_LOGGING){const t=` * Tone.js v${sr} * `;console.log(`%c${t}`,"background: #000; color: #fff")}function Ll(s){return Math.pow(10,s/20)}function Bl(s){return 20*(Math.log(s)/Math.LN10)}function ii(s){return Math.pow(2,s/12)}let En=440;function jl(){return En}function Ul(s){En=s}function Jn(s){return Math.round(oi(s))}function oi(s){return 69+12*Math.log2(s/En)}function Gl(s){return En*Math.pow(2,(s-69)/12)}class Ts extends Xt{constructor(t,e,n){super(),this.defaultUnits="s",this._val=e,this._units=n,this.context=t,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:t=>this._frequencyToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:t=>this._ticksToUnits(parseInt(t,10)),regexp:/^(\d+)i$/i},m:{method:t=>this._beatsToUnits(parseInt(t,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(t,e)=>{const n=parseInt(t,10),r=e==="."?1.5:1;return n===1?this._beatsToUnits(this._getTimeSignature())*r:this._beatsToUnits(4/n)*r},regexp:/^(\d+)n(\.?)$/i},number:{method:t=>this._expressions[this.defaultUnits].method.call(this,t),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:t=>this._secondsToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:t=>parseInt(t,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:t=>{const e=parseInt(t,10);return this._beatsToUnits(8/(Math.floor(e)*3))},regexp:/^(\d+)t$/i},tr:{method:(t,e,n)=>{let r=0;return t&&t!=="0"&&(r+=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&e!=="0"&&(r+=this._beatsToUnits(parseFloat(e))),n&&n!=="0"&&(r+=this._beatsToUnits(parseFloat(n)/4)),r},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof Ts&&this.fromType(this._val),It(this._val))return this._noArg();if($t(this._val)&&It(this._units)){for(const t in this._expressions)if(this._expressions[t].regexp.test(this._val.trim())){this._units=t;break}}else if(ce(this._val)){let t=0;for(const e in this._val)if(z(this._val[e])){const n=this._val[e],r=new this.constructor(this.context,e).valueOf()*n;t+=r}return t}if(z(this._units)){const t=this._expressions[this._units],e=this._val.toString().trim().match(t.regexp);return e?t.method.apply(this,e.slice(1)):t.method.call(this,this._val)}else return $t(this._val)?parseFloat(this._val):this._val}_frequencyToUnits(t){return 1/t}_beatsToUnits(t){return 60/this._getBpm()*t}_secondsToUnits(t){return t}_ticksToUnits(t){return t*this._beatsToUnits(1)/this._getPPQ()}_noArg(){return this._now()}_getBpm(){return this.context.transport.bpm.value}_getTimeSignature(){return this.context.transport.timeSignature}_getPPQ(){return this.context.transport.PPQ}fromType(t){switch(this._units=void 0,this.defaultUnits){case"s":this._val=t.toSeconds();break;case"i":this._val=t.toTicks();break;case"hz":this._val=t.toFrequency();break;case"midi":this._val=t.toMidi();break}return this}toFrequency(){return 1/this.toSeconds()}toSamples(){return this.toSeconds()*this.context.sampleRate}toMilliseconds(){return this.toSeconds()*1e3}}class Rt extends Ts{constructor(){super(...arguments),this.name="TimeClass"}_getExpressions(){return Object.assign(super._getExpressions(),{now:{method:t=>this._now()+new this.constructor(this.context,t).valueOf(),regexp:/^\+(.+)/},quantize:{method:t=>{const e=new Rt(this.context,t).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(e))},regexp:/^@(.+)/}})}quantize(t,e=1){const n=new this.constructor(this.context,t).valueOf(),r=this.valueOf(),o=Math.round(r/n)*n-r;return r+o*e}toNotation(){const t=this.toSeconds(),e=["1m"];for(let i=1;i<9;i++){const a=Math.pow(2,i);e.push(a+"n."),e.push(a+"n"),e.push(a+"t")}e.push("0");let n=e[0],r=new Rt(this.context,e[0]).toSeconds();return e.forEach(i=>{const a=new Rt(this.context,i).toSeconds();Math.abs(a-t)<Math.abs(r-t)&&(n=i,r=a)}),n}toBarsBeatsSixteenths(){const t=this._beatsToUnits(1);let e=this.valueOf()/t;e=parseFloat(e.toFixed(4));const n=Math.floor(e/this._getTimeSignature());let r=e%1*4;e=Math.floor(e)%this._getTimeSignature();const i=r.toString();return i.length>3&&(r=parseFloat(parseFloat(i).toFixed(3))),[n,e,r].join(":")}toTicks(){const t=this._beatsToUnits(1);return this.valueOf()/t*this._getPPQ()}toSeconds(){return this.valueOf()}toMidi(){return Jn(this.toFrequency())}_now(){return this.context.now()}}class Et extends Rt{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return jl()}static set A4(t){Ul(t)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(t){return this.defaultUnits==="midi"?t:Et.mtof(t)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(t,e){const r=zl[t.toLowerCase()]+(parseInt(e,10)+1)*12;return this.defaultUnits==="midi"?r:Et.mtof(r)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(t,e,n){let r=1;return t&&t!=="0"&&(r*=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&e!=="0"&&(r*=this._beatsToUnits(parseFloat(e))),n&&n!=="0"&&(r*=this._beatsToUnits(parseFloat(n)/4)),r}}})}transpose(t){return new Et(this.context,this.valueOf()*ii(t))}harmonize(t){return t.map(e=>this.transpose(e))}toMidi(){return Jn(this.valueOf())}toNote(){const t=this.toFrequency(),e=Math.log2(t/Et.A4);let n=Math.round(12*e)+57;const r=Math.floor(n/12);return r<0&&(n+=-12*r),$l[n%12]+r.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){const t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.floor(e*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(t){return t}_ticksToUnits(t){return 1/(t*60/(this._getBpm()*this._getPPQ()))}_beatsToUnits(t){return 1/super._beatsToUnits(t)}_secondsToUnits(t){return 1/t}static mtof(t){return Gl(t)}static ftom(t){return Jn(t)}}const zl={cbbb:-3,cbb:-2,cb:-1,c:0,"c#":1,cx:2,"c##":2,"c###":3,"cx#":3,"c#x":3,dbbb:-1,dbb:0,db:1,d:2,"d#":3,dx:4,"d##":4,"d###":5,"dx#":5,"d#x":5,ebbb:1,ebb:2,eb:3,e:4,"e#":5,ex:6,"e##":6,"e###":7,"ex#":7,"e#x":7,fbbb:2,fbb:3,fb:4,f:5,"f#":6,fx:7,"f##":7,"f###":8,"fx#":8,"f#x":8,gbbb:4,gbb:5,gb:6,g:7,"g#":8,gx:9,"g##":9,"g###":10,"gx#":10,"g#x":10,abbb:6,abb:7,ab:8,a:9,"a#":10,ax:11,"a##":11,"a###":12,"ax#":12,"a#x":12,bbbb:8,bbb:9,bb:10,b:11,"b#":12,bx:13,"b##":13,"b###":14,"bx#":14,"b#x":14},$l=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];class qe extends Rt{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}}class Ct extends Xt{constructor(){super();const t=L(Ct.getDefaults(),arguments,["context"]);this.defaultContext?this.context=this.defaultContext:this.context=t.context}static getDefaults(){return{context:bt()}}now(){return this.context.currentTime+this.context.lookAhead}immediate(){return this.context.currentTime}get sampleTime(){return 1/this.context.sampleRate}get blockTime(){return 128/this.context.sampleRate}toSeconds(t){return Sl(t),new Rt(this.context,t).toSeconds()}toFrequency(t){return new Et(this.context,t).toFrequency()}toTicks(t){return new qe(this.context,t).toTicks()}_getPartialProperties(t){const e=this.get();return Object.keys(e).forEach(n=>{It(t[n])&&delete e[n]}),e}get(){const t=Rl(this);return Object.keys(t).forEach(e=>{if(Reflect.has(this,e)){const n=this[e];z(n)&&z(n.value)&&z(n.setValueAtTime)?t[e]=n.value:n instanceof Ct?t[e]=n._getPartialProperties(t[e]):Pt(n)||le(n)||$t(n)||Cl(n)?t[e]=n:delete t[e]}}),t}set(t){return Object.keys(t).forEach(e=>{Reflect.has(this,e)&&z(this[e])&&(this[e]&&z(this[e].value)&&z(this[e].setValueAtTime)?this[e].value!==t[e]&&(this[e].value=t[e]):this[e]instanceof Ct?this[e].set(t[e]):this[e]=t[e])}),this}}class ws extends Mt{constructor(t="stopped"){super(),this.name="StateTimeline",this._initial=t,this.setStateAtTime(this._initial,0)}getValueAtTime(t){const e=this.get(t);return e!==null?e.state:this._initial}setStateAtTime(t,e,n){return te(e,0),this.add(Object.assign({},n,{state:t,time:e})),this}getLastState(t,e){const n=this._search(e);for(let r=n;r>=0;r--){const i=this._timeline[r];if(i.state===t)return i}}getNextState(t,e){const n=this._search(e);if(n!==-1)for(let r=n;r<this._timeline.length;r++){const i=this._timeline[r];if(i.state===t)return i}}}class nt extends Ct{constructor(){const t=L(nt.getDefaults(),arguments,["param","units","convert"]);for(super(t),this.name="Param",this.overridden=!1,this._minOutput=1e-7,B(z(t.param)&&(he(t.param)||t.param instanceof nt),"param must be an AudioParam");!he(t.param);)t.param=t.param._param;this._swappable=z(t.swappable)?t.swappable:!1,this._swappable?(this.input=this.context.createGain(),this._param=t.param,this.input.connect(this._param)):this._param=this.input=t.param,this._events=new Mt(1e3),this._initialValue=this._param.defaultValue,this.units=t.units,this.convert=t.convert,this._minValue=t.minValue,this._maxValue=t.maxValue,z(t.value)&&t.value!==this._toType(this._initialValue)&&this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(Ct.getDefaults(),{convert:!0,units:"number"})}get value(){const t=this.now();return this.getValueAtTime(t)}set value(t){this.cancelScheduledValues(this.now()),this.setValueAtTime(t,this.now())}get minValue(){return z(this._minValue)?this._minValue:this.units==="time"||this.units==="frequency"||this.units==="normalRange"||this.units==="positive"||this.units==="transportTime"||this.units==="ticks"||this.units==="bpm"||this.units==="hertz"||this.units==="samples"?0:this.units==="audioRange"?-1:this.units==="decibels"?-1/0:this._param.minValue}get maxValue(){return z(this._maxValue)?this._maxValue:this.units==="normalRange"||this.units==="audioRange"?1:this._param.maxValue}_is(t,e){return this.units===e}_assertRange(t){return z(this.maxValue)&&z(this.minValue)&&te(t,this._fromType(this.minValue),this._fromType(this.maxValue)),t}_fromType(t){return this.convert&&!this.overridden?this._is(t,"time")?this.toSeconds(t):this._is(t,"decibels")?Ll(t):this._is(t,"frequency")?this.toFrequency(t):t:this.overridden?0:t}_toType(t){return this.convert&&this.units==="decibels"?Bl(t):t}setValueAtTime(t,e){const n=this.toSeconds(e),r=this._fromType(t);return B(isFinite(r)&&isFinite(n),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(r),this.log(this.units,"setValueAtTime",t,n),this._events.add({time:n,type:"setValueAtTime",value:r}),this._param.setValueAtTime(r,n),this}getValueAtTime(t){const e=Math.max(this.toSeconds(t),0),n=this._events.getAfter(e),r=this._events.get(e);let i=this._initialValue;if(r===null)i=this._initialValue;else if(r.type==="setTargetAtTime"&&(n===null||n.type==="setValueAtTime")){const a=this._events.getBefore(r.time);let o;a===null?o=this._initialValue:o=a.value,r.type==="setTargetAtTime"&&(i=this._exponentialApproach(r.time,o,r.value,r.constant,e))}else if(n===null)i=r.value;else if(n.type==="linearRampToValueAtTime"||n.type==="exponentialRampToValueAtTime"){let a=r.value;if(r.type==="setTargetAtTime"){const o=this._events.getBefore(r.time);o===null?a=this._initialValue:a=o.value}n.type==="linearRampToValueAtTime"?i=this._linearInterpolate(r.time,a,n.time,n.value,e):i=this._exponentialInterpolate(r.time,a,n.time,n.value,e)}else i=r.value;return this._toType(i)}setRampPoint(t){t=this.toSeconds(t);let e=this.getValueAtTime(t);return this.cancelAndHoldAtTime(t),this._fromType(e)===0&&(e=this._toType(this._minOutput)),this.setValueAtTime(e,t),this}linearRampToValueAtTime(t,e){const n=this._fromType(t),r=this.toSeconds(e);return B(isFinite(n)&&isFinite(r),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(n),this._events.add({time:r,type:"linearRampToValueAtTime",value:n}),this.log(this.units,"linearRampToValueAtTime",t,r),this._param.linearRampToValueAtTime(n,r),this}exponentialRampToValueAtTime(t,e){let n=this._fromType(t);n=Dt(n,0)?this._minOutput:n,this._assertRange(n);const r=this.toSeconds(e);return B(isFinite(n)&&isFinite(r),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({time:r,type:"exponentialRampToValueAtTime",value:n}),this.log(this.units,"exponentialRampToValueAtTime",t,r),this._param.exponentialRampToValueAtTime(n,r),this}exponentialRampTo(t,e,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialRampToValueAtTime(t,n+this.toSeconds(e)),this}linearRampTo(t,e,n){return n=this.toSeconds(n),this.setRampPoint(n),this.linearRampToValueAtTime(t,n+this.toSeconds(e)),this}targetRampTo(t,e,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialApproachValueAtTime(t,n,e),this}exponentialApproachValueAtTime(t,e,n){e=this.toSeconds(e),n=this.toSeconds(n);const r=Math.log(n+1)/Math.log(200);return this.setTargetAtTime(t,e,r),this.cancelAndHoldAtTime(e+n*.9),this.linearRampToValueAtTime(t,e+n),this}setTargetAtTime(t,e,n){const r=this._fromType(t);B(isFinite(n)&&n>0,"timeConstant must be a number greater than 0");const i=this.toSeconds(e);return this._assertRange(r),B(isFinite(r)&&isFinite(i),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({constant:n,time:i,type:"setTargetAtTime",value:r}),this.log(this.units,"setTargetAtTime",t,i,n),this._param.setTargetAtTime(r,i,n),this}setValueCurveAtTime(t,e,n,r=1){n=this.toSeconds(n),e=this.toSeconds(e);const i=this._fromType(t[0])*r;this.setValueAtTime(this._toType(i),e);const a=n/(t.length-1);for(let o=1;o<t.length;o++){const c=this._fromType(t[o])*r;this.linearRampToValueAtTime(this._toType(c),e+o*a)}return this}cancelScheduledValues(t){const e=this.toSeconds(t);return B(isFinite(e),`Invalid argument to cancelScheduledValues: ${JSON.stringify(t)}`),this._events.cancel(e),this._param.cancelScheduledValues(e),this.log(this.units,"cancelScheduledValues",e),this}cancelAndHoldAtTime(t){const e=this.toSeconds(t),n=this._fromType(this.getValueAtTime(e));B(isFinite(e),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(t)}`),this.log(this.units,"cancelAndHoldAtTime",e,"value="+n);const r=this._events.get(e),i=this._events.getAfter(e);return r&&Dt(r.time,e)?i?(this._param.cancelScheduledValues(i.time),this._events.cancel(i.time)):(this._param.cancelAndHoldAtTime(e),this._events.cancel(e+this.sampleTime)):i&&(this._param.cancelScheduledValues(i.time),this._events.cancel(i.time),i.type==="linearRampToValueAtTime"?this.linearRampToValueAtTime(this._toType(n),e):i.type==="exponentialRampToValueAtTime"&&this.exponentialRampToValueAtTime(this._toType(n),e)),this._events.add({time:e,type:"setValueAtTime",value:n}),this._param.setValueAtTime(n,e),this}rampTo(t,e=.1,n){return this.units==="frequency"||this.units==="bpm"||this.units==="decibels"?this.exponentialRampTo(t,e,n):this.linearRampTo(t,e,n),this}apply(t){const e=this.context.currentTime;t.setValueAtTime(this.getValueAtTime(e),e);const n=this._events.get(e);if(n&&n.type==="setTargetAtTime"){const r=this._events.getAfter(n.time),i=r?r.time:e+2,a=(i-e)/10;for(let o=e;o<i;o+=a)t.linearRampToValueAtTime(this.getValueAtTime(o),o)}return this._events.forEachAfter(this.context.currentTime,r=>{r.type==="cancelScheduledValues"?t.cancelScheduledValues(r.time):r.type==="setTargetAtTime"?t.setTargetAtTime(r.value,r.time,r.constant):t[r.type](r.value,r.time)}),this}setParam(t){B(this._swappable,"The Param must be assigned as 'swappable' in the constructor");const e=this.input;return e.disconnect(this._param),this.apply(t),this._param=t,e.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(t,e,n,r,i){return n+(e-n)*Math.exp(-(i-t)/r)}_linearInterpolate(t,e,n,r,i){return e+(r-e)*((i-t)/(n-t))}_exponentialInterpolate(t,e,n,r,i){return e*Math.pow(r/e,(i-t)/(n-t))}}class U extends Ct{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return z(this.input)?he(this.input)||this.input instanceof nt?1:this.input.numberOfInputs:0}get numberOfOutputs(){return z(this.output)?this.output.numberOfOutputs:0}_isAudioNode(t){return z(t)&&(t instanceof U||Kt(t))}_getInternalNodes(){const t=this._internalChannels.slice(0);return this._isAudioNode(this.input)&&t.push(this.input),this._isAudioNode(this.output)&&this.input!==this.output&&t.push(this.output),t}_setChannelProperties(t){this._getInternalNodes().forEach(n=>{n.channelCount=t.channelCount,n.channelCountMode=t.channelCountMode,n.channelInterpretation=t.channelInterpretation})}_getChannelProperties(){const t=this._getInternalNodes();B(t.length>0,"ToneAudioNode does not have any internal nodes");const e=t[0];return{channelCount:e.channelCount,channelCountMode:e.channelCountMode,channelInterpretation:e.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCount:t}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCountMode:t}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelInterpretation:t}))}connect(t,e=0,n=0){return Ve(this,t,e,n),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return vs("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(t,e=0,n=0){return Zl(this,t,e,n),this}chain(...t){return Kn(this,...t),this}fan(...t){return t.forEach(e=>this.connect(e)),this}dispose(){return super.dispose(),z(this.input)&&(this.input instanceof U?this.input.dispose():Kt(this.input)&&this.input.disconnect()),z(this.output)&&(this.output instanceof U?this.output.dispose():Kt(this.output)&&this.output.disconnect()),this._internalChannels=[],this}}function Kn(...s){const t=s.shift();s.reduce((e,n)=>(e instanceof U?e.connect(n):Kt(e)&&Ve(e,n),n),t)}function Ve(s,t,e=0,n=0){for(B(z(s),"Cannot connect from undefined node"),B(z(t),"Cannot connect to undefined node"),(t instanceof U||Kt(t))&&B(t.numberOfInputs>0,"Cannot connect to node with no inputs"),B(s.numberOfOutputs>0,"Cannot connect from node with no outputs");t instanceof U||t instanceof nt;)z(t.input)&&(t=t.input);for(;s instanceof U;)z(s.output)&&(s=s.output);he(t)?s.connect(t,e):s.connect(t,e,n)}function Zl(s,t,e=0,n=0){if(z(t))for(;t instanceof U;)t=t.input;for(;!Kt(s);)z(s.output)&&(s=s.output);he(t)?s.disconnect(t,e):Kt(t)?s.disconnect(t,e,n):s.disconnect()}class mt extends U{constructor(){const t=L(mt.getDefaults(),arguments,["gain","units"]);super(t),this.name="Gain",this._gainNode=this.context.createGain(),this.input=this._gainNode,this.output=this._gainNode,this.gain=new nt({context:this.context,convert:t.convert,param:this._gainNode.gain,units:t.units,value:t.gain,minValue:t.minValue,maxValue:t.maxValue}),it(this,"gain")}static getDefaults(){return Object.assign(U.getDefaults(),{convert:!0,gain:1,units:"gain"})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}}class ke extends U{constructor(t){super(t),this.onended=X,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new mt({context:this.context,gain:0}),this._gainNode=this.output,this.getStateAtTime=function(e){const n=this.toSeconds(e);return this._startTime!==-1&&n>=this._startTime&&(this._stopTime===-1||n<=this._stopTime)?"started":"stopped"},this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut,this._curve=t.curve,this.onended=t.onended}static getDefaults(){return Object.assign(U.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:X})}_startGain(t,e=1){B(this._startTime===-1,"Source cannot be started more than once");const n=this.toSeconds(this._fadeIn);return this._startTime=t+n,this._startTime=Math.max(this._startTime,this.context.currentTime),n>0?(this._gainNode.gain.setValueAtTime(0,t),this._curve==="linear"?this._gainNode.gain.linearRampToValueAtTime(e,t+n):this._gainNode.gain.exponentialApproachValueAtTime(e,t,n)):this._gainNode.gain.setValueAtTime(e,t),this}stop(t){return this.log("stop",t),this._stopGain(this.toSeconds(t)),this}_stopGain(t){B(this._startTime!==-1,"'start' must be called before 'stop'"),this.cancelStop();const e=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(t)+e,this._stopTime=Math.max(this._stopTime,this.now()),e>0?this._curve==="linear"?this._gainNode.gain.linearRampTo(0,e,t):this._gainNode.gain.targetRampTo(0,e,t):(this._gainNode.gain.cancelAndHoldAtTime(t),this._gainNode.gain.setValueAtTime(0,t)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout(()=>{const n=this._curve==="exponential"?e*2:0;this._stopSource(this.now()+n),this._onended()},this._stopTime-this.context.currentTime),this}_onended(){if(this.onended!==X&&(this.onended(this),this.onended=X,!this.context.isOffline)){const t=()=>this.dispose();typeof requestIdleCallback<"u"?requestIdleCallback(t):setTimeout(t,10)}}get state(){return this.getStateAtTime(this.now())}cancelStop(){return this.log("cancelStop"),B(this._startTime!==-1,"Source is not started"),this._gainNode.gain.cancelScheduledValues(this._startTime+this.sampleTime),this.context.clearTimeout(this._timeout),this._stopTime=-1,this}dispose(){return super.dispose(),this._gainNode.dispose(),this.onended=X,this}}class bs extends ke{constructor(){const t=L(bs.getDefaults(),arguments,["offset"]);super(t),this.name="ToneConstantSource",this._source=this.context.createConstantSource(),Ve(this._source,this._gainNode),this.offset=new nt({context:this.context,convert:t.convert,param:this._source.offset,units:t.units,value:t.offset,minValue:t.minValue,maxValue:t.maxValue})}static getDefaults(){return Object.assign(ke.getDefaults(),{convert:!0,offset:1,units:"number"})}start(t){const e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._source.start(e),this}_stopSource(t){this._source.stop(t)}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._source.disconnect(),this.offset.dispose(),this}}class pt extends U{constructor(){const t=L(pt.getDefaults(),arguments,["value","units"]);super(t),this.name="Signal",this.override=!0,this.output=this._constantSource=new bs({context:this.context,convert:t.convert,offset:t.value,units:t.units,minValue:t.minValue,maxValue:t.maxValue}),this._constantSource.start(0),this.input=this._param=this._constantSource.offset}static getDefaults(){return Object.assign(U.getDefaults(),{convert:!0,units:"number",value:0})}connect(t,e=0,n=0){return Cs(this,t,e,n),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(t,e){return this._param.setValueAtTime(t,e),this}getValueAtTime(t){return this._param.getValueAtTime(t)}setRampPoint(t){return this._param.setRampPoint(t),this}linearRampToValueAtTime(t,e){return this._param.linearRampToValueAtTime(t,e),this}exponentialRampToValueAtTime(t,e){return this._param.exponentialRampToValueAtTime(t,e),this}exponentialRampTo(t,e,n){return this._param.exponentialRampTo(t,e,n),this}linearRampTo(t,e,n){return this._param.linearRampTo(t,e,n),this}targetRampTo(t,e,n){return this._param.targetRampTo(t,e,n),this}exponentialApproachValueAtTime(t,e,n){return this._param.exponentialApproachValueAtTime(t,e,n),this}setTargetAtTime(t,e,n){return this._param.setTargetAtTime(t,e,n),this}setValueCurveAtTime(t,e,n,r){return this._param.setValueCurveAtTime(t,e,n,r),this}cancelScheduledValues(t){return this._param.cancelScheduledValues(t),this}cancelAndHoldAtTime(t){return this._param.cancelAndHoldAtTime(t),this}rampTo(t,e,n){return this._param.rampTo(t,e,n),this}get value(){return this._param.value}set value(t){this._param.value=t}get convert(){return this._param.convert}set convert(t){this._param.convert=t}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(t){this._param.overridden=t}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(t){return this._param.apply(t),this}}function Cs(s,t,e,n){(t instanceof nt||he(t)||t instanceof pt&&t.override)&&(t.cancelScheduledValues(0),t.setValueAtTime(0,0),t instanceof pt&&(t.overridden=!0)),Ve(s,t,e,n)}class Ss extends nt{constructor(){const t=L(Ss.getDefaults(),arguments,["value"]);super(t),this.name="TickParam",this._events=new Mt(1/0),this._multiplier=1,this._multiplier=t.multiplier,this._events.cancel(0),this._events.add({ticks:0,time:0,type:"setValueAtTime",value:this._fromType(t.value)}),this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(nt.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(t,e,n){e=this.toSeconds(e),this.setRampPoint(e);const r=this._fromType(t),i=this._events.get(e),a=Math.round(Math.max(1/n,1));for(let o=0;o<=a;o++){const c=n*o+e,u=this._exponentialApproach(i.time,i.value,r,n,c);this.linearRampToValueAtTime(this._toType(u),c)}return this}setValueAtTime(t,e){const n=this.toSeconds(e);super.setValueAtTime(t,e);const r=this._events.get(n),i=this._events.previousEvent(r),a=this._getTicksUntilEvent(i,n);return r.ticks=Math.max(a,0),this}linearRampToValueAtTime(t,e){const n=this.toSeconds(e);super.linearRampToValueAtTime(t,e);const r=this._events.get(n),i=this._events.previousEvent(r),a=this._getTicksUntilEvent(i,n);return r.ticks=Math.max(a,0),this}exponentialRampToValueAtTime(t,e){e=this.toSeconds(e);const n=this._fromType(t),r=this._events.get(e),i=Math.round(Math.max((e-r.time)*10,1)),a=(e-r.time)/i;for(let o=0;o<=i;o++){const c=a*o+r.time,u=this._exponentialInterpolate(r.time,r.value,e,n,c);this.linearRampToValueAtTime(this._toType(u),c)}return this}_getTicksUntilEvent(t,e){if(t===null)t={ticks:0,time:0,type:"setValueAtTime",value:0};else if(It(t.ticks)){const a=this._events.previousEvent(t);t.ticks=this._getTicksUntilEvent(a,t.time)}const n=this._fromType(this.getValueAtTime(t.time));let r=this._fromType(this.getValueAtTime(e));const i=this._events.get(e);return i&&i.time===e&&i.type==="setValueAtTime"&&(r=this._fromType(this.getValueAtTime(e-this.sampleTime))),.5*(e-t.time)*(n+r)+t.ticks}getTicksAtTime(t){const e=this.toSeconds(t),n=this._events.get(e);return Math.max(this._getTicksUntilEvent(n,e),0)}getDurationOfTicks(t,e){const n=this.toSeconds(e),r=this.getTicksAtTime(e);return this.getTimeOfTick(r+t)-n}getTimeOfTick(t){const e=this._events.get(t,"ticks"),n=this._events.getAfter(t,"ticks");if(e&&e.ticks===t)return e.time;if(e&&n&&n.type==="linearRampToValueAtTime"&&e.value!==n.value){const r=this._fromType(this.getValueAtTime(e.time)),a=(this._fromType(this.getValueAtTime(n.time))-r)/(n.time-e.time),o=Math.sqrt(Math.pow(r,2)-2*a*(e.ticks-t)),c=(-r+o)/a,u=(-r-o)/a;return(c>0?c:u)+e.time}else return e?e.value===0?1/0:e.time+(t-e.ticks)/e.value:t/this._initialValue}ticksToTime(t,e){return this.getDurationOfTicks(t,e)}timeToTicks(t,e){const n=this.toSeconds(e),r=this.toSeconds(t),i=this.getTicksAtTime(n);return this.getTicksAtTime(n+r)-i}_fromType(t){return this.units==="bpm"&&this.multiplier?1/(60/t/this.multiplier):super._fromType(t)}_toType(t){return this.units==="bpm"&&this.multiplier?t/this.multiplier*60:super._toType(t)}get multiplier(){return this._multiplier}set multiplier(t){const e=this.value;this._multiplier=t,this.cancelScheduledValues(0),this.setValueAtTime(e,0)}}class As extends pt{constructor(){const t=L(As.getDefaults(),arguments,["value"]);super(t),this.name="TickSignal",this.input=this._param=new Ss({context:this.context,convert:t.convert,multiplier:t.multiplier,param:this._constantSource.offset,units:t.units,value:t.value})}static getDefaults(){return Object.assign(pt.getDefaults(),{multiplier:1,units:"hertz",value:1})}ticksToTime(t,e){return this._param.ticksToTime(t,e)}timeToTicks(t,e){return this._param.timeToTicks(t,e)}getTimeOfTick(t){return this._param.getTimeOfTick(t)}getDurationOfTicks(t,e){return this._param.getDurationOfTicks(t,e)}getTicksAtTime(t){return this._param.getTicksAtTime(t)}get multiplier(){return this._param.multiplier}set multiplier(t){this._param.multiplier=t}dispose(){return super.dispose(),this._param.dispose(),this}}class ks extends Ct{constructor(){const t=L(ks.getDefaults(),arguments,["frequency"]);super(t),this.name="TickSource",this._state=new ws,this._tickOffset=new Mt,this._ticksAtTime=new Mt,this._secondsAtTime=new Mt,this.frequency=new As({context:this.context,units:t.units,value:t.frequency}),it(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},Ct.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(t,e){const n=this.toSeconds(t);return this._state.getValueAtTime(n)!=="started"&&(this._state.setStateAtTime("started",n),z(e)&&this.setTicksAtTime(e,n),this._ticksAtTime.cancel(n),this._secondsAtTime.cancel(n)),this}stop(t){const e=this.toSeconds(t);if(this._state.getValueAtTime(e)==="stopped"){const n=this._state.get(e);n&&n.time>0&&(this._tickOffset.cancel(n.time),this._state.cancel(n.time))}return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this.setTicksAtTime(0,e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}pause(t){const e=this.toSeconds(t);return this._state.getValueAtTime(e)==="started"&&(this._state.setStateAtTime("paused",e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e)),this}cancel(t){return t=this.toSeconds(t),this._state.cancel(t),this._tickOffset.cancel(t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}getTicksAtTime(t){const e=this.toSeconds(t),n=this._state.getLastState("stopped",e),r=this._ticksAtTime.get(e),i={state:"paused",time:e};this._state.add(i);let a=r||n,o=r?r.ticks:0,c=null;return this._state.forEachBetween(a.time,e+this.sampleTime,u=>{let l=a.time;const h=this._tickOffset.get(u.time);h&&h.time>=a.time&&(o=h.ticks,l=h.time),a.state==="started"&&u.state!=="started"&&(o+=this.frequency.getTicksAtTime(u.time)-this.frequency.getTicksAtTime(l),u.time!==i.time&&(c={state:u.state,time:u.time,ticks:o})),a=u}),this._state.remove(i),c&&this._ticksAtTime.add(c),o}get ticks(){return this.getTicksAtTime(this.now())}set ticks(t){this.setTicksAtTime(t,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(t){const e=this.now(),n=this.frequency.timeToTicks(t,e);this.setTicksAtTime(n,e)}getSecondsAtTime(t){t=this.toSeconds(t);const e=this._state.getLastState("stopped",t),n={state:"paused",time:t};this._state.add(n);const r=this._secondsAtTime.get(t);let i=r||e,a=r?r.seconds:0,o=null;return this._state.forEachBetween(i.time,t+this.sampleTime,c=>{let u=i.time;const l=this._tickOffset.get(c.time);l&&l.time>=i.time&&(a=l.seconds,u=l.time),i.state==="started"&&c.state!=="started"&&(a+=c.time-u,c.time!==n.time&&(o={state:c.state,time:c.time,seconds:a})),i=c}),this._state.remove(n),o&&this._secondsAtTime.add(o),a}setTicksAtTime(t,e){return e=this.toSeconds(e),this._tickOffset.cancel(e),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(t,e),ticks:t,time:e}),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}getStateAtTime(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)}getTimeOfTick(t,e=this.now()){const n=this._tickOffset.get(e),r=this._state.get(e),i=Math.max(n.time,r.time),a=this.frequency.getTicksAtTime(i)+t-n.ticks;return this.frequency.getTimeOfTick(a)}forEachTickBetween(t,e,n){let r=this._state.get(t);this._state.forEachBetween(t,e,a=>{r&&r.state==="started"&&a.state!=="started"&&this.forEachTickBetween(Math.max(r.time,t),a.time-this.sampleTime,n),r=a});let i=null;if(r&&r.state==="started"){const a=Math.max(r.time,t),o=this.frequency.getTicksAtTime(a),c=this.frequency.getTicksAtTime(r.time),u=o-c;let l=Math.ceil(u)-u;l=Dt(l,1)?0:l;let h=this.frequency.getTimeOfTick(o+l);for(;h<e;){try{n(h,Math.round(this.getTicksAtTime(h)))}catch(p){i=p;break}h+=this.frequency.getDurationOfTicks(1,h)}}if(i)throw i;return this}dispose(){return super.dispose(),this._state.dispose(),this._tickOffset.dispose(),this._ticksAtTime.dispose(),this._secondsAtTime.dispose(),this.frequency.dispose(),this}}class In extends Ct{constructor(){const t=L(In.getDefaults(),arguments,["callback","frequency"]);super(t),this.name="Clock",this.callback=X,this._lastUpdate=0,this._state=new ws("stopped"),this._boundLoop=this._loop.bind(this),this.callback=t.callback,this._tickSource=new ks({context:this.context,frequency:t.frequency,units:t.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,it(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(Ct.getDefaults(),{callback:X,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(t,e){Qr(this.context);const n=this.toSeconds(t);return this.log("start",n),this._state.getValueAtTime(n)!=="started"&&(this._state.setStateAtTime("started",n),this._tickSource.start(n,e),n<this._lastUpdate&&this.emit("start",n,e)),this}stop(t){const e=this.toSeconds(t);return this.log("stop",e),this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._tickSource.stop(e),e<this._lastUpdate&&this.emit("stop",e),this}pause(t){const e=this.toSeconds(t);return this._state.getValueAtTime(e)==="started"&&(this._state.setStateAtTime("paused",e),this._tickSource.pause(e),e<this._lastUpdate&&this.emit("pause",e)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(t){this._tickSource.ticks=t}get seconds(){return this._tickSource.seconds}set seconds(t){this._tickSource.seconds=t}getSecondsAtTime(t){return this._tickSource.getSecondsAtTime(t)}setTicksAtTime(t,e){return this._tickSource.setTicksAtTime(t,e),this}getTimeOfTick(t,e=this.now()){return this._tickSource.getTimeOfTick(t,e)}getTicksAtTime(t){return this._tickSource.getTicksAtTime(t)}nextTickTime(t,e){const n=this.toSeconds(e),r=this.getTicksAtTime(n);return this._tickSource.getTimeOfTick(r+t,n)}_loop(){const t=this._lastUpdate,e=this.now();this._lastUpdate=e,this.log("loop",t,e),t!==e&&(this._state.forEachBetween(t,e,n=>{switch(n.state){case"started":const r=this._tickSource.getTicksAtTime(n.time);this.emit("start",n.time,r);break;case"stopped":n.time!==0&&this.emit("stop",n.time);break;case"paused":this.emit("pause",n.time);break}}),this._tickSource.forEachTickBetween(t,e,(n,r)=>{this.callback(n,r)}))}getStateAtTime(t){const e=this.toSeconds(t);return this._state.getValueAtTime(e)}dispose(){return super.dispose(),this.context.off("tick",this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}}Qe.mixin(In);class Fe extends U{constructor(){const t=L(Fe.getDefaults(),arguments,["volume"]);super(t),this.name="Volume",this.input=this.output=new mt({context:this.context,gain:t.volume,units:"decibels"}),this.volume=this.output.gain,it(this,"volume"),this._unmutedVolume=t.volume,this.mute=t.mute}static getDefaults(){return Object.assign(U.getDefaults(),{mute:!1,volume:0})}get mute(){return this.volume.value===-1/0}set mute(t){!this.mute&&t?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!t&&(this.volume.value=this._unmutedVolume)}dispose(){return super.dispose(),this.input.dispose(),this.volume.dispose(),this}}class xs extends U{constructor(){const t=L(xs.getDefaults(),arguments);super(t),this.name="Destination",this.input=new Fe({context:this.context}),this.output=new mt({context:this.context}),this.volume=this.input.volume,Kn(this.input,this.output,this.context.rawContext.destination),this.mute=t.mute,this._internalChannels=[this.input,this.context.rawContext.destination,this.output]}static getDefaults(){return Object.assign(U.getDefaults(),{mute:!1,volume:0})}get mute(){return this.input.mute}set mute(t){this.input.mute=t}chain(...t){return this.input.disconnect(),t.unshift(this.input),t.push(this.output),Kn(...t),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}}xn(s=>{s.destination=new xs({context:s})});Nn(s=>{s.destination.dispose()});class Xl extends U{constructor(){super(...arguments),this.name="Listener",this.positionX=new nt({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new nt({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new nt({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new nt({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new nt({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new nt({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new nt({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new nt({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new nt({context:this.context,param:this.context.rawContext.listener.upZ})}static getDefaults(){return Object.assign(U.getDefaults(),{positionX:0,positionY:0,positionZ:0,forwardX:0,forwardY:0,forwardZ:-1,upX:0,upY:1,upZ:0})}dispose(){return super.dispose(),this.positionX.dispose(),this.positionY.dispose(),this.positionZ.dispose(),this.forwardX.dispose(),this.forwardY.dispose(),this.forwardZ.dispose(),this.upX.dispose(),this.upY.dispose(),this.upZ.dispose(),this}}xn(s=>{s.listener=new Xl({context:s})});Nn(s=>{s.listener.dispose()});function Yl(s,t){return ot(this,arguments,void 0,function*(e,n,r=2,i=bt().sampleRate){const a=bt(),o=new On(r,n,i);vn(o),yield e(o);const c=o.render();vn(a);const u=yield c;return new Q(u)})}class Ns extends Xt{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;const t=L(Ns.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");this.baseUrl=t.baseUrl,Object.keys(t.urls).forEach(e=>{this._loadingCount++;const n=t.urls[e];this.add(e,n,this._bufferLoaded.bind(this,t.onload),t.onerror)})}static getDefaults(){return{baseUrl:"",onerror:X,onload:X,urls:{}}}has(t){return this._buffers.has(t.toString())}get(t){return B(this.has(t),`ToneAudioBuffers has no buffer named: ${t}`),this._buffers.get(t.toString())}_bufferLoaded(t){this._loadingCount--,this._loadingCount===0&&t&&t()}get loaded(){return Array.from(this._buffers).every(([t,e])=>e.loaded)}add(t,e,n=X,r=X){return $t(e)?(this.baseUrl&&e.trim().substring(0,11).toLowerCase()==="data:audio/"&&(this.baseUrl=""),this._buffers.set(t.toString(),new Q(this.baseUrl+e,n,r))):this._buffers.set(t.toString(),new Q(e,n,r)),this}dispose(){return super.dispose(),this._buffers.forEach(t=>t.dispose()),this._buffers.clear(),this}}class ye extends qe{constructor(){super(...arguments),this.name="Ticks",this.defaultUnits="i"}_now(){return this.context.transport.ticks}_beatsToUnits(t){return this._getPPQ()*t}_secondsToUnits(t){return Math.floor(t/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(t){return t}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}}class Hl extends Ct{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new Mt,this._boundDrawLoop=this._drawLoop.bind(this),this._animationFrame=-1}schedule(t,e){return this._events.add({callback:t,time:this.toSeconds(e)}),this._events.length===1&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop)),this}cancel(t){return this._events.cancel(this.toSeconds(t)),this}_drawLoop(){const t=this.context.currentTime;this._events.forEachBefore(t+this.anticipation,e=>{t-e.time<=this.expiration&&e.callback(),this._events.remove(e)}),this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}}xn(s=>{s.draw=new Hl({context:s})});Nn(s=>{s.draw.dispose()});class Ql extends Xt{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(t){B(z(t.time),"Events must have a time property"),B(z(t.duration),"Events must have a duration parameter"),t.time=t.time.valueOf();let e=new Jl(t.time,t.time+t.duration,t);for(this._root===null?this._root=e:this._root.insert(e),this._length++;e!==null;)e.updateHeight(),e.updateMax(),this._rebalance(e),e=e.parent;return this}remove(t){if(this._root!==null){const e=[];this._root.search(t.time,e);for(const n of e)if(n.event===t){this._removeNode(n),this._length--;break}}return this}get length(){return this._length}cancel(t){return this.forEachFrom(t,e=>this.remove(e)),this}_setRoot(t){this._root=t,this._root!==null&&(this._root.parent=null)}_replaceNodeInParent(t,e){t.parent!==null?(t.isLeftChild()?t.parent.left=e:t.parent.right=e,this._rebalance(t.parent)):this._setRoot(e)}_removeNode(t){if(t.left===null&&t.right===null)this._replaceNodeInParent(t,null);else if(t.right===null)this._replaceNodeInParent(t,t.left);else if(t.left===null)this._replaceNodeInParent(t,t.right);else{const e=t.getBalance();let n,r=null;if(e>0)if(t.left.right===null)n=t.left,n.right=t.right,r=n;else{for(n=t.left.right;n.right!==null;)n=n.right;n.parent&&(n.parent.right=n.left,r=n.parent,n.left=t.left,n.right=t.right)}else if(t.right.left===null)n=t.right,n.left=t.left,r=n;else{for(n=t.right.left;n.left!==null;)n=n.left;n.parent&&(n.parent.left=n.right,r=n.parent,n.left=t.left,n.right=t.right)}t.parent!==null?t.isLeftChild()?t.parent.left=n:t.parent.right=n:this._setRoot(n),r&&this._rebalance(r)}t.dispose()}_rotateLeft(t){const e=t.parent,n=t.isLeftChild(),r=t.right;r&&(t.right=r.left,r.left=t),e!==null?n?e.left=r:e.right=r:this._setRoot(r)}_rotateRight(t){const e=t.parent,n=t.isLeftChild(),r=t.left;r&&(t.left=r.right,r.right=t),e!==null?n?e.left=r:e.right=r:this._setRoot(r)}_rebalance(t){const e=t.getBalance();e>1&&t.left?t.left.getBalance()<0?this._rotateLeft(t.left):this._rotateRight(t):e<-1&&t.right&&(t.right.getBalance()>0?this._rotateRight(t.right):this._rotateLeft(t))}get(t){if(this._root!==null){const e=[];if(this._root.search(t,e),e.length>0){let n=e[0];for(let r=1;r<e.length;r++)e[r].low>n.low&&(n=e[r]);return n.event}}return null}forEach(t){if(this._root!==null){const e=[];this._root.traverse(n=>e.push(n)),e.forEach(n=>{n.event&&t(n.event)})}return this}forEachAtTime(t,e){if(this._root!==null){const n=[];this._root.search(t,n),n.forEach(r=>{r.event&&e(r.event)})}return this}forEachFrom(t,e){if(this._root!==null){const n=[];this._root.searchAfter(t,n),n.forEach(r=>{r.event&&e(r.event)})}return this}dispose(){return super.dispose(),this._root!==null&&this._root.traverse(t=>t.dispose()),this._root=null,this}}class Jl{constructor(t,e,n){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=n,this.low=t,this.high=e,this.max=this.high}insert(t){t.low<=this.low?this.left===null?this.left=t:this.left.insert(t):this.right===null?this.right=t:this.right.insert(t)}search(t,e){t>this.max||(this.left!==null&&this.left.search(t,e),this.low<=t&&this.high>t&&e.push(this),!(this.low>t)&&this.right!==null&&this.right.search(t,e))}searchAfter(t,e){this.low>=t&&(e.push(this),this.left!==null&&this.left.searchAfter(t,e)),this.right!==null&&this.right.searchAfter(t,e)}traverse(t){t(this),this.left!==null&&this.left.traverse(t),this.right!==null&&this.right.traverse(t)}updateHeight(){this.left!==null&&this.right!==null?this.height=Math.max(this.left.height,this.right.height)+1:this.right!==null?this.height=this.right.height+1:this.left!==null?this.height=this.left.height+1:this.height=0}updateMax(){this.max=this.high,this.left!==null&&(this.max=Math.max(this.max,this.left.max)),this.right!==null&&(this.max=Math.max(this.max,this.right.max))}getBalance(){let t=0;return this.left!==null&&this.right!==null?t=this.left.height-this.right.height:this.left!==null?t=this.left.height+1:this.right!==null&&(t=-(this.right.height+1)),t}isLeftChild(){return this.parent!==null&&this.parent.left===this}get left(){return this._left}set left(t){this._left=t,t!==null&&(t.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(t){this._right=t,t!==null&&(t.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}}class Kl extends Xt{constructor(t){super(),this.name="TimelineValue",this._timeline=new Mt({memory:10}),this._initialValue=t}set(t,e){return this._timeline.add({value:t,time:e}),this}get(t){const e=this._timeline.get(t);return e?e.value:this._initialValue}}class xe extends U{constructor(){super(L(xe.getDefaults(),arguments,["context"]))}connect(t,e=0,n=0){return Cs(this,t,e,n),this}}class Ke extends xe{constructor(){const t=L(Ke.getDefaults(),arguments,["mapping","length"]);super(t),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper,Pt(t.mapping)||t.mapping instanceof Float32Array?this.curve=Float32Array.from(t.mapping):bl(t.mapping)&&this.setMap(t.mapping,t.length)}static getDefaults(){return Object.assign(pt.getDefaults(),{length:1024})}setMap(t,e=1024){const n=new Float32Array(e);for(let r=0,i=e;r<i;r++){const a=r/(i-1)*2-1;n[r]=t(a,r)}return this.curve=n,this}get curve(){return this._shaper.curve}set curve(t){this._shaper.curve=t}get oversample(){return this._shaper.oversample}set oversample(t){const e=["none","2x","4x"].some(n=>n.includes(t));B(e,"oversampling must be either 'none', '2x', or '4x'"),this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.disconnect(),this}}class Os extends xe{constructor(){const t=L(Os.getDefaults(),arguments,["value"]);super(t),this.name="Pow",this._exponentScaler=this.input=this.output=new Ke({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(xe.getDefaults(),{value:1})}_expFunc(t){return e=>Math.pow(Math.abs(e),t)}get value(){return this._exponent}set value(t){this._exponent=t,this._exponentScaler.setMap(this._expFunc(this._exponent))}dispose(){return super.dispose(),this._exponentScaler.dispose(),this}}class ee{constructor(t,e){this.id=ee._eventId++,this._remainderTime=0;const n=Object.assign(ee.getDefaults(),e);this.transport=t,this.callback=n.callback,this._once=n.once,this.time=Math.floor(n.time),this._remainderTime=n.time-this.time}static getDefaults(){return{callback:X,once:!1,time:0}}get floatTime(){return this.time+this._remainderTime}invoke(t){if(this.callback){const e=this.transport.bpm.getDurationOfTicks(1,t);this.callback(t+this._remainderTime*e),this._once&&this.transport.clear(this.id)}}dispose(){return this.callback=void 0,this}}ee._eventId=0;class Es extends ee{constructor(t,e){super(t,e),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);const n=Object.assign(Es.getDefaults(),e);this.duration=n.duration,this._interval=n.interval,this._nextTick=n.time,this.transport.on("start",this._boundRestart),this.transport.on("loopStart",this._boundRestart),this.transport.on("ticks",this._boundRestart),this.context=this.transport.context,this._restart()}static getDefaults(){return Object.assign({},ee.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(t){this._createEvents(t),super.invoke(t)}_createEvent(){return gn(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new ye(this.context,this._nextTick).toSeconds()):-1}_createEvents(t){gn(this._nextTick+this._interval,this.floatTime+this.duration)&&(this._nextTick+=this._interval,this._currentId=this._nextId,this._nextId=this.transport.scheduleOnce(this.invoke.bind(this),new ye(this.context,this._nextTick).toSeconds()))}_restart(t){this.transport.clear(this._currentId),this.transport.clear(this._nextId),this._nextTick=this.floatTime;const e=this.transport.getTicksAtTime(t);Ae(e,this.time)&&(this._nextTick=this.floatTime+Math.ceil((e-this.floatTime)/this._interval)*this._interval),this._currentId=this._createEvent(),this._nextTick+=this._interval,this._nextId=this._createEvent()}dispose(){return super.dispose(),this.transport.clear(this._currentId),this.transport.clear(this._nextId),this.transport.off("start",this._boundRestart),this.transport.off("loopStart",this._boundRestart),this.transport.off("ticks",this._boundRestart),this}}class Mn extends Ct{constructor(){const t=L(Mn.getDefaults(),arguments);super(t),this.name="Transport",this._loop=new Kl(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Mt,this._repeatedEvents=new Ql,this._syncedSignals=[],this._swingAmount=0,this._ppq=t.ppq,this._clock=new In({callback:this._processTick.bind(this),context:this.context,frequency:0,units:"bpm"}),this._bindClockEvents(),this.bpm=this._clock.frequency,this._clock.frequency.multiplier=t.ppq,this.bpm.setValueAtTime(t.bpm,0),it(this,"bpm"),this._timeSignature=t.timeSignature,this._swingTicks=t.ppq/2}static getDefaults(){return Object.assign(Ct.getDefaults(),{bpm:120,loopEnd:"4m",loopStart:0,ppq:192,swing:0,swingSubdivision:"8n",timeSignature:4})}_processTick(t,e){if(this._loop.get(t)&&e>=this._loopEnd&&(this.emit("loopEnd",t),this._clock.setTicksAtTime(this._loopStart,t),e=this._loopStart,this.emit("loopStart",t,this._clock.getSecondsAtTime(t)),this.emit("loop",t)),this._swingAmount>0&&e%this._ppq!==0&&e%(this._swingTicks*2)!==0){const n=e%(this._swingTicks*2)/(this._swingTicks*2),r=Math.sin(n*Math.PI)*this._swingAmount;t+=new ye(this.context,this._swingTicks*2/3).toSeconds()*r}tr(!0),this._timeline.forEachAtTime(e,n=>n.invoke(t)),tr(!1)}schedule(t,e){const n=new ee(this,{callback:t,time:new qe(this.context,e).toTicks()});return this._addEvent(n,this._timeline)}scheduleRepeat(t,e,n,r=1/0){const i=new Es(this,{callback:t,duration:new Rt(this.context,r).toTicks(),interval:new Rt(this.context,e).toTicks(),time:new qe(this.context,n).toTicks()});return this._addEvent(i,this._repeatedEvents)}scheduleOnce(t,e){const n=new ee(this,{callback:t,once:!0,time:new qe(this.context,e).toTicks()});return this._addEvent(n,this._timeline)}clear(t){if(this._scheduledEvents.hasOwnProperty(t)){const e=this._scheduledEvents[t.toString()];e.timeline.remove(e.event),e.event.dispose(),delete this._scheduledEvents[t.toString()]}return this}_addEvent(t,e){return this._scheduledEvents[t.id.toString()]={event:t,timeline:e},e.add(t),t.id}cancel(t=0){const e=this.toTicks(t);return this._timeline.forEachFrom(e,n=>this.clear(n.id)),this._repeatedEvents.forEachFrom(e,n=>this.clear(n.id)),this}_bindClockEvents(){this._clock.on("start",(t,e)=>{e=new ye(this.context,e).toSeconds(),this.emit("start",t,e)}),this._clock.on("stop",t=>{this.emit("stop",t)}),this._clock.on("pause",t=>{this.emit("pause",t)})}get state(){return this._clock.getStateAtTime(this.now())}start(t,e){this.context.resume();let n;return z(e)&&(n=this.toTicks(e)),this._clock.start(t,n),this}stop(t){return this._clock.stop(t),this}pause(t){return this._clock.pause(t),this}toggle(t){return t=this.toSeconds(t),this._clock.getStateAtTime(t)!=="started"?this.start(t):this.stop(t),this}get timeSignature(){return this._timeSignature}set timeSignature(t){Pt(t)&&(t=t[0]/t[1]*4),this._timeSignature=t}get loopStart(){return new Rt(this.context,this._loopStart,"i").toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t)}get loopEnd(){return new Rt(this.context,this._loopEnd,"i").toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t)}get loop(){return this._loop.get(this.now())}set loop(t){this._loop.set(t,this.now())}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get swing(){return this._swingAmount}set swing(t){this._swingAmount=t}get swingSubdivision(){return new ye(this.context,this._swingTicks).toNotation()}set swingSubdivision(t){this._swingTicks=this.toTicks(t)}get position(){const t=this.now(),e=this._clock.getTicksAtTime(t);return new ye(this.context,e).toBarsBeatsSixteenths()}set position(t){const e=this.toTicks(t);this.ticks=e}get seconds(){return this._clock.seconds}set seconds(t){const e=this.now(),n=this._clock.frequency.timeToTicks(t,e);this.ticks=n}get progress(){if(this.loop){const t=this.now();return(this._clock.getTicksAtTime(t)-this._loopStart)/(this._loopEnd-this._loopStart)}else return 0}get ticks(){return this._clock.ticks}set ticks(t){if(this._clock.ticks!==t){const e=this.now();if(this.state==="started"){const n=this._clock.getTicksAtTime(e),r=this._clock.frequency.getDurationOfTicks(Math.ceil(n)-n,e),i=e+r;this.emit("stop",i),this._clock.setTicksAtTime(t,i),this.emit("start",i,this._clock.getSecondsAtTime(i))}else this.emit("ticks",e),this._clock.setTicksAtTime(t,e)}}getTicksAtTime(t){return this._clock.getTicksAtTime(t)}getSecondsAtTime(t){return this._clock.getSecondsAtTime(t)}get PPQ(){return this._clock.frequency.multiplier}set PPQ(t){this._clock.frequency.multiplier=t}nextSubdivision(t){if(t=this.toTicks(t),this.state!=="started")return 0;{const e=this.now(),n=this.getTicksAtTime(e),r=t-n%t;return this._clock.nextTickTime(r,e)}}syncSignal(t,e){const n=this.now();let r=this.bpm,i=1/(60/r.getValueAtTime(n)/this.PPQ),a=[];if(t.units==="time"){const c=.015625/i,u=new mt(c),l=new Os(-1),h=new mt(c);r.chain(u,l,h),r=h,i=1/i,a=[u,l,h]}e||(t.getValueAtTime(n)!==0?e=t.getValueAtTime(n)/i:e=0);const o=new mt(e);return r.connect(o),o.connect(t._param),a.push(o),this._syncedSignals.push({initial:t.value,nodes:a,signal:t}),t.value=0,this}unsyncSignal(t){for(let e=this._syncedSignals.length-1;e>=0;e--){const n=this._syncedSignals[e];n.signal===t&&(n.nodes.forEach(r=>r.dispose()),n.signal.value=n.initial,this._syncedSignals.splice(e,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),si(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}}Qe.mixin(Mn);xn(s=>{s.transport=new Mn({context:s})});Nn(s=>{s.transport.dispose()});class Nt extends U{constructor(t){super(t),this.input=void 0,this._state=new ws("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=X,this._syncedStop=X,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new Fe({context:this.context,mute:t.mute,volume:t.volume}),this.volume=this._volume.volume,it(this,"volume"),this.onstop=t.onstop}static getDefaults(){return Object.assign(U.getDefaults(),{mute:!1,onstop:X,volume:0})}get state(){return this._synced?this.context.transport.state==="started"?this._state.getValueAtTime(this.context.transport.seconds):"stopped":this._state.getValueAtTime(this.now())}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}_clampToCurrentTime(t){return this._synced?t:Math.max(t,this.context.currentTime)}start(t,e,n){let r=It(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(r=this._clampToCurrentTime(r),!this._synced&&this._state.getValueAtTime(r)==="started")B(Ae(r,this._state.get(r).time),"Start time must be strictly greater than previous start time"),this._state.cancel(r),this._state.setStateAtTime("started",r),this.log("restart",r),this.restart(r,e,n);else if(this.log("start",r),this._state.setStateAtTime("started",r),this._synced){const i=this._state.get(r);i&&(i.offset=this.toSeconds(be(e,0)),i.duration=n?this.toSeconds(n):void 0);const a=this.context.transport.schedule(o=>{this._start(o,e,n)},r);this._scheduled.push(a),this.context.transport.state==="started"&&this.context.transport.getSecondsAtTime(this.immediate())>r&&this._syncedStart(this.now(),this.context.transport.seconds)}else Qr(this.context),this._start(r,e,n);return this}stop(t){let e=It(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(e=this._clampToCurrentTime(e),this._state.getValueAtTime(e)==="started"||z(this._state.getNextState("started",e))){if(this.log("stop",e),!this._synced)this._stop(e);else{const n=this.context.transport.schedule(this._stop.bind(this),e);this._scheduled.push(n)}this._state.cancel(e),this._state.setStateAtTime("stopped",e)}return this}restart(t,e,n){return t=this.toSeconds(t),this._state.getValueAtTime(t)==="started"&&(this._state.cancel(t),this._restart(t,e,n)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(t,e)=>{if(Ae(e,0)){const n=this._state.get(e);if(n&&n.state==="started"&&n.time!==e){const r=e-this.toSeconds(n.time);let i;n.duration&&(i=this.toSeconds(n.duration)-r),this._start(t,this.toSeconds(n.offset)+r,i)}}},this._syncedStop=t=>{const e=this.context.transport.getSecondsAtTime(Math.max(t-this.sampleTime,0));this._state.getValueAtTime(e)==="started"&&this._stop(t)},this.context.transport.on("start",this._syncedStart),this.context.transport.on("loopStart",this._syncedStart),this.context.transport.on("stop",this._syncedStop),this.context.transport.on("pause",this._syncedStop),this.context.transport.on("loopEnd",this._syncedStop)),this}unsync(){return this._synced&&(this.context.transport.off("stop",this._syncedStop),this.context.transport.off("pause",this._syncedStop),this.context.transport.off("loopEnd",this._syncedStop),this.context.transport.off("start",this._syncedStart),this.context.transport.off("loopStart",this._syncedStart)),this._synced=!1,this._scheduled.forEach(t=>this.context.transport.clear(t)),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=X,this.unsync(),this._volume.dispose(),this._state.dispose(),this}}class Dn extends ke{constructor(){const t=L(Dn.getDefaults(),arguments,["url","onload"]);super(t),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,Ve(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new nt({context:this.context,param:this._source.playbackRate,units:"positive",value:t.playbackRate}),this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this._buffer=new Q(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(ke.getDefaults(),{url:new Q,loop:!1,loopEnd:0,loopStart:0,onload:X,onerror:X,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t}get curve(){return this._curve}set curve(t){this._curve=t}start(t,e,n,r=1){B(this.buffer.loaded,"buffer is either not set or not loaded");const i=this.toSeconds(t);this._startGain(i,r),this.loop?e=be(e,this.loopStart):e=be(e,0);let a=Math.max(this.toSeconds(e),0);if(this.loop){const o=this.toSeconds(this.loopEnd)||this.buffer.duration,c=this.toSeconds(this.loopStart),u=o-c;Qn(a,o)&&(a=(a-c)%u+c),Dt(a,this.buffer.duration)&&(a=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,gn(a,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(i,a)),z(n)){let o=this.toSeconds(n);o=Math.max(o,0),this.stop(i+o)}return this}_stopSource(t){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(t)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(t){this._source.loopStart=this.toSeconds(t)}get loopEnd(){return this._source.loopEnd}set loopEnd(t){this._source.loopEnd=this.toSeconds(t)}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._source.loop}set loop(t){this._source.loop=t,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}}function fe(s,t){return ot(this,void 0,void 0,function*(){const e=t/s.context.sampleRate,n=new On(1,e,s.context.sampleRate);return new s.constructor(Object.assign(s.get(),{frequency:2/e,detune:0,context:n})).toDestination().start(0),(yield n.render()).getChannelData(0)})}class Is extends ke{constructor(){const t=L(Is.getDefaults(),arguments,["frequency","type"]);super(t),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],Ve(this._oscillator,this._gainNode),this.type=t.type,this.frequency=new nt({context:this.context,param:this._oscillator.frequency,units:"frequency",value:t.frequency}),this.detune=new nt({context:this.context,param:this._oscillator.detune,units:"cents",value:t.detune}),it(this,["frequency","detune"])}static getDefaults(){return Object.assign(ke.getDefaults(),{detune:0,frequency:440,type:"sine"})}start(t){const e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._oscillator.start(e),this}_stopSource(t){this._oscillator.stop(t)}setPeriodicWave(t){return this._oscillator.setPeriodicWave(t),this}get type(){return this._oscillator.type}set type(t){this._oscillator.type=t}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this}}class ut extends Nt{constructor(){const t=L(ut.getDefaults(),arguments,["frequency","type"]);super(t),this.name="Oscillator",this._oscillator=null,this.frequency=new pt({context:this.context,units:"frequency",value:t.frequency}),it(this,"frequency"),this.detune=new pt({context:this.context,units:"cents",value:t.detune}),it(this,"detune"),this._partials=t.partials,this._partialCount=t.partialCount,this._type=t.type,t.partialCount&&t.type!=="custom"&&(this._type=this.baseType+t.partialCount.toString()),this.phase=t.phase}static getDefaults(){return Object.assign(Nt.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(t){const e=this.toSeconds(t),n=new Is({context:this.context,onended:()=>this.onstop(this)});this._oscillator=n,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(e)}_stop(t){const e=this.toSeconds(t);this._oscillator&&this._oscillator.stop(e)}_restart(t){const e=this.toSeconds(t);return this.log("restart",e),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(e),this}syncFrequency(){return this.context.transport.syncSignal(this.frequency),this}unsyncFrequency(){return this.context.transport.unsyncSignal(this.frequency),this}_getCachedPeriodicWave(){if(this._type==="custom")return ut._periodicWaveCache.find(e=>e.phase===this._phase&&Dl(e.partials,this._partials));{const t=ut._periodicWaveCache.find(e=>e.type===this._type&&e.phase===this._phase);return this._partialCount=t?t.partialCount:this._partialCount,t}}get type(){return this._type}set type(t){this._type=t;const e=["sine","square","sawtooth","triangle"].indexOf(t)!==-1;if(this._phase===0&&e)this._wave=void 0,this._partialCount=0,this._oscillator!==null&&(this._oscillator.type=t);else{const n=this._getCachedPeriodicWave();if(z(n)){const{partials:r,wave:i}=n;this._wave=i,this._partials=r,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave)}else{const[r,i]=this._getRealImaginary(t,this._phase),a=this.context.createPeriodicWave(r,i);this._wave=a,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave),ut._periodicWaveCache.push({imag:i,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:r,type:this._type,wave:this._wave}),ut._periodicWaveCache.length>100&&ut._periodicWaveCache.shift()}}}get baseType(){return this._type.replace(this.partialCount.toString(),"")}set baseType(t){this.partialCount&&this._type!=="custom"&&t!=="custom"?this.type=t+this.partialCount:this.type=t}get partialCount(){return this._partialCount}set partialCount(t){te(t,0);let e=this._type;const n=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(n&&(e=n[1]),this._type!=="custom")t===0?this.type=e:this.type=e+t.toString();else{const r=new Float32Array(t);this._partials.forEach((i,a)=>r[a]=i),this._partials=Array.from(r),this.type=this._type}}_getRealImaginary(t,e){let r=2048;const i=new Float32Array(r),a=new Float32Array(r);let o=1;if(t==="custom"){if(o=this._partials.length+1,this._partialCount=this._partials.length,r=o,this._partials.length===0)return[i,a]}else{const c=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(t);c?(o=parseInt(c[2],10)+1,this._partialCount=parseInt(c[2],10),t=c[1],o=Math.max(o,2),r=o):this._partialCount=0,this._partials=[]}for(let c=1;c<r;++c){const u=2/(c*Math.PI);let l;switch(t){case"sine":l=c<=o?1:0,this._partials[c-1]=l;break;case"square":l=c&1?2*u:0,this._partials[c-1]=l;break;case"sawtooth":l=u*(c&1?1:-1),this._partials[c-1]=l;break;case"triangle":c&1?l=2*(u*u)*(c-1>>1&1?-1:1):l=0,this._partials[c-1]=l;break;case"custom":l=this._partials[c-1];break;default:throw new TypeError("Oscillator: invalid type: "+t)}l!==0?(i[c]=-l*Math.sin(e*c),a[c]=l*Math.cos(e*c)):(i[c]=0,a[c]=0)}return[i,a]}_inverseFFT(t,e,n){let r=0;const i=t.length;for(let a=0;a<i;a++)r+=t[a]*Math.cos(a*n)+e[a]*Math.sin(a*n);return r}getInitialValue(){const[t,e]=this._getRealImaginary(this._type,0);let n=0;const r=Math.PI*2,i=32;for(let a=0;a<i;a++)n=Math.max(this._inverseFFT(t,e,a/i*r),n);return Pl(-this._inverseFFT(t,e,this._phase)/n,-1,1)}get partials(){return this._partials.slice(0,this.partialCount)}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this.type="custom")}get phase(){return this._phase*(180/Math.PI)}set phase(t){this._phase=t*Math.PI/180,this.type=this._type}asArray(){return ot(this,arguments,void 0,function*(t=1024){return fe(this,t)})}dispose(){return super.dispose(),this._oscillator!==null&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}}ut._periodicWaveCache=[];class th extends xe{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new Ke({context:this.context,mapping:t=>(t+1)/2}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}}class Ne extends pt{constructor(){const t=L(Ne.getDefaults(),arguments,["value"]);super(t),this.name="Multiply",this.override=!1,this._mult=this.input=this.output=new mt({context:this.context,minValue:t.minValue,maxValue:t.maxValue}),this.factor=this._param=this._mult.gain,this.factor.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(pt.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}}class Rn extends Nt{constructor(){const t=L(Rn.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="AMOscillator",this._modulationScale=new th({context:this.context}),this._modulationNode=new mt({context:this.context}),this._carrier=new ut({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.frequency=this._carrier.frequency,this.detune=this._carrier.detune,this._modulator=new ut({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Ne({context:this.context,units:"positive",value:t.harmonicity}),this.frequency.chain(this.harmonicity,this._modulator.frequency),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),it(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(ut.getDefaults(),{harmonicity:1,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){this._modulator.restart(t),this._carrier.restart(t)}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(){return ot(this,arguments,void 0,function*(t=1024){return fe(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this._modulationScale.dispose(),this}}class Pn extends Nt{constructor(){const t=L(Pn.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="FMOscillator",this._modulationNode=new mt({context:this.context,gain:0}),this._carrier=new ut({context:this.context,detune:t.detune,frequency:0,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.detune=this._carrier.detune,this.frequency=new pt({context:this.context,units:"frequency",value:t.frequency}),this._modulator=new ut({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Ne({context:this.context,units:"positive",value:t.harmonicity}),this.modulationIndex=new Ne({context:this.context,units:"positive",value:t.modulationIndex}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output),this.detune.connect(this._modulator.detune),it(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(ut.getDefaults(),{harmonicity:1,modulationIndex:2,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){return this._modulator.restart(t),this._carrier.restart(t),this}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(){return ot(this,arguments,void 0,function*(t=1024){return fe(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this.modulationIndex.dispose(),this}}class tn extends Nt{constructor(){const t=L(tn.getDefaults(),arguments,["frequency","width"]);super(t),this.name="PulseOscillator",this._widthGate=new mt({context:this.context,gain:0}),this._thresh=new Ke({context:this.context,mapping:e=>e<=0?-1:1}),this.width=new pt({context:this.context,units:"audioRange",value:t.width}),this._triangle=new ut({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase,type:"triangle"}),this.frequency=this._triangle.frequency,this.detune=this._triangle.detune,this._triangle.chain(this._thresh,this.output),this.width.chain(this._widthGate,this._thresh),it(this,["width","frequency","detune"])}static getDefaults(){return Object.assign(Nt.getDefaults(),{detune:0,frequency:440,phase:0,type:"pulse",width:.2})}_start(t){t=this.toSeconds(t),this._triangle.start(t),this._widthGate.gain.setValueAtTime(1,t)}_stop(t){t=this.toSeconds(t),this._triangle.stop(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(0,t)}_restart(t){this._triangle.restart(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(1,t)}get phase(){return this._triangle.phase}set phase(t){this._triangle.phase=t}get type(){return"pulse"}get baseType(){return"pulse"}get partials(){return[]}get partialCount(){return 0}set carrierType(t){this._triangle.type=t}asArray(){return ot(this,arguments,void 0,function*(t=1024){return fe(this,t)})}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}}class Vn extends Nt{constructor(){const t=L(Vn.getDefaults(),arguments,["frequency","type","spread"]);super(t),this.name="FatOscillator",this._oscillators=[],this.frequency=new pt({context:this.context,units:"frequency",value:t.frequency}),this.detune=new pt({context:this.context,units:"cents",value:t.detune}),this._spread=t.spread,this._type=t.type,this._phase=t.phase,this._partials=t.partials,this._partialCount=t.partialCount,this.count=t.count,it(this,["frequency","detune"])}static getDefaults(){return Object.assign(ut.getDefaults(),{count:3,spread:20,type:"sawtooth"})}_start(t){t=this.toSeconds(t),this._forEach(e=>e.start(t))}_stop(t){t=this.toSeconds(t),this._forEach(e=>e.stop(t))}_restart(t){this._forEach(e=>e.restart(t))}_forEach(t){for(let e=0;e<this._oscillators.length;e++)t(this._oscillators[e],e)}get type(){return this._type}set type(t){this._type=t,this._forEach(e=>e.type=t)}get spread(){return this._spread}set spread(t){if(this._spread=t,this._oscillators.length>1){const e=-t/2,n=t/(this._oscillators.length-1);this._forEach((r,i)=>r.detune.value=e+n*i)}}get count(){return this._oscillators.length}set count(t){if(te(t,1),this._oscillators.length!==t){this._forEach(e=>e.dispose()),this._oscillators=[];for(let e=0;e<t;e++){const n=new ut({context:this.context,volume:-6-t*1.1,type:this._type,phase:this._phase+e/t*360,partialCount:this._partialCount,onstop:e===0?()=>this.onstop(this):X});this.type==="custom"&&(n.partials=this._partials),this.frequency.connect(n.frequency),this.detune.connect(n.detune),n.detune.overridden=!1,n.connect(this.output),this._oscillators[e]=n}this.spread=this._spread,this.state==="started"&&this._forEach(e=>e.start())}}get phase(){return this._phase}set phase(t){this._phase=t,this._forEach((e,n)=>e.phase=this._phase+n/this.count*360)}get baseType(){return this._oscillators[0].baseType}set baseType(t){this._forEach(e=>e.baseType=t),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this._type="custom",this._forEach(e=>e.partials=t))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(t){this._partialCount=t,this._forEach(e=>e.partialCount=t),this._type=this._oscillators[0].type}asArray(){return ot(this,arguments,void 0,function*(t=1024){return fe(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach(t=>t.dispose()),this}}class Fn extends Nt{constructor(){const t=L(Fn.getDefaults(),arguments,["frequency","modulationFrequency"]);super(t),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new Ne({context:this.context,value:2}),this._pulse=new tn({context:this.context,frequency:t.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new ut({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase}),this.frequency=this._modulator.frequency,this.detune=this._modulator.detune,this._modulator.chain(this._scale,this._pulse.width),this._pulse.connect(this.output),it(this,["modulationFrequency","frequency","detune"])}static getDefaults(){return Object.assign(Nt.getDefaults(),{detune:0,frequency:440,modulationFrequency:.4,phase:0,type:"pwm"})}_start(t){t=this.toSeconds(t),this._modulator.start(t),this._pulse.start(t)}_stop(t){t=this.toSeconds(t),this._modulator.stop(t),this._pulse.stop(t)}_restart(t){this._modulator.restart(t),this._pulse.restart(t)}get type(){return"pwm"}get baseType(){return"pwm"}get partials(){return[]}get partialCount(){return 0}get phase(){return this._modulator.phase}set phase(t){this._modulator.phase=t}asArray(){return ot(this,arguments,void 0,function*(t=1024){return fe(this,t)})}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}}const nr={am:Rn,fat:Vn,fm:Pn,oscillator:ut,pulse:tn,pwm:Fn};class yn extends Nt{constructor(){const t=L(yn.getDefaults(),arguments,["frequency","type"]);super(t),this.name="OmniOscillator",this.frequency=new pt({context:this.context,units:"frequency",value:t.frequency}),this.detune=new pt({context:this.context,units:"cents",value:t.detune}),it(this,["frequency","detune"]),this.set(t)}static getDefaults(){return Object.assign(ut.getDefaults(),Pn.getDefaults(),Rn.getDefaults(),Vn.getDefaults(),tn.getDefaults(),Fn.getDefaults())}_start(t){this._oscillator.start(t)}_stop(t){this._oscillator.stop(t)}_restart(t){return this._oscillator.restart(t),this}get type(){let t="";return["am","fm","fat"].some(e=>this._sourceType===e)&&(t=this._sourceType),t+this._oscillator.type}set type(t){t.substr(0,2)==="fm"?(this._createNewOscillator("fm"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):t.substr(0,2)==="am"?(this._createNewOscillator("am"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):t.substr(0,3)==="fat"?(this._createNewOscillator("fat"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(3)):t==="pwm"?(this._createNewOscillator("pwm"),this._oscillator=this._oscillator):t==="pulse"?this._createNewOscillator("pulse"):(this._createNewOscillator("oscillator"),this._oscillator=this._oscillator,this._oscillator.type=t)}get partials(){return this._oscillator.partials}set partials(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partials=t)}get partialCount(){return this._oscillator.partialCount}set partialCount(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partialCount=t)}set(t){return Reflect.has(t,"type")&&t.type&&(this.type=t.type),super.set(t),this}_createNewOscillator(t){if(t!==this._sourceType){this._sourceType=t;const e=nr[t],n=this.now();if(this._oscillator){const r=this._oscillator;r.stop(n),this.context.setTimeout(()=>r.dispose(),this.blockTime)}this._oscillator=new e({context:this.context}),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this._oscillator.onstop=()=>this.onstop(this),this.state==="started"&&this._oscillator.start(n)}}get phase(){return this._oscillator.phase}set phase(t){this._oscillator.phase=t}get sourceType(){return this._sourceType}set sourceType(t){let e="sine";this._oscillator.type!=="pwm"&&this._oscillator.type!=="pulse"&&(e=this._oscillator.type),t==="fm"?this.type="fm"+e:t==="am"?this.type="am"+e:t==="fat"?this.type="fat"+e:t==="oscillator"?this.type=e:t==="pulse"?this.type="pulse":t==="pwm"&&(this.type="pwm")}_getOscType(t,e){return t instanceof nr[e]}get baseType(){return this._oscillator.baseType}set baseType(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&t!=="pulse"&&t!=="pwm"&&(this._oscillator.baseType=t)}get width(){if(this._getOscType(this._oscillator,"pulse"))return this._oscillator.width}get count(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.count}set count(t){this._getOscType(this._oscillator,"fat")&&le(t)&&(this._oscillator.count=t)}get spread(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.spread}set spread(t){this._getOscType(this._oscillator,"fat")&&le(t)&&(this._oscillator.spread=t)}get modulationType(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.modulationType}set modulationType(t){(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))&&$t(t)&&(this._oscillator.modulationType=t)}get modulationIndex(){if(this._getOscType(this._oscillator,"fm"))return this._oscillator.modulationIndex}get harmonicity(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.harmonicity}get modulationFrequency(){if(this._getOscType(this._oscillator,"pwm"))return this._oscillator.modulationFrequency}asArray(){return ot(this,arguments,void 0,function*(t=1024){return fe(this,t)})}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}}function ai(s,t=1/0){const e=new WeakMap;return function(n,r){Reflect.defineProperty(n,r,{configurable:!0,enumerable:!0,get:function(){return e.get(this)},set:function(i){te(i,s,t),e.set(this,i)}})}}function Yt(s,t=1/0){const e=new WeakMap;return function(n,r){Reflect.defineProperty(n,r,{configurable:!0,enumerable:!0,get:function(){return e.get(this)},set:function(i){te(this.toSeconds(i),s,t),e.set(this,i)}})}}class Wn extends Nt{constructor(){const t=L(Wn.getDefaults(),arguments,["url","onload"]);super(t),this.name="Player",this._activeSources=new Set,this._buffer=new Q({onload:this._onload.bind(this,t.onload),onerror:t.onerror,reverse:t.reverse,url:t.url}),this.autostart=t.autostart,this._loop=t.loop,this._loopStart=t.loopStart,this._loopEnd=t.loopEnd,this._playbackRate=t.playbackRate,this.fadeIn=t.fadeIn,this.fadeOut=t.fadeOut}static getDefaults(){return Object.assign(Nt.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:X,onerror:X,playbackRate:1,reverse:!1})}load(t){return ot(this,void 0,void 0,function*(){return yield this._buffer.load(t),this._onload(),this})}_onload(t=X){t(),this.autostart&&this.start()}_onSourceEnd(t){this.onstop(this),this._activeSources.delete(t),this._activeSources.size===0&&!this._synced&&this._state.getValueAtTime(this.now())==="started"&&(this._state.cancel(this.now()),this._state.setStateAtTime("stopped",this.now()))}start(t,e,n){return super.start(t,e,n),this}_start(t,e,n){this._loop?e=be(e,this._loopStart):e=be(e,0);const r=this.toSeconds(e),i=n;n=be(n,Math.max(this._buffer.duration-r,0));let a=this.toSeconds(n);a=a/this._playbackRate,t=this.toSeconds(t);const o=new Dn({url:this._buffer,context:this.context,fadeIn:this.fadeIn,fadeOut:this.fadeOut,loop:this._loop,loopEnd:this._loopEnd,loopStart:this._loopStart,onended:this._onSourceEnd.bind(this),playbackRate:this._playbackRate}).connect(this.output);!this._loop&&!this._synced&&(this._state.cancel(t+a),this._state.setStateAtTime("stopped",t+a,{implicitEnd:!0})),this._activeSources.add(o),this._loop&&It(i)?o.start(t,r):o.start(t,r,a-this.toSeconds(this.fadeOut))}_stop(t){const e=this.toSeconds(t);this._activeSources.forEach(n=>n.stop(e))}restart(t,e,n){return super.restart(t,e,n),this}_restart(t,e,n){var r;(r=[...this._activeSources].pop())===null||r===void 0||r.stop(t),this._start(t,e,n)}seek(t,e){const n=this.toSeconds(e);if(this._state.getValueAtTime(n)==="started"){const r=this.toSeconds(t);this._stop(n),this._start(n,r)}return this}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this.buffer.loaded&&te(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach(e=>{e.loopStart=t})}get loopEnd(){return this._loopEnd}set loopEnd(t){this._loopEnd=t,this.buffer.loaded&&te(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach(e=>{e.loopEnd=t})}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._loop}set loop(t){if(this._loop!==t&&(this._loop=t,this._activeSources.forEach(e=>{e.loop=t}),t)){const e=this._state.getNextState("stopped",this.now());e&&this._state.cancel(e.time)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t;const e=this.now(),n=this._state.getNextState("stopped",e);n&&n.implicitEnd&&(this._state.cancel(n.time),this._activeSources.forEach(r=>r.cancelStop())),this._activeSources.forEach(r=>{r.playbackRate.setValueAtTime(t,e)})}get reverse(){return this._buffer.reverse}set reverse(t){this._buffer.reverse=t}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach(t=>t.dispose()),this._activeSources.clear(),this._buffer.dispose(),this}}qt([Yt(0)],Wn.prototype,"fadeIn",void 0);qt([Yt(0)],Wn.prototype,"fadeOut",void 0);class re extends U{constructor(){const t=L(re.getDefaults(),arguments,["attack","decay","sustain","release"]);super(t),this.name="Envelope",this._sig=new pt({context:this.context,value:0}),this.output=this._sig,this.input=void 0,this.attack=t.attack,this.decay=t.decay,this.sustain=t.sustain,this.release=t.release,this.attackCurve=t.attackCurve,this.releaseCurve=t.releaseCurve,this.decayCurve=t.decayCurve}static getDefaults(){return Object.assign(U.getDefaults(),{attack:.01,attackCurve:"linear",decay:.1,decayCurve:"exponential",release:1,releaseCurve:"exponential",sustain:.5})}get value(){return this.getValueAtTime(this.now())}_getCurve(t,e){if($t(t))return t;{let n;for(n in rn)if(rn[n][e]===t)return n;return t}}_setCurve(t,e,n){if($t(n)&&Reflect.has(rn,n)){const r=rn[n];ce(r)?t!=="_decayCurve"&&(this[t]=r[e]):this[t]=r}else if(Pt(n)&&t!=="_decayCurve")this[t]=n;else throw new Error("Envelope: invalid curve: "+n)}get attackCurve(){return this._getCurve(this._attackCurve,"In")}set attackCurve(t){this._setCurve("_attackCurve","In",t)}get releaseCurve(){return this._getCurve(this._releaseCurve,"Out")}set releaseCurve(t){this._setCurve("_releaseCurve","Out",t)}get decayCurve(){return this._getCurve(this._decayCurve,"Out")}set decayCurve(t){this._setCurve("_decayCurve","Out",t)}triggerAttack(t,e=1){this.log("triggerAttack",t,e),t=this.toSeconds(t);let r=this.toSeconds(this.attack);const i=this.toSeconds(this.decay),a=this.getValueAtTime(t);if(a>0){const o=1/r;r=(1-a)/o}if(r<this.sampleTime)this._sig.cancelScheduledValues(t),this._sig.setValueAtTime(e,t);else if(this._attackCurve==="linear")this._sig.linearRampTo(e,r,t);else if(this._attackCurve==="exponential")this._sig.targetRampTo(e,r,t);else{this._sig.cancelAndHoldAtTime(t);let o=this._attackCurve;for(let c=1;c<o.length;c++)if(o[c-1]<=a&&a<=o[c]){o=this._attackCurve.slice(c),o[0]=a;break}this._sig.setValueCurveAtTime(o,t,r,e)}if(i&&this.sustain<1){const o=e*this.sustain,c=t+r;this.log("decay",c),this._decayCurve==="linear"?this._sig.linearRampToValueAtTime(o,i+c):this._sig.exponentialApproachValueAtTime(o,c,i)}return this}triggerRelease(t){this.log("triggerRelease",t),t=this.toSeconds(t);const e=this.getValueAtTime(t);if(e>0){const n=this.toSeconds(this.release);n<this.sampleTime?this._sig.setValueAtTime(0,t):this._releaseCurve==="linear"?this._sig.linearRampTo(0,n,t):this._releaseCurve==="exponential"?this._sig.targetRampTo(0,n,t):(B(Pt(this._releaseCurve),"releaseCurve must be either 'linear', 'exponential' or an array"),this._sig.cancelAndHoldAtTime(t),this._sig.setValueCurveAtTime(this._releaseCurve,t,n,e))}return this}getValueAtTime(t){return this._sig.getValueAtTime(t)}triggerAttackRelease(t,e,n=1){return e=this.toSeconds(e),this.triggerAttack(e,n),this.triggerRelease(e+this.toSeconds(t)),this}cancel(t){return this._sig.cancelScheduledValues(this.toSeconds(t)),this}connect(t,e=0,n=0){return Cs(this,t,e,n),this}asArray(){return ot(this,arguments,void 0,function*(t=1024){const e=t/this.context.sampleRate,n=new On(1,e,this.context.sampleRate),r=this.toSeconds(this.attack)+this.toSeconds(this.decay),i=r+this.toSeconds(this.release),a=i*.1,o=i+a,c=new this.constructor(Object.assign(this.get(),{attack:e*this.toSeconds(this.attack)/o,decay:e*this.toSeconds(this.decay)/o,release:e*this.toSeconds(this.release)/o,context:n}));return c._sig.toDestination(),c.triggerAttackRelease(e*(r+a)/o,0),(yield n.render()).getChannelData(0)})}dispose(){return super.dispose(),this._sig.dispose(),this}}qt([Yt(0)],re.prototype,"attack",void 0);qt([Yt(0)],re.prototype,"decay",void 0);qt([ai(0,1)],re.prototype,"sustain",void 0);qt([Yt(0)],re.prototype,"release",void 0);const rn=(()=>{let t,e;const n=[];for(t=0;t<128;t++)n[t]=Math.sin(t/127*(Math.PI/2));const r=[],i=6.4;for(t=0;t<127;t++){e=t/127;const p=Math.sin(e*(Math.PI*2)*i-Math.PI/2)+1;r[t]=p/10+e*.83}r[127]=1;const a=[],o=5;for(t=0;t<128;t++)a[t]=Math.ceil(t/127*o)/o;const c=[];for(t=0;t<128;t++)e=t/127,c[t]=.5*(1-Math.cos(Math.PI*e));const u=[];for(t=0;t<128;t++){e=t/127;const p=Math.pow(e,3)*4+.2,f=Math.cos(p*Math.PI*2*e);u[t]=Math.abs(f*(1-e))}function l(p){const f=new Array(p.length);for(let d=0;d<p.length;d++)f[d]=1-p[d];return f}function h(p){return p.slice(0).reverse()}return{bounce:{In:l(u),Out:u},cosine:{In:n,Out:h(n)},exponential:"exponential",linear:"linear",ripple:{In:r,Out:l(r)},sine:{In:c,Out:l(c)},step:{In:a,Out:l(a)}}})();class Oe extends U{constructor(){const t=L(Oe.getDefaults(),arguments);super(t),this._scheduledEvents=[],this._synced=!1,this._original_triggerAttack=this.triggerAttack,this._original_triggerRelease=this.triggerRelease,this._syncedRelease=e=>this._original_triggerRelease(e),this._volume=this.output=new Fe({context:this.context,volume:t.volume}),this.volume=this._volume.volume,it(this,"volume")}static getDefaults(){return Object.assign(U.getDefaults(),{volume:0})}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",0),this.context.transport.on("stop",this._syncedRelease),this.context.transport.on("pause",this._syncedRelease),this.context.transport.on("loopEnd",this._syncedRelease)),this}_syncState(){let t=!1;return this._synced||(this._synced=!0,t=!0),t}_syncMethod(t,e){const n=this["_original_"+t]=this[t];this[t]=(...r)=>{const i=r[e],a=this.context.transport.schedule(o=>{r[e]=o,n.apply(this,r)},i);this._scheduledEvents.push(a)}}unsync(){return this._scheduledEvents.forEach(t=>this.context.transport.clear(t)),this._scheduledEvents=[],this._synced&&(this._synced=!1,this.triggerAttack=this._original_triggerAttack,this.triggerRelease=this._original_triggerRelease,this.context.transport.off("stop",this._syncedRelease),this.context.transport.off("pause",this._syncedRelease),this.context.transport.off("loopEnd",this._syncedRelease)),this}triggerAttackRelease(t,e,n,r){const i=this.toSeconds(n),a=this.toSeconds(e);return this.triggerAttack(t,i,r),this.triggerRelease(i+a),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}}class Ee extends Oe{constructor(){const t=L(Ee.getDefaults(),arguments);super(t),this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(Oe.getDefaults(),{detune:0,onsilence:X,portamento:0})}triggerAttack(t,e,n=1){this.log("triggerAttack",t,e,n);const r=this.toSeconds(e);return this._triggerEnvelopeAttack(r,n),this.setNote(t,r),this}triggerRelease(t){this.log("triggerRelease",t);const e=this.toSeconds(t);return this._triggerEnvelopeRelease(e),this}setNote(t,e){const n=this.toSeconds(e),r=t instanceof Et?t.toFrequency():t;if(this.portamento>0&&this.getLevelAtTime(n)>.05){const i=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(r,i,n)}else this.frequency.setValueAtTime(r,n);return this}}qt([Yt(0)],Ee.prototype,"portamento",void 0);class Ms extends re{constructor(){super(L(Ms.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="AmplitudeEnvelope",this._gainNode=new mt({context:this.context,gain:0}),this.output=this._gainNode,this.input=this._gainNode,this._sig.connect(this._gainNode.gain),this.output=this._gainNode,this.input=this._gainNode}dispose(){return super.dispose(),this._gainNode.dispose(),this}}class Tn extends Ee{constructor(){const t=L(Tn.getDefaults(),arguments);super(t),this.name="Synth",this.oscillator=new yn(Object.assign({context:this.context,detune:t.detune,onstop:()=>this.onsilence(this)},t.oscillator)),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new Ms(Object.assign({context:this.context},t.envelope)),this.oscillator.chain(this.envelope,this.output),it(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(Ee.getDefaults(),{envelope:Object.assign(er(re.getDefaults(),Object.keys(U.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(er(yn.getDefaults(),[...Object.keys(Nt.getDefaults()),"frequency","detune"]),{type:"triangle"})})}_triggerEnvelopeAttack(t,e){if(this.envelope.triggerAttack(t,e),this.oscillator.start(t),this.envelope.sustain===0){const n=this.toSeconds(this.envelope.attack),r=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+n+r)}}_triggerEnvelopeRelease(t){this.envelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}}class qn extends Tn{constructor(){const t=L(qn.getDefaults(),arguments);super(t),this.name="MembraneSynth",this.portamento=0,this.pitchDecay=t.pitchDecay,this.octaves=t.octaves,it(this,["oscillator","envelope"])}static getDefaults(){return we(Ee.getDefaults(),Tn.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:"sine"},pitchDecay:.05})}setNote(t,e){const n=this.toSeconds(e),r=this.toFrequency(t instanceof Et?t.toFrequency():t),i=r*this.octaves;return this.oscillator.frequency.setValueAtTime(i,n),this.oscillator.frequency.exponentialRampToValueAtTime(r,n+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}}qt([ai(0)],qn.prototype,"octaves",void 0);qt([Yt(0)],qn.prototype,"pitchDecay",void 0);const ci=new Set;function Ds(s){ci.add(s)}function ui(s,t){const e=`registerProcessor("${s}", ${t})`;ci.add(e)}const eh=`
|
|
24
|
+
/**
|
|
25
|
+
* The base AudioWorkletProcessor for use in Tone.js. Works with the {@link ToneAudioWorklet}.
|
|
26
|
+
*/
|
|
27
|
+
class ToneAudioWorkletProcessor extends AudioWorkletProcessor {
|
|
28
|
+
|
|
29
|
+
constructor(options) {
|
|
30
|
+
|
|
31
|
+
super(options);
|
|
32
|
+
/**
|
|
33
|
+
* If the processor was disposed or not. Keep alive until it's disposed.
|
|
34
|
+
*/
|
|
35
|
+
this.disposed = false;
|
|
36
|
+
/**
|
|
37
|
+
* The number of samples in the processing block
|
|
38
|
+
*/
|
|
39
|
+
this.blockSize = 128;
|
|
40
|
+
/**
|
|
41
|
+
* the sample rate
|
|
42
|
+
*/
|
|
43
|
+
this.sampleRate = sampleRate;
|
|
44
|
+
|
|
45
|
+
this.port.onmessage = (event) => {
|
|
46
|
+
// when it receives a dispose
|
|
47
|
+
if (event.data === "dispose") {
|
|
48
|
+
this.disposed = true;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`;Ds(eh);const nh=`
|
|
54
|
+
/**
|
|
55
|
+
* Abstract class for a single input/output processor.
|
|
56
|
+
* has a 'generate' function which processes one sample at a time
|
|
57
|
+
*/
|
|
58
|
+
class SingleIOProcessor extends ToneAudioWorkletProcessor {
|
|
59
|
+
|
|
60
|
+
constructor(options) {
|
|
61
|
+
super(Object.assign(options, {
|
|
62
|
+
numberOfInputs: 1,
|
|
63
|
+
numberOfOutputs: 1
|
|
64
|
+
}));
|
|
65
|
+
/**
|
|
66
|
+
* Holds the name of the parameter and a single value of that
|
|
67
|
+
* parameter at the current sample
|
|
68
|
+
* @type { [name: string]: number }
|
|
69
|
+
*/
|
|
70
|
+
this.params = {}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Generate an output sample from the input sample and parameters
|
|
75
|
+
* @abstract
|
|
76
|
+
* @param input number
|
|
77
|
+
* @param channel number
|
|
78
|
+
* @param parameters { [name: string]: number }
|
|
79
|
+
* @returns number
|
|
80
|
+
*/
|
|
81
|
+
generate(){}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Update the private params object with the
|
|
85
|
+
* values of the parameters at the given index
|
|
86
|
+
* @param parameters { [name: string]: Float32Array },
|
|
87
|
+
* @param index number
|
|
88
|
+
*/
|
|
89
|
+
updateParams(parameters, index) {
|
|
90
|
+
for (const paramName in parameters) {
|
|
91
|
+
const param = parameters[paramName];
|
|
92
|
+
if (param.length > 1) {
|
|
93
|
+
this.params[paramName] = parameters[paramName][index];
|
|
94
|
+
} else {
|
|
95
|
+
this.params[paramName] = parameters[paramName][0];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Process a single frame of the audio
|
|
102
|
+
* @param inputs Float32Array[][]
|
|
103
|
+
* @param outputs Float32Array[][]
|
|
104
|
+
*/
|
|
105
|
+
process(inputs, outputs, parameters) {
|
|
106
|
+
const input = inputs[0];
|
|
107
|
+
const output = outputs[0];
|
|
108
|
+
// get the parameter values
|
|
109
|
+
const channelCount = Math.max(input && input.length || 0, output.length);
|
|
110
|
+
for (let sample = 0; sample < this.blockSize; sample++) {
|
|
111
|
+
this.updateParams(parameters, sample);
|
|
112
|
+
for (let channel = 0; channel < channelCount; channel++) {
|
|
113
|
+
const inputSample = input && input.length ? input[channel][sample] : 0;
|
|
114
|
+
output[channel][sample] = this.generate(inputSample, channel, this.params);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return !this.disposed;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
`;Ds(nh);const sh=`
|
|
121
|
+
/**
|
|
122
|
+
* A multichannel buffer for use within an AudioWorkletProcessor as a delay line
|
|
123
|
+
*/
|
|
124
|
+
class DelayLine {
|
|
125
|
+
|
|
126
|
+
constructor(size, channels) {
|
|
127
|
+
this.buffer = [];
|
|
128
|
+
this.writeHead = []
|
|
129
|
+
this.size = size;
|
|
130
|
+
|
|
131
|
+
// create the empty channels
|
|
132
|
+
for (let i = 0; i < channels; i++) {
|
|
133
|
+
this.buffer[i] = new Float32Array(this.size);
|
|
134
|
+
this.writeHead[i] = 0;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Push a value onto the end
|
|
140
|
+
* @param channel number
|
|
141
|
+
* @param value number
|
|
142
|
+
*/
|
|
143
|
+
push(channel, value) {
|
|
144
|
+
this.writeHead[channel] += 1;
|
|
145
|
+
if (this.writeHead[channel] > this.size) {
|
|
146
|
+
this.writeHead[channel] = 0;
|
|
147
|
+
}
|
|
148
|
+
this.buffer[channel][this.writeHead[channel]] = value;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Get the recorded value of the channel given the delay
|
|
153
|
+
* @param channel number
|
|
154
|
+
* @param delay number delay samples
|
|
155
|
+
*/
|
|
156
|
+
get(channel, delay) {
|
|
157
|
+
let readHead = this.writeHead[channel] - Math.floor(delay);
|
|
158
|
+
if (readHead < 0) {
|
|
159
|
+
readHead += this.size;
|
|
160
|
+
}
|
|
161
|
+
return this.buffer[channel][readHead];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
`;Ds(sh);const rh="feedback-comb-filter",ih=`
|
|
165
|
+
class FeedbackCombFilterWorklet extends SingleIOProcessor {
|
|
166
|
+
|
|
167
|
+
constructor(options) {
|
|
168
|
+
super(options);
|
|
169
|
+
this.delayLine = new DelayLine(this.sampleRate, options.channelCount || 2);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
static get parameterDescriptors() {
|
|
173
|
+
return [{
|
|
174
|
+
name: "delayTime",
|
|
175
|
+
defaultValue: 0.1,
|
|
176
|
+
minValue: 0,
|
|
177
|
+
maxValue: 1,
|
|
178
|
+
automationRate: "k-rate"
|
|
179
|
+
}, {
|
|
180
|
+
name: "feedback",
|
|
181
|
+
defaultValue: 0.5,
|
|
182
|
+
minValue: 0,
|
|
183
|
+
maxValue: 0.9999,
|
|
184
|
+
automationRate: "k-rate"
|
|
185
|
+
}];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
generate(input, channel, parameters) {
|
|
189
|
+
const delayedSample = this.delayLine.get(channel, parameters.delayTime * this.sampleRate);
|
|
190
|
+
this.delayLine.push(channel, input + delayedSample * parameters.feedback);
|
|
191
|
+
return delayedSample;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
`;ui(rh,ih);class Ln extends Oe{constructor(){const t=L(Ln.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");super(t),this.name="Sampler",this._activeSources=new Map;const e={};Object.keys(t.urls).forEach(n=>{const r=parseInt(n,10);if(B(sn(n)||le(r)&&isFinite(r),`url key is neither a note or midi pitch: ${n}`),sn(n)){const i=new Et(this.context,n).toMidi();e[i]=t.urls[n]}else le(r)&&isFinite(r)&&(e[r]=t.urls[r])}),this._buffers=new Ns({urls:e,onload:t.onload,baseUrl:t.baseUrl,onerror:t.onerror}),this.attack=t.attack,this.release=t.release,this.curve=t.curve,this._buffers.loaded&&Promise.resolve().then(t.onload)}static getDefaults(){return Object.assign(Oe.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:X,onerror:X,release:.1,urls:{}})}_findClosest(t){let n=0;for(;n<96;){if(this._buffers.has(t+n))return-n;if(this._buffers.has(t-n))return n;n++}throw new Error(`No available buffers for note: ${t}`)}triggerAttack(t,e,n=1){return this.log("triggerAttack",t,e,n),Array.isArray(t)||(t=[t]),t.forEach(r=>{const i=oi(new Et(this.context,r).toFrequency()),a=Math.round(i),o=i-a,c=this._findClosest(a),u=a-c,l=this._buffers.get(u),h=ii(c+o),p=new Dn({url:l,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,playbackRate:h}).connect(this.output);p.start(e,0,l.duration/h,n),Pt(this._activeSources.get(a))||this._activeSources.set(a,[]),this._activeSources.get(a).push(p),p.onended=()=>{if(this._activeSources&&this._activeSources.has(a)){const f=this._activeSources.get(a),d=f.indexOf(p);d!==-1&&f.splice(d,1)}}}),this}triggerRelease(t,e){return this.log("triggerRelease",t,e),Array.isArray(t)||(t=[t]),t.forEach(n=>{const r=new Et(this.context,n).toMidi();if(this._activeSources.has(r)&&this._activeSources.get(r).length){const i=this._activeSources.get(r);e=this.toSeconds(e),i.forEach(a=>{a.stop(e)}),this._activeSources.set(r,[])}}),this}releaseAll(t){const e=this.toSeconds(t);return this._activeSources.forEach(n=>{for(;n.length;)n.shift().stop(e)}),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1)),this}triggerAttackRelease(t,e,n,r=1){const i=this.toSeconds(n);return this.triggerAttack(t,i,r),Pt(e)?(B(Pt(t),"notes must be an array when duration is array"),t.forEach((a,o)=>{const c=e[Math.min(o,e.length-1)];this.triggerRelease(a,i+this.toSeconds(c))})):this.triggerRelease(t,i+this.toSeconds(e)),this}add(t,e,n){if(B(sn(t)||isFinite(t),`note must be a pitch or midi: ${t}`),sn(t)){const r=new Et(this.context,t).toMidi();this._buffers.add(r,e,n)}else this._buffers.add(t,e,n);return this}get loaded(){return this._buffers.loaded}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach(t=>{t.forEach(e=>e.dispose())}),this._activeSources.clear(),this}}qt([Yt(0)],Ln.prototype,"attack",void 0);qt([Yt(0)],Ln.prototype,"release",void 0);class Rs extends U{constructor(){const t=L(Rs.getDefaults(),arguments,["pan"]);super(t),this.name="Panner",this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner,this.pan=new nt({context:this.context,param:this._panner.pan,value:t.pan,minValue:-1,maxValue:1}),this._panner.channelCount=t.channelCount,this._panner.channelCountMode="explicit",it(this,"pan")}static getDefaults(){return Object.assign(U.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}}const oh="bit-crusher",ah=`
|
|
195
|
+
class BitCrusherWorklet extends SingleIOProcessor {
|
|
196
|
+
|
|
197
|
+
static get parameterDescriptors() {
|
|
198
|
+
return [{
|
|
199
|
+
name: "bits",
|
|
200
|
+
defaultValue: 12,
|
|
201
|
+
minValue: 1,
|
|
202
|
+
maxValue: 16,
|
|
203
|
+
automationRate: 'k-rate'
|
|
204
|
+
}];
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
generate(input, _channel, parameters) {
|
|
208
|
+
const step = Math.pow(0.5, parameters.bits - 1);
|
|
209
|
+
const val = step * Math.floor(input / step + 0.5);
|
|
210
|
+
return val;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
`;ui(oh,ah);class ct extends U{constructor(){const t=L(ct.getDefaults(),arguments,["solo"]);super(t),this.name="Solo",this.input=this.output=new mt({context:this.context}),ct._allSolos.has(this.context)||ct._allSolos.set(this.context,new Set),ct._allSolos.get(this.context).add(this),this.solo=t.solo}static getDefaults(){return Object.assign(U.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(t){t?this._addSolo():this._removeSolo(),ct._allSolos.get(this.context).forEach(e=>e._updateSolo())}get muted(){return this.input.gain.value===0}_addSolo(){ct._soloed.has(this.context)||ct._soloed.set(this.context,new Set),ct._soloed.get(this.context).add(this)}_removeSolo(){ct._soloed.has(this.context)&&ct._soloed.get(this.context).delete(this)}_isSoloed(){return ct._soloed.has(this.context)&&ct._soloed.get(this.context).has(this)}_noSolos(){return!ct._soloed.has(this.context)||ct._soloed.has(this.context)&&ct._soloed.get(this.context).size===0}_updateSolo(){this._isSoloed()?this.input.gain.value=1:this._noSolos()?this.input.gain.value=1:this.input.gain.value=0}dispose(){return super.dispose(),ct._allSolos.get(this.context).delete(this),this._removeSolo(),this}}ct._allSolos=new Map;ct._soloed=new Map;class Ps extends U{constructor(){const t=L(Ps.getDefaults(),arguments,["pan","volume"]);super(t),this.name="PanVol",this._panner=this.input=new Rs({context:this.context,pan:t.pan,channelCount:t.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new Fe({context:this.context,volume:t.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=t.mute,it(this,["pan","volume"])}static getDefaults(){return Object.assign(U.getDefaults(),{mute:!1,pan:0,volume:0,channelCount:1})}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}}class Te extends U{constructor(){const t=L(Te.getDefaults(),arguments,["volume","pan"]);super(t),this.name="Channel",this._solo=this.input=new ct({solo:t.solo,context:this.context}),this._panVol=this.output=new Ps({context:this.context,pan:t.pan,volume:t.volume,mute:t.mute,channelCount:t.channelCount}),this.pan=this._panVol.pan,this.volume=this._panVol.volume,this._solo.connect(this._panVol),it(this,["pan","volume"])}static getDefaults(){return Object.assign(U.getDefaults(),{pan:0,volume:0,mute:!1,solo:!1,channelCount:1})}get solo(){return this._solo.solo}set solo(t){this._solo.solo=t}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(t){this._panVol.mute=t}_getBus(t){return Te.buses.has(t)||Te.buses.set(t,new mt({context:this.context})),Te.buses.get(t)}send(t,e=0){const n=this._getBus(t),r=new mt({context:this.context,units:"decibels",gain:e});return this.connect(r),r.connect(n),r}receive(t){return this._getBus(t).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}}Te.buses=new Map;bt().transport;bt().destination;bt().destination;bt().listener;bt().draw;bt();function Lh(s){return vn(s),{context:s,isBridged:()=>bt().rawContext===s}}function Bh(s,t){s.connect(t)}async function jh(){await ql()}const ch=44100,uh=2;async function Uh(s){const{start:t,end:e,sampleRate:n=ch,channels:r=uh,compose:i,signal:a}=s;if(!Number.isFinite(t)||!Number.isFinite(e)||e<=t)throw new Error(`[tone-offline-render] invalid range [${t}, ${e}) — end must be a finite number > start`);if(!Number.isFinite(n)||n<=0)throw new Error(`[tone-offline-render] sampleRate must be a finite number > 0, got ${n}`);if(!Number.isInteger(r)||r<=0)throw new Error(`[tone-offline-render] channels must be a positive integer, got ${r}`);if(a?.aborted)throw li();const o=e-t,c=Yl(i,o,r,n),l=(a?await lh(c,a):await c).get();if(!l)throw new Error("[tone-offline-render] Tone.Offline resolved without a decoded AudioBuffer");return{buffer:l,durationSeconds:o,sampleRate:l.sampleRate,channels:l.numberOfChannels}}function li(){return new DOMException("[tone-offline-render] render canceled","AbortError")}function lh(s,t){return new Promise((e,n)=>{const r=()=>n(li());t.addEventListener("abort",r,{once:!0}),s.then(i=>{t.removeEventListener("abort",r),e(i)},i=>{t.removeEventListener("abort",r),n(i)})})}export{hh as bindClockToTone,Lh as bridgeToneToThreeAudio,Bh as connectToneBusToMasterGain,Uh as renderToneOffline,jh as resumeSharedAudio};
|