@prostgles/app 2.3.6-dev.1793121759 → 2.3.6-dev.1795896332
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/LICENSE-EXCEPTION +24 -0
- package/client/build/index.html +1 -1
- package/client/build/js/34.bundle.js +1 -0
- package/client/build/js/474.bundle.js +1 -0
- package/client/build/js/478.bundle.js +2 -0
- package/client/build/js/630.bundle.js +1 -0
- package/client/build/js/640.bundle.js +1 -0
- package/client/build/js/733.bundle.js +1 -1
- package/client/build/js/776.bundle.js +1 -0
- package/client/build/js/977.bundle.js +1 -0
- package/client/build/js/deckgl.bundle.js +1 -2
- package/client/build/js/deckglExtensions.bundle.js +1 -1
- package/client/build/js/main.bundle.js +2 -2
- package/client/build/js/mvtLoader.bundle.js +1 -1
- package/client/build/mvt-worker.js +2 -0
- package/client/build/mvt-worker.js.LICENSE.txt +5 -0
- package/client/build/static/css/{main.eaea5128.css → main.d3fe6599.css} +484 -217
- package/client/static/util.css +23 -0
- package/dist/common/ColumnConfig/ColumnConfig.d.ts +9 -5
- package/dist/common/ColumnConfig/ColumnConfig.d.ts.map +1 -1
- package/dist/common/ColumnConfig/ColumnConfig.js +3 -0
- package/dist/common/ColumnConfig/ColumnConfig.js.map +1 -1
- package/dist/common/ColumnConfig/FUNCTIONS.d.ts +4 -0
- package/dist/common/ColumnConfig/FUNCTIONS.d.ts.map +1 -1
- package/dist/common/ColumnConfig/FUNCTIONS.js.map +1 -1
- package/dist/common/ColumnConfig/WindowData.d.ts +4 -26
- package/dist/common/ColumnConfig/WindowData.d.ts.map +1 -1
- package/dist/common/ColumnConfig/WindowData.js +0 -6
- package/dist/common/ColumnConfig/WindowData.js.map +1 -1
- package/dist/common/ColumnConfig/cardLayout.d.ts +26 -28
- package/dist/common/ColumnConfig/cardLayout.d.ts.map +1 -1
- package/dist/common/ColumnConfig/cardLayout.js +32 -31
- package/dist/common/ColumnConfig/cardLayout.js.map +1 -1
- package/dist/common/ColumnConfig/chipColors.d.ts +9 -58
- package/dist/common/ColumnConfig/chipColors.d.ts.map +1 -1
- package/dist/common/ColumnConfig/chipColors.js +34 -76
- package/dist/common/ColumnConfig/chipColors.js.map +1 -1
- package/dist/common/ColumnConfig/columnConfigSchema.d.ts +2 -1788
- package/dist/common/ColumnConfig/columnConfigSchema.d.ts.map +1 -1
- package/dist/common/ColumnConfig/columnConfigSchema.js +24 -11
- package/dist/common/ColumnConfig/columnConfigSchema.js.map +1 -1
- package/dist/common/DBGeneratedSchema.d.ts +1400 -95
- package/dist/common/DBGeneratedSchema.d.ts.map +1 -1
- package/dist/common/DashboardTypes.d.ts +143 -13
- package/dist/common/DashboardTypes.d.ts.map +1 -1
- package/dist/common/DashboardTypes.js +14 -4
- package/dist/common/DashboardTypes.js.map +1 -1
- package/dist/common/OAuthUtils.d.ts +1 -2
- package/dist/common/OAuthUtils.d.ts.map +1 -1
- package/dist/common/OAuthUtils.js +3 -6
- package/dist/common/OAuthUtils.js.map +1 -1
- package/dist/common/Testing.d.ts +11 -0
- package/dist/common/Testing.js +11 -0
- package/dist/common/actionColumn.d.ts +62 -3
- package/dist/common/actionColumn.d.ts.map +1 -1
- package/dist/common/actionColumn.js +18 -12
- package/dist/common/actionColumn.js.map +1 -1
- package/dist/common/alertQuerySchema.d.ts +109 -0
- package/dist/common/alertQuerySchema.d.ts.map +1 -0
- package/dist/common/alertQuerySchema.js +53 -0
- package/dist/common/alertQuerySchema.js.map +1 -0
- package/dist/common/annotationText.d.ts.map +1 -1
- package/dist/common/annotationText.js +2 -1
- package/dist/common/annotationText.js.map +1 -1
- package/dist/common/columnDisplayFormat.schema.d.ts +123 -19
- package/dist/common/columnDisplayFormat.schema.d.ts.map +1 -1
- package/dist/common/columnDisplayFormat.schema.js +119 -25
- package/dist/common/columnDisplayFormat.schema.js.map +1 -1
- package/dist/common/createActionColumn.d.ts +1 -1
- package/dist/common/detailedFilterSchema.d.ts +23 -0
- package/dist/common/detailedFilterSchema.d.ts.map +1 -0
- package/dist/common/detailedFilterSchema.js +95 -0
- package/dist/common/detailedFilterSchema.js.map +1 -0
- package/dist/common/electronInitTypes.d.ts +2 -9
- package/dist/common/electronInitTypes.d.ts.map +1 -1
- package/dist/common/electronInitTypes.js.map +1 -1
- package/dist/common/filterOperators.d.ts +104 -0
- package/dist/common/filterOperators.d.ts.map +1 -0
- package/dist/common/filterOperators.js +80 -0
- package/dist/common/filterOperators.js.map +1 -0
- package/dist/common/filterUtils.d.ts +15 -143
- package/dist/common/filterUtils.d.ts.map +1 -1
- package/dist/common/filterUtils.js +132 -122
- package/dist/common/filterUtils.js.map +1 -1
- package/dist/common/functionOptions.d.ts +88 -11
- package/dist/common/functionOptions.d.ts.map +1 -1
- package/dist/common/functionOptions.js +16 -5
- package/dist/common/functionOptions.js.map +1 -1
- package/dist/common/htmlColumnStyles.d.ts +23 -0
- package/dist/common/htmlColumnStyles.d.ts.map +1 -0
- package/dist/common/htmlColumnStyles.js +38 -0
- package/dist/common/htmlColumnStyles.js.map +1 -0
- package/dist/common/jobAction.d.ts +11 -3
- package/dist/common/jobAction.d.ts.map +1 -1
- package/dist/common/jobAction.js +81 -17
- package/dist/common/jobAction.js.map +1 -1
- package/dist/common/llmUtils.d.ts.map +1 -1
- package/dist/common/managedTableSchema.d.ts +58 -56
- package/dist/common/managedTableSchema.d.ts.map +1 -1
- package/dist/common/managedTableSchema.js +44 -29
- package/dist/common/managedTableSchema.js.map +1 -1
- package/dist/common/mcp/db.mcp.schema.d.ts +219 -68
- package/dist/common/mcp/db.mcp.schema.d.ts.map +1 -1
- package/dist/common/mcp/db.mcp.schema.js +46 -30
- package/dist/common/mcp/db.mcp.schema.js.map +1 -1
- package/dist/common/mcp/documents.mcp.schema.d.ts +3 -3
- package/dist/common/mcp/documents.mcp.schema.d.ts.map +1 -1
- package/dist/common/mcp/documents.mcp.schema.js +43 -4
- package/dist/common/mcp/documents.mcp.schema.js.map +1 -1
- package/dist/common/mcp/getUserInputFieldSchema.d.ts +8 -0
- package/dist/common/mcp/getUserInputFieldSchema.d.ts.map +1 -0
- package/dist/common/mcp/getUserInputFieldSchema.js +79 -0
- package/dist/common/mcp/getUserInputFieldSchema.js.map +1 -0
- package/dist/common/mcp/runCodeInSandboxSchema.d.ts +147 -0
- package/dist/common/mcp/runCodeInSandboxSchema.d.ts.map +1 -1
- package/dist/common/mcp/startAgenticWorkflowSchema.d.ts +165 -90
- package/dist/common/mcp/startAgenticWorkflowSchema.d.ts.map +1 -1
- package/dist/common/mcp/startAgenticWorkflowSchema.js +4 -2
- package/dist/common/mcp/startAgenticWorkflowSchema.js.map +1 -1
- package/dist/common/mcp/tableOptionsJsonbSchema.d.ts +356 -1940
- package/dist/common/mcp/tableOptionsJsonbSchema.d.ts.map +1 -1
- package/dist/common/mcp/tableOptionsJsonbSchema.js +4 -3
- package/dist/common/mcp/tableOptionsJsonbSchema.js.map +1 -1
- package/dist/common/mcp/ui.mcp.schema.d.ts +438 -1875
- package/dist/common/mcp/ui.mcp.schema.d.ts.map +1 -1
- package/dist/common/mcp/ui.mcp.schema.js +2 -2
- package/dist/common/mcp/ui.mcp.schema.js.map +1 -1
- package/dist/common/mcp/userInputSchema.d.ts +150 -0
- package/dist/common/mcp/userInputSchema.d.ts.map +1 -1
- package/dist/common/mcp/userInputSchema.js +39 -1
- package/dist/common/mcp/userInputSchema.js.map +1 -1
- package/dist/common/prostglesApiTypes.d.ts +1 -1
- package/dist/common/prostglesApiTypes.d.ts.map +1 -1
- package/dist/common/prostglesApiTypes.js +6 -4
- package/dist/common/prostglesApiTypes.js.map +1 -1
- package/dist/common/prostglesMcp.d.ts +808 -2094
- package/dist/common/prostglesMcp.d.ts.map +1 -1
- package/dist/common/publishUtils.d.ts +2 -5
- package/dist/common/publishUtils.d.ts.map +1 -1
- package/dist/common/publishUtils.js +3 -2
- package/dist/common/publishUtils.js.map +1 -1
- package/dist/common/resolveActionFunction.d.ts.map +1 -1
- package/dist/common/resolveActionFunction.js +2 -2
- package/dist/common/resolveActionFunction.js.map +1 -1
- package/dist/common/utils.d.ts +7 -3
- package/dist/common/utils.d.ts.map +1 -1
- package/dist/common/utils.js +7 -4
- package/dist/common/utils.js.map +1 -1
- package/dist/server/package.json +27 -22
- package/dist/server/src/Alerts/AlertTypes.d.ts +22 -18
- package/dist/server/src/Alerts/AlertTypes.d.ts.map +1 -1
- package/dist/server/src/Alerts/AlertTypes.js +0 -4
- package/dist/server/src/Alerts/AlertTypes.js.map +1 -1
- package/dist/server/src/Alerts/alertQuerySchema.d.ts +3 -0
- package/dist/server/src/Alerts/alertQuerySchema.d.ts.map +1 -0
- package/dist/server/src/Alerts/alertQuerySchema.js +6 -0
- package/dist/server/src/Alerts/alertQuerySchema.js.map +1 -0
- package/dist/server/src/Alerts/deduplicateAlertRows.d.ts +7 -0
- package/dist/server/src/Alerts/deduplicateAlertRows.d.ts.map +1 -0
- package/dist/server/src/Alerts/deduplicateAlertRows.js +97 -0
- package/dist/server/src/Alerts/deduplicateAlertRows.js.map +1 -0
- package/dist/server/src/Alerts/enqueueAlerts.d.ts +2 -1
- package/dist/server/src/Alerts/enqueueAlerts.d.ts.map +1 -1
- package/dist/server/src/Alerts/enqueueAlerts.js +37 -26
- package/dist/server/src/Alerts/enqueueAlerts.js.map +1 -1
- package/dist/server/src/Alerts/getAlertFunctions.d.ts +118 -0
- package/dist/server/src/Alerts/getAlertFunctions.d.ts.map +1 -0
- package/dist/server/src/Alerts/getAlertFunctions.js +140 -0
- package/dist/server/src/Alerts/getAlertFunctions.js.map +1 -0
- package/dist/server/src/Alerts/getAlertRecipients.d.ts +12 -0
- package/dist/server/src/Alerts/getAlertRecipients.d.ts.map +1 -0
- package/dist/server/src/Alerts/getAlertRecipients.js +16 -0
- package/dist/server/src/Alerts/getAlertRecipients.js.map +1 -0
- package/dist/server/src/Alerts/getAlertTableOptions.d.ts +1 -1
- package/dist/server/src/Alerts/getAlertTableOptions.d.ts.map +1 -1
- package/dist/server/src/Alerts/getAlertTableOptions.js +116 -43
- package/dist/server/src/Alerts/getAlertTableOptions.js.map +1 -1
- package/dist/server/src/Alerts/getAlertTables.d.ts +191 -154
- package/dist/server/src/Alerts/getAlertTables.d.ts.map +1 -1
- package/dist/server/src/Alerts/getAlertTables.js +58 -49
- package/dist/server/src/Alerts/getAlertTables.js.map +1 -1
- package/dist/server/src/Alerts/getAlertsPlugin.d.ts +2 -1
- package/dist/server/src/Alerts/getAlertsPlugin.d.ts.map +1 -1
- package/dist/server/src/Alerts/getAlertsPlugin.js +66 -24
- package/dist/server/src/Alerts/getAlertsPlugin.js.map +1 -1
- package/dist/server/src/Alerts/prepareAlert.d.ts +13 -0
- package/dist/server/src/Alerts/prepareAlert.d.ts.map +1 -0
- package/dist/server/src/Alerts/prepareAlert.js +32 -0
- package/dist/server/src/Alerts/prepareAlert.js.map +1 -0
- package/dist/server/src/Alerts/prepareQueryAlert.d.ts +4 -3
- package/dist/server/src/Alerts/prepareQueryAlert.d.ts.map +1 -1
- package/dist/server/src/Alerts/prepareQueryAlert.js +35 -75
- package/dist/server/src/Alerts/prepareQueryAlert.js.map +1 -1
- package/dist/server/src/Alerts/runAlertDelivery.d.ts +2 -1
- package/dist/server/src/Alerts/runAlertDelivery.d.ts.map +1 -1
- package/dist/server/src/Alerts/runAlertDelivery.js +40 -41
- package/dist/server/src/Alerts/runAlertDelivery.js.map +1 -1
- package/dist/server/src/BackupManager/BackupManager.d.ts +1120 -40
- package/dist/server/src/BackupManager/BackupManager.d.ts.map +1 -1
- package/dist/server/src/BackupManager/utils.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/ConnectionManager.d.ts +1128 -44
- package/dist/server/src/ConnectionManager/ConnectionManager.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/ConnectionManager.js +41 -26
- package/dist/server/src/ConnectionManager/ConnectionManager.js.map +1 -1
- package/dist/server/src/ConnectionManager/applyStartupSchemaConfig.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/applyStartupSchemaConfig.js +7 -0
- package/dist/server/src/ConnectionManager/applyStartupSchemaConfig.js.map +1 -1
- package/dist/server/src/ConnectionManager/compileSchemaConfigProject.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/compileSchemaConfigProject.js +28 -2
- package/dist/server/src/ConnectionManager/compileSchemaConfigProject.js.map +1 -1
- package/dist/server/src/ConnectionManager/dbsConnectionOptions.d.ts +37 -0
- package/dist/server/src/ConnectionManager/dbsConnectionOptions.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/dbsConnectionOptions.js +32 -0
- package/dist/server/src/ConnectionManager/dbsConnectionOptions.js.map +1 -1
- package/dist/server/src/ConnectionManager/getAuditActorTableConfig.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/getAuditActorTableConfig.js +2 -1
- package/dist/server/src/ConnectionManager/getAuditActorTableConfig.js.map +1 -1
- package/dist/server/src/ConnectionManager/getConnectionAuth.d.ts +54 -42
- package/dist/server/src/ConnectionManager/getConnectionAuth.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/getConnectionServerFunctions.d.ts +11 -5
- package/dist/server/src/ConnectionManager/getConnectionServerFunctions.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/getConnectionServerFunctions.js +45 -10
- package/dist/server/src/ConnectionManager/getConnectionServerFunctions.js.map +1 -1
- package/dist/server/src/ConnectionManager/getHotReloadConfigs.d.ts +60 -44
- package/dist/server/src/ConnectionManager/getHotReloadConfigs.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/getHotReloadConfigs.js +8 -6
- package/dist/server/src/ConnectionManager/getHotReloadConfigs.js.map +1 -1
- package/dist/server/src/ConnectionManager/getResetSharedWorkspaces.d.ts +16 -0
- package/dist/server/src/ConnectionManager/getResetSharedWorkspaces.d.ts.map +1 -0
- package/dist/server/src/ConnectionManager/getResetSharedWorkspaces.js +80 -0
- package/dist/server/src/ConnectionManager/getResetSharedWorkspaces.js.map +1 -0
- package/dist/server/src/ConnectionManager/getSchemaConfig.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/getSchemaConfig.js +4 -0
- package/dist/server/src/ConnectionManager/getSchemaConfig.js.map +1 -1
- package/dist/server/src/ConnectionManager/getTableAuditConfig.d.ts +1 -1
- package/dist/server/src/ConnectionManager/getTableAuditConfig.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/getTableAuditConfig.js +0 -3
- package/dist/server/src/ConnectionManager/getTableAuditConfig.js.map +1 -1
- package/dist/server/src/ConnectionManager/getUserTableOptions.d.ts +3 -0
- package/dist/server/src/ConnectionManager/getUserTableOptions.d.ts.map +1 -0
- package/dist/server/src/ConnectionManager/getUserTableOptions.js +91 -0
- package/dist/server/src/ConnectionManager/getUserTableOptions.js.map +1 -0
- package/dist/server/src/ConnectionManager/initConnectionManager.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/initConnectionManager.js +3 -0
- package/dist/server/src/ConnectionManager/initConnectionManager.js.map +1 -1
- package/dist/server/src/ConnectionManager/modifyClientFunctionSchema.d.ts +6 -2
- package/dist/server/src/ConnectionManager/modifyClientFunctionSchema.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/modifyClientFunctionSchema.js +29 -8
- package/dist/server/src/ConnectionManager/modifyClientFunctionSchema.js.map +1 -1
- package/dist/server/src/ConnectionManager/modifyClientSchema.d.ts +3 -2
- package/dist/server/src/ConnectionManager/modifyClientSchema.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/modifyClientSchema.js +55 -86
- package/dist/server/src/ConnectionManager/modifyClientSchema.js.map +1 -1
- package/dist/server/src/ConnectionManager/setSyncUserSub.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/setSyncUserSub.js +3 -1
- package/dist/server/src/ConnectionManager/setSyncUserSub.js.map +1 -1
- package/dist/server/src/ConnectionManager/startConnection.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/startConnection.js +25 -2
- package/dist/server/src/ConnectionManager/startConnection.js.map +1 -1
- package/dist/server/src/ConnectionManager/syncConfiguredLlmCredential.d.ts +4 -0
- package/dist/server/src/ConnectionManager/syncConfiguredLlmCredential.d.ts.map +1 -0
- package/dist/server/src/ConnectionManager/syncConfiguredLlmCredential.js +64 -0
- package/dist/server/src/ConnectionManager/syncConfiguredLlmCredential.js.map +1 -0
- package/dist/server/src/ConnectionManager/syncSchemaConfig.d.ts +4 -4
- package/dist/server/src/ConnectionManager/syncSchemaConfig.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/syncSchemaConfig.js +10 -6
- package/dist/server/src/ConnectionManager/syncSchemaConfig.js.map +1 -1
- package/dist/server/src/ConnectionManager/syncSchemaConfigResources.d.ts +4 -3
- package/dist/server/src/ConnectionManager/syncSchemaConfigResources.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/syncSchemaConfigResources.js +24 -6
- package/dist/server/src/ConnectionManager/syncSchemaConfigResources.js.map +1 -1
- package/dist/server/src/ConnectionManager/validateSchemaConfigActions.d.ts.map +1 -1
- package/dist/server/src/ConnectionManager/validateSchemaConfigActions.js +18 -4
- package/dist/server/src/ConnectionManager/validateSchemaConfigActions.js.map +1 -1
- package/dist/server/src/ConnectionManager/validateTableCardOptions.d.ts +3 -0
- package/dist/server/src/ConnectionManager/validateTableCardOptions.d.ts.map +1 -0
- package/dist/server/src/ConnectionManager/validateTableCardOptions.js +57 -0
- package/dist/server/src/ConnectionManager/validateTableCardOptions.js.map +1 -0
- package/dist/server/src/Emails/EmailOutboxTypes.d.ts +0 -2
- package/dist/server/src/Emails/EmailOutboxTypes.d.ts.map +1 -1
- package/dist/server/src/Emails/deliverOutboxEmail.d.ts.map +1 -1
- package/dist/server/src/Emails/deliverOutboxEmail.js +6 -4
- package/dist/server/src/Emails/deliverOutboxEmail.js.map +1 -1
- package/dist/server/src/Emails/getEmailOutboxPlugin.d.ts.map +1 -1
- package/dist/server/src/Emails/getEmailOutboxPlugin.js +7 -2
- package/dist/server/src/Emails/getEmailOutboxPlugin.js.map +1 -1
- package/dist/server/src/Emails/getEmailOutboxTables.d.ts +1 -7
- package/dist/server/src/Emails/getEmailOutboxTables.d.ts.map +1 -1
- package/dist/server/src/Emails/getEmailOutboxTables.js +1 -3
- package/dist/server/src/Emails/getEmailOutboxTables.js.map +1 -1
- package/dist/server/src/FileStorage/getAnnotationsTableHook.d.ts +14 -5
- package/dist/server/src/FileStorage/getAnnotationsTableHook.d.ts.map +1 -1
- package/dist/server/src/FileStorage/getAnnotationsTableHook.js +101 -42
- package/dist/server/src/FileStorage/getAnnotationsTableHook.js.map +1 -1
- package/dist/server/src/FileStorage/{getAnnotationPageText.d.ts → getFilePages.d.ts} +5 -18
- package/dist/server/src/FileStorage/getFilePages.d.ts.map +1 -0
- package/dist/server/src/FileStorage/{getAnnotationPageText.js → getFilePages.js} +48 -38
- package/dist/server/src/FileStorage/getFilePages.js.map +1 -0
- package/dist/server/src/FileStorage/getFilePagesTable.d.ts +3 -0
- package/dist/server/src/FileStorage/getFilePagesTable.d.ts.map +1 -0
- package/dist/server/src/FileStorage/getFilePagesTable.js +24 -0
- package/dist/server/src/FileStorage/getFilePagesTable.js.map +1 -0
- package/dist/server/src/FileStorage/getFileTableOptions.d.ts +4 -0
- package/dist/server/src/FileStorage/getFileTableOptions.d.ts.map +1 -0
- package/dist/server/src/FileStorage/getFileTableOptions.js +100 -0
- package/dist/server/src/FileStorage/getFileTableOptions.js.map +1 -0
- package/dist/server/src/FileStorage/getFilesPlugin.d.ts +1 -1
- package/dist/server/src/FileStorage/getFilesPlugin.d.ts.map +1 -1
- package/dist/server/src/FileStorage/getFilesPlugin.js +60 -15
- package/dist/server/src/FileStorage/getFilesPlugin.js.map +1 -1
- package/dist/server/src/FileStorage/getFilesTableHook.d.ts +2 -64
- package/dist/server/src/FileStorage/getFilesTableHook.d.ts.map +1 -1
- package/dist/server/src/FileStorage/getFilesTableHook.js +21 -18
- package/dist/server/src/FileStorage/getFilesTableHook.js.map +1 -1
- package/dist/server/src/FileStorage/getFilesTableJobs.d.ts +73 -7
- package/dist/server/src/FileStorage/getFilesTableJobs.d.ts.map +1 -1
- package/dist/server/src/FileStorage/getFilesTableJobs.js +57 -55
- package/dist/server/src/FileStorage/getFilesTableJobs.js.map +1 -1
- package/dist/server/src/FileStorage/replaceFilePages.d.ts +11 -0
- package/dist/server/src/FileStorage/replaceFilePages.d.ts.map +1 -0
- package/dist/server/src/FileStorage/replaceFilePages.js +11 -0
- package/dist/server/src/FileStorage/replaceFilePages.js.map +1 -0
- package/dist/server/src/Logger.d.ts.map +1 -1
- package/dist/server/src/Logger.js +1 -26
- package/dist/server/src/Logger.js.map +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/McpHub.js +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/McpHub.js.map +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/McpOAuth/authenticateMcpServer.d.ts +1 -0
- package/dist/server/src/McpHub/AnthropicMcpHub/McpOAuth/authenticateMcpServer.d.ts.map +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/McpOAuth/authenticateMcpServer.js +11 -6
- package/dist/server/src/McpHub/AnthropicMcpHub/McpOAuth/authenticateMcpServer.js.map +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/McpOAuth/connectToRemoteMCPServer.d.ts.map +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/McpOAuth/connectToRemoteMCPServer.js +107 -45
- package/dist/server/src/McpHub/AnthropicMcpHub/McpOAuth/connectToRemoteMCPServer.js.map +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/McpOAuth/createMcpOAuthProvider.d.ts +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/McpOAuth/createMcpOAuthProvider.d.ts.map +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/McpOAuth/createMcpOAuthProvider.js +45 -12
- package/dist/server/src/McpHub/AnthropicMcpHub/McpOAuth/createMcpOAuthProvider.js.map +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/McpOAuth/getRemoteMcpServerParameters.d.ts +2 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/McpOAuth/getRemoteMcpServerParameters.d.ts.map +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/McpOAuth/getRemoteMcpServerParameters.js +11 -0
- package/dist/server/src/McpHub/AnthropicMcpHub/McpOAuth/getRemoteMcpServerParameters.js.map +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/McpOAuth/updateRemoteMcpAuthorizationCode.d.ts.map +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/McpOAuth/updateRemoteMcpAuthorizationCode.js +3 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/McpOAuth/updateRemoteMcpAuthorizationCode.js.map +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/McpTypes.d.ts +2 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/McpTypes.d.ts.map +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/McpTypes.js.map +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/createMcpServerHandlers.d.ts +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/createMcpServerHandlers.d.ts.map +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/createMcpServerHandlers.js +21 -15
- package/dist/server/src/McpHub/AnthropicMcpHub/createMcpServerHandlers.js.map +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/startMcpHub.d.ts.map +1 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/startMcpHub.js +21 -1
- package/dist/server/src/McpHub/AnthropicMcpHub/startMcpHub.js.map +1 -1
- package/dist/server/src/McpHub/DockerSandbox/createContainer.d.ts.map +1 -1
- package/dist/server/src/McpHub/DockerSandbox/createContainer.js +14 -13
- package/dist/server/src/McpHub/DockerSandbox/createContainer.js.map +1 -1
- package/dist/server/src/McpHub/DockerSandbox/createContainer.spec.js +54 -3
- package/dist/server/src/McpHub/DockerSandbox/createContainer.spec.js.map +1 -1
- package/dist/server/src/McpHub/DockerSandbox/dockerMCPServerProxy/dockerContainerAuthRegistry.d.ts +4 -4
- package/dist/server/src/McpHub/DockerSandbox/dockerMCPServerProxy/dockerContainerAuthRegistry.d.ts.map +1 -1
- package/dist/server/src/McpHub/DockerSandbox/dockerMCPServerProxy/dockerContainerAuthRegistry.js +0 -55
- package/dist/server/src/McpHub/DockerSandbox/dockerMCPServerProxy/dockerContainerAuthRegistry.js.map +1 -1
- package/dist/server/src/McpHub/DockerSandbox/dockerMCPServerProxy/dockerMCPServerProxy.d.ts.map +1 -1
- package/dist/server/src/McpHub/DockerSandbox/dockerMCPServerProxy/dockerMCPServerProxy.js +17 -21
- package/dist/server/src/McpHub/DockerSandbox/dockerMCPServerProxy/dockerMCPServerProxy.js.map +1 -1
- package/dist/server/src/McpHub/DockerSandbox/getDockerRunArgs.d.ts.map +1 -1
- package/dist/server/src/McpHub/DockerSandbox/getDockerRunArgs.js +8 -5
- package/dist/server/src/McpHub/DockerSandbox/getDockerRunArgs.js.map +1 -1
- package/dist/server/src/McpHub/DockerSandbox/runContainerWithProxyAccess.d.ts +3 -3
- package/dist/server/src/McpHub/DockerSandbox/runContainerWithProxyAccess.d.ts.map +1 -1
- package/dist/server/src/McpHub/DockerSandbox/runContainerWithProxyAccess.js +2 -1
- package/dist/server/src/McpHub/DockerSandbox/runContainerWithProxyAccess.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServerTypes.d.ts +2 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServerTypes.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Db.mcp.d.ts +219 -68
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Db.mcp.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Db.mcp.js +13 -8
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Db.mcp.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Documents.mcp.d.ts +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Documents.mcp.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Documents.mcp.js +1 -3
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Documents.mcp.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/assertWorkflowSqlAllowed.d.ts +3 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/assertWorkflowSqlAllowed.d.ts.map +1 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/assertWorkflowSqlAllowed.js +14 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/assertWorkflowSqlAllowed.js.map +1 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/createAgenticWorkflow.d.ts +19 -2
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/createAgenticWorkflow.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/createAgenticWorkflow.js +33 -20
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/createAgenticWorkflow.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/definitionValidation/validateAgenticWorkflowDefinitions.d.ts +10 -13
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/definitionValidation/validateAgenticWorkflowDefinitions.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/definitionValidation/validateAgenticWorkflowDefinitions.js +3 -9
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/definitionValidation/validateAgenticWorkflowDefinitions.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/definitionValidation/validateDatabaseAccessDefinitions.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/definitionValidation/validateDatabaseAccessDefinitions.js +4 -2
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/definitionValidation/validateDatabaseAccessDefinitions.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/definitionValidation/validateUserInput.d.ts +9 -6
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/definitionValidation/validateUserInput.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/definitionValidation/validateUserInput.js +26 -104
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/definitionValidation/validateUserInput.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/definitionValidation/validateUserInputDefinitions.d.ts +2 -2
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/definitionValidation/validateUserInputDefinitions.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/definitionValidation/validateUserInputDefinitions.js +18 -14
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/definitionValidation/validateUserInputDefinitions.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/execution/getVolumesFromUserInput.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/execution/getVolumesFromUserInput.js +4 -8
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/execution/getVolumesFromUserInput.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/execution/startAgenticWorkflowContainer.d.ts +5 -5
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/execution/startAgenticWorkflowContainer.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/execution/startAgenticWorkflowContainer.js +9 -28
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/execution/startAgenticWorkflowContainer.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/getConfiguredWorkflow.d.ts +281 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/getConfiguredWorkflow.d.ts.map +1 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/getConfiguredWorkflow.js +86 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/getConfiguredWorkflow.js.map +1 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/getStartAgenticWorkflow.d.ts +10 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/getStartAgenticWorkflow.d.ts.map +1 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/getStartAgenticWorkflow.js +61 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/getStartAgenticWorkflow.js.map +1 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/proxyHandlers/createWorkflowExecutionHandlers.d.ts +13 -14
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/proxyHandlers/createWorkflowExecutionHandlers.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/proxyHandlers/createWorkflowExecutionHandlers.js +8 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/proxyHandlers/createWorkflowExecutionHandlers.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/proxyHandlers/getAgentConfigWithDefaults.d.ts +53 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/proxyHandlers/getAgentConfigWithDefaults.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/proxyHandlers/getAgentConfigWithDefaults.js +33 -24
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/proxyHandlers/getAgentConfigWithDefaults.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/proxyHandlers/setupOrchestrationToolPermissions.d.ts +8 -13
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/proxyHandlers/setupOrchestrationToolPermissions.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/proxyHandlers/setupOrchestrationToolPermissions.js +2 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/proxyHandlers/setupOrchestrationToolPermissions.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/defineAgenticWorkflow.d.ts +31 -18
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/defineAgenticWorkflow.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/defineAgenticWorkflow.js +2 -2
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/defineAgenticWorkflow.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/defineAgenticWorkflow.spec.js +38 -8
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/defineAgenticWorkflow.spec.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/defineAgenticWorkflowHandlers.types.d.ts +6 -14
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/defineAgenticWorkflowHandlers.types.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/defineAgenticWorkflowHandlers.types.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/definitionHandler.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/ensureWorkflowIsExecuted.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/ensureWorkflowIsExecuted.js +6 -4
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/ensureWorkflowIsExecuted.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/tableHandlers.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/tableHandlers.js +30 -5
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/tableHandlers.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/workflowConstants.d.ts +4 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/workflowConstants.d.ts.map +1 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/workflowConstants.js +7 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/workflowConstants.js.map +1 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSetup/getAgenticWorkflowDockerCoreFiles.d.ts +3 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSetup/getAgenticWorkflowDockerCoreFiles.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSetup/getAgenticWorkflowDockerCoreFiles.js +6 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSetup/getAgenticWorkflowDockerCoreFiles.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSetup/getDefineAgenticWorkflowTsWithDbAndMcpTypes.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSetup/getDefineAgenticWorkflowTsWithDbAndMcpTypes.js +6 -5
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSetup/getDefineAgenticWorkflowTsWithDbAndMcpTypes.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSetup/getWorkflowDeclaration.d.ts +2 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSetup/getWorkflowDeclaration.d.ts.map +1 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSetup/getWorkflowDeclaration.js +13 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSetup/getWorkflowDeclaration.js.map +1 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/startAgenticWorkflow.d.ts +27 -23
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/startAgenticWorkflow.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/startAgenticWorkflow.js +132 -88
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/startAgenticWorkflow.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/runCodeInSandboxContainer.d.ts +2 -2
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/runCodeInSandboxContainer.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/runCodeInSandboxContainer.js +9 -2
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/runCodeInSandboxContainer.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/schemas/getAgenticToolSchemas.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/schemas/getAgenticToolSchemas.js +6 -4
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/schemas/getAgenticToolSchemas.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/schemas/getContainerToolSchemas.d.ts +147 -0
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/schemas/getContainerToolSchemas.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/startAgent.d.ts +2 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/startAgent.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/startAgent.js +3 -2
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/startAgent.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/validateCreateDashboards.d.ts +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/validateCreateDashboards.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/validateCreateDashboards.js +9 -5
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/validateCreateDashboards.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Ui.mcp.d.ts +438 -1875
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Ui.mcp.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Ui.mcp.js +3 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Ui.mcp.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Web/Web.mcp.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Web/Web.mcp.js +1 -3
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Web/Web.mcp.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/WebDev/tools/getWebDevChatAndConnection.d.ts +1124 -50
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/WebDev/tools/getWebDevChatAndConnection.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/getClientDBHandlersForChat.d.ts +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/getClientDBHandlersForChat.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/getClientDBHandlersForChat.js +4 -3
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/getClientDBHandlersForChat.js.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers.d.ts +4482 -7054
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMCPServers.d.ts.map +1 -1
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMcpHub.d.ts +5527 -8099
- package/dist/server/src/McpHub/ProstglesMcpHub/ProstglesMcpHub.d.ts.map +1 -1
- package/dist/server/src/McpHub/callMCPServerTool.d.ts +3 -2
- package/dist/server/src/McpHub/callMCPServerTool.d.ts.map +1 -1
- package/dist/server/src/McpHub/callMCPServerTool.js +5 -1
- package/dist/server/src/McpHub/callMCPServerTool.js.map +1 -1
- package/dist/server/src/McpHub/getMcpServerParameters.js +5 -5
- package/dist/server/src/McpHub/getMcpServerParameters.js.map +1 -1
- package/dist/server/src/Plugins/Plugins.d.ts +6 -8
- package/dist/server/src/Plugins/Plugins.d.ts.map +1 -1
- package/dist/server/src/Plugins/jobsPlugin.d.ts +14 -0
- package/dist/server/src/Plugins/jobsPlugin.d.ts.map +1 -0
- package/dist/server/src/Plugins/jobsPlugin.js +218 -0
- package/dist/server/src/Plugins/jobsPlugin.js.map +1 -0
- package/dist/server/src/Plugins/mergeDefinitions.d.ts +2 -0
- package/dist/server/src/Plugins/mergeDefinitions.d.ts.map +1 -0
- package/dist/server/src/Plugins/mergeDefinitions.js +15 -0
- package/dist/server/src/Plugins/mergeDefinitions.js.map +1 -0
- package/dist/server/src/Plugins/parsePlugins.d.ts +5 -7
- package/dist/server/src/Plugins/parsePlugins.d.ts.map +1 -1
- package/dist/server/src/Plugins/parsePlugins.js +41 -31
- package/dist/server/src/Plugins/parsePlugins.js.map +1 -1
- package/dist/server/src/ServiceManager/ServiceManager.d.ts +1 -1
- package/dist/server/src/ServiceManager/ServiceManager.d.ts.map +1 -1
- package/dist/server/src/ServiceManager/ServiceManager.spec.js +89 -2
- package/dist/server/src/ServiceManager/ServiceManager.spec.js.map +1 -1
- package/dist/server/src/ServiceManager/enableService.d.ts.map +1 -1
- package/dist/server/src/ServiceManager/enableService.js +1 -3
- package/dist/server/src/ServiceManager/enableService.js.map +1 -1
- package/dist/server/src/ServiceManager/stopService.d.ts +1 -1
- package/dist/server/src/ServiceManager/stopService.d.ts.map +1 -1
- package/dist/server/src/ServiceManager/stopService.js +20 -5
- package/dist/server/src/ServiceManager/stopService.js.map +1 -1
- package/dist/server/src/authConfig/OAuthProviders/loginWithProvider.d.ts.map +1 -1
- package/dist/server/src/authConfig/OAuthProviders/loginWithProvider.js +7 -1
- package/dist/server/src/authConfig/OAuthProviders/loginWithProvider.js.map +1 -1
- package/dist/server/src/authConfig/createPasswordlessAdminSessionIfNeeded.js.map +1 -1
- package/dist/server/src/authConfig/createPublicUserSessionIfAllowed.js.map +1 -1
- package/dist/server/src/authConfig/emailProvider/getEmailAuthProvider.d.ts.map +1 -1
- package/dist/server/src/authConfig/emailProvider/getEmailAuthProvider.js +6 -10
- package/dist/server/src/authConfig/emailProvider/getEmailAuthProvider.js.map +1 -1
- package/dist/server/src/authConfig/emailProvider/{getEmailSenderWithMockTest.d.ts → getEmailClient.d.ts} +5 -6
- package/dist/server/src/authConfig/emailProvider/getEmailClient.d.ts.map +1 -0
- package/dist/server/src/authConfig/emailProvider/{getEmailSenderWithMockTest.js → getEmailClient.js} +5 -20
- package/dist/server/src/authConfig/emailProvider/getEmailClient.js.map +1 -0
- package/dist/server/src/authConfig/emailProvider/onEmailRegistration.d.ts +2 -2
- package/dist/server/src/authConfig/emailProvider/onEmailRegistration.d.ts.map +1 -1
- package/dist/server/src/authConfig/emailProvider/onEmailRegistration.js +54 -11
- package/dist/server/src/authConfig/emailProvider/onEmailRegistration.js.map +1 -1
- package/dist/server/src/authConfig/emailProvider/validateAuthEmailTemplate.d.ts +5 -0
- package/dist/server/src/authConfig/emailProvider/validateAuthEmailTemplate.d.ts.map +1 -0
- package/dist/server/src/authConfig/emailProvider/validateAuthEmailTemplate.js +26 -0
- package/dist/server/src/authConfig/emailProvider/validateAuthEmailTemplate.js.map +1 -0
- package/dist/server/src/authConfig/getAuth.d.ts +26 -15
- package/dist/server/src/authConfig/getAuth.d.ts.map +1 -1
- package/dist/server/src/authConfig/getAuth.js +5 -8
- package/dist/server/src/authConfig/getAuth.js.map +1 -1
- package/dist/server/src/authConfig/getLogin.d.ts +1 -2
- package/dist/server/src/authConfig/getLogin.d.ts.map +1 -1
- package/dist/server/src/authConfig/getLogin.js +121 -86
- package/dist/server/src/authConfig/getLogin.js.map +1 -1
- package/dist/server/src/authConfig/getTotpLoginError.d.ts +4 -0
- package/dist/server/src/authConfig/getTotpLoginError.d.ts.map +1 -0
- package/dist/server/src/authConfig/getTotpLoginError.js +23 -0
- package/dist/server/src/authConfig/getTotpLoginError.js.map +1 -0
- package/dist/server/src/authConfig/invites/sendInviteEmail.d.ts +4 -0
- package/dist/server/src/authConfig/invites/sendInviteEmail.d.ts.map +1 -0
- package/dist/server/src/authConfig/invites/sendInviteEmail.js +58 -0
- package/dist/server/src/authConfig/invites/sendInviteEmail.js.map +1 -0
- package/dist/server/src/authConfig/onMagicLinkOrOTP.d.ts +14 -6
- package/dist/server/src/authConfig/onMagicLinkOrOTP.d.ts.map +1 -1
- package/dist/server/src/authConfig/onMagicLinkOrOTP.js +101 -92
- package/dist/server/src/authConfig/onMagicLinkOrOTP.js.map +1 -1
- package/dist/server/src/authConfig/registrationConfirmation.d.ts +7 -0
- package/dist/server/src/authConfig/registrationConfirmation.d.ts.map +1 -0
- package/dist/server/src/authConfig/registrationConfirmation.js +13 -0
- package/dist/server/src/authConfig/registrationConfirmation.js.map +1 -0
- package/dist/server/src/authConfig/sendUserMagicLinkEmail.d.ts +6 -0
- package/dist/server/src/authConfig/sendUserMagicLinkEmail.d.ts.map +1 -0
- package/dist/server/src/authConfig/sendUserMagicLinkEmail.js +46 -0
- package/dist/server/src/authConfig/sendUserMagicLinkEmail.js.map +1 -0
- package/dist/server/src/authConfig/sessionUtils.d.ts +15 -12
- package/dist/server/src/authConfig/sessionUtils.d.ts.map +1 -1
- package/dist/server/src/authConfig/sessionUtils.js.map +1 -1
- package/dist/server/src/authConfig/startRateLimitedLoginAttempt.d.ts +14 -11
- package/dist/server/src/authConfig/startRateLimitedLoginAttempt.d.ts.map +1 -1
- package/dist/server/src/authConfig/startRateLimitedLoginAttempt.js +4 -1
- package/dist/server/src/authConfig/startRateLimitedLoginAttempt.js.map +1 -1
- package/dist/server/src/authConfig/subscribeToAuthSetupChanges.d.ts +5 -2
- package/dist/server/src/authConfig/subscribeToAuthSetupChanges.d.ts.map +1 -1
- package/dist/server/src/cli/cli.js +4 -1
- package/dist/server/src/cli/cli.js.map +1 -1
- package/dist/server/src/cli/cliTemplateFiles.d.ts +8 -4
- package/dist/server/src/cli/cliTemplateFiles.d.ts.map +1 -1
- package/dist/server/src/cli/cliTemplateFiles.js +206 -86
- package/dist/server/src/cli/cliTemplateFiles.js.map +1 -1
- package/dist/server/src/cli/configModuleConventions.d.ts +24 -0
- package/dist/server/src/cli/configModuleConventions.d.ts.map +1 -0
- package/dist/server/src/cli/configModuleConventions.js +73 -0
- package/dist/server/src/cli/configModuleConventions.js.map +1 -0
- package/dist/server/src/cli/configModuleEslintPlugin.d.ts +9 -0
- package/dist/server/src/cli/configModuleEslintPlugin.d.ts.map +1 -0
- package/dist/server/src/cli/configModuleEslintPlugin.js +64 -0
- package/dist/server/src/cli/configModuleEslintPlugin.js.map +1 -0
- package/dist/server/src/cli/getCliTableConfigMigrations.d.ts +5 -0
- package/dist/server/src/cli/getCliTableConfigMigrations.d.ts.map +1 -0
- package/dist/server/src/cli/getCliTableConfigMigrations.js +28 -0
- package/dist/server/src/cli/getCliTableConfigMigrations.js.map +1 -0
- package/dist/server/src/cli/getConfigAggregateErrors.d.ts +4 -0
- package/dist/server/src/cli/getConfigAggregateErrors.d.ts.map +1 -0
- package/dist/server/src/cli/getConfigAggregateErrors.js +66 -0
- package/dist/server/src/cli/getConfigAggregateErrors.js.map +1 -0
- package/dist/server/src/cli/getConfigModuleErrors.d.ts +4 -0
- package/dist/server/src/cli/getConfigModuleErrors.d.ts.map +1 -0
- package/dist/server/src/cli/getConfigModuleErrors.js +103 -0
- package/dist/server/src/cli/getConfigModuleErrors.js.map +1 -0
- package/dist/server/src/cli/getConfigModules.d.ts +12 -0
- package/dist/server/src/cli/getConfigModules.d.ts.map +1 -0
- package/dist/server/src/cli/getConfigModules.js +81 -0
- package/dist/server/src/cli/getConfigModules.js.map +1 -0
- package/dist/server/src/cli/overrides/createJobControlFunctionDefiner.d.ts +170 -0
- package/dist/server/src/cli/overrides/createJobControlFunctionDefiner.d.ts.map +1 -0
- package/dist/server/src/cli/overrides/createJobControlFunctionDefiner.js +11 -0
- package/dist/server/src/cli/overrides/createJobControlFunctionDefiner.js.map +1 -0
- package/dist/server/src/cli/overrides/createJobDefiner.d.ts +25 -0
- package/dist/server/src/cli/overrides/createJobDefiner.d.ts.map +1 -0
- package/dist/server/src/cli/overrides/createJobDefiner.js +7 -0
- package/dist/server/src/cli/overrides/createJobDefiner.js.map +1 -0
- package/dist/server/src/cli/overrides/defineFunction.d.ts +22 -0
- package/dist/server/src/cli/overrides/defineFunction.d.ts.map +1 -0
- package/dist/server/src/cli/overrides/defineFunction.js +6 -0
- package/dist/server/src/cli/overrides/defineFunction.js.map +1 -0
- package/dist/server/src/cli/upgradeCli.d.ts.map +1 -1
- package/dist/server/src/cli/upgradeCli.js +6 -2
- package/dist/server/src/cli/upgradeCli.js.map +1 -1
- package/dist/server/src/createHttpAndIOServers/setHttpAppSecurity.js.map +1 -1
- package/dist/server/src/electronConfig.d.ts +16 -0
- package/dist/server/src/electronConfig.d.ts.map +1 -1
- package/dist/server/src/electronConfig.js +18 -14
- package/dist/server/src/electronConfig.js.map +1 -1
- package/dist/server/src/index.d.ts +3 -3
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/index.js +11 -7
- package/dist/server/src/index.js.map +1 -1
- package/dist/server/src/init/initExpressAndIOServers.d.ts.map +1 -1
- package/dist/server/src/init/initExpressAndIOServers.js +0 -6
- package/dist/server/src/init/initExpressAndIOServers.js.map +1 -1
- package/dist/server/src/init/initUsers.d.ts +14 -11
- package/dist/server/src/init/initUsers.d.ts.map +1 -1
- package/dist/server/src/init/prostglesOnReady.d.ts.map +1 -1
- package/dist/server/src/init/prostglesOnReady.js +7 -0
- package/dist/server/src/init/prostglesOnReady.js.map +1 -1
- package/dist/server/src/init/setDBSRoutesForElectron.js +9 -10
- package/dist/server/src/init/setDBSRoutesForElectron.js.map +1 -1
- package/dist/server/src/init/startProstgles.d.ts.map +1 -1
- package/dist/server/src/init/startProstgles.js +4 -7
- package/dist/server/src/init/startProstgles.js.map +1 -1
- package/dist/server/src/init/tryStartProstgles.d.ts.map +1 -1
- package/dist/server/src/init/tryStartProstgles.js +25 -3
- package/dist/server/src/init/tryStartProstgles.js.map +1 -1
- package/dist/server/src/init/utils.js.map +1 -1
- package/dist/server/src/publish/getPublishLLM.d.ts +19 -25
- package/dist/server/src/publish/getPublishLLM.d.ts.map +1 -1
- package/dist/server/src/publish/getPublishLLM.js +3 -2
- package/dist/server/src/publish/getPublishLLM.js.map +1 -1
- package/dist/server/src/publish/getPublishLlmChats.d.ts +19 -25
- package/dist/server/src/publish/getPublishLlmChats.d.ts.map +1 -1
- package/dist/server/src/publish/getPublishLlmChats.js +13 -7
- package/dist/server/src/publish/getPublishLlmChats.js.map +1 -1
- package/dist/server/src/publish/publish.d.ts.map +1 -1
- package/dist/server/src/publish/publish.js +9 -28
- package/dist/server/src/publish/publish.js.map +1 -1
- package/dist/server/src/schemaConfig.d.ts +36 -15
- package/dist/server/src/schemaConfig.d.ts.map +1 -1
- package/dist/server/src/schemaConfig.js +7 -8
- package/dist/server/src/schemaConfig.js.map +1 -1
- package/dist/server/src/serverFunctions/adminServerFunctions/agenticWorkflowFunctions.d.ts +627 -354
- package/dist/server/src/serverFunctions/adminServerFunctions/agenticWorkflowFunctions.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/adminServerFunctions/agenticWorkflowFunctions.js +92 -59
- package/dist/server/src/serverFunctions/adminServerFunctions/agenticWorkflowFunctions.js.map +1 -1
- package/dist/server/src/serverFunctions/adminServerFunctions/backupServerFunctions.d.ts +72 -72
- package/dist/server/src/serverFunctions/adminServerFunctions/mcpServerFunctions.d.ts +74 -68
- package/dist/server/src/serverFunctions/adminServerFunctions/mcpServerFunctions.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/adminServerFunctions/mcpServerFunctions.js +6 -2
- package/dist/server/src/serverFunctions/adminServerFunctions/mcpServerFunctions.js.map +1 -1
- package/dist/server/src/serverFunctions/adminServerFunctions/stateServerAdminFunctions.d.ts +4020 -1548
- package/dist/server/src/serverFunctions/adminServerFunctions/stateServerAdminFunctions.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/adminServerFunctions/stateServerAdminFunctions.js +11 -6
- package/dist/server/src/serverFunctions/adminServerFunctions/stateServerAdminFunctions.js.map +1 -1
- package/dist/server/src/serverFunctions/adminServerFunctions/webApp/getTemplatedWebAppConnection.d.ts +1120 -40
- package/dist/server/src/serverFunctions/adminServerFunctions/webApp/getTemplatedWebAppConnection.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/adminServerFunctions/webAppServerFunctions.d.ts +62 -62
- package/dist/server/src/serverFunctions/applySampleSchema.d.ts +1125 -42
- package/dist/server/src/serverFunctions/applySampleSchema.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/LLMResponseTypes.d.ts +1 -0
- package/dist/server/src/serverFunctions/askLLM/LLMResponseTypes.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/applyCreateAgentDefaultsToMessage.d.ts +4 -0
- package/dist/server/src/serverFunctions/askLLM/applyCreateAgentDefaultsToMessage.d.ts.map +1 -0
- package/dist/server/src/serverFunctions/askLLM/applyCreateAgentDefaultsToMessage.js +24 -0
- package/dist/server/src/serverFunctions/askLLM/applyCreateAgentDefaultsToMessage.js.map +1 -0
- package/dist/server/src/serverFunctions/askLLM/askLLM.d.ts +3 -0
- package/dist/server/src/serverFunctions/askLLM/askLLM.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/askLLM.js +13 -15
- package/dist/server/src/serverFunctions/askLLM/askLLM.js.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/defaultPrompts/createAgenticWorkflow.prompt.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/defaultPrompts/createAgenticWorkflow.prompt.js +6 -5
- package/dist/server/src/serverFunctions/askLLM/defaultPrompts/createAgenticWorkflow.prompt.js.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/fetchLLMResponse.d.ts +3 -1
- package/dist/server/src/serverFunctions/askLLM/fetchLLMResponse.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/fetchLLMResponse.js +7 -13
- package/dist/server/src/serverFunctions/askLLM/fetchLLMResponse.js.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/fetchModels.d.ts +60 -0
- package/dist/server/src/serverFunctions/askLLM/fetchModels.d.ts.map +1 -0
- package/dist/server/src/serverFunctions/askLLM/fetchModels.js +217 -0
- package/dist/server/src/serverFunctions/askLLM/fetchModels.js.map +1 -0
- package/dist/server/src/serverFunctions/askLLM/getCreateAgentInputWithDefaults.d.ts +1 -1
- package/dist/server/src/serverFunctions/askLLM/getCreateAgentInputWithDefaults.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/getCreateAgentInputWithDefaults.js +9 -2
- package/dist/server/src/serverFunctions/askLLM/getCreateAgentInputWithDefaults.js.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/getFullPrompt.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/getFullPrompt.js +2 -1
- package/dist/server/src/serverFunctions/askLLM/getFullPrompt.js.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/getLLMRequestBody.d.ts +2 -0
- package/dist/server/src/serverFunctions/askLLM/getLLMRequestBody.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/getLLMRequestBody.js +128 -83
- package/dist/server/src/serverFunctions/askLLM/getLLMRequestBody.js.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/getLLMUsageCost.d.ts +1 -0
- package/dist/server/src/serverFunctions/askLLM/getLLMUsageCost.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/getLLMUsageCost.js +21 -12
- package/dist/server/src/serverFunctions/askLLM/getLLMUsageCost.js.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/getOpenAIModelCatalog.d.ts +12 -0
- package/dist/server/src/serverFunctions/askLLM/getOpenAIModelCatalog.d.ts.map +1 -0
- package/dist/server/src/serverFunctions/askLLM/getOpenAIModelCatalog.js +75 -0
- package/dist/server/src/serverFunctions/askLLM/getOpenAIModelCatalog.js.map +1 -0
- package/dist/server/src/serverFunctions/askLLM/getPastMessages.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/getToolResultText.d.ts +5 -0
- package/dist/server/src/serverFunctions/askLLM/getToolResultText.d.ts.map +1 -0
- package/dist/server/src/serverFunctions/askLLM/getToolResultText.js +9 -0
- package/dist/server/src/serverFunctions/askLLM/getToolResultText.js.map +1 -0
- package/dist/server/src/serverFunctions/askLLM/getValidatedAskLLMChatOptions.d.ts +8 -20
- package/dist/server/src/serverFunctions/askLLM/getValidatedAskLLMChatOptions.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/handleToolUseResultConfirmation.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/openAIResponses.d.ts +82 -0
- package/dist/server/src/serverFunctions/askLLM/openAIResponses.d.ts.map +1 -0
- package/dist/server/src/serverFunctions/askLLM/openAIResponses.js +165 -0
- package/dist/server/src/serverFunctions/askLLM/openAIResponses.js.map +1 -0
- package/dist/server/src/serverFunctions/askLLM/prostglesLLMTools/getMCPServerTools.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/prostglesLLMTools/getMcpToolsWithDynamicDescription.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/readFetchStream.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/readFetchStream.js +0 -1
- package/dist/server/src/serverFunctions/askLLM/readFetchStream.js.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/refreshOpenAIModelMetadata.d.ts +3 -0
- package/dist/server/src/serverFunctions/askLLM/refreshOpenAIModelMetadata.d.ts.map +1 -0
- package/dist/server/src/serverFunctions/askLLM/refreshOpenAIModelMetadata.js +44 -0
- package/dist/server/src/serverFunctions/askLLM/refreshOpenAIModelMetadata.js.map +1 -0
- package/dist/server/src/serverFunctions/askLLM/runApprovedTools/runApprovedTools.js +1 -0
- package/dist/server/src/serverFunctions/askLLM/runApprovedTools/runApprovedTools.js.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/saveToolUseResults.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/setupLLMProviders.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/askLLM/setupLLMProviders.js +11 -59
- package/dist/server/src/serverFunctions/askLLM/setupLLMProviders.js.map +1 -1
- package/dist/server/src/serverFunctions/deleteConnection.d.ts +1120 -40
- package/dist/server/src/serverFunctions/deleteConnection.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/getConnectionAndDatabaseConfig.d.ts +1125 -42
- package/dist/server/src/serverFunctions/getConnectionAndDatabaseConfig.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/getNodeTypes.js +16 -48
- package/dist/server/src/serverFunctions/getNodeTypes.js.map +1 -1
- package/dist/server/src/serverFunctions/getNodeTypes.spec.js +60 -0
- package/dist/server/src/serverFunctions/getNodeTypes.spec.js.map +1 -1
- package/dist/server/src/serverFunctions/loadGeneratedWorkspaces/loadGeneratedBarchart.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/loadGeneratedWorkspaces/loadGeneratedBarchart.js +0 -2
- package/dist/server/src/serverFunctions/loadGeneratedWorkspaces/loadGeneratedBarchart.js.map +1 -1
- package/dist/server/src/serverFunctions/loadGeneratedWorkspaces/loadGeneratedMap.d.ts +219 -5
- package/dist/server/src/serverFunctions/loadGeneratedWorkspaces/loadGeneratedMap.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/loadGeneratedWorkspaces/loadGeneratedMap.js +63 -34
- package/dist/server/src/serverFunctions/loadGeneratedWorkspaces/loadGeneratedMap.js.map +1 -1
- package/dist/server/src/serverFunctions/loadGeneratedWorkspaces/loadGeneratedTable.d.ts +11 -231
- package/dist/server/src/serverFunctions/loadGeneratedWorkspaces/loadGeneratedTable.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/loadGeneratedWorkspaces/loadGeneratedTable.js +44 -45
- package/dist/server/src/serverFunctions/loadGeneratedWorkspaces/loadGeneratedTable.js.map +1 -1
- package/dist/server/src/serverFunctions/loadGeneratedWorkspaces/loadGeneratedWorkspaces.d.ts +1 -1
- package/dist/server/src/serverFunctions/loadGeneratedWorkspaces/loadGeneratedWorkspaces.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/loadGeneratedWorkspaces/loadGeneratedWorkspaces.js +29 -14
- package/dist/server/src/serverFunctions/loadGeneratedWorkspaces/loadGeneratedWorkspaces.js.map +1 -1
- package/dist/server/src/serverFunctions/loadGeneratedWorkspaces/loadGeneratedWorkspacesFunction.d.ts +13 -13
- package/dist/server/src/serverFunctions/loadGeneratedWorkspaces/loadGeneratedWorkspacesFunction.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/setFileStorage.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/setFileStorage.js +10 -7
- package/dist/server/src/serverFunctions/setFileStorage.js.map +1 -1
- package/dist/server/src/serverFunctions/stateServerFunctions.d.ts +3852 -1306
- package/dist/server/src/serverFunctions/stateServerFunctions.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/stateServerFunctions.js +2 -0
- package/dist/server/src/serverFunctions/stateServerFunctions.js.map +1 -1
- package/dist/server/src/serverFunctions/userInviteFunctions.d.ts +156 -0
- package/dist/server/src/serverFunctions/userInviteFunctions.d.ts.map +1 -0
- package/dist/server/src/serverFunctions/userInviteFunctions.js +117 -0
- package/dist/server/src/serverFunctions/userInviteFunctions.js.map +1 -0
- package/dist/server/src/serverFunctions/userServerFunctions/userServerFunctions.d.ts +75 -63
- package/dist/server/src/serverFunctions/userServerFunctions/userServerFunctions.d.ts.map +1 -1
- package/dist/server/src/serverFunctions/userServerFunctions/userServerFunctions.js +7 -1
- package/dist/server/src/serverFunctions/userServerFunctions/userServerFunctions.js.map +1 -1
- package/dist/server/src/tableConfig/tableConfig.js +1 -1
- package/dist/server/src/tableConfig/tableConfig.js.map +1 -1
- package/dist/server/src/tableConfig/tableConfigAgenticWorkflow.d.ts.map +1 -1
- package/dist/server/src/tableConfig/tableConfigAgenticWorkflow.js +19 -5
- package/dist/server/src/tableConfig/tableConfigAgenticWorkflow.js.map +1 -1
- package/dist/server/src/tableConfig/tableConfigDatabaseConfig.d.ts +2 -0
- package/dist/server/src/tableConfig/tableConfigDatabaseConfig.d.ts.map +1 -1
- package/dist/server/src/tableConfig/tableConfigDatabaseConfig.js +24 -4
- package/dist/server/src/tableConfig/tableConfigDatabaseConfig.js.map +1 -1
- package/dist/server/src/tableConfig/tableConfigLlm/tableConfigLlm.d.ts.map +1 -1
- package/dist/server/src/tableConfig/tableConfigLlm/tableConfigLlm.js +10 -3
- package/dist/server/src/tableConfig/tableConfigLlm/tableConfigLlm.js.map +1 -1
- package/dist/server/src/tableConfig/tableConfigLlm/tableConfigLlmChats.d.ts.map +1 -1
- package/dist/server/src/tableConfig/tableConfigLlm/tableConfigLlmChats.js +10 -0
- package/dist/server/src/tableConfig/tableConfigLlm/tableConfigLlmChats.js.map +1 -1
- package/dist/server/src/tableConfig/tableConfigLlm/tableConfigLlmExtraRequestData.d.ts.map +1 -1
- package/dist/server/src/tableConfig/tableConfigLlm/tableConfigLlmExtraRequestData.js +0 -1
- package/dist/server/src/tableConfig/tableConfigLlm/tableConfigLlmExtraRequestData.js.map +1 -1
- package/dist/server/src/tableConfig/tableConfigMCPServers.d.ts.map +1 -1
- package/dist/server/src/tableConfig/tableConfigMCPServers.js +6 -1
- package/dist/server/src/tableConfig/tableConfigMCPServers.js.map +1 -1
- package/dist/server/src/tableConfig/tableConfigMigrations.d.ts +1 -1
- package/dist/server/src/tableConfig/tableConfigMigrations.d.ts.map +1 -1
- package/dist/server/src/tableConfig/tableConfigMigrations.js +34 -32
- package/dist/server/src/tableConfig/tableConfigMigrations.js.map +1 -1
- package/dist/server/src/tableConfig/tableConfigUsers.d.ts +37 -23
- package/dist/server/src/tableConfig/tableConfigUsers.d.ts.map +1 -1
- package/dist/server/src/tableConfig/tableConfigUsers.js +46 -15
- package/dist/server/src/tableConfig/tableConfigUsers.js.map +1 -1
- package/dist/server/src/tableConfig/tableConfigWindows.d.ts +15 -7
- package/dist/server/src/tableConfig/tableConfigWindows.d.ts.map +1 -1
- package/dist/server/src/tableConfig/tableConfigWindows.js +23 -3
- package/dist/server/src/tableConfig/tableConfigWindows.js.map +1 -1
- package/dist/server/src/tableHooks/connections.tableHooks.js +2 -2
- package/dist/server/src/tableHooks/connections.tableHooks.js.map +1 -1
- package/dist/server/src/tableHooks/database_configs.tableHooks.d.ts +563 -0
- package/dist/server/src/tableHooks/database_configs.tableHooks.d.ts.map +1 -0
- package/dist/server/src/tableHooks/database_configs.tableHooks.js +24 -0
- package/dist/server/src/tableHooks/database_configs.tableHooks.js.map +1 -0
- package/dist/server/src/tableHooks/llm_credentials.tableHooks.d.ts.map +1 -1
- package/dist/server/src/tableHooks/llm_credentials.tableHooks.js +2 -52
- package/dist/server/src/tableHooks/llm_credentials.tableHooks.js.map +1 -1
- package/dist/server/src/tableHooks/tableHooks.d.ts +5115 -1050
- package/dist/server/src/tableHooks/tableHooks.d.ts.map +1 -1
- package/dist/server/src/tableHooks/tableHooks.js +2 -0
- package/dist/server/src/tableHooks/tableHooks.js.map +1 -1
- package/dist/server/src/tableHooks/users.tableHooks.d.ts +1277 -104
- package/dist/server/src/tableHooks/users.tableHooks.d.ts.map +1 -1
- package/dist/server/src/tableHooks/users.tableHooks.js +1 -0
- package/dist/server/src/tableHooks/users.tableHooks.js.map +1 -1
- package/dist/server/src/testing/cleanupTestServices.d.ts.map +1 -1
- package/dist/server/src/testing/cleanupTestServices.js +40 -21
- package/dist/server/src/testing/cleanupTestServices.js.map +1 -1
- package/dist/server/src/testing/createTestDeployment.d.ts +2 -0
- package/dist/server/src/testing/createTestDeployment.d.ts.map +1 -1
- package/dist/server/src/testing/createTestDeployment.js +15 -1
- package/dist/server/src/testing/createTestDeployment.js.map +1 -1
- package/dist/server/src/testing/ui/fixtures.d.ts +3 -1
- package/dist/server/src/testing/ui/index.d.ts +3 -1
- package/dist/server/src/testing/ui/utils.d.ts +5 -5
- package/dist/server/src/testing/ui/utils.js +15 -11
- package/dist/server/src/testing/waitForTestUserSync.d.ts +6 -0
- package/dist/server/src/testing/waitForTestUserSync.d.ts.map +1 -0
- package/dist/server/src/testing/waitForTestUserSync.js +40 -0
- package/dist/server/src/testing/waitForTestUserSync.js.map +1 -0
- package/dist/server/src/upsertConnection.d.ts +1125 -42
- package/dist/server/src/upsertConnection.d.ts.map +1 -1
- package/dist/server/src/upsertConnection.js +11 -11
- package/dist/server/src/upsertConnection.js.map +1 -1
- package/dist/server/src/utils/logTimedStep.d.ts +2 -0
- package/dist/server/src/utils/logTimedStep.d.ts.map +1 -0
- package/dist/server/src/utils/logTimedStep.js +13 -0
- package/dist/server/src/utils/logTimedStep.js.map +1 -0
- package/package.json +27 -22
- package/sample_schemas/crypto/dist/index.js +9 -0
- package/sample_schemas/crypto/dist/onMount.js +757 -0
- package/sample_schemas/crypto/dist/tableConfig.js +81 -0
- package/sample_schemas/crypto/dist/workspaceConfig.js +262 -0
- package/sample_schemas/crypto/onMount.ts +24 -15
- package/sample_schemas/food_delivery/dist/connection.js +1008 -0
- package/sample_schemas/food_delivery/dist/databaseConfig.js +116 -0
- package/sample_schemas/food_delivery/dist/index.js +17 -0
- package/sample_schemas/food_delivery/dist/onMount.js +132 -0
- package/sample_schemas/food_delivery/dist/workspaceConfig.js +55 -0
- package/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/defineAgenticWorkflow.spec.ts +47 -7
- package/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/defineAgenticWorkflow.ts +39 -27
- package/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/defineAgenticWorkflowHandlers.types.ts +14 -17
- package/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/definitionHandler.ts +1 -0
- package/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/ensureWorkflowIsExecuted.ts +6 -4
- package/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/tableHandlers.ts +111 -76
- package/src/McpHub/ProstglesMcpHub/ProstglesMCPServers/Prostgles/agenticWorkflow/runtimeSdk/workflowConstants.ts +3 -0
- package/client/build/js/199.bundle.js +0 -1
- package/client/build/js/261.bundle.js +0 -2
- package/client/build/js/587.bundle.js +0 -1
- package/client/build/js/deckgl.bundle.js.LICENSE.txt +0 -25
- package/dist/common/KeyObjMap.d.ts +0 -14
- package/dist/common/KeyObjMap.d.ts.map +0 -1
- package/dist/common/KeyObjMap.js +0 -86
- package/dist/common/KeyObjMap.js.map +0 -1
- package/dist/server/src/Alerts/alertRuleSchema.d.ts +0 -76
- package/dist/server/src/Alerts/alertRuleSchema.d.ts.map +0 -1
- package/dist/server/src/Alerts/alertRuleSchema.js +0 -56
- package/dist/server/src/Alerts/alertRuleSchema.js.map +0 -1
- package/dist/server/src/Alerts/resolveAlertValue.d.ts +0 -3
- package/dist/server/src/Alerts/resolveAlertValue.d.ts.map +0 -1
- package/dist/server/src/Alerts/resolveAlertValue.js +0 -59
- package/dist/server/src/Alerts/resolveAlertValue.js.map +0 -1
- package/dist/server/src/ConnectionManager/validateTableInfoLevels.d.ts +0 -3
- package/dist/server/src/ConnectionManager/validateTableInfoLevels.d.ts.map +0 -1
- package/dist/server/src/ConnectionManager/validateTableInfoLevels.js +0 -13
- package/dist/server/src/ConnectionManager/validateTableInfoLevels.js.map +0 -1
- package/dist/server/src/Emails/enqueueEmail.d.ts +0 -23
- package/dist/server/src/Emails/enqueueEmail.d.ts.map +0 -1
- package/dist/server/src/Emails/enqueueEmail.js +0 -25
- package/dist/server/src/Emails/enqueueEmail.js.map +0 -1
- package/dist/server/src/FileStorage/getAnnotationPageText.d.ts.map +0 -1
- package/dist/server/src/FileStorage/getAnnotationPageText.js.map +0 -1
- package/dist/server/src/authConfig/emailProvider/getEmailSenderWithMockTest.d.ts.map +0 -1
- package/dist/server/src/authConfig/emailProvider/getEmailSenderWithMockTest.js.map +0 -1
- package/dist/server/src/serverFunctions/askLLM/refreshModels.d.ts +0 -12
- package/dist/server/src/serverFunctions/askLLM/refreshModels.d.ts.map +0 -1
- package/dist/server/src/serverFunctions/askLLM/refreshModels.js +0 -166
- package/dist/server/src/serverFunctions/askLLM/refreshModels.js.map +0 -1
- package/dist/server/src/tableConfig/migrateCardOptions.d.ts +0 -11
- package/dist/server/src/tableConfig/migrateCardOptions.d.ts.map +0 -1
- package/dist/server/src/tableConfig/migrateCardOptions.js +0 -43
- package/dist/server/src/tableConfig/migrateCardOptions.js.map +0 -1
- /package/client/build/js/{261.bundle.js.LICENSE.txt → 478.bundle.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([[474],{6540(e,t,n){n.d(t,{A:()=>Controller});var i=n(2357);const r=()=>{},s={mode:"preserve"},o={mode:"hard"},a=2,c=3,l=e=>e,u=1;class TransitionManager{constructor(e){this._onTransitionUpdate=e=>{const{time:t,settings:{interpolator:n,startProps:i,endProps:r,duration:o,easing:a}}=e,c=a(t/o),l=n.interpolateProps(i,r,c);this.propsInTransition=this.getControllerState({...this.props,...l},s).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new i.A(e.timeline),this.onViewStateChange=e.onViewStateChange||r,this.onStateChange=e.onStateChange||r}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let t=!1;const n=this.props;if(this.props=e,!n||this._shouldIgnoreViewportChange(n,e))return!1;if(this._isTransitionEnabled(e)){let i=n;if(this.transition.inProgress){const{interruption:e,endProps:t}=this.transition.settings;i={...n,...e===a?t:this.propsInTransition||n}}this._triggerTransition(i,e),t=!0}else this.transition.cancel();return t}updateTransition(){this.transition.update()}_isTransitionEnabled(e){const{transitionDuration:t,transitionInterpolator:n}=e;return(t>0||"auto"===t)&&Boolean(n)}_isUpdateDueToCurrentTransition(e){return!(!this.transition.inProgress||!this.propsInTransition)&&this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition)}_shouldIgnoreViewportChange(e,t){if(this.transition.inProgress){return this.transition.settings.interruption===c||this._isUpdateDueToCurrentTransition(t)}return!this._isTransitionEnabled(t)||t.transitionInterpolator.arePropsEqual(e,t)}_triggerTransition(e,t){const n=this.getControllerState(e,s),i=this.getControllerState(t,o).shortestPathFrom(n),r=t.transitionInterpolator,a=r.getDuration?r.getDuration(e,t):t.transitionDuration;if(0===a)return;const c=r.initializeProps(e,i);this.propsInTransition={};const d={duration:a,easing:t.transitionEasing||l,interpolator:r,interruption:t.transitionInterruption||u,startProps:c.start,endProps:c.end,onStart:t.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(t.onTransitionInterrupt),onEnd:this._onTransitionEnd(t.onTransitionEnd)};this.transition.start(d),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return t=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(t)}}}var d=n(70053),h=n(7914),f=n(45249);const p={transitionDuration:0},g=e=>1-(1-e)*(1-e),m=e=>1===e?1:1-Math.pow(2,-10*e),v=["wheel"],y=["panstart","panmove","panend"],b=["pinchstart","pinchmove","pinchend"],_=["multipanstart","multipanmove","multipanend"],x=["dblclick"],w=["dblclickdragstart","dblclickdragmove","dblclickdragend","dblclickdragcancel"],P=["keydown"],C={};class Controller{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this._multiPanMode=null,this._multiPanStartCenter=null,this._doubleClickDragAnchor=null,this._suppressDoubleClickUntil=0,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.doubleClickDragZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.multiTouchDrag=null,this.trackpadGesture=!1,this.zoomAround="pointer",this.keyboard=!0,this.transitionManager=new TransitionManager({...e,getControllerState:(t,n)=>new this.ControllerState({...t,constraintContext:n,makeViewport:e.makeViewport}),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport,this.pickPosition=e.pickPosition}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(const e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;const t=this._eventStartBlocked;switch(e.type){case"panstart":return!t&&this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return!(t||!this._isTrackpadGestureAllowed(e))&&this._onPinchStart(e);case"pinchmove":return!!this._isTrackpadGestureAllowed(e)&&this._onPinch(e);case"pinchend":return!!this._isTrackpadGestureAllowed(e)&&this._onPinchEnd(e);case"multipanstart":return!t&&this._onMultiPanStart(e);case"multipanmove":return this._onMultiPan(e);case"multipanend":return this._onMultiPanEnd(e);case"dblclick":return this._onDoubleClick(e);case"dblclickdragstart":return!t&&this._onDoubleClickDragStart(e);case"dblclickdragmove":return this._onDoubleClickDrag(e);case"dblclickdragend":case"dblclickdragcancel":return this._onDoubleClickDragEnd(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){const{x:t,y:n}=this.props,{offsetCenter:i}=e;return[i.x-t,i.y-n]}getZoomPosition(e){if("pointer"===this.zoomAround)return e;const t=this.makeViewport(this.controllerState.getViewportProps()),[n,i]=(0,f.VJ)(t.center,t.pixelProjectionMatrix);return[n,i]}isPointInBounds(e,t){const{width:n,height:i}=this.props;if(t&&t.handled)return!1;const r=e[0]>=0&&e[0]<=n&&e[1]>=0&&e[1]<=i;return r&&t&&t.stopPropagation(),r}isFunctionKeyPressed(e){const{srcEvent:t}=e;return Boolean(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){const t=setTimeout(()=>{this._eventStartBlocked===t&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=t}setProps(e){void 0===e.maxBoundsPadding&&(e.maxBoundsPadding=null),e.dragMode&&(this.dragMode=e.dragMode);const t=this.props;this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);const{inertia:n}=e;this.inertia=Number.isFinite(n)?n:!0===n?300:0;const{scrollZoom:i=!0,dragPan:r=!0,dragRotate:s=!0,doubleClickZoom:o=!0,doubleClickDragZoom:a=!1,touchZoom:c=!0,touchRotate:l=!1,multiTouchDrag:u=(l?"rotate":null),trackpadGesture:d=!1,zoomAround:f="pointer",keyboard:p=!0}=e,g=Boolean(this.onViewStateChange);this.toggleEvents(v,g&&i),this.toggleEvents(y,g),this.toggleEvents(b,g&&(c||"rotate"===u)),this.toggleEvents(_,g&&Boolean(u)),this.toggleEvents(x,g&&o),this.toggleEvents(w,g&&a),this.toggleEvents(P,g&&p),this.scrollZoom=i,this.dragPan=r,this.dragRotate=s,this.doubleClickZoom=o,this.doubleClickDragZoom=a,this.touchZoom=c,this.touchRotate="rotate"===u,this.multiTouchDrag=u,this.trackpadGesture=d,this.zoomAround=f,this.keyboard=p;if((!t||t.height!==e.height||t.width!==e.width||t.maxBounds!==e.maxBounds||t.maxBoundsPadding!==e.maxBoundsPadding)&&e.maxBounds){const t=new this.ControllerState({...e,makeViewport:this.makeViewport}),n=t.getViewportProps();Object.keys(n).some(t=>!(0,h.b)(n[t],e[t],1))&&this.updateViewport(t)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,t){this.eventManager&&e.forEach(e=>{this._events[e]!==t&&(this._events[e]=t,t?this.eventManager.on(e,this.handleEvent):this.eventManager.off(e,this.handleEvent))})}updateViewport(e,t=null,n={}){const i={...e.getViewportProps(),...t},r=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(n),r){const e=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:i,interactionState:this._interactionState,oldViewState:e,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_getConstraintContext(e,t){return this.props.rubberBand?{mode:"update"===t?"elastic":"end"===t?"rebound":"hard"}:{mode:"hard"}}_getReboundTransition(e,t){if("rebound"!==e.mode)return null;const n=t.getViewportProps();return Object.keys(n).some(e=>!(0,h.b)(this.props[e],n[e],1))?{...this._getTransitionProps(),transitionDuration:300,transitionEasing:m}:null}_onPanStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||"pan"===this.dragMode)&&(n=!n);const i=n?"pan":"rotate",r=this._getConstraintContext(i,"start"),s=n?this.controllerState.panStart({pos:t},r):this.controllerState.rotateStart({pos:t},r);return this._panMove=n,this.updateViewport(s,p,{isDragging:!0}),!0}_onPan(e){return!!this.isDragging()&&(this._panMove?this._onPanMove(e):this._onPanRotate(e))}_onPanEnd(e){return!!this.isDragging()&&(this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e))}_onPanMove(e){if(!this.dragPan)return!1;const t=this.getCenter(e),n=this.controllerState.pan({pos:t},this._getConstraintContext("pan","update"));return this.updateViewport(n,p,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){const{inertia:t}=this;if(this.dragPan&&t&&e.velocity){const n=this.getCenter(e),i=[n[0]+e.velocityX*t/2,n[1]+e.velocityY*t/2],r=this.controllerState.pan({pos:i}).panEnd();this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:g},{isDragging:!1,isPanning:!0})}else{const e=this.controllerState,t=this._getConstraintContext("pan","end"),n=e.panEnd(t),i=this._getReboundTransition(t,n);this.updateViewport(n,i,{isDragging:!1,isPanning:Boolean(i)})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;const t=this.getCenter(e),n=this.controllerState.rotate({pos:t},this._getConstraintContext("rotate","update"));return this.updateViewport(n,p,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){const{inertia:t}=this;if(this.dragRotate&&t&&e.velocity){const n=this.getCenter(e),i=[n[0]+e.velocityX*t/2,n[1]+e.velocityY*t/2],r=this.controllerState.rotate({pos:i}).rotateEnd();this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:g},{isDragging:!1,isRotating:!0})}else{const e=this.controllerState,t=this._getConstraintContext("rotate","end"),n=e.rotateEnd(t),i=this._getReboundTransition(t,n);this.updateViewport(n,i,{isDragging:!1,isRotating:Boolean(i)})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;if(this.trackpadGesture&&"mouse"!==e.device)return!1;const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;e.srcEvent.preventDefault();const{speed:n=.01,smooth:i=!1}=!0===this.scrollZoom?{}:this.scrollZoom,{delta:r}=e;let s=2/(1+Math.exp(-Math.abs(r*n)));r<0&&0!==s&&(s=1/s);const o=this.getZoomPosition(t),a=i?{...this._getTransitionProps({around:o}),transitionDuration:250}:p,c=this.controllerState.zoom({pos:o,scale:s});return this.updateViewport(c,a,{isZooming:!0,isPanning:!0}),i||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){const{multiTouchDrag:t}=this;if(!t||!this._isMultiPanEventAllowed(e,t))return!1;const n=e.offsetCenter;if(!this.isPointInBounds(this.getCenter(e),e))return!1;const i="trackpad"===e.pointerType,r={x:n.x-(i?0:e.deltaX),y:n.y-(i?0:e.deltaY)},s={...e,offsetCenter:r},o=this.getCenter(s),a="pan"===t?this.controllerState.panStart({pos:o},this._getConstraintContext("pan","start")):this.controllerState.rotateStart({pos:o},this._getConstraintContext("rotate","start"));return this._multiPanMode=t,this._multiPanStartCenter=r,this.updateViewport(a,p,{isDragging:!0}),!0}_onMultiPan(e){const{mode:t,event:n}=this._getMultiPanEvent(e);return!!(t&&n&&this.isDragging())&&("pan"===t?this._onPanMove(n):this._onPanRotate(n))}_onMultiPanEnd(e){const{mode:t,event:n}=this._getMultiPanEvent(e);if(!t||!n||!this.isDragging())return this._resetMultiPan(),!1;const i="pan"===t?this._onPanMoveEnd(n):this._onPanRotateEnd(n);return this._resetMultiPan(),i}_isTrackpadGestureAllowed(e){return"trackpad"!==e.pointerType||this.trackpadGesture}_isMultiPanEventAllowed(e,t){return"trackpad"===e.pointerType?this.trackpadGesture&&("pan"===t?this.dragPan:this.dragRotate):"touch"===e.pointerType&&("pan"===t?this.dragPan:this.dragRotate)}_getMultiPanEvent(e){const t=this._multiPanMode,n=this._multiPanStartCenter;return t&&n?{mode:t,event:{...e,offsetCenter:{x:n.x+e.deltaX,y:n.y+e.deltaY}}}:{mode:null,event:null}}_resetMultiPan(){this._multiPanMode=null,this._multiPanStartCenter=null}_onPinchStart(e){this._doubleClickDragAnchor=null;const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const n=this.controllerState.zoomStart({pos:this.getZoomPosition(t)},this._getConstraintContext("zoom","start")).rotateStart({pos:t},this._getConstraintContext("rotate","start"));return C._startPinchRotation=e.rotation,C._lastPinchEvent=e,this.updateViewport(n,p,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate)return!1;if(!this.isDragging())return!1;let t=this.controllerState;if(this.touchZoom){const{scale:n}=e,i=this.getCenter(e);t=t.zoom({pos:this.getZoomPosition(i),scale:n},this._getConstraintContext("zoom","update"))}if(this.touchRotate){const{rotation:n}=e;t=t.rotate({deltaAngleX:C._startPinchRotation-n},this._getConstraintContext("rotate","update"))}return this.updateViewport(t,p,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),C._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;const{inertia:t}=this,{_lastPinchEvent:n}=C;if(this.touchZoom&&t&&n&&e.scale!==n.scale){const i=this.getCenter(e),r=this.getZoomPosition(i);let s=this.controllerState.rotateEnd();const o=Math.log2(e.scale),a=(o-Math.log2(n.scale))/(e.deltaTime-n.deltaTime),c=Math.pow(2,o+a*t/2);s=s.zoom({pos:r,scale:c}).zoomEnd(),this.updateViewport(s,{...this._getTransitionProps({around:r}),transitionDuration:t,transitionEasing:g},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(t)}else{const e=this.controllerState,t=this._getConstraintContext("zoom","end"),n=this._getConstraintContext("rotate","end"),i=e.zoomEnd(t).rotateEnd(n),r=this._getReboundTransition(this.touchZoom?t:n,i);this.updateViewport(i,r,{isDragging:!1,isPanning:Boolean(r)&&this.touchZoom,isZooming:Boolean(r)&&this.touchZoom,isRotating:Boolean(r)&&this.touchRotate})}return C._startPinchRotation=null,C._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom)return!1;if(Date.now()<this._suppressDoubleClickUntil)return!1;const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const n=this.isFunctionKeyPressed(e),i=this.getZoomPosition(t),r=this.controllerState.zoom({pos:i,scale:n?.5:2});return this.updateViewport(r,this._getTransitionProps({around:i}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onDoubleClickDragStart(e){if(!this.doubleClickDragZoom)return this._doubleClickDragAnchor=null,!1;const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return this._doubleClickDragAnchor=null,!1;this._doubleClickDragAnchor=this.getZoomPosition(t);let n=this.controllerState.zoomStart({pos:this._doubleClickDragAnchor},this._getConstraintContext("zoom","start"));return 1!==e.scale&&(n=n.zoom({pos:this._doubleClickDragAnchor,scale:e.scale},this._getConstraintContext("zoom","update"))),this.updateViewport(n,p,{isDragging:!0,isPanning:!0,isZooming:!0}),!0}_onDoubleClickDrag(e){const t=this._doubleClickDragAnchor;if(!t)return!1;const n=this.controllerState.zoom({pos:t,scale:e.scale},this._getConstraintContext("zoom","update"));return this.updateViewport(n,p,{isDragging:!0,isPanning:!0,isZooming:!0}),!0}_onDoubleClickDragEnd(e){if(!this._doubleClickDragAnchor)return!1;this._doubleClickDragAnchor=null;const t=this.controllerState,n=this._getConstraintContext("zoom","end"),i=t.zoomEnd(n),r=this._getReboundTransition(n,i);return this.updateViewport(i,r,{isDragging:!1,isPanning:Boolean(r),isZooming:Boolean(r)}),this._suppressDoubleClickUntil=Date.now()+100,this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;const t=this.isFunctionKeyPressed(e),{zoomSpeed:n,moveSpeed:i,rotateSpeedX:r,rotateSpeedY:s}=!0===this.keyboard?{}:this.keyboard,{controllerState:o}=this;let a;const c={};switch(e.srcEvent.code){case"Minus":a=t?o.zoomOut(n).zoomOut(n):o.zoomOut(n),c.isZooming=!0;break;case"Equal":a=t?o.zoomIn(n).zoomIn(n):o.zoomIn(n),c.isZooming=!0;break;case"ArrowLeft":t?(a=o.rotateLeft(r),c.isRotating=!0):(a=o.moveLeft(i),c.isPanning=!0);break;case"ArrowRight":t?(a=o.rotateRight(r),c.isRotating=!0):(a=o.moveRight(i),c.isPanning=!0);break;case"ArrowUp":t?(a=o.rotateUp(s),c.isRotating=!0):(a=o.moveUp(i),c.isPanning=!0);break;case"ArrowDown":t?(a=o.rotateDown(s),c.isRotating=!0):(a=o.moveDown(i),c.isPanning=!0);break;default:return!1}return this.updateViewport(a,this._getTransitionProps(),c),!0}_getTransitionProps(e){const{transition:t}=this;return t&&t.transitionInterpolator?e?{...t,transitionInterpolator:new d.A({...e,...t.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:t:p}}},58532(e,t,n){n.d(t,{CI:()=>s,GT:()=>r,jo:()=>o});var i=n(33945);function r(e,t,n){const i=e-t;return i&&Number.isFinite(i)?t+i*n/(n+Math.abs(i)):t}function s(e,t,n){const r=(0,i.E9)((0,i.rk)(n?.left??0),e),s=(0,i.E9)((0,i.rk)(n?.right??0),e),o=(0,i.E9)((0,i.rk)(n?.top??0),t);return{x:r,y:o,width:e-r-s,height:t-o-(0,i.E9)((0,i.rk)(n?.bottom??0),t)}}function o(e,t,n){let[i,r]=e.project(t);return i=Number.isFinite(i)?i:e.width/2,r=Number.isFinite(r)?r:e.height/2,{left:i-n.x,right:n.x+n.width-i,top:r-n.y,bottom:n.y+n.height-r}}},60676(e,t,n){n.d(t,{A:()=>ViewState});const i=Symbol("constraintAround");class ViewState{constructor(e,t,n,i){this.makeViewport=n,this._viewportProps=this.applyConstraints(e,i),this._state=t}getViewportProps(){return this._viewportProps}getState(){return this._state}}n.d(t,["y",0,i])},43411(e,t,n){n.d(t,{A:()=>o,k:()=>s});var i=n(3459);let r={};function s(e){r=e}function o(e,t,n,s){i.A.level>0&&r[e]&&r[e].call(null,t,n,s)}},59452(e,t,n){var i=n(45069),r=n(43411),s=n(38055),o=n(12897);class CompositeLayer extends i.A{get isComposite(){return!0}get isDrawable(){return!1}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(e=>e.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(e){}setState(e){super.setState(e),this.setNeedsUpdate()}getPickingInfo({info:e}){const{object:t}=e;return t&&t.__source&&t.__source.parent&&t.__source.parent.id===this.id?(e.object=t.__source.object,e.index=t.__source.index,e):e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,t){return t&&t.length}getSubLayerClass(e,t){const{_subLayerProps:n}=this.props;return n&&n[e]&&n[e].type||t}getSubLayerRow(e,t,n){return e.__source={parent:this,object:t,index:n},e}getSubLayerAccessor(e){if("function"==typeof e){const t={index:-1,data:this.props.data,target:[]};return(n,i)=>n&&n.__source?(t.index=n.__source.index,e(n.__source.object,t)):e(n,i)}return e}getSubLayerProps(e={}){const{opacity:t,pickable:n,visible:i,parameters:r,getPolygonOffset:s,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:u,coordinateOrigin:d,wrapLongitude:h,positionFormat:f,modelMatrix:p,extensions:g,fetch:m,operation:v,_subLayerProps:y}=this.props,b={id:"",updateTriggers:{},opacity:t,pickable:n,visible:i,parameters:r,getPolygonOffset:s,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:u,coordinateOrigin:d,wrapLongitude:h,positionFormat:f,modelMatrix:p,extensions:g,fetch:m,operation:v},_=y&&e.id&&y[e.id],x=_&&_.updateTriggers,w=e.id||"sublayer";if(_){const t=this.props[o.fW],n=e.type?e.type._propTypes:{};for(const e in _){const i=n[e]||t[e];i&&"accessor"===i.type&&(_[e]=this.getSubLayerAccessor(_[e]))}}Object.assign(b,e,_),b.id=`${this.props.id}-${w}`,b.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...x};for(const e of g){const t=e.getSubLayerProps.call(this,e);t&&Object.assign(b,t,{updateTriggers:Object.assign(b.updateTriggers,t.updateTriggers)})}return b}_updateAutoHighlight(e){for(const t of this.getSubLayers())t.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,t){let n=this.internalState.subLayers;const i=!n||this.needsUpdate();if(i){const e=this.renderLayers();n=(0,s.B)(e,Boolean),this.internalState.subLayers=n}(0,r.A)("compositeLayer.renderLayers",this,i,n);for(const e of n)e.parent=this}}CompositeLayer.layerName="CompositeLayer";const a=CompositeLayer;n.d(t,["A",0,a])},33517(e,t,n){n.d(t,{A:()=>lt});let i=1,r=1;class Timeline{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){const{delay:t=0,duration:n=Number.POSITIVE_INFINITY,rate:r=1,repeat:s=1}=e,o=i++,a={time:0,delay:t,duration:n,rate:r,repeat:s};return this._setChannelTime(a,this.time),this.channels.set(o,a),o}removeChannel(e){this.channels.delete(e);for(const[t,n]of this.animations)n.channel===e&&this.detachAnimation(t)}isFinished(e){const t=this.channels.get(e);return void 0!==t&&this.time>=t.delay+t.duration*t.repeat}getTime(e){if(void 0===e)return this.time;const t=this.channels.get(e);return void 0===t?-1:t.time}setTime(e){this.time=Math.max(0,e);const t=this.channels.values();for(const e of t)this._setChannelTime(e,this.time);const n=this.animations.values();for(const e of n){const{animation:t,channel:n}=e;t.setTime(this.getTime(n))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){const n=r++;return this.animations.set(n,{animation:e,channel:t}),e.setTime(this.getTime(t)),n}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(-1===this.lastEngineTime&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){const n=t-e.delay;n>=e.duration*e.repeat?e.time=e.duration*e.rate:(e.time=Math.max(0,n)%e.duration,e.time*=e.rate)}}var s=n(5959);const o=[n(3065).A],a=["vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)","vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)","vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)","fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)"],c=[];function l(e){const t=s._P.getDefaultShaderAssembler(e);for(const e of o)t.addDefaultModule(e);t._hookFunctions.length=0;const n="glsl"===e?a:c;for(const e of n)t.addShaderHook(e);return t}const u="layout(std140) uniform layerUniforms {\n uniform float opacity;\n} layer;\n",d={name:"layer",source:"struct LayerUniforms {\n opacity: f32,\n};\n\n@group(0) @binding(auto)\nvar<uniform> layer: LayerUniforms;\n",vs:u,fs:u,getUniforms:e=>({opacity:Math.pow(e.opacity,1/2.2)}),uniformTypes:{opacity:"f32"}};var h=n(12897),f=n(3459),p=n(43411),g=n(38055),m=n(30568),v=n(22662);class Resource{constructor(e,t,n){this._loadCount=0,this._subscribers=new Set,this.id=e,this.context=n,this.setData(t)}subscribe(e){this._subscribers.add(e)}unsubscribe(e){this._subscribers.delete(e)}inUse(){return this._subscribers.size>0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,t){if(e===this._data&&!t)return;this._data=e;const n=++this._loadCount;let i=e;"string"==typeof e&&(i=(0,v.H)(e)),i instanceof Promise?(this.isLoaded=!1,this._loader=i.then(e=>{this._loadCount===n&&(this.isLoaded=!0,this._error=void 0,this._content=e)}).catch(e=>{this._loadCount===n&&(this.isLoaded=!0,this._error=e||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(const e of this._subscribers)e.onChange(this.getData())}}class ResourceManager{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return!!e.startsWith(this.protocol)||e in this._resources}add({resourceId:e,data:t,forceUpdate:n=!1,persistent:i=!0}){let r=this._resources[e];r?r.setData(t,n):(r=new Resource(e,t,this._context),this._resources[e]=r),r.persistent=i}remove(e){const t=this._resources[e];t&&(t.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){const t=this._consumers[e];if(t){for(const e in t){const n=t[e],i=this._resources[n.resourceId];i&&i.unsubscribe(n)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:t,consumerId:n,requestId:i="default"}){const{_resources:r,protocol:s}=this;e.startsWith(s)&&(r[e=e.replace(s,"")]||this.add({resourceId:e,data:null,persistent:!1}));const o=r[e];if(this._track(n,i,o,t),o)return o.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(const e in this._resources)this._resources[e].delete()}_track(e,t,n,i){const r=this._consumers,s=r[e]=r[e]||{};let o=s[t];const a=o&&o.resourceId&&this._resources[o.resourceId];a&&(a.unsubscribe(o),this.prune()),n&&(o?(o.onChange=i,o.resourceId=n.id):o={onChange:i,resourceId:n.id},s[t]=o,n.subscribe(o))}_prune(){this._pruneRequest=null;for(const e of Object.keys(this._resources)){const t=this._resources[e];t.persistent||t.inUse()||(t.delete(),delete this._resources[e])}}}var y=n(47345);class LayerManager{constructor(e,t){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=e=>{(0,p.A)("layerManager.activateViewport",this,e),e&&(this.context.viewport=e)};const{deck:n,stats:i,viewport:r,timeline:s}=t||{};this.layers=[],this.resourceManager=new ResourceManager({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:n,shaderAssembler:l(e?.info?.shadingLanguage||"glsl"),defaultShaderModules:[d],renderPass:void 0,stats:i||new m.A({id:"deck.gl"}),viewport:r||new y.A({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:s||new Timeline,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(const e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(const n of this.layers){const i=n.getNeedsRedraw(e);t=t||i}return t}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(t=>e.find(e=>0===t.id.indexOf(e))):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,t){(0,p.A)("layerManager.setLayers",this,t,e),this._lastRenderedLayers=e;const n=(0,g.B)(e,Boolean);for(const e of n)e.context=this.context;this._updateLayers(this.layers,n)}updateLayers(){const e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){const{defaultShaderModules:t}=this.context;t.find(t=>t.name===e.name)||(t.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){const{defaultShaderModules:t}=this.context,n=t.findIndex(t=>t.name===e.name);n>=0&&(t.splice(n,1),this._defaultShaderModulesChanged=!0)}_handleError(e,t,n){n.raiseError(t,`${e} of ${n}`)}_updateLayers(e,t){const n={};for(const t of e)n[t.id]?f.A.warn(`Multiple old layers with same id ${t.id}`)():n[t.id]=t;if(this._defaultShaderModulesChanged){for(const t of e)t.setNeedsUpdate(),t.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}const i=[];this._updateSublayersRecursively(t,n,i),this._finalizeOldLayers(n);let r=!1;for(const e of i)if(e.hasUniformTransition()){r=`Uniform transition in ${e}`;break}this._needsUpdate=r,this.layers=i}_updateSublayersRecursively(e,t,n){for(const i of e){i.context=this.context;const e=t[i.id];null===e&&f.A.warn(`Multiple new layers with same id ${i.id}`)(),t[i.id]=null;let r=null;try{this._debug&&e!==i&&i.validateProps(),e?(this._transferLayerState(e,i),this._updateLayer(i)):this._initializeLayer(i),n.push(i),r=i.isComposite?i.getSubLayers():null}catch(e){this._handleError("matching",e,i)}r&&this._updateSublayersRecursively(r,t,n)}}_finalizeOldLayers(e){for(const t in e){const n=e[t];n&&this._finalizeLayer(n)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=h.VD.INITIALIZED}catch(t){this._handleError("initialization",t,e)}}_transferLayerState(e,t){t._transferState(e),t.lifecycle=h.VD.MATCHED,t!==e&&(e.lifecycle=h.VD.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(t){this._handleError("update",t,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=h.VD.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=h.VD.FINALIZED}catch(t){this._handleError("finalization",t,e)}}}var b=n(7914);const _="default-canvas";class ViewManager{constructor(e){this.views=[],this.width=100,this.height=100,this.viewState={},this.controllers={},this.timeline=e.timeline,this._viewports=[],this._viewportMap={},this._isUpdating=!1,this._needsRedraw="First render",this._needsUpdate="Initialize",this._eventManager=e.eventManager,this._eventManagers=e.eventManagers||{},this._viewEventManagers={},this._eventCallbacks={onViewStateChange:e.onViewStateChange,onInteractionStateChange:e.onInteractionStateChange},this._pickPosition=e.pickPosition,this._getCanvasContext=e.getCanvasContext,Object.seal(this),this.setProps(e)}finalize(){for(const e in this.controllers){const t=this.controllers[e];t&&t.finalize()}this.controllers={}}needsRedraw(e={clearRedrawFlags:!1}){const t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e,this._needsRedraw=this._needsRedraw||e}updateViewStates(){for(const e in this.controllers){const t=this.controllers[e];t&&t.updateTransition()}}getViewports(e){return e?this._viewports.filter(t=>{const n=!e.canvasId||this.getCanvasId(t.id)===e.canvasId,i=!("x"in e)||t.containsPixel(e);return n&&i}):this._viewports}getViews(){const e={};return this.views.forEach(t=>{e[t.id]=t}),e}getView(e){return this.views.find(t=>t.id===e)}getViewState(e){const t="string"==typeof e?this.getView(e):e,n=t&&this.viewState[t.getViewStateId()]||this.viewState;return t?t.filterViewState(n):n}getViewport(e){return this._viewportMap[e]}getCanvasId(e){const t="string"==typeof e?this.getView(e):e;return t?this._viewEventManagers[t.id]?.canvasId||this._getCanvasIdFromView(t):void 0}unproject(e,t){const n=this.getViewports(),i={x:e[0],y:e[1]};for(let r=n.length-1;r>=0;--r){const s=n[r];if(s.containsPixel(i)){const n=e.slice();return n[0]-=s.x,n[1]-=s.y,s.unproject(n,t)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),"pickPosition"in e&&(this._pickPosition=e.pickPosition),"eventManagers"in e&&this._setEventManagers(e.eventManagers||{}),this._isUpdating||this._update()}_update(){this._isUpdating=!0;try{this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports())}finally{this._isUpdating=!1}}_hasViewState(e){const t=e.props.viewState;if(t&&"object"==typeof t&&!t.id)return!0;if(this.viewState[e.getViewStateId()])return!0;const n=Object.values(this.viewState);return 0===n.length||n.some(e=>!e||"object"!=typeof e||Array.isArray(e))}_setSize(e,t){e===this.width&&t===this.height||(this.width=e,this.height=t,this.setNeedsUpdate("Size changed"))}_setViews(e){e=(0,g.B)(e,Boolean);this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){if(e){!(0,b.b)(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e}else f.A.warn("missing `viewState` or `initialViewState`")()}_setEventManagers(e){this._eventManagers!==e&&(this._eventManagers=e,this.setNeedsUpdate("eventManagers changed"))}_getCanvasIdFromView(e){return e.props.canvasId||this._getCanvasContext?.(e.id)?.id||_}_getCanvasDimensions(e){const t=this._getCanvasContext?.(e.id),[n,i]=t?.getCSSSize()||[this.width,this.height];return{width:n,height:i}}_getViewEventManager(e){const t=this.getCanvasId(e)||_;return{canvasId:t,eventManager:this._eventManagers[t]||this._eventManager}}_startViewportRebuild(){const e=this.controllers,t=this._viewEventManagers;return this._viewports=[],this.controllers={},this._viewEventManagers={},{oldControllers:e,oldViewEventManagers:t}}_getReusableController(e,t,n){return!e||t?.canvasId===n.canvasId&&t?.eventManager===n.eventManager?e:(e.finalize(),null)}_createController(e,t){return new(0,t.type)({timeline:this.timeline,eventManager:this._getViewEventManager(e).eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:t=>this.getView(e.id)?.makeViewport({viewState:t,...this._getCanvasDimensions(e)}),pickPosition:(t,n)=>this._pickPosition?.(t,n,e.id)})}_updateController(e,t,n,i){const r=e.controller;if(r&&n){const s={...t,...r,id:e.id,x:n.x,y:n.y,width:n.width,height:n.height};return i&&i.constructor===r.type||(i=this._createController(e,s)),i&&i.setProps(s),i}return null}_rebuildViewports(){const{views:e}=this,{oldControllers:t,oldViewEventManagers:n}=this._startViewportRebuild();let i=!1;for(let r=e.length;r--;){const s=e[r],{width:o,height:a}=this._getCanvasDimensions(s),c=this._getViewEventManager(s);this._viewEventManagers[s.id]=c;const l=this.getViewState(s),u=s.makeViewport({viewState:l,width:o,height:a});let d=this._getReusableController(t[s.id],n[s.id],c),h=Boolean(s.controller);h&&!this._hasViewState(s)&&(h=!1),h&&!d&&(i=!0),!i&&h||!d||(d.finalize(),d=null),this.controllers[s.id]=h?this._updateController(s,l,u,d):null,u&&this._viewports.unshift(u)}for(const e in t){const n=t[e];n&&!this.controllers[e]&&n.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,t){return e.length!==t.length||e.some((n,i)=>!e[i].equals(t[i]))}}var x=n(75524);const w=[255,255,255],P=1;let C=0;class AmbientLight{constructor(e={}){this.type="ambient";const{color:t=w}=e,{intensity:n=P}=e;this.id=e.id||"ambient-"+C++,this.color=t,this.intensity=n}}var S=n(87597);const L=[255,255,255],A=1,E=[0,0,-1];let T=0;class DirectionalLight{constructor(e={}){this.type="directional";const{color:t=L}=e,{intensity:n=A}=e,{direction:i=E}=e,{_shadow:r=!1}=e;this.id=e.id||"directional-"+T++,this.color=t,this.intensity=n,this.type="directional",this.direction=new S.P(i).normalize().toArray(),this.shadow=r}getProjectedLight(e){return this}}var M=n(31886),I=n(98043);class ShadowPass extends I.A{constructor(e,t){super(e,t);const n=e.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),i=e.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[n],depthStencilAttachment:i})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){const t=this.fbo,n=this.device.canvasContext.cssToDeviceRatio(),i=e.viewports[0],r=i.width*n,s=i.height*n;r===t.width&&s===t.height||t.resize({width:r,height:s}),super.render({...e,clearColor:[1,1,1,1],target:t,pass:"shadow"})}getLayerParameters(e,t,n){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal",depthBias:0}}shouldDrawLayer(e){return!1!==e.props.shadowEnabled}getShaderModuleProps(e,t,n){return{shadow:{project:n.project,drawToShadowMap:!0},lighting:{enabled:!1}}}}var B=n(9350),k=n(4782),R=n(82417),O=n(45249),z=n(74334);const D="\nlayout(std140) uniform shadowUniforms {\n bool drawShadowMap;\n bool useShadowMap;\n vec4 color;\n highp int lightId;\n float lightCount;\n mat4 viewProjectionMatrix0;\n mat4 viewProjectionMatrix1;\n vec4 projectCenter0;\n vec4 projectCenter1;\n} shadow;\n",F=`\n${D}\n\nconst int max_lights = 2;\n\nout vec3 shadow_vPosition[max_lights];\n\nvec4 shadow_setVertexPosition(vec4 position_commonspace) {\n mat4 viewProjectionMatrices[max_lights];\n viewProjectionMatrices[0] = shadow.viewProjectionMatrix0;\n viewProjectionMatrices[1] = shadow.viewProjectionMatrix1;\n vec4 projectCenters[max_lights];\n projectCenters[0] = shadow.projectCenter0;\n projectCenters[1] = shadow.projectCenter1;\n\n if (shadow.drawShadowMap) {\n return project_common_position_to_clipspace(position_commonspace, viewProjectionMatrices[shadow.lightId], projectCenters[shadow.lightId]);\n }\n if (shadow.useShadowMap) {\n for (int i = 0; i < max_lights; i++) {\n if(i < int(shadow.lightCount)) {\n vec4 shadowMap_position = project_common_position_to_clipspace(position_commonspace, viewProjectionMatrices[i], projectCenters[i]);\n shadow_vPosition[i] = (shadowMap_position.xyz / shadowMap_position.w + 1.0) / 2.0;\n }\n }\n }\n return gl_Position;\n}\n\n`,N=`\n${D}\n\nconst int max_lights = 2;\nuniform sampler2D shadow_uShadowMap0;\nuniform sampler2D shadow_uShadowMap1;\n\nin vec3 shadow_vPosition[max_lights];\n\nconst vec4 bitPackShift = vec4(1.0, 255.0, 65025.0, 16581375.0);\nconst vec4 bitUnpackShift = 1.0 / bitPackShift;\nconst vec4 bitMask = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n\nfloat shadow_getShadowWeight(vec3 position, sampler2D shadowMap) {\n vec4 rgbaDepth = texture(shadowMap, position.xy);\n\n float z = dot(rgbaDepth, bitUnpackShift);\n return smoothstep(0.001, 0.01, position.z - z);\n}\n\nvec4 shadow_filterShadowColor(vec4 color) {\n if (shadow.drawShadowMap) {\n vec4 rgbaDepth = fract(gl_FragCoord.z * bitPackShift);\n rgbaDepth -= rgbaDepth.gbaa * bitMask;\n return rgbaDepth;\n }\n if (shadow.useShadowMap) {\n float shadowAlpha = 0.0;\n shadowAlpha += shadow_getShadowWeight(shadow_vPosition[0], shadow_uShadowMap0);\n if(shadow.lightCount > 1.0) {\n shadowAlpha += shadow_getShadowWeight(shadow_vPosition[1], shadow_uShadowMap1);\n }\n shadowAlpha *= shadow.color.a / shadow.lightCount;\n float blendedAlpha = shadowAlpha + color.a * (1.0 - shadowAlpha);\n\n return vec4(\n mix(color.rgb, shadow.color.rgb, shadowAlpha / blendedAlpha),\n blendedAlpha\n );\n }\n return color;\n}\n\n`,$=(0,R.A)(function({viewport:e,center:t}){return new M.k(e.viewProjectionMatrix).invert().transform(t)}),U=(0,R.A)(function({viewport:e,shadowMatrices:t}){const n=[],i=function(e){const{width:t,height:n,pixelUnprojectionMatrix:i}=e,r=[[0,0],[t,0],[t,n],[0,n]],s=r.map(([e,t])=>(0,O.xJ)([e,t,-1],i)),o=r.map(([e,t])=>(0,O.xJ)([e,t,1],i));if(!e.isGeospatial)return s.concat(o);const a=s.concat(o).filter(e=>e[2]>=0);for(let e=0;e<4;e++){const t=(e+1)%4;for(const[n,i]of[[s[e],o[e]],[s[e],s[t]],[o[e],o[t]]])if(n[2]<0!=i[2]<0){const e=n[2]/(n[2]-i[2]);a.push([n[0]+(i[0]-n[0])*e,n[1]+(i[1]-n[1])*e,0])}}return a.length>0?a:s.concat(o)}(e);for(const r of t){const t=r.clone().translate(new S.P(e.center).negate()),s=i.map(e=>t.transform(e)),o=(new M.k).ortho({left:Math.min(...s.map(e=>e[0])),right:Math.max(...s.map(e=>e[0])),bottom:Math.min(...s.map(e=>e[1])),top:Math.max(...s.map(e=>e[1])),near:Math.min(...s.map(e=>-e[2])),far:Math.max(...s.map(e=>-e[2]))});n.push(o.multiplyRight(r))}return n}),V=[0,0,0,1],G=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];const j={name:"shadow",dependencies:[k.A],vs:F,fs:N,inject:{"vs:DECKGL_FILTER_GL_POSITION":"\n position = shadow_setVertexPosition(geometry.position);\n ","fs:DECKGL_FILTER_COLOR":"\n color = shadow_filterShadowColor(color);\n "},getUniforms:function(e){const{shadowEnabled:t=!0,project:n}=e;if(!(t&&n&&e.shadowMatrices&&e.shadowMatrices.length))return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:e.dummyShadowMap,shadow_uShadowMap1:e.dummyShadowMap};const i=k.A.getUniforms(n),r=$({viewport:n.viewport,center:i.center}),s=[],o=U({shadowMatrices:e.shadowMatrices,viewport:n.viewport}).slice();for(let t=0;t<e.shadowMatrices.length;t++){const e=o[t],a=e.clone().translate(new S.P(n.viewport.center).negate());i.coordinateSystem===(0,z.LB)("lnglat")&&i.projectionMode===B.Kx.WEB_MERCATOR?(o[t]=a,s[t]=r):(o[t]=e.clone().multiplyRight(G),s[t]=a.transform(r))}const a={drawShadowMap:Boolean(e.drawToShadowMap),useShadowMap:!!e.shadowMaps&&e.shadowMaps.length>0,color:e.shadowColor||V,lightId:e.shadowLightId||0,lightCount:e.shadowMatrices.length,shadow_uShadowMap0:e.dummyShadowMap,shadow_uShadowMap1:e.dummyShadowMap};for(let e=0;e<o.length;e++)a[`viewProjectionMatrix${e}`]=o[e],a[`projectCenter${e}`]=s[e];for(let t=0;t<2;t++)a[`shadow_uShadowMap${t}`]=e.shadowMaps&&e.shadowMaps[t]||e.dummyShadowMap;return a},uniformTypes:{drawShadowMap:"f32",useShadowMap:"f32",color:"vec4<f32>",lightId:"i32",lightCount:"f32",viewProjectionMatrix0:"mat4x4<f32>",viewProjectionMatrix1:"mat4x4<f32>",projectCenter0:"vec4<f32>",projectCenter1:"vec4<f32>"}},W={color:[255,255,255],intensity:1},H=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],q=[0,0,0,200/255];class LightingEffect{constructor(e={}){this.id="lighting-effect",this.shadowColor=q,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;const{device:t,deck:n}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(t),n._addDefaultShaderModule(j),this.dummyShadowMap=t.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(const t in e){const n=e[t];switch(n.type){case"ambient":this.ambientLight=n;break;case"directional":this.directionalLights.push(n);break;case"point":this.pointLights.push(n)}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(e=>e.shadow),this.context&&(this.shadow||this.cleanup(this.context),this.setup(this.context)),this.props=e}preRender({layers:e,layerFilter:t,viewports:n,onViewportActive:i,views:r}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let s=0;s<this.shadowPasses.length;s++){this.shadowPasses[s].render({layers:e,layerFilter:t,viewports:n,onViewportActive:i,views:r,shaderModuleProps:{shadow:{shadowLightId:s,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}}})}}}getShaderModuleProps(e,t){const n=this.shadow?{project:t.project,shadowMaps:this.shadowPasses.map(e=>e.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},i={enabled:!0,lights:this._getLights(e)},r=e.props.material;return{shadow:n,lighting:i,phongMaterial:r,gouraudMaterial:r}}cleanup(e){for(const e of this.shadowPasses)e.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(j))}_calculateMatrices(){const e=[];for(const t of this.directionalLights){const n=(new M.k).lookAt({eye:new S.P(t.direction).negate()});e.push(n)}return e}_createShadowPasses(e){for(let t=0;t<this.directionalLights.length;t++){const n=new ShadowPass(e);this.shadowPasses[t]=n}}_applyDefaultLights(){const{ambientLight:e,pointLights:t,directionalLights:n}=this;e||0!==t.length||0!==n.length||(this.ambientLight=new AmbientLight(W),this.directionalLights.push(new DirectionalLight(H[0]),new DirectionalLight(H[1])))}_getLights(e){const t=[];this.ambientLight&&t.push(this.ambientLight);for(const n of this.pointLights)t.push(n.getProjectedLight({layer:e}));for(const n of this.directionalLights)t.push(n.getProjectedLight({layer:e}));return t}}const Z=new LightingEffect;class EffectManager{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){const t=this._defaultEffects;if(!t.find(t=>t.id===e.id)){const n=t.findIndex(t=>{return n=e,(t.order??1/0)-(n.order??1/0)>0;var n});n<0?t.push(e):t.splice(n,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&((0,b.b)(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){const t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}getEffects(){return this._resolvedEffects}_setEffects(e){const t={};for(const e of this.effects)t[e.id]=e;const n=[];for(const i of e){const e=t[i.id];let r=i;e&&e!==i?e.setProps?(e.setProps(i.props),r=e):e.cleanup(this._context):e||i.setup(this._context),n.push(r),delete t[i.id]}for(const e in t)t[e].cleanup(this._context);this.effects=n,this._resolvedEffects=n.concat(this._defaultEffects),e.some(e=>e instanceof LightingEffect)||this._resolvedEffects.push(Z),this._needsRedraw="effects changed"}finalize(){for(const e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}}class DrawLayersPass extends I.A{shouldDrawLayer(e){const{operation:t}=e.props;return t.includes("draw")||t.includes("terrain")}render(e){return this._render(e)}}const Y={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant",blendAlphaDstFactor:"zero"};class PickLayersPass extends I.A{constructor(){super(...arguments),this._colorEncoderState=null}render(e){if("pickingFBO"in e)return this._drawPickingBuffer(e);return{decodePickingColor:null,stats:super._render(e)}}_drawPickingBuffer({layers:e,layerFilter:t,views:n,viewports:i,onViewportActive:r,pickingFBO:s,deviceRect:{x:o,y:a,width:c,height:l},cullRect:u,effects:d,pass:h="picking",pickZ:f,canvasContext:p,shaderModuleProps:g,clearColor:m}){this.pickZ=f;const v=this._resetColorEncoder(f),y=[o,a,c,l],b=super._render({target:s,layers:e,layerFilter:t,views:n,viewports:i,onViewportActive:r,cullRect:u,effects:d?.filter(e=>e.useInPicking),pass:h,canvasContext:p,isPicking:!0,shaderModuleProps:g,clearColor:m??[0,0,0,0],colorMask:15,scissorRect:y});this._colorEncoderState=null;return{decodePickingColor:v&&Q.bind(null,v),stats:b}}shouldDrawLayer(e){const{pickable:t,operation:n}=e.props;return t&&n.includes("draw")||n.includes("terrain")||n.includes("mask")}getShaderModuleProps(e,t,n){return{picking:{isActive:1,isAttribute:this.pickZ,disabledPickingIndices:e.internalState?.disabledPickingIndices},lighting:{enabled:!1}}}getLayerParameters(e,t,n){const i={...e.props.parameters},{pickable:r,operation:s}=e.props;return this._colorEncoderState?r&&s.includes("draw")?(Object.assign(i,Y),i.blend=!0,"webgpu"===this.device.type?i.blendConstant=K(this._colorEncoderState,e,n):i.blendColor=K(this._colorEncoderState,e,n),s.includes("terrain")&&e.state?._hasPickingCover&&(i.blendAlphaSrcFactor="one")):s.includes("terrain")&&(i.blend=!1):i.blend=!1,i}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}}function K(e,t,n){const{byLayer:i,byAlpha:r}=e;let s,o=i.get(t);return o?(o.viewports.push(n),s=o.a):(s=i.size+1,s<=255?(o={a:s,layer:t,viewports:[n]},i.set(t,o),r[s]=o):(f.A.warn("Too many pickable layers, only picking the first 255")(),s=0)),[0,0,0,s/255]}function Q(e,t){const n=e.byAlpha[t[3]];return n&&{pickedLayer:n.layer,pickedViewports:n.viewports,pickedObjectIndex:n.layer.decodePickingColor(t)}}class DeckRenderer{constructor(e,t={}){this.device=e,this.stats=t.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new DrawLayersPass(e),this.pickLayersPass=new PickLayersPass(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){const t=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,n={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};if(!e.viewports.length){const e=t.render(n),i="stats"in e?e.stats:e;return void this._updateStats(i)}n.effects&&this._preRender(n.effects,n);const i=this.lastPostProcessEffect?this.renderBuffers[0]:n.target;this.lastPostProcessEffect&&(n.clearColor=[0,0,0,0],n.clearCanvas=!0);const r=t.render({...n,target:i}),s="stats"in r?r.stats:r;n.effects&&(this.lastPostProcessEffect&&(n.clearCanvas=void 0===e.clearCanvas||e.clearCanvas),this._postRender(n.effects,n)),this.renderCount++,(0,p.A)("deckRenderer.renderLayers",this,s,e),this._updateStats(s)}needsRedraw(e={clearRedrawFlags:!1}){const t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}finalize(){const{renderBuffers:e}=this;for(const t of e)t.delete();e.length=0}_updateStats(e){if(!this.stats)return;let t=0;for(const{visibleCount:n}of e)t+=n;this.stats.get("Layers rendered").addCount(t)}_preRender(e,t){this.lastPostProcessEffect=null,t.preRenderStats=t.preRenderStats||{};for(const n of e)t.preRenderStats[n.id]=n.preRender(t),n.postRender&&(this.lastPostProcessEffect=n.id);this.lastPostProcessEffect&&this._resizeRenderBuffers(t.canvasContext)}_resizeRenderBuffers(e=this.device.canvasContext){const{renderBuffers:t}=this,n=e.getDrawingBufferSize(),[i,r]=n;0===t.length&&[0,1].map(e=>{const n=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:i,height:r});t.push(this.device.createFramebuffer({id:`deck-renderbuffer-${e}`,colorAttachments:[n]}))});for(const e of t)e.resize(n)}_postRender(e,t){const{renderBuffers:n}=this,i=t.target??t.canvasContext?.getCurrentFramebuffer()??t.target,r={...t,inputBuffer:n[0],swapBuffer:n[1]};for(const t of e)if(t.postRender){r.target=t.id===this.lastPostProcessEffect?i:void 0;const e=t.postRender(r);r.inputBuffer=e,r.swapBuffer=e===n[0]?n[1]:n[0]}}}var X=n(80698),J=n(26839);const ee={pickedColor:null,pickedObjectIndex:-1};function te({pickedColors:e,decodePickingColor:t,deviceX:n,deviceY:i,deviceRadius:r,deviceRect:s}){const{x:o,y:a,width:c,height:l}=s;let u=r*r,d=-1,h=0;for(let t=0;t<l;t++){const r=t+a-i,s=r*r;if(s>u)h+=4*c;else for(let t=0;t<c;t++){if(e[h+3]-1>=0){const e=t+o-n,i=e*e+s;i<=u&&(u=i,d=h)}h+=4}}if(d>=0){const n=e.slice(d,d+4),i=t(n);if(i){const e=Math.floor(d/4/c),t=d/4-e*c;return{...i,pickedColor:n,pickedX:o+t,pickedY:a+e}}f.A.error("Picked non-existent layer. Is picking buffer corrupt?")()}return ee}function ne({pickedColors:e,decodePickingColor:t}){const n=new Map;if(e)for(let i=0;i<e.length;i+=4){if(e[i+3]-1>=0){const r=e.slice(i,i+4),s=r.join(",");if(!n.has(s)){const e=t(r);e?n.set(s,{...e,color:r}):f.A.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(n.values())}function ie({pickInfo:e,viewports:t,pixelRatio:n,x:i,y:r,z:s}){let o,a=t[0];if(t.length>1&&(a=function(e,t){for(let n=e.length-1;n>=0;n--){const i=e[n];if(i.containsPixel(t))return i}return e[0]}(e?.pickedViewports||t,{x:i,y:r})),a){const e=[i-a.x,r-a.y];void 0!==s&&(e[2]=s),o=a.unproject(e)}return{color:null,layer:null,viewport:a,index:-1,picked:!1,x:i,y:r,pixel:[i,r],coordinate:o,devicePixel:e&&"pickedX"in e?[e.pickedX,e.pickedY]:void 0,pixelRatio:n}}function re(e){const{pickInfo:t,lastPickedInfo:n,mode:i,layers:r}=e,{pickedColor:s,pickedLayer:o,pickedObjectIndex:a}=t,c=o?[o]:[];if("hover"===i){const e=n.index,t=n.layerId,i=o?o.props.id:null;if(i!==t||a!==e){if(i!==t){const e=r.find(e=>e.props.id===t);e&&c.unshift(e)}n.layerId=i,n.index=a,n.info=null}}const l=ie(e),u=new Map;return u.set(null,l),c.forEach(e=>{let t={...l};e===o&&(t.color=s,t.index=a,t.picked=!0),t=se({layer:e,info:t,mode:i});const r=t.layer;e===o&&"hover"===i&&(n.info=t),u.set(r.id,t),"hover"===i&&r.updateAutoHighlight(t)}),u}function se({layer:e,info:t,mode:n}){for(;e&&t;){const i=t.layer||null;t.sourceLayer=i,t.layer=e,t=e.getPickingInfo({info:t,mode:n,sourceLayer:i}),e=e.parent}return t}class DeckPicker{constructor(e,t={}){this._pickable=!0,this.device=e,this.stats=t.stats,this.pickLayersPass=new PickLayersPass(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(e){return this._pickClosestObjectAsync(e)}pickObjectsAsync(e){return this._pickVisibleObjectsAsync(e)}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:t,layers:n,viewports:i},r=this.lastPickedInfo.info){const s=r&&r.layer&&r.layer.id,o=r&&r.viewport&&r.viewport.id,a=s?n.find(e=>e.id===s):null,c=o&&i.find(e=>e.id===o)||i[0],l=c&&c.unproject([e-c.x,t-c.y]),u={x:e,y:t,viewport:c,coordinate:l,layer:a};return{...r,...u}}_resizeBuffer(e=this.device.getDefaultCanvasContext()){if(!this.pickingFBO){const e=this.device.createTexture({format:"rgba8unorm",width:1,height:1,usage:X.g.RENDER_ATTACHMENT|X.g.COPY_SRC});if(this.pickingFBO=this.device.createFramebuffer({colorAttachments:[e],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float")){const e=this.device.createTexture({format:"rgba32float",width:1,height:1,usage:X.g.RENDER_ATTACHMENT|X.g.COPY_SRC}),t=this.device.createFramebuffer({colorAttachments:[e],depthStencilAttachment:"depth16unorm"});this.depthFBO=t}}const[t,n]=e.getDrawingBufferSize();this.pickingFBO?.resize({width:t,height:n}),this.depthFBO?.resize({width:t,height:n})}_getPickable(e){if(!1===this._pickable)return null;const t=e.filter(e=>this.pickLayersPass.shouldDrawLayer(e)&&!e.isComposite);return t.length?t:null}async _pickClosestObjectAsync({layers:e,views:t,viewports:n,x:i,y:r,radius:s=0,depth:o=1,mode:a="query",unproject3D:c,canvasContext:l=this.device.getDefaultCanvasContext(),onViewportActive:u,effects:d}){const h=l.cssToDeviceRatio(),f=this._getPickable(e);if(!f||0===n.length)return{result:[],emptyInfo:ie({viewports:n,x:i,y:r,pixelRatio:h})};this._resizeBuffer(l);const p=l.cssToDevicePixels([i,r],!0),g=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(s*h),{width:v,height:y}=this.pickingFBO,b=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceWidth:v,deviceHeight:y}),_={x:i-s,y:r-s,width:2*s+1,height:2*s+1};let x;const w=[],P=new Set;for(let e=0;e<o;e++){let s,p;if(b){s=te({...await this._drawAndSampleAsync({layers:f,views:t,viewports:n,onViewportActive:u,deviceRect:b,cullRect:_,effects:d,pass:`picking:${a}`,canvasContext:l}),deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceRect:b})}else s={pickedColor:null,pickedObjectIndex:-1};const v=this._getDepthLayers(s,f,c);if(v.length>0){const{pickedColors:e}=await this._drawAndSampleAsync({layers:v,views:t,viewports:n,onViewportActive:u,deviceRect:{x:s.pickedX??g[0],y:s.pickedY??g[1],width:1,height:1},cullRect:_,effects:d,pass:`picking:${a}:z`,canvasContext:l},!0);e[3]&&(p=e[0])}s.pickedLayer&&e+1<o&&(P.add(s.pickedLayer),s.pickedLayer.disablePickingIndex(s.pickedObjectIndex)),x=re({pickInfo:s,lastPickedInfo:this.lastPickedInfo,mode:a,layers:f,viewports:n,x:i,y:r,z:p,pixelRatio:h});for(const e of x.values())e.layer&&w.push(e);if(!s.pickedColor)break}for(const e of P)e.restorePickingColors();return{result:w,emptyInfo:x.get(null)}}_pickClosestObject({layers:e,views:t,viewports:n,x:i,y:r,radius:s=0,depth:o=1,mode:a="query",unproject3D:c,canvasContext:l=this.device.getDefaultCanvasContext(),onViewportActive:u,effects:d}){const h=l.cssToDeviceRatio(),f=this._getPickable(e);if(!f||0===n.length)return{result:[],emptyInfo:ie({viewports:n,x:i,y:r,pixelRatio:h})};this._resizeBuffer(l);const p=l.cssToDevicePixels([i,r],!0),g=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(s*h),{width:v,height:y}=this.pickingFBO,b=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceWidth:v,deviceHeight:y}),_={x:i-s,y:r-s,width:2*s+1,height:2*s+1};let x;const w=[],P=new Set;for(let e=0;e<o;e++){let s,p;if(b){s=te({...this._drawAndSample({layers:f,views:t,viewports:n,onViewportActive:u,deviceRect:b,cullRect:_,effects:d,pass:`picking:${a}`,canvasContext:l}),deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceRect:b})}else s={pickedColor:null,pickedObjectIndex:-1};const v=this._getDepthLayers(s,f,c);if(v.length>0){const{pickedColors:e}=this._drawAndSample({layers:v,views:t,viewports:n,onViewportActive:u,deviceRect:{x:s.pickedX??g[0],y:s.pickedY??g[1],width:1,height:1},cullRect:_,effects:d,pass:`picking:${a}:z`,canvasContext:l},!0);e[3]&&(p=e[0])}s.pickedLayer&&e+1<o&&(P.add(s.pickedLayer),s.pickedLayer.disablePickingIndex(s.pickedObjectIndex)),x=re({pickInfo:s,lastPickedInfo:this.lastPickedInfo,mode:a,layers:f,viewports:n,x:i,y:r,z:p,pixelRatio:h});for(const e of x.values())e.layer&&w.push(e);if(!s.pickedColor)break}for(const e of P)e.restorePickingColors();return{result:w,emptyInfo:x.get(null)}}async _pickVisibleObjectsAsync({layers:e,views:t,viewports:n,x:i,y:r,width:s=1,height:o=1,mode:a="query",maxObjects:c=null,canvasContext:l=this.device.getDefaultCanvasContext(),onViewportActive:u,effects:d}){const h=this._getPickable(e);if(!h||0===n.length)return[];this._resizeBuffer(l);const f=l.cssToDeviceRatio(),p=l.cssToDevicePixels([i,r],!0),g=p.x,m=p.y+p.height,v=l.cssToDevicePixels([i+s,r+o],!0),y=v.x+v.width,b=v.y,_={x:g,y:b,width:y-g,height:m-b},x=ne(await this._drawAndSampleAsync({layers:h,views:t,viewports:n,onViewportActive:u,deviceRect:_,cullRect:{x:i,y:r,width:s,height:o},effects:d,pass:`picking:${a}`,canvasContext:l})),w=new Map,P=[],C=Number.isFinite(c);for(let e=0;e<x.length&&!(C&&P.length>=c);e++){const t=x[e];let n={color:t.pickedColor,layer:null,index:t.pickedObjectIndex,picked:!0,x:i,y:r,pixelRatio:f};n=se({layer:t.pickedLayer,info:n,mode:a});const s=n.layer.id;w.has(s)||w.set(s,new Set);const o=w.get(s),c=n.object??n.index;o.has(c)||(o.add(c),P.push(n))}return P}_pickVisibleObjects({layers:e,views:t,viewports:n,x:i,y:r,width:s=1,height:o=1,mode:a="query",maxObjects:c=null,canvasContext:l=this.device.getDefaultCanvasContext(),onViewportActive:u,effects:d}){const h=this._getPickable(e);if(!h||0===n.length)return[];this._resizeBuffer(l);const f=l.cssToDeviceRatio(),p=l.cssToDevicePixels([i,r],!0),g=p.x,m=p.y+p.height,v=l.cssToDevicePixels([i+s,r+o],!0),y=v.x+v.width,b=v.y,_={x:g,y:b,width:y-g,height:m-b},x=ne(this._drawAndSample({layers:h,views:t,viewports:n,onViewportActive:u,deviceRect:_,cullRect:{x:i,y:r,width:s,height:o},effects:d,pass:`picking:${a}`,canvasContext:l})),w=new Map,P=[],C=Number.isFinite(c);for(let e=0;e<x.length&&!(C&&P.length>=c);e++){const t=x[e];let n={color:t.pickedColor,layer:null,index:t.pickedObjectIndex,picked:!0,x:i,y:r,pixelRatio:f};n=se({layer:t.pickedLayer,info:n,mode:a});const s=n.layer.id;w.has(s)||w.set(s,new Set);const o=w.get(s),c=n.object??n.index;o.has(c)||(o.add(c),P.push(n))}return P}async _drawAndSampleAsync({layers:e,views:t,viewports:n,onViewportActive:i,deviceRect:r,cullRect:s,effects:o,pass:a,canvasContext:c},l=!1){const u=l?this.depthFBO:this.pickingFBO,d={layers:e,layerFilter:this.layerFilter,views:t,viewports:n,onViewportActive:i,pickingFBO:u,deviceRect:r,cullRect:s,effects:o,pass:a,canvasContext:c,pickZ:l,preRenderStats:{},isPicking:!0};for(const e of o)e.useInPicking&&(d.preRenderStats[e.id]=e.preRender(d));const{decodePickingColor:h,stats:p}=this.pickLayersPass.render(d);this._updateStats(p);const{x:g,y:m,width:v,height:y}=r,b=u.colorAttachments[0]?.texture;if(!b)throw new Error("Picking framebuffer color attachment is missing");const _=await this._readTextureDataAsync(b,{x:g,y:m,width:v,height:y},l?Float32Array:Uint8Array);if(!l){let e=!1;for(let t=3;t<_.length;t+=4)if(0!==_[t]){e=!0;break}!e&&_.length>0&&f.A.warn("Async pick readback returned only zero alpha values",{deviceRect:r,bytes:Array.from(_.subarray(0,Math.min(_.length,16)))})()}return{pickedColors:_,decodePickingColor:h}}async _readTextureDataAsync(e,t,n){const{width:i,height:r}=t,s=e.computeMemoryLayout(t),o=this.device.createBuffer({byteLength:s.byteLength,usage:J.h.COPY_DST|J.h.MAP_READ});try{e.readBuffer(t,o);const a=await o.readAsync(0,s.byteLength),c=n.BYTES_PER_ELEMENT;if(s.bytesPerRow%c!==0)throw new Error(`Texture readback row stride ${s.bytesPerRow} is not aligned to ${c}-byte elements.`);const l=new n(a.buffer,a.byteOffset,s.byteLength/c),u=4*i,d=s.bytesPerRow/c;if(d<u)throw new Error(`Texture readback row stride ${d} is smaller than packed row length ${u}.`);const h=new n(i*r*4);for(let e=0;e<r;e++){const t=e*d;h.set(l.subarray(t,t+u),e*u)}return h}finally{o.destroy()}}_drawAndSample({layers:e,views:t,viewports:n,onViewportActive:i,deviceRect:r,cullRect:s,effects:o,pass:a,canvasContext:c},l=!1){const u=l?this.depthFBO:this.pickingFBO,d={layers:e,layerFilter:this.layerFilter,views:t,viewports:n,onViewportActive:i,pickingFBO:u,deviceRect:r,cullRect:s,effects:o,pass:a,canvasContext:c,pickZ:l,preRenderStats:{},isPicking:!0};for(const e of o)e.useInPicking&&(d.preRenderStats[e.id]=e.preRender(d));const{decodePickingColor:h,stats:f}=this.pickLayersPass.render(d);this._updateStats(f);const{x:p,y:g,width:m,height:v}=r,y=new(l?Float32Array:Uint8Array)(m*v*4);return this.device.readPixelsToArrayWebGL(u,{sourceX:p,sourceY:g,sourceWidth:m,sourceHeight:v,target:y}),{pickedColors:y,decodePickingColor:h}}_updateStats(e){if(!this.stats)return;let t=0;for(const{visibleCount:n}of e)t+=n;this.stats.get("Layers picked").addCount(t)}_getDepthLayers(e,t,n){if(!n||!this.depthFBO)return[];const{pickedLayer:i}=e;return i&&!("drape"===i?.state?.terrainDrawMode)?[i]:t.filter(e=>e.props.operation.includes("terrain"))}_getPickingRect({deviceX:e,deviceY:t,deviceRadius:n,deviceWidth:i,deviceHeight:r}){const s=Math.max(0,e-n),o=Math.max(0,t-n),a=Math.min(i,e+n+1)-s,c=Math.min(r,t+n+1)-o;return a<=0||c<=0?null:{x:s,y:o,width:a,height:c}}}const oe={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},ae="top-left",ce="root";class WidgetManager{constructor({deck:e,parentElement:t}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,t?.classList.add("deck-widget-container"),this.parentElement=t}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!(0,b.b)(e.widgets,this.widgets,1)){const t=e.widgets.filter(Boolean);this._setWidgets(t)}}finalize(){for(const e of this.getWidgets())this._removeWidget(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(const e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(t=>t.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:t}){const n=e.reduce((e,t)=>(e[t.id]=t,e),{});for(const i of this.getWidgets()){const{viewId:r}=i;if(r){const e=n[r];e&&(i.onViewportChange&&i.onViewportChange(e),i.onRedraw?.({viewports:[e],layers:t}))}else{if(i.onViewportChange)for(const t of e)i.onViewportChange(t);i.onRedraw?.({viewports:e,layers:t})}}this.lastViewports=n,this._updateContainers()}onHover(e,t){for(const n of this.getWidgets()){const{viewId:i}=n;i&&i!==e.viewport?.id||n.onHover?.(e,t)}}getCanvasBounds(e){const t=this.deck?.getCanvas?.(),n=t?.getBoundingClientRect(),i=this.parentElement?.getBoundingClientRect(),r=this.deck?.getCanvasContext?.(e?.id);if(r&&i){r.updatePosition();const[e,t]=r.getPosition(),[n,s]=r.getCSSSize();return{x:e-i.left,y:t-i.top,width:n,height:s}}return{x:n&&i?n.left-i.left:0,y:n&&i?n.top-i.top:0,width:n?.width||this.deck?.width||0,height:n?.height||this.deck?.height||0}}onEvent(e,t){const n=B.tg[t.type];if(n)for(const i of this.getWidgets()){const{viewId:r}=i;r&&r!==e.viewport?.id||i[n]?.(e,t)}}_setWidgets(e){const t={};for(const e of this.resolvedWidgets)t[e.id]=e;this.resolvedWidgets.length=0;for(const e of this.defaultWidgets)t[e.id]=null,this.resolvedWidgets.push(e);for(let n of e){const e=t[n.id];e?e.viewId!==n.viewId||e.placement!==n.placement?(this._removeWidget(e),this._addWidget(n)):n!==e&&(e.setProps(n.props),n=e):this._addWidget(n),t[n.id]=null,this.resolvedWidgets.push(n)}for(const e in t){const n=t[e];n&&this._removeWidget(n)}this.widgets=e}_addWidget(e){const{viewId:t=null,placement:n=ae}=e,i=e.props._container??t;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:t}),e.rootElement&&this._getContainer(i,n).append(e.rootElement),e.updateHTML()}_removeWidget(e){e.onRemove?.(),e.rootElement&&e.rootElement.remove(),e.rootElement=void 0,e.deck=void 0,e.widgetManager=void 0}_getContainer(e,t){if(e&&"string"!=typeof e)return e;const n=e||ce;let i=this.containers[n];i||(i=document.createElement("div"),i.style.pointerEvents="none",i.style.position="absolute",i.style.overflow="hidden",this.parentElement?.append(i),this.containers[n]=i);let r=i.querySelector(`.${t}`);return r||(r=globalThis.document.createElement("div"),r.className=t,r.style.position="absolute",r.style.zIndex="2",Object.assign(r.style,oe[t]),i.append(r)),r}_updateContainers(){for(const e in this.containers){const t=this.lastViewports[e]||null,n=e===ce||t,i=this.containers[e];if(n){const e=this._getContainerBounds(t);i.style.display="block",i.style.left=`${e.x}px`,i.style.top=`${e.y}px`,i.style.width=`${e.width}px`,i.style.height=`${e.height}px`}else i.style.display="none"}}_getContainerBounds(e){if(!e)return{x:0,y:0,width:this.parentElement?.clientWidth||this.deck.width,height:this.parentElement?.clientHeight||this.deck.height};const t=this.getCanvasBounds(e);return{x:t.x+e.x,y:t.y+e.y,width:e.width,height:e.height}}}function le(e,t){t&&Object.entries(t).map(([t,n])=>{t.startsWith("--")?e.style.setProperty(t,n):e.style[t]=n})}class Widget{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){const t=this.props,n=this.rootElement;var i,r;n&&t.className!==e.className&&(t.className&&n.classList.remove(t.className),e.className&&n.classList.add(e.className)),n&&!(0,b.b)(t.style,e.style,1)&&(i=n,(r=t.style)&&Object.keys(r).map(e=>{e.startsWith("--")?i.style.removeProperty(e):i.style[e]=""}),le(n,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}get viewIds(){return this.viewId?[this.viewId]:this.deck?.getViews().map(e=>e.id)??[]}getViewState(e){return this.deck?.viewManager?.getViewState(e)||{}}setViewState(e,t){this.deck?._onViewStateChange({viewId:e,viewState:t,interactionState:{}})}onCreateRootElement(){const e=["deck-widget",this.className,this.props.className],t=document.createElement("div");return e.filter(e=>"string"==typeof e&&e.length>0).forEach(e=>t.classList.add(e)),le(t,this.props.style),t}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,t){}onClick(e,t){}onDrag(e,t){}onDragStart(e,t){}onDragEnd(e,t){}}Widget.defaultProps={id:"widget",style:{},_container:null,className:""};const ue={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"};class TooltipWidget extends Widget{constructor(e={}){super(e),this.id="default-tooltip",this.placement="fill",this.className="deck-tooltip",this.isVisible=!1,this.setProps(e)}onCreateRootElement(){const e=document.createElement("div");return e.className=this.className,Object.assign(e.style,ue),e}onRenderHTML(e){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&!e.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=e}onHover(e){const{deck:t}=this,n=t&&t.props.getTooltip;if(!n)return;const i=n(e),r=this.widgetManager?.getCanvasBounds(e.viewport),s=e.x+(r?.x||0),o=e.y+(r?.y||0);this.setTooltip(i,s,o)}setTooltip(e,t,n){const i=this.rootElement;if(i){if("string"==typeof e)i.innerText=e;else{if(!e)return this.isVisible=!1,void(i.style.display="none");e.text&&(i.innerText=e.text),e.html&&(i.innerHTML=e.html),e.className&&(i.className=e.className)}this.isVisible=!0,i.style.display="block",i.style.transform=`translate(${t}px, ${n}px)`,e&&"object"==typeof e&&"style"in e&&Object.assign(i.style,e.style)}}}TooltipWidget.defaultProps={...Widget.defaultProps};var de=n(24067);class CanvasManager{constructor(e){this.targets={},this.order=[],this.eventManagers={},this._eventRootToCanvasId=new WeakMap,this._createEventManager=e.createEventManager,this._getEventRoot=e.getEventRoot}finalize(){for(const e of Object.values(this.targets))e.eventManager.destroy(),e.presentationContext.destroy();this.targets={},this.order=[],this.eventManagers={},this._eventRootToCanvasId=new WeakMap}syncCanvasEntries(e){const t=this._normalizeCanvasList(e.canvases),n={},i=[],r=new Map;for(const{canvas:e}of t){const t=this._getEventRoot(e);r.set(t,(r.get(t)||0)+1)}for(const{id:s,canvas:o}of t){const t=this._getEventRoot(o),a=1===r.get(t)?t:o;let c=this.targets[s];if(!c||c.device!==e.device||c.canvas!==o||c.eventRoot!==a){c?.eventManager.destroy(),c?.presentationContext.destroy();const t=e.device.createPresentationContext({id:s,canvas:o,useDevicePixels:e.useDevicePixels,autoResize:!0});c={id:s,device:e.device,canvas:o,eventRoot:a,presentationContext:t,eventManager:this._createEventManager(a)}}this._eventRootToCanvasId.set(a,s),this._eventRootToCanvasId.set(o,s),n[s]=c,i.push(s)}for(const[e,t]of Object.entries(this.targets))n[e]||(t.eventManager.destroy(),t.presentationContext.destroy());this.targets=n,this.order=i;const s=Object.fromEntries(Object.entries(n).map(([e,t])=>[e,t.eventManager]));this._haveSameEventManagers(s)||(this.eventManagers=s)}getCanvasIdFromEvent(e){return e?this._eventRootToCanvasId.get(e):void 0}getTarget(e){return this.targets[e||this.order[0]||_]||null}_normalizeCanvasList(e=[]){const t=new Set;return e.map((e,n)=>{let i,r;return"string"==typeof e?(i=document.getElementById(e),(0,de.A)(i,`Canvas with id ${e} not found`),r=e):(i=e,r=i.id||`deckgl-canvas-${n}`),(0,de.A)(!t.has(r),`Duplicate canvas id ${r}`),t.add(r),{id:r,canvas:i}})}_haveSameEventManagers(e){const t=Object.keys(e),n=Object.keys(this.eventManagers);return t.length===n.length&&t.every(t=>e[t]===this.eventManagers[t])}}var he=n(23459),fe=n(5223),pe=n(94976),ge=n(47612);const me=globalThis.loaders?.parseImageNode,ve="undefined"!=typeof Image,ye="undefined"!=typeof ImageBitmap,be=Boolean(me),_e=!!ge.Bd||be;function xe(e){const t=Pe(e);if(!t)throw new Error("Not an image");return t}function we(e){switch(xe(e)){case"data":return e;case"image":case"imagebitmap":const t=document.createElement("canvas"),n=t.getContext("2d");if(!n)throw new Error("getImageData");return t.width=e.width,t.height=e.height,n.drawImage(e,0,0),n.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}function Pe(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?"imagebitmap":"undefined"!=typeof Image&&e instanceof Image?"image":e&&"object"==typeof e&&e.data&&e.width&&e.height?"data":null}const Ce=/^data:image\/svg\+xml/,Se=/\.svg((\?|#).*)?$/;function Le(e){return e&&(Ce.test(e)||Se.test(e))}function Ae(e,t){if(Le(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function Ee(e,t,n){const i=function(e,t){if(Le(t)){let t=(new TextDecoder).decode(e);try{"function"==typeof unescape&&"function"==typeof encodeURIComponent&&(t=unescape(encodeURIComponent(t)))}catch(e){throw new Error(e.message)}return`data:image/svg+xml;base64,${btoa(t)}`}return Ae(e,t)}(e,n),r=self.URL||self.webkitURL,s="string"!=typeof i&&r.createObjectURL(i);try{return await async function(e,t){const n=new Image;if(n.src=e,t.image&&t.image.decode&&n.decode)return await n.decode(),n;return await new Promise((e,t)=>{try{n.onload=()=>e(n),n.onerror=e=>{const n=e instanceof Error?e.message:"error";t(new Error(n))}}catch(e){t(e)}})}(s||i,t)}finally{s&&r.revokeObjectURL(s)}}let Te=!0;async function Me(e,t,n){let i;if(Le(n)){i=await Ee(e,t,n)}else i=Ae(e,n);const r=t&&t.imagebitmap;return await async function(e,t=null){!function(e){if(!e)return!0;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}(t)&&Te||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),Te=!1}return await createImageBitmap(e)}(i,r)}function Ie(e){return function(e,t,n=0){const i=(r=t,[...r].map(e=>e.charCodeAt(0)));var r;for(let t=0;t<i.length;++t)if(i[t]!==e[t+n])return!1;return!0}(e,"ftyp",4)&&96&e[8]?function(e){switch((t=e,n=8,i=12,String.fromCharCode(...t.slice(n,i))).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}var t,n,i}(e):null}const Be=!1,ke=!0;function Re(e){const t=Oe(e);return function(e){const t=Oe(e),n=t.byteLength>=24&&2303741511===t.getUint32(0,Be);if(!n)return null;return{mimeType:"image/png",width:t.getUint32(16,Be),height:t.getUint32(20,Be)}}(t)||function(e){const t=Oe(e),n=t.byteLength>=3&&65496===t.getUint16(0,Be)&&255===t.getUint8(2);if(!n)return null;const{tableMarkers:i,sofMarkers:r}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let s=2;for(;s+9<t.byteLength;){const e=t.getUint16(s,Be);if(r.has(e))return{mimeType:"image/jpeg",height:t.getUint16(s+5,Be),width:t.getUint16(s+7,Be)};if(!i.has(e))return null;s+=2,s+=t.getUint16(s,Be)}return null}(t)||function(e){const t=Oe(e),n=t.byteLength>=10&&1195984440===t.getUint32(0,Be);if(!n)return null;return{mimeType:"image/gif",width:t.getUint16(6,ke),height:t.getUint16(8,ke)}}(t)||function(e){const t=Oe(e),n=t.byteLength>=14&&16973===t.getUint16(0,Be)&&t.getUint32(2,ke)===t.byteLength;if(!n)return null;return{mimeType:"image/bmp",width:t.getUint32(18,ke),height:t.getUint32(22,ke)}}(t)||function(e){const t=new Uint8Array(e instanceof DataView?e.buffer:e),n=Ie(t);if(!n)return null;return{mimeType:n.mimeType,width:0,height:0}}(t)}function Oe(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}const ze={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:"4.5.4",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],parse:async function(e,t,n){const i=((t=t||{}).image||{}).type||"auto",{url:r}=n||{};let s;switch(function(e){switch(e){case"auto":case"data":return function(){if(ye)return"imagebitmap";if(ve)return"image";if(_e)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return ye||ve||_e;case"imagebitmap":return ye;case"image":return ve;case"data":return _e;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}(e),e}}(i)){case"imagebitmap":s=await Me(e,t,r);break;case"image":s=await Ee(e,t,r);break;case"data":s=await async function(e){const{mimeType:t}=Re(e)||{},n=globalThis.loaders?.parseImageNode;return(0,pe.v)(n),await n(e,t)}(e);break;default:(0,pe.v)(!1)}return"data"===i&&(s=we(s)),s},tests:[e=>Boolean(Re(new DataView(e)))],options:{image:{type:"auto",decode:!0}}};const De={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:function(e){const t=e[0],n=e[e.length-1];return"{"===t&&"}"===n||"["===t&&"]"===n},parseTextSync:JSON.parse};const Fe=function(){const e="9.4.1",t=globalThis.deck&&globalThis.deck.VERSION;if(t&&t!==e)throw new Error(`deck.gl - multiple versions detected: ${t} vs ${e}`);return t||(f.A.log(1,`deck.gl ${e}`)(),globalThis.deck={...globalThis.deck,VERSION:e,version:e,log:f.A,_registerLoggers:p.k},(0,fe.mk)([De,[ze,{imagebitmap:{premultiplyAlpha:"none"}}]])),e}();var Ne=n(19548),$e=n(76028),Ue=n(29651);const Ve="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.";class Luma{static defaultProps={...Ne.M,type:"best-available",adapters:void 0,waitForPageLoad:!0};stats=$e.d;log=Ue.R;VERSION="9.4.2";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw Ue.R.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),Ue.R.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");Ue.R.error("This version of luma.gl has already been initialized")()}Ue.R.log(1,`${this.VERSION} - set luma.log.level=1 (or higher) to trace rendering`)(),globalThis.luma=this}async createDevice(e={}){const t={...Luma.defaultProps,...e},n=this.selectAdapter(t.type,t.adapters);if(!n)throw new Error(Ve);return t.waitForPageLoad&&await n.pageLoaded,await n.create(t)}async attachDevice(e,t){const n=this._getTypeFromHandle(e,t.adapters),i=n&&this.selectAdapter(n,t.adapters);if(!i)throw new Error(Ve);return await(i?.attach?.(e,t))}registerAdapters(e){for(const t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){const t=this._getAdapterMap(e);return Array.from(t).map(([,e])=>e).filter(e=>e.isSupported?.()).map(e=>e.type)}getBestAvailableAdapterType(e=[]){const t=["webgpu","webgl","null"],n=this._getAdapterMap(e);for(const e of t)if(n.get(e)?.isSupported?.())return e;return null}selectAdapter(e,t=[]){let n=e;"best-available"===e&&(n=this.getBestAvailableAdapterType(t));const i=this._getAdapterMap(t);return n&&i.get(n)||null}enforceWebGL2(e=!0,t=[]){const n=this._getAdapterMap(t).get("webgl");n||Ue.R.warn("enforceWebGL2: webgl adapter not found")(),n?.enforceWebGL2?.(e)}setDefaultDeviceProps(e){Object.assign(Luma.defaultProps,e)}_getAdapterMap(e=[]){const t=new Map(this.preregisteredAdapters);for(const n of e)t.set(n.type,n);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?"webgl":"undefined"!=typeof GPUDevice&&e instanceof GPUDevice||e?.queue?"webgpu":null===e?"null":(e instanceof WebGLRenderingContext?Ue.R.warn("WebGL1 is not supported",e)():Ue.R.warn("Unknown handle type",e)(),null)}}const Ge=new Luma;var je=n(16769);class Adapter{get pageLoaded(){return function(){He||(He=We&&"complete"===document.readyState||"undefined"==typeof window?Promise.resolve():new Promise(e=>window.addEventListener("load",()=>e())));return He}()}}const We=(0,je.B)()&&"undefined"!=typeof document;let He=null;var qe=n(77296);const Ze={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},Ye=e=>({drawBuffersWEBGL:t=>e.drawBuffers(t),COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),Ke=e=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES:()=>e.createVertexArray(),deleteVertexArrayOES:t=>e.deleteVertexArray(t),isVertexArrayOES:t=>e.isVertexArray(t),bindVertexArrayOES:t=>e.bindVertexArray(t)}),Qe=e=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE:(...t)=>e.drawArraysInstanced(...t),drawElementsInstancedANGLE:(...t)=>e.drawElementsInstanced(...t),vertexAttribDivisorANGLE:(...t)=>e.vertexAttribDivisor(...t)});function Xe(e=!0){const t=HTMLCanvasElement.prototype;if(!e&&t.originalGetContext)return t.getContext=t.originalGetContext,void(t.originalGetContext=void 0);t.originalGetContext=t.getContext,t.getContext=function(e,t){if("webgl"===e||"experimental-webgl"===e){const e=this.originalGetContext("webgl2",t);return e instanceof HTMLElement&&function(e){e.getExtension("EXT_color_buffer_float");const t={...Ze,WEBGL_disjoint_timer_query:e.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:Ye(e),OES_vertex_array_object:Ke(e),ANGLE_instanced_arrays:Qe(e)},n=e.getExtension.bind(e);e.getExtension=function(e){const i=n(e);return i||(e in t?t[e]:null)};const i=e.getSupportedExtensions;e.getSupportedExtensions=function(){const n=i.apply(e)||[];return n?.concat(Object.keys(t))}}(e),e}return this.originalGetContext(e,t)}}var Je=n(89689);const et=new class WebGLAdapter extends Adapter{type="webgl";enforceWebGL2(e){Xe(e)}isSupported(){return"undefined"!=typeof WebGL2RenderingContext}isDeviceHandle(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||("undefined"!=typeof WebGLRenderingContext&&e instanceof WebGLRenderingContext&&Ue.R.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){const{WebGLDevice:i}=await Promise.resolve().then(()=>n(8719));if(e instanceof i)return e;const r=i.getDeviceFromContext(e);if(r)return r;if(!function(e){if("undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext)return!0;return Boolean(e&&"function"==typeof e.createVertexArray)}(e))throw new Error("Invalid WebGL2RenderingContext");t=tt(t),await nt(t);const s=!0===t.createCanvasContext?{}:t.createCanvasContext;return new i({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...s}})}async create(e={}){const{WebGLDevice:t}=await Promise.resolve().then(()=>n(8719));e=tt(e),await nt(e);try{const n=new t(e);Ue.R.groupCollapsed(1,`WebGLDevice ${n.id} created`)();const i=`${n._reused?"Reusing":"Created"} device with WebGL2 ${n.props.debug?"debug ":""}context: ${n.info.vendor}, ${n.info.renderer} for canvas: ${n.canvasContext.id}`;return Ue.R.probe(1,i)(),Ue.R.table(1,n.info)(),n}finally{Ue.R.groupEnd(1)(),Ue.R.info(1,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}};function tt(e){return{...e,debug:e.debug??qe.pF.defaultProps.debug,debugWebGL:e.debugWebGL??qe.pF.defaultProps.debugWebGL,debugSpectorJS:e.debugSpectorJS??Boolean(Ue.R.get("debug-spectorjs"))}}async function nt(e){const t=[];(e.debugWebGL||e.debug)&&t.push((0,Je.z2)()),e.debugSpectorJS&&t.push((0,Je.Oy)(e));const n=await Promise.allSettled(t);for(const e of n)"rejected"===e.status&&Ue.R.error(`Failed to initialize debug libraries ${e.reason}`)()}let it=0;const rt={requestAnimationFrame:e=>function(e){const t="undefined"!=typeof window?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return t?t.call(window,e):setTimeout(()=>e("undefined"!=typeof performance?performance.now():Date.now()),1e3/60)}(e),cancelAnimationFrame:e=>function(e){const t="undefined"!=typeof window?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;t?t.call(window,e):clearTimeout(e)}(e)};class AnimationLoop{static defaultAnimationLoopProps={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>{console.error(e)},stats:void 0,autoResizeViewport:!1,animationFrameProvider:rt};device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(e){if(this.props={...AnimationLoop.defaultAnimationLoopProps,...e},!(e=this.props).device)throw new Error("No device provided");this.stats=e.stats||new m.A({id:"animation-loop-"+it++}),this.sharedStats=Ge.stats.get("Animation Loop"),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.setProps({autoResizeViewport:e.autoResizeViewport,animationFrameProvider:e.animationFrameProvider}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(e){this._error=e,this.props.onError(e),this.props.onError===AnimationLoop.defaultAnimationLoopProps.onError&&"undefined"!=typeof window&&"undefined"!=typeof ErrorEvent&&window.dispatchEvent(new ErrorEvent("error",{error:e,message:e.message}))}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){const e=this._needsRedraw;return this._needsRedraw=!1,e}setProps(e){if("autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"animationFrameProvider"in e){const t=e.animationFrameProvider||rt;if(t!==this.props.animationFrameProvider){const e=null!==this._animationFrameId;e&&this._cancelAnimationFrame(),this.props.animationFrameProvider=t,e&&this._requestAnimationFrame()}}return this}async start(){if(this._running)return this;this._running=!0;try{let e;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(!1!==e&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){const t=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(t),t}}stop(){if(this._running){const e=this.animationProps;this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0,e&&this.props.onFinalize(e)}return this}redraw(e,t=null){return this.device?.isLost||this._error||(this._beginFrameTimers(e),this._setupFrame(),this.animationProps&&(this.animationProps.animationFrame=t),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers()),this}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=this.props.animationFrameProvider.requestAnimationFrame(this._animationFrame.bind(this)))}_cancelAnimationFrame(){null!==this._animationFrameId&&(this.props.animationFrameProvider.cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e,t){if(this._running)try{this.redraw(e,t??null),this._requestAnimationFrame()}catch(e){const t=e instanceof Error?e:new Error(String(e));this.reportError(t),this.stop()}}_renderFrame(e){if(this.display)return void this.display._renderFrame(e);const t=this.props.onRender(this._getAnimationProps());this.device&&!1!==t&&this.device.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){const e=this.device?.getDefaultCanvasContext();if(!this.device||!e)throw new Error("loop");const t=e?.canvas,n=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:t,useDevicePixels:n,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,animationFrame:null,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;const{width:e,height:t,aspect:n}=this._getSizeAndAspect();e===this.animationProps.width&&t===this.animationProps.height||this.setNeedsRedraw("drawing buffer resized"),n!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=n,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){const e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";const t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);const n=this.props.onAddHTML(t);n&&(t.innerHTML=n)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};const[e,t]=this.device.getDefaultCanvasContext().getDrawingBufferSize();return{width:e,height:t,aspect:e>0&&t>0?e/t:1}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(e){const t=e??("undefined"!=typeof performance?performance.now():Date.now());if(this._lastFrameTime){const e=t-this._lastFrameTime;e>0&&this.frameRate.addTime(e)}this._lastFrameTime=t,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;const e=this.device.commandEncoder._gpuTimeMs;void 0!==e&&(this.gpuTime.addTime(e),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(const e of Object.keys(this.sharedStats.stats))this.stats.stats[e]||delete this.sharedStats.stats[e];this.stats.forEach(e=>{const t=this.sharedStats.get(e.name,e.type);t.sampleSize=e.sampleSize,t.time=e.time,t.count=e.count,t.samples=e.samples,t.lastTiming=e.lastTiming,t.lastSampleTime=e.lastSampleTime,t.lastSampleCount=e.lastSampleCount,t._count=e._count,t._time=e._time,t._samples=e._samples,t._startTime=e._startTime,t._timerPending=e._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}}var st=n(19852);function ot(){}function at(e){return e.deviceProps?.debug??e.debug}const ct={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,pickAsync:"auto",layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,_canvases:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:ot,onWebGLInitialized:ot,onResize:ot,onViewStateChange:ot,onInteractionStateChange:ot,onBeforeRender:ot,onAfterRender:ot,onLoad:ot,onError:e=>f.A.error(e.message,e.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:({isDragging:e})=>e?"grabbing":"grab",getTooltip:null,debug:!1,drawPickingColors:!1};class Deck{constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.eventManagers={},this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this._canvasContext=null,this._deviceResizeHandler=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new m.A({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._hoverPickSequence=0,this._pointerDownPickSequence=0,this._needsRedraw="Initial render",this._canvasManager=new CanvasManager({createEventManager:e=>this._createEventManager(e),getEventRoot:e=>this._getEventRoot(e)}),this._ownedCanvas=null,this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,canvasId:void 0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=e=>{const{_pickRequest:t}=this,n=this._getCanvasIdFromEvent(e);if("pointerleave"===e.type)t.x=-1,t.y=-1,t.radius=0,t.canvasId=n;else{if(e.leftButton||e.rightButton)return;{const i=e.offsetCenter;if(!i)return;t.x=i.x,t.y=i.y,t.radius=this.props.pickingRadius,t.canvasId=n}}this.layerManager&&(this.layerManager.context.mousePosition={x:t.x,y:t.y}),t.event=e},this._onEvent=e=>{const t=B.tg[e.type],n=e.offsetCenter,i=this._getCanvasIdFromEvent(e);if(!t||!n||!this.layerManager)return;const r=this.layerManager.getLayers(),s=this._getInternalPickingMode();if(!s)return;if("sync"===s){const t="click"===e.type&&this._shouldUnproject3D(r)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(n.x,n.y,{unproject3D:!0,canvasId:i},r))):this._getLastPointerDownPickingInfo(n.x,n.y,i,r);return void this._dispatchPickingEvent(t,e)}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(n.x,n.y,i,r))).then(t=>{this._dispatchPickingEvent(t,e)}).catch(e=>this.props.onError?.(e))},this._onPointerDown=e=>{const t=e.offsetCenter,n=this._getCanvasIdFromEvent(e);if(!t)return;const i=this._getInternalPickingMode();if(!i)return;const r=this.layerManager?.getLayers()||[],s=++this._pointerDownPickSequence;if("sync"===i){const e=this._pickPointSync({x:t.x,y:t.y,canvasId:n,radius:this.props.pickingRadius}),i=this._getFirstPickedInfo(e);return this._lastPointerDownInfo=i,void(this._lastPointerDownInfoPromise=Promise.resolve(i))}const o=this._pickPointAsync(this._getPointPickOptions(t.x,t.y,{canvasId:n},r)).then(e=>this._getFirstPickedInfo(e)).then(e=>(s===this._pointerDownPickSequence&&(this._lastPointerDownInfo=e),e)).catch(e=>{this.props.onError?.(e);const i=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(t.x,t.y,n,r):{};return s===this._pointerDownPickSequence&&(this._lastPointerDownInfo=i),i});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=o};const t=e;this.props={...ct,...e},e=this.props,this._validateCanvasConfiguration(e),e.viewState&&e.initialViewState&&f.A.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device&&(this.device=e.device,this._setDeviceCanvasContext(e.device));let n=this.device;!n&&e.gl&&(e.gl instanceof WebGLRenderingContext&&f.A.error("WebGL1 context not supported.")(),n=et.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps,debug:at(e)})),n||(n=this._createDevice(e)),this.animationLoop=this._createAnimationLoop(n,e),this.setProps(t),e._typedArrayManagerProps&&he.A.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this._restoreDeviceResizeHandler(),this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._hoverPickSequence++,this._pointerDownPickSequence++,this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,Object.keys(this._canvasManager.targets).length||this.eventManager?.destroy(),this.eventManager=null,this.eventManagers={},this.widgetManager?.finalize(),this.widgetManager=null,this._canvasManager.finalize(),this._isMultiCanvasMode()?this.canvas=null:this.canvas&&this.canvas===this._ownedCanvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null,this._ownedCanvas=null),this._canvasContext=null}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&f.A.removed("onLayerHover","onHover")(),"onLayerClick"in e&&f.A.removed("onLayerClick","onClick")(),e.initialViewState&&!(0,b.b)(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),(0,de.A)(!("_canvases"in e)||Array.isArray(e._canvases)===this._isMultiCanvasMode()),Object.assign(this.props,e),this._validateCanvasConfiguration(this.props),this._validateInternalPickingMode(),this.device&&this._isMultiCanvasMode()&&this._syncCanvasTargets(),this._setCanvasSize(this.props);const t=Object.create(this.props);if(Object.assign(t,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState(),eventManagers:this.eventManagers}),e.device&&e.device.id!==this.device?.id){const t=e.device.getDefaultCanvasContext();this.animationLoop?.stop(),this._isMultiCanvasMode()||this.canvas===t.canvas||(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),this._setDeviceCanvasContext(e.device),f.A.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()}if(this.animationLoop?.setProps(t),void 0!==e.useDevicePixels&&this._canvasContext?.setProps){this._canvasContext.setProps({useDevicePixels:e.useDevicePixels});for(const t of Object.values(this._canvasManager.targets))t.presentationContext.setProps({useDevicePixels:e.useDevicePixels})}this.layerManager&&(this.viewManager.setProps(t),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(t),this.effectManager.setProps(t),this.deckRenderer.setProps(t),this.deckPicker.setProps(t),this.widgetManager.setProps(t)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);const n=this.viewManager.needsRedraw(e),i=this.layerManager.needsRedraw(e),r=this.effectManager.needsRedraw(e),s=this.deckRenderer.needsRedraw(e);return t=t||n||i||r||s,t}redraw(e){if(!this.layerManager)return;let t=this.needsRedraw({clearRedrawFlags:!0});t=e||t,t&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(t):this._drawLayers(t))}get isInitialized(){return null!==this.viewManager}getViews(){return(0,de.A)(this.viewManager),this.viewManager.views}getView(e){return(0,de.A)(this.viewManager),this.viewManager.getView(e)}getViewports(e){return(0,de.A)(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}getCanvasContext(e){const t=e?this.viewManager?.getView(e)?.props.canvasId:void 0;return this._getCanvasContext(t)}getEventManager(e){if(!e||!this.viewManager)return this.eventManager;const t=this.viewManager.getCanvasId(e)||_;return this.eventManagers[t]||this.eventManager}async pickObjectAsync(e){const t=(await this._pickAsync("pickObjectAsync","pickObject Time",e)).result;return t.length?t[0]:null}async pickObjectsAsync(e){return await this._pickAsync("pickObjectsAsync","pickObjects Time",e)}pickObject(e){const t=this._pick("pickObject","pickObject Time",e).result;return t.length?t[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_pickPositionForController(e,t,n){return"sync"!==this._getInternalPickingMode()?null:this.pickObject({x:e,y:t,radius:0,unproject3D:!0,canvasId:n?this.viewManager?.getCanvasId(n):void 0})}_addResources(e,t=!1){for(const n in e)this.layerManager.resourceManager.add({resourceId:n,data:e[n],forceUpdate:t})}_removeResources(e){for(const t of e)this.layerManager.resourceManager.remove(t)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_resolveInternalPickingMode(){const{pickAsync:e}=this.props,t=this.device?.type||this.props.deviceProps?.type;if("auto"===e)return"webgpu"===t?"async":"sync";if("sync"===e&&"webgpu"===t)throw new Error('`pickAsync: "sync"` is not supported when Deck is using a WebGPU device.');return e}_getInternalPickingMode(){try{return this._resolveInternalPickingMode()}catch(e){return this.props.onError?.(e),null}}_validateInternalPickingMode(){this._getInternalPickingMode()}_getFirstPickedInfo({result:e,emptyInfo:t}){return e[0]||t}_shouldUnproject3D(e=this.layerManager?.getLayers()||[]){return e.some(e=>"3d"===e.props.pickable)}_getPointPickOptions(e,t,n={},i=this.layerManager?.getLayers()||[]){return{x:e,y:t,canvasId:n.canvasId,radius:this.props.pickingRadius,unproject3D:this._shouldUnproject3D(i),...n}}_pickPointSync(e){return this._pick("pickObject","pickObject Time",e)}_pickPointAsync(e){return this._pickAsync("pickObjectAsync","pickObject Time",e)}_getLastPointerDownPickingInfo(e,t,n,i=this.layerManager?.getLayers()||[]){return this.deckPicker.getLastPickedObject({x:e,y:t,layers:i,viewports:this.getViewports({x:e,y:t,canvasId:n})},this._lastPointerDownInfo)}_applyHoverCallbacks({result:e,emptyInfo:t},n){if(!this.widgetManager)return;this.cursorState.isHovering=e.length>0;let i=t,r=!1;for(const t of e)i=t,r=t.layer?.onHover(t,n)||r;r||(this.props.onHover?.(i,n),this.widgetManager.onHover(i,n))}_dispatchPickingEvent(e,t){if(!this.layerManager||!this.widgetManager)return;const n=B.tg[t.type];if(!n)return;const{layer:i}=e,r=i&&(i[n]||i.props[n]),s=this.props[n];let o=!1;r&&(o=r.call(i,e,t)),o||(s?.(e,t),this.widgetManager.onEvent(e,t))}_pickAsync(e,t,n){(0,de.A)(this.deckPicker);const{stats:i}=this,r=this._isMultiCanvasMode()?n.canvasId||this._getDefaultCanvasId():n.canvasId,s=this._getCanvasContext(r)||void 0;i.get("Pick Count").incrementCount(),i.get(t).timeStart(),this._resizeForCanvasTarget(r);const o=this.deckPicker[e]({layers:this.layerManager.getLayers(n),views:this.viewManager.getViews(),viewports:this.getViewports({...n,canvasId:r}),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...n,canvasId:r,canvasContext:s});return i.get(t).timeEnd(),o}_pick(e,t,n){(0,de.A)(this.deckPicker);const{stats:i}=this,r=this._isMultiCanvasMode()?n.canvasId||this._getDefaultCanvasId():n.canvasId,s=this._getCanvasContext(r)||void 0;i.get("Pick Count").incrementCount(),i.get(t).timeStart(),this._resizeForCanvasTarget(r);const o=this.deckPicker[e]({layers:this.layerManager.getLayers(n),views:this.viewManager.getViews(),viewports:this.getViewports({...n,canvasId:r}),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...n,canvasId:r,canvasContext:s});return i.get(t).timeEnd(),o}_createCanvas(e){let t=e.canvas;if("string"==typeof t&&(t=document.getElementById(t),(0,de.A)(t)),t)this._ownedCanvas=null;else{t=document.createElement("canvas"),t.id=e.id||"deckgl-overlay",e.width&&"number"==typeof e.width&&(t.width=e.width),e.height&&"number"==typeof e.height&&(t.height=e.height);(e.parent||document.body).appendChild(t),this._ownedCanvas=t}return Object.assign(t.style,e.style),t}_isMultiCanvasMode(){return Array.isArray(this.props._canvases)}_getDefaultCanvasId(){return this._canvasManager.order[0]||_}_validateCanvasConfiguration(e){Array.isArray(e._canvases)&&((0,de.A)(!e.canvas),(0,de.A)(!e.gl),(0,de.A)(!e.device?.canvasContext||e.device.getDefaultCanvasContext().offscreenCanvas))}_createEventManager(e){const t=new st.EU(e,{touchAction:this.props.touchAction,recognizers:Object.keys(B.We).map(e=>{const[t,n,i,r]=B.We[e],s=this.props.eventRecognizerOptions?.[e];return{recognizer:new t({...n,...s,event:e}),recognizeWith:i,requireFailure:r}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(const e in B.tg)"dblclick"===e?t.watch(e,this._onEvent):t.on(e,this._onEvent);return t}_getEventRoot(e){return e.closest(".deck-events-root")||this.props.parent?.querySelector(".deck-events-root")||e}_syncCanvasTargets(){if(!this.device||!this._isMultiCanvasMode())return;this._canvasManager.syncCanvasEntries({device:this.device,canvases:this.props._canvases||[],useDevicePixels:this.props.useDevicePixels}),this.eventManagers=this._canvasManager.eventManagers;const e=this._getDefaultCanvasId();this.eventManager=this.eventManagers[e]||null,this.canvas=this._canvasManager.targets[e]?.canvas||null}_setCanvasContext(e){this._canvasContext=e,"style"in e.canvas&&(this.canvas=e.canvas)}_setDeviceCanvasContext(e,t={}){const n=e.getDefaultCanvasContext();this._setCanvasContext(n),this._setDeviceResizeHandler(e,t)}_setDeviceResizeHandler(e,t={}){const n=Boolean(t.syncDrawingBuffer);if(this._deviceResizeHandler?.device===e)return void(this._deviceResizeHandler.syncDrawingBuffer=n);this._restoreDeviceResizeHandler();const i=e=>{this._isMultiCanvasMode()?this._updateMultiCanvasDimensions():e===this._canvasContext&&this._canvasContext&&this._onCanvasContextResize(this._canvasContext,{syncDrawingBuffer:this._deviceResizeHandler?.syncDrawingBuffer})};e.props.onResize=i,this._deviceResizeHandler={device:e,onResize:i,syncDrawingBuffer:n}}_restoreDeviceResizeHandler(){const e=this._deviceResizeHandler;e&&e.device.props?.onResize===e.onResize&&(e.device.props.onResize=ot),this._deviceResizeHandler=null}_setCanvasSize(e){if(this._isMultiCanvasMode()||!this.canvas)return;const{width:t,height:n}=e;if(t||0===t){const e=Number.isFinite(t)?`${t}px`:t;this.canvas.style.width=e}if(n||0===n){const t=Number.isFinite(n)?`${n}px`:n;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=t}}_getCanvasIdFromEvent(e){return this._canvasManager.getCanvasIdFromEvent(e?.rootElement)}_getCanvasContext(e){return this._canvasManager.getTarget(e)?.presentationContext||this._canvasContext}_resizeForCanvasTarget(e){const t=this._canvasManager.getTarget(e);if(!t||!this.device?.canvasContext)return;const[n,i]=t.presentationContext.getDrawingBufferSize();this.device.canvasContext.setDrawingBufferSize(n,i)}_createDeviceCanvas(e){if(this._isMultiCanvasMode()){const t=globalThis.OffscreenCanvas;if(!t)throw new Error("`_canvases` requires OffscreenCanvas support.");return new t("number"==typeof e.width&&Number.isFinite(e.width)?e.width:1,"number"==typeof e.height&&Number.isFinite(e.height)?e.height:1)}return this._createCanvas(e)}_updateCanvasSize(e=this._canvasContext){if(this._isMultiCanvasMode())return void this._updateMultiCanvasDimensions();const{canvas:t}=this,[n,i]=e?e.getCSSSize():[t?.clientWidth??t?.width??0,t?.clientHeight??t?.height??0];n===this.width&&i===this.height||(this.width=n,this.height=i,this.viewManager?.setProps({width:n,height:i}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:n,height:i},e||void 0))}_onCanvasContextResize(e,t={}){if(t.syncDrawingBuffer){const{width:t,height:n}=e.canvas;e.setDrawingBufferSize(t,n)}this._needsRedraw="Canvas resized",this._updateCanvasSize(e)}_updateMultiCanvasDimensions(){const[e,t]=this._getCanvasContext()?.getCSSSize()||[0,0];e===this.width&&t===this.height||(this.width=e,this.height=t,this.props.onResize({width:e,height:t})),this._needsRedraw="Canvas resized",this.viewManager?.setNeedsUpdate("Canvas resized"),this.viewManager?.setProps({width:this.width,height:this.height})}_createAnimationLoop(e,t){const{gl:n,onError:i}=t;return new AnimationLoop({device:e,autoResizeDrawingBuffer:!n&&!Array.isArray(t._canvases),autoResizeViewport:!1,onInitialize:e=>this._setDevice(e.device),onRender:this._onRenderFrame.bind(this),onError:i})}_createDevice(e){const t=this.props.deviceProps?.createCanvasContext,n="object"==typeof t?t:void 0,i={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps,debug:at(e)};i.adapters.includes(et)||i.adapters.push(et);const r={alphaMode:"webgpu"===this.props.deviceProps?.type?"premultiplied":void 0};return Ge.createDevice({_reuseDevices:!0,type:"webgl",...i,createCanvasContext:{...r,...n,canvas:this._createDeviceCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){const{views:e}=this.props,t=Array.isArray(e)?e:e?[e]:[new x.A({id:"default-view"})];return t.length&&this.props.controller&&(t[0]=t[0].clone({controller:this.props.controller})),t}_onContextLost(){const{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){const{_pickRequest:e}=this;if(e.event){const t=e.event,n=this.layerManager?.getLayers()||[],i=this._getPointPickOptions(e.x,e.y,{canvasId:e.canvasId,radius:e.radius,mode:e.mode},n),r=this._getInternalPickingMode(),s=++this._hoverPickSequence;if(e.event=null,e.canvasId=void 0,!r)return;if("sync"===r)return void this._applyHoverCallbacks(this._pickPointSync(i),t);this._pickPointAsync(i).then(({result:e,emptyInfo:n})=>{s===this._hoverPickSequence&&this._applyHoverCallbacks({result:e,emptyInfo:n},t)}).catch(e=>this.props.onError?.(e))}}_updateCursor(){const e=this.props.getCursor(this.cursorState);if(this._isMultiCanvasMode()){for(const t of Object.values(this._canvasManager.targets))t.canvas.style.cursor=e;return}const t=this.props.parent||this.canvas;t&&(t.style.cursor=e)}_setDevice(e){if(this.device=e,this._validateInternalPickingMode(),!this.animationLoop)return;this._setDeviceCanvasContext(e,{syncDrawingBuffer:Boolean(this.props.gl&&this.props.device!==e)}),this._isMultiCanvasMode()?this._syncCanvasTargets():this.canvas&&!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild),"webgl"===this.device.type&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),"webgl"===this.device.type&&this.props.onWebGLInitialized(this.device.gl);const t=new Timeline;if(t.play(),this.animationLoop.attachTimeline(t),!this._isMultiCanvasMode()){const e=this.canvas&&this._getEventRoot(this.canvas);(0,de.A)(e),this.eventManager=this._createEventManager(e),this.eventManagers={[_]:this.eventManager}}this.viewManager=new ViewManager({timeline:t,eventManager:this.eventManager,eventManagers:this.eventManagers,getCanvasContext:this._isMultiCanvasMode()?this.getCanvasContext.bind(this):void 0,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});const n=this.viewManager.getViewports()[0];this.layerManager=new LayerManager(this.device,{deck:this,stats:this.stats,viewport:n,timeline:t}),this.effectManager=new EffectManager({deck:this,device:this.device}),this.deckRenderer=new DeckRenderer(this.device,{stats:this.stats}),this.deckPicker=new DeckPicker(this.device,{stats:this.stats});const i=this.props.parent?.querySelector(".deck-widgets-root")||(this._isMultiCanvasMode()?this.props.parent||this.canvas?.parentElement:null)||this.canvas?.parentElement;this.widgetManager=new WidgetManager({deck:this,parentElement:i}),this.widgetManager.addDefault(new TooltipWidget),this.setProps({}),this._updateCanvasSize(this._canvasContext),this.props.onLoad()}_drawLayers(e,t){const{device:n,gl:i}=this.layerManager.context;this.props.onBeforeRender({device:n,gl:i});const r={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...t};if(this._isMultiCanvasMode()&&"screen"===r.pass&&!r.target&&this._canvasManager.order.length)for(const e of this._canvasManager.order){const t=r.viewports.filter(t=>this.viewManager.getCanvasId(t.id)===e);if(!t.length){const t=this._canvasManager.targets[e];this._resizeForCanvasTarget(e),this.deckRenderer?.renderLayers({...r,canvasContext:t.presentationContext,target:t.presentationContext.getCurrentFramebuffer(),viewports:[],clearCanvas:!0}),t.presentationContext.present();continue}const n=this._canvasManager.targets[e];this._resizeForCanvasTarget(e);const i=n.presentationContext.getCurrentFramebuffer();this.deckRenderer?.renderLayers({...r,canvasContext:n.presentationContext,target:i,viewports:t}),n.presentationContext.present()}else this.deckRenderer?.renderLayers(r);"screen"===r.pass&&this.widgetManager.onRedraw({viewports:r.viewports,layers:r.layers}),this.props.onAfterRender({device:n,gl:i})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60==0&&(this._getMetrics(),this.stats.reset(),f.A.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){const t=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:t},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){const{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();const t=this.animationLoop.stats;e.get("GPU Time").addTime(t.get("GPU Time").lastTiming),e.get("CPU Time").addTime(t.get("CPU Time").lastTiming)}_getMetrics(){const{metrics:e,stats:t}=this;e.fps=t.get("frameRate").getHz(),e.setPropsTime=t.get("setProps Time").time,e.updateAttributesTime=t.get("Update Attributes").time,e.framesRedrawn=t.get("Redraw Count").count,e.pickTime=t.get("pickObject Time").time+t.get("pickMultipleObjects Time").time+t.get("pickObjects Time").time,e.pickCount=t.get("Pick Count").count,e.layersCount=this.layerManager?.layers.length??0,e.drawLayersCount=t.get("Layers rendered").lastSampleCount,e.pickLayersCount=t.get("Layers picked").lastSampleCount,e.updateLayersCount=t.get("Layer updates").count,e.updateAttributesCount=t.get("Attributes updated").count,e.gpuTime=t.get("GPU Time").time,e.cpuTime=t.get("CPU Time").time,e.gpuTimePerFrame=t.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=t.get("CPU Time").getAverageTime();const n=Ge.stats.get("GPU Time and Memory");e.bufferMemory=n.get("Buffer Memory").count,e.textureMemory=n.get("Texture Memory").count,e.renderbufferMemory=n.get("Renderbuffer Memory").count,e.gpuMemory=n.get("GPU Memory").count}}Deck.defaultProps=ct,Deck.VERSION=Fe;const lt=Deck},45069(e,t,n){n.d(t,{A:()=>bt});var i={};n.r(i),n.d(i,{arithmetic:()=>A,dot:()=>R,equalAll:()=>O,extent:()=>T,fround:()=>M,gather:()=>I,interleave:()=>k,length:()=>z,segmentedMap:()=>D,select:()=>N,sequence:()=>U,swizzle:()=>V});var r=n(26839),s=n(8719),o=n(68597),a=n(57285);const c=a.r.getDataType.bind(a.r);function l(e,t,n){if(t.size>4)return null;const i="webgpu"===n&&"uint8"===t.type?"unorm8":t.type,r=t.size,s=Boolean("webgpu"!==n&&3===r&&i&&["uint8","sint8","unorm8","snorm8","uint16","sint16","unorm16","snorm16"].includes(i));return{attribute:e,format:r>1?`${i}x${r}${s?"-webgl":""}`:t.type,byteOffset:t.offset||0}}function u(e){return e.stride||e.size*e.bytesPerElement}var d=n(23459),h=n(25667),f=n(3459);function p(e,t){t.offset&&f.A.removed("shaderAttribute.offset","vertexOffset, elementOffset")();const n=u(e),i=(void 0!==t.vertexOffset?t.vertexOffset:e.vertexOffset||0)*n+(t.elementOffset||0)*e.bytesPerElement+(e.offset||0);return{...t,offset:i,stride:n}}class DataColumn{constructor(e,t,n){this._buffer=null,this.device=e,this.id=t.id||"",this.size=t.size||1;const i=t.logicalType||t.type,r="float64"===i;let s,{defaultValue:a}=t;a=Number.isFinite(a)?[a]:a||new Array(this.size).fill(0),s=r?"float32":!i&&t.isIndexed?"uint32":i||"float32";let c=function(e){switch(e){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return(0,o.Ak)(e)}}(i||s);this.doublePrecision=r,r&&!1===t.fp64&&(c=Float32Array),this.value=null,this.settings={...t,defaultType:c,defaultValue:a,logicalType:i,type:s,normalized:s.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...n,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){const e=this.getAccessor();return e.vertexOffset?e.vertexOffset*u(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}get isDoublePrecisionBuffer(){return this._shouldSplitDoublePrecisionValue(this.value)}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),d.A.release(this.state.allocatedValue),this.state.allocatedValue=null}getBuffer(){return this.state.constant&&"webgpu"!==this.device.type?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,t=null){const n={};if(this.state.constant){const i=this.value;if("webgpu"===this.device.type&&this._buffer)n[e]=this._buffer;else if(t){const r=p(this.getAccessor(),t),s=r.offset/i.BYTES_PER_ELEMENT,o=r.size||this.size;n[e]=i.subarray(s,s+o)}else n[e]=i}else n[e]=this.getBuffer();return this.doublePrecision&&(this.isDoublePrecisionBuffer?n[`${e}64Low`]=n[e]:n[`${e}64Low`]=new Float32Array(this.size)),n}_getBufferLayout(e=this.id,t=null){const n=this.getAccessor(),i=[],r={name:this.id,byteStride:"webgpu"===this.device.type&&this.state.constant?0:u(n)};if(this.doublePrecision){const r=function(e,t){const n=p(e,t);return{high:n,low:{...n,offset:n.offset+4*e.size}}}(n,t||{});i.push(l(e,{...n,...r.high},this.device.type),l(`${e}64Low`,{...n,...r.low},this.device.type))}else if(t){const r=p(n,t);i.push(l(e,{...n,...r},this.device.type))}else i.push(l(e,n,this.device.type));return r.attributes=i.filter(Boolean),r}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){const t=Array.from(this.value);e=[t,t]}else{const{value:t,numInstances:n,size:i}=this,r=n*i;if(t&&r&&t.length>=r){const n=new Array(i).fill(1/0),s=new Array(i).fill(-1/0);for(let e=0;e<r;)for(let r=0;r<i;r++){const i=t[e++];i<n[r]&&(n[r]=i),i>s[r]&&(s[r]=i)}e=[n,s]}}return this.state.bounds=e,e}setData(e){const{state:t}=this;let n;n=ArrayBuffer.isView(e)?{value:e}:e instanceof r.h?{buffer:e}:e;const i={...this.settings,...n};if(ArrayBuffer.isView(n.value)){if(!n.type){if(this.doublePrecision&&n.value instanceof Float64Array)i.type="float32";else{const e=c(n.value);i.type=i.normalized?e.replace("int","norm"):e}}i.bytesPerElement=n.value.BYTES_PER_ELEMENT,i.stride=u(i)}if(t.bounds=null,n.constant){let e=n.value;e=this._normalizeValue(e,[],0),this.settings.normalized&&(e=this.normalizeConstant(e));if(!(!t.constant||!this._areValuesEqual(e,this.value)))return!1;t.externalBuffer=null,t.constant=!0,this.value=ArrayBuffer.isView(e)?e:new Float32Array(e)}else if(n.buffer){const e=n.buffer;t.externalBuffer=e,t.constant=!1,this.value=n.value||null}else if(n.value){this._checkExternalBuffer(n);const e=n.value;let r=e;t.externalBuffer=null,t.constant=!1,this.value=e,this._shouldSplitDoublePrecisionValue(r)&&(r=(0,h.cT)(r,i),e instanceof Float32Array&&(i.stride=2*i.size*Float32Array.BYTES_PER_ELEMENT));let{buffer:s}=this;const o=u(i),a=(i.vertexOffset||0)*o;if(this.settings.isIndexed){const e=this.settings.defaultType;r.constructor!==e&&(r=new e(r))}const c=r.byteLength+a+2*o;(!s||s.byteLength<c)&&(s=this._createBuffer(c)),s.write(r,a)}return this.setAccessor(i),!0}updateSubBuffer(e={}){this.state.bounds=null;const t=this.value,{startOffset:n=0,endOffset:i}=e,r=this._shouldSplitDoublePrecisionValue(t);this.buffer.write(r?(0,h.cT)(t,{size:this.size,startIndex:n,endIndex:i}):t.subarray(n,i),n*(r?8:t.BYTES_PER_ELEMENT)+this.byteOffset)}allocate(e,t=!1){const{state:n}=this,i=n.allocatedValue,r=d.A.allocate(i,e+1,{size:this.size,type:this.settings.defaultType,copy:t});this.value=r;const s=this._shouldSplitDoublePrecisionValue(r),o=s&&r instanceof Float32Array?{...this.settings,stride:2*this.size*Float32Array.BYTES_PER_ELEMENT}:this.settings;this.setAccessor(o);const{byteOffset:a}=this;let{buffer:c}=this;const l=r.byteLength*(s&&r instanceof Float32Array?2:1);return(!c||c.byteLength<l+a)&&(c=this._createBuffer(l+a),t&&i&&c.write(this._shouldSplitDoublePrecisionValue(i)?(0,h.cT)(i,this):i,a)),n.allocatedValue=r,n.constant=!1,n.externalBuffer=null,!0}_shouldSplitDoublePrecisionValue(e){return Boolean(this.doublePrecision&&(e instanceof Float64Array||"webgpu"===this.device.type&&e instanceof Float32Array))}_checkExternalBuffer(e){const{value:t}=e;if(!ArrayBuffer.isView(t))throw new Error(`Attribute ${this.id} value is not TypedArray`);const n=this.settings.defaultType;let i=!1;if(this.doublePrecision&&(i=t.BYTES_PER_ELEMENT<4),i)throw new Error(`Attribute ${this.id} does not support ${t.constructor.name}`);t instanceof n||!this.settings.normalized||"normalized"in e||f.A.warn(`Attribute ${this.id} is normalized`)()}normalizeConstant(e){switch(this.settings.type){case"snorm8":return new Float32Array(e).map(e=>(e+128)/255*2-1);case"snorm16":return new Float32Array(e).map(e=>(e+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(e=>e/255);case"unorm16":return new Float32Array(e).map(e=>e/65535);default:return e}}_normalizeValue(e,t,n){const{defaultValue:i,size:r}=this.settings;if(Number.isFinite(e))return t[n]=e,t;if(!e){let e=r;for(;--e>=0;)t[n+e]=i[e];return t}switch(r){case 4:t[n+3]=Number.isFinite(e[3])?e[3]:i[3];case 3:t[n+2]=Number.isFinite(e[2])?e[2]:i[2];case 2:t[n+1]=Number.isFinite(e[1])?e[1]:i[1];case 1:t[n+0]=Number.isFinite(e[0])?e[0]:i[0];break;default:let s=r;for(;--s>=0;)t[n+s]=Number.isFinite(e[s])?e[s]:i[s]}return t}_areValuesEqual(e,t){if(!e||!t)return!1;const{size:n}=this;for(let i=0;i<n;i++)if(e[i]!==t[i])return!1;return!0}_createBuffer(e){this._buffer&&this._buffer.destroy();const{isIndexed:t,type:n}=this.settings,i="webgpu"!==this.device.type||t?(t?r.h.INDEX:r.h.VERTEX)|r.h.COPY_DST:r.h.VERTEX|r.h.STORAGE|r.h.COPY_DST|r.h.COPY_SRC;return this._buffer=this.device.createBuffer({...this._buffer?.props,id:this.id,usage:i,indexType:t?n:void 0,byteLength:e}),this._buffer}}var g=n(24067),m=n(53439),v=n(38055);const y=[],b=[[0,1/0]];const _={interpolation:{duration:0,easing:e=>e},spring:{stiffness:.05,damping:.5}};function x(e,t){if(!e)return null;Number.isFinite(e)&&(e={type:"interpolation",duration:e});const n=e.type||"interpolation";return{..._[n],...t,...e,type:n}}class Attribute extends DataColumn{constructor(e,t){super(e,t,{startIndices:null,constantValue:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:b}),this.constant=!1,this.settings.update=t.update||(t.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){const t=this.state.needsRedraw;return this.state.needsRedraw=t&&!e,t}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var t,n,i;(t=this.state).layoutChanged||(t.layoutChanged=(n=e,i=this.getAccessor(),!(n.type===i.type&&n.size===i.size&&u(n)===u(i)&&(n.offset||0)===(i.offset||0)))),super.setAccessor(e)}getUpdateTriggers(){const{accessor:e}=this.settings;return[this.id].concat("function"!=typeof e&&e||[])}supportsTransition(){return Boolean(this.settings.transition)}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;const{accessor:t}=this.settings,n=this.settings.transition;return x(Array.isArray(t)?e[t.find(t=>e[t])]:e[t],n)}setNeedsUpdate(e=this.id,t){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),t){const{startRow:e=0,endRow:n=1/0}=t;this.state.updateRanges=function(e,t){if(e===b)return e;if(t[0]<0&&(t[0]=0),t[0]>=t[1])return e;const n=[],i=e.length;let r=0;for(let s=0;s<i;s++){const i=e[s];i[1]<t[0]?(n.push(i),r=s+1):i[0]>t[1]?n.push(i):t=[Math.min(i[0],t[0]),Math.max(i[1],t[1])]}return n.splice(r,0,t),n}(this.state.updateRanges,[e,n])}else this.state.updateRanges=b}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=y}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){const{state:t,settings:n}=this;if(n.noAlloc)return!1;if(n.update){const n=this.isConstant;return super.allocate(e,t.updateRanges!==b),t.layoutChanged||(t.layoutChanged=n&&"webgpu"===this.device.type),!0}return!1}updateBuffer({numInstances:e,data:t,props:n,context:i}){if(!this.needsUpdate())return!1;const{state:{updateRanges:r},settings:{update:s,noAlloc:o}}=this;let a=!0;if(s){for(const[o,a]of r)s.call(i,this,{data:t,startRow:o,endRow:a,props:n,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLength<this.value.byteLength+this.byteOffset){if(this.constant){const e=this.value;this.value=null,this.setConstantValue(i,e)}else this.setData({value:this.value,constant:this.constant});this.constant=!1}else for(const[t,n]of r){const i=Number.isFinite(t)?this.getVertexOffset(t):0,r=Number.isFinite(n)?this.getVertexOffset(n):o||!Number.isFinite(e)?this.value.length:e*this.size;super.updateSubBuffer({startOffset:i,endOffset:r})}else;this._checkAttributeArray()}else a=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),a}setConstantValue(e,t){var n;if(void 0===t||"function"==typeof t)return!1;const i=this.isConstant,r=this.settings.transform&&e?this.settings.transform.call(e,t):t,s=this.settings.defaultType;this.state.constantValue=this._normalizeValue(r,new s(this.size),0);const o=this.setData({constant:!0,value:r});if("webgpu"===this.device.type){let e=this.state.constantValue;this.doublePrecision&&(e instanceof Float32Array||e instanceof Float64Array)&&(e=(0,h.cT)(e,{size:this.size}),this.setAccessor({...this.getAccessor(),stride:2*this.size*Float32Array.BYTES_PER_ELEMENT}));let t=this._buffer;(!t||t.byteLength<e.byteLength)&&(t=this._createBuffer(e.byteLength)),t.write(e),(n=this.state).layoutChanged||(n.layoutChanged=!i),this.constant=!1}return o&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0}getConstantValue(){return this.isConstant?this.state.constantValue:null}setExternalBuffer(e){const{state:t}=this;return e?(this.clearNeedsUpdate(),t.lastExternalBuffer===e||(t.lastExternalBuffer=e,this.setNeedsRedraw(),this.setData(e)),!0):(t.lastExternalBuffer=null,!1)}setBinaryValue(e,t=null){const{state:n,settings:i}=this;if(!e)return n.binaryValue=null,n.binaryAccessor=null,!1;if(i.noAlloc)return!1;if(n.binaryValue===e)return this.clearNeedsUpdate(),!0;n.binaryValue=e,this.setNeedsRedraw();if(i.transform||t!==this.startIndices){ArrayBuffer.isView(e)&&(e={value:e});const r=e;(0,g.A)(ArrayBuffer.isView(r.value),`invalid ${i.accessor}`);const s=Boolean(r.size)&&r.size!==this.size;return n.binaryAccessor=(0,m.I)(r.value,{size:r.size||this.size,stride:r.stride,offset:r.offset,startIndices:t,nested:s}),!1}return this.clearNeedsUpdate(),this.setData(e),!0}getVertexOffset(e){const{startIndices:t}=this;return(t?e<t.length?t[e]:this.numInstances:e)*this.size}getValue(){const e=this.settings.shaderAttributes,t=super.getValue();if(!e)return t;for(const n in e)Object.assign(t,super.getValue(n,e[n]));return t}getBufferLayout(e){this.state.layoutChanged=!1;const t=this.settings.shaderAttributes,n=super._getBufferLayout(),{stepMode:i}=this.settings;if(n.stepMode="dynamic"===i?e?e.isInstanced?"instance":"vertex":"instance":i??"vertex",!t)return n;for(const e in t){const i=super._getBufferLayout(e,t[e]);n.attributes.push(...i.attributes)}return n}_autoUpdater(e,{data:t,startRow:n,endRow:i,props:r,numInstances:s}){const{settings:o,state:a,value:c,size:l,startIndices:u}=e,{accessor:d,transform:h}=o,f=a.binaryAccessor||("function"==typeof d?d:r[d]);(0,g.A)("function"==typeof f,`accessor "${d}" is not a function`);let p=e.getVertexOffset(n);const{iterable:y,objectInfo:b}=(0,m.X)(t,n,i);for(const t of y){b.index++;let n=f(t,b);if(h&&(n=h.call(this,n)),u){const t=(b.index<u.length-1?u[b.index+1]:s)-u[b.index];if(n&&Array.isArray(n[0])){let t=p;for(const i of n)e._normalizeValue(i,c,t),t+=l}else n&&n.length>l?c.set(n,p):(e._normalizeValue(n,b.target,0),(0,v.R)({target:c,source:b.target,start:p,count:t}));p+=t*l}else e._normalizeValue(n,c,p),p+=l}}_validateAttributeUpdaters(){const{settings:e}=this;if(!(e.noAlloc||"function"==typeof e.update))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){const{value:e}=this,t=Math.min(4,this.size);if(e&&e.length>=t){let n=!0;switch(t){case 4:n=n&&Number.isFinite(e[3]);case 3:n=n&&Number.isFinite(e[2]);case 2:n=n&&Number.isFinite(e[1]);case 1:n=n&&Number.isFinite(e[0]);break;default:n=!1}if(!n)throw new Error(`Illegal attribute generated for ${this.id}`)}}}var w=n(29651),P=n(78705);function C({elementWise:e,func:t,inputs:n,output:i,outputBuffer:r}){const s=Array.isArray(n)?n:Object.values(n);for(const e of s)if(!e.value)throw new Error(`${e} does not have CPU value`);const o=i.length,a=i.size,c=new i.ValueType(o*a);for(let n=0;n<o;n++){const i=s.map(e=>S(e,n));if(e)for(let e=0;e<a;e++)c[n*a+e]=t.apply(null,i.map(t=>t[e]));else t.call(null,c.subarray(n*a,n*a+a),...i)}const l=i.ValueType.BYTES_PER_ELEMENT,u=i.offset/l,d=i.stride/l,h=a;let f=c;if(0!==u||d!==h){f=new i.ValueType(u+i.byteLength/l);for(let e=0;e<o;e++){const t=e*h,n=u+e*d,i=c.subarray(t,t+a);f.set(i,n),r.write(i,n*l)}}else r.write(c);return{success:!0,value:f}}function S(e,t){const n=e.value,i=e.size,r=e.offset/e.ValueType.BYTES_PER_ELEMENT,s=e.stride/e.ValueType.BYTES_PER_ELEMENT,o=r+(e.isConstant?0:t)*s,a=n.slice(o,o+i);if(!e.normalized)return a;const c=new Float32Array(i);for(let t=0;t<i;t++)c[t]=L(a[t],e.type);return c}function L(e,t){switch(t){case"uint8":return e/255;case"uint16":return e/65535;case"uint32":return e/4294967295;case"sint8":return Math.max(e/127,-1);case"sint16":return Math.max(e/32767,-1);case"sint32":return Math.max(e/2147483647,-1);case"float32":return e;default:throw new Error(`Unsupported normalized source type ${t}`)}}const A=({inputs:e,output:t,target:n})=>{for(const t of Object.values(e.namedInputs))if(!t.value)throw new Error(`${t} does not have CPU value`);const i=new t.ValueType(t.length*t.size);for(let n=0;n<t.length;n++){const r=Object.fromEntries(Object.entries(e.namedInputs).map(([e,t])=>[e,S(t,n)]));for(let s=0;s<t.size;s++)i[n*t.size+s]=E(e.expression,r,s)}return n.write(i),{success:!0,value:i}};function E(e,t,n){switch(e.kind){case"input":{const i=t[e.name];return n<i.length?i[n]:1===i.length?i[0]:0}case"literal":return Array.isArray(e.value)?e.value[n]??0:e.value;case"call":{!function(e,t){const n=P.E[e].arity;if(t!==n)throw new Error(`Arithmetic op '${e}' expects ${n} args, got ${t}`)}(e.op,e.args.length);const i=e.args.map(e=>E(e,t,n));switch(e.op){case"add":return i[0]+i[1];case"subtract":return i[0]-i[1];case"multiply":return i[0]*i[1];case"divide":return i[0]/i[1];case"pow":return Math.pow(i[0],i[1]);case"sqrt":return Math.sqrt(i[0]);case"abs":return Math.abs(i[0]);case"sin":return Math.sin(i[0]);case"cos":return Math.cos(i[0]);case"tan":return Math.tan(i[0]);case"exp":return Math.exp(i[0]);case"log":return Math.log(i[0]);default:{const t=e.op;throw new Error(`Unsupported arithmetic op ${t}`)}}}default:throw new Error(`Unsupported expression node ${e.kind}`)}}const T=({inputs:e,output:t,target:n})=>{const{sourceValues:i}=e;if(!i.value)throw new Error(`${i} does not have CPU value`);const r=new t.ValueType(t.length*t.size);if(0===i.length)return{success:!1,error:new Error(`${i} is empty`)};for(let e=0;e<i.size;e++){const n=S(i,0)[e],s=e*t.size,o=s+1;r[s]=n,r[o]=n;for(let t=1;t<i.length;t++){const n=S(i,t)[e];n<r[s]&&(r[s]=n),n>r[o]&&(r[o]=n)}}return n.write(r),{success:!0,value:r}},M=({inputs:e,output:t,target:n})=>C({func:(e,t)=>{const n=e.length/2,i=new Float64Array(t.buffer);for(let t=0;t<n;t++){const r=i[t];e[t]=Math.fround(r),e[t+n]=r-e[t]}return e},inputs:e,output:t,outputBuffer:n}),I=async({inputs:e,output:t,target:n})=>{const{ids:i,sourceValues:r}=e,s=i.value,o=r.value;if(!s)throw new Error(`${i} does not have CPU value`);if(!o)throw new Error(`${r} does not have CPU value`);const a=new t.ValueType(t.length*t.size),c=new Array(t.size).fill(0);for(let e=0;e<t.length;e++){const n=S(i,e),s=Number(n[0]),o=B(s,r.length)?S(r,s):c;a.set(o,e*t.size)}return n.write(a),{success:!0,value:a}};function B(e,t){return Number.isInteger(e)&&e>=0&&e<t}const k=({inputs:e,output:t,target:n})=>C({func:(e,...t)=>{let n=0;for(const i of t)e.set(i,n),n+=i.length},inputs:e,output:t,outputBuffer:n}),R=({inputs:e,output:t,target:n})=>{const{x:i,y:r}=e,s=new t.ValueType(t.length);for(let e=0;e<t.length;e++){const t=S(i,e),n=S(r,e);let o=0;for(let e=0;e<i.size;e++)o+=t[e]*n[e];s[e]=o}return n.write(s),{success:!0,value:s}},O=({inputs:e,output:t,target:n})=>{const{x:i,y:r}=e,s=new t.ValueType(t.length);for(let e=0;e<t.length;e++){const t=S(i,e),n=S(r,e);let o=1;for(let e=0;e<i.size;e++)if(t[e]!==n[e]){o=0;break}s[e]=o}return n.write(s),{success:!0,value:s}},z=({inputs:e,output:t,target:n})=>{const{x:i}=e,r=new t.ValueType(t.length);for(let e=0;e<t.length;e++){const t=S(i,e);let n=0;for(let e=0;e<i.size;e++)n+=t[e]*t[e];r[e]=Math.sqrt(n)}return n.write(r),{success:!0,value:r}},D=async({inputs:e,output:t,target:n})=>{const{segments:i,vertexCount:r}=e,s=i.value;if(!s)throw new Error(`${i} does not have CPU value`);!function(e,t,n){if(t.length<1)throw new Error("segmentedMap segments must contain at least one segment start");let i=0;for(let n=0;n<t.length;n++){const r=e[F(t,n)];if(0===n&&0!==r)throw new Error(`segmentedMap segments must start at 0, got ${r}`);if(n>0&&r<i)throw new Error(`segmentedMap segments must be non-decreasing, got ${r} after ${i}`);i=r}if(i>n)throw new Error(`segmentedMap last segment start must be <= vertexCount, got ${i} > ${n}`)}(s,i,r);const o=new t.ValueType(t.length*t.size);let a=0;for(let e=0;e<r;e++){for(;a+1<i.length&&s[F(i,a+1)]<=e;)a++;const n=s[F(i,a)],r=e*t.size;o[r]=a,o[r+1]=e-n}return n.write(o),{success:!0,value:o}};function F(e,t){return e.offset/e.ValueType.BYTES_PER_ELEMENT+t*(e.stride/e.ValueType.BYTES_PER_ELEMENT)}const N=async({inputs:e,output:t,target:n})=>{const{condition:i,whenTrue:r,whenFalse:s}=e,o=new t.ValueType(t.length*t.size);for(let e=0;e<t.length;e++){const n=S(i,e),a=S(r,e),c=S(s,e);for(let l=0;l<t.size;l++){const u=$(n,i.size,l);o[e*t.size+l]=0!==u?$(a,r.size,l):$(c,s.size,l)}}return n.write(o),{success:!0,value:o}};function $(e,t,n){return n<t?e[n]:1===t?e[0]:0}const U=({inputs:e,output:t,target:n})=>{const i=new t.ValueType(t.length);for(let n=0;n<t.length;n++)i[n]=e.start+n*e.step;return n.write(i),{success:!0,value:i}},V=({inputs:e,output:t,target:n})=>{const{columns:i}=e;return C({func:(e,t)=>{for(let n=0;n<i.length;n++)e[n]=t[i[n]]},inputs:{x:e.x},output:t,outputBuffer:n})};const G=new class BackendRegistry{_modules={cpu:i};add(e,t){const n=this._modules[e];if("function"==typeof t.then){const i=Promise.all([Promise.resolve(n||{}),t]).then(([e,t])=>({...e,...t}));return this._modules[e]=i,i.then(t=>{this._modules[e]=t}).catch(t=>{w.R.error(`Failed to register ${e} backend: ${t}`)()}),i}if(n&&"function"==typeof n.then){const i=Promise.resolve(n).then(e=>({...e,...t})).then(t=>(this._modules[e]=t,t)).catch(t=>{throw w.R.error(`Failed to register ${e} backend: ${t}`)(),t});return this._modules[e]=i,i}const i={...n||{},...t};return this._modules[e]=i,Promise.resolve(i)}async get(e,t){let i=this._modules[e];if(!i)if("webgl"===e)i=this.add("webgl",n.e(630).then(()=>n(66630)));else{if("webgpu"!==e)throw new Error(`${e} backend not registered`);i=this.add("webgpu",n.e(34).then(()=>n(13034)))}const r=(await i)[t];if("function"!=typeof r)throw new Error(`${e} backend does not implement ${t}`);return r}getSync(e,t){const n=this._modules[e];if(!n)throw new Error(`${e} backend not registered`);if("function"==typeof n.then)throw new Error(`${e} backend is not loaded yet`);const i=n[t];if("function"!=typeof i)throw new Error(`${e} backend does not implement ${t}`);return i}clear(){this._modules={}}};var j=n(34010);class Operation{inputs;dependencies;constructor(e){this.inputs=e,this.dependencies=Array.from(e instanceof Array?e:Object.values(e)).filter(e=>e instanceof j.GL)}async execute(e,t){return await this._resolveDependencies(e),await this._executeWithHandler(await G.get(this._getHandlerRegistry(e),this.name),t)}executeSync(e,t){this._resolveDependenciesSync(e);const n=this._executeWithHandler(G.getSync(this._getHandlerRegistry(e),this.name),t);if(i=n,"function"==typeof i?.then)throw new Error(`${this.name} returned a Promise in executeSync()`);var i;return n}shouldExecuteOnCPU(){return this.output.length<=1&&Array.from(this.dependencies).every(e=>Boolean(e.value))}_getHandlerRegistry(e){return this.shouldExecuteOnCPU()?"cpu":e.type}async _resolveDependencies(e){for(const t of this.dependencies)await t.evaluate(e);if("cpu"===this._getHandlerRegistry(e)||"null"===e.type)for(const e of this.dependencies)await e.ensureCPUValue()}_resolveDependenciesSync(e){for(const t of this.dependencies)t.evaluateSync(e);if("cpu"===this._getHandlerRegistry(e)||"null"===e.type)for(const e of this.dependencies)e.ensureCPUValueSync()}_executeWithHandler(e,t){return e({device:t.device,inputs:this.inputs,output:this.output,target:t})}}function W(...e){let t=function(e){let t=0,n=0;for(const i of e){if("f"===i[0])return"float32";const e=i.endsWith("8")?8:i.endsWith("6")?16:32;"u"===i[0]?t=Math.max(t,e):n=Math.max(n,e)}if(t&&!n)return`uint${t}`;if(n&&t<32)return`sint${Math.max(n,2*t)}`;return"float32"}(e.map(e=>e.type));return"f"!==t[0]&&e.some(e=>e.normalized)&&(t="float32"),{isConstant:e.every(e=>e.isConstant),type:t,size:e.reduce((e,t)=>Math.max(e,t.size),0),length:e.reduce((e,t)=>Math.max(e,t.length),0)}}class InterleaveOperation extends Operation{name="interleave";output;constructor(e){super(e);const{isConstant:t,type:n,length:i}=W(...e);this.output=new j.GL({isConstant:t,type:n,size:e.reduce((e,t)=>e+t.size,0),length:i,source:this})}toString(){return`_${this.inputs.join("_")}_`}}var H=n(99305),q=n(65181);class GPUVectorEvaluator{gpuDataEvaluators;format;length;id;_gpuVector;_ownsGPUDataEvaluators;_destroyed=!1;static fromGPUVector(e){if(e.bufferLayout)throw new Error(`GPUVectorEvaluator.fromGPUVector() does not accept interleaved vector "${e.name}"`);if(0===e.data.length)throw new Error(`GPUVectorEvaluator.fromGPUVector() requires GPUData for "${e.name}"`);return new GPUVectorEvaluator({id:e.name,gpuDataEvaluators:e.data.map(t=>j.GL.fromGPUData(t,{id:e.name})),gpuVector:e,format:e.format})}static fromGPUDataEvaluators(e,t={}){return new GPUVectorEvaluator({id:t.id,gpuDataEvaluators:e,format:t.format})}constructor({id:e,gpuDataEvaluators:t,gpuVector:n,format:i}){if(0===t.length)throw new Error("GPUVectorEvaluator requires at least one GPUData evaluator");!function(e){const t=e[0];for(const n of e.slice(1))if(n.type!==t.type||n.size!==t.size||n.normalized!==t.normalized||n.format!==t.format)throw new Error("GPUVectorEvaluator requires matching GPUData evaluator layouts")}(t),this.id=e,this.gpuDataEvaluators=t,this.format=i??t[0].format,this.length=t.reduce((e,t)=>e+t.length,0),this._gpuVector=n,this._ownsGPUDataEvaluators=!n}get evaluated(){return Boolean(this._gpuVector)}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}mapGPUData(e){return GPUVectorEvaluator.fromGPUDataEvaluators(this.gpuDataEvaluators.map((t,n)=>e(t,n)),{id:this.id})}async evaluate(e,t={}){if(this._destroyed)throw new Error(`GPUVectorEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;const n=await Promise.all(this.gpuDataEvaluators.map(n=>n.evaluate(e,t))),i=n[0],r=n.map(Z),s=t.format??this.format??i.format;return this._gpuVector=new q.M({type:"data",name:t.name??this.id??"vector",format:s,data:r,stride:i.stride,byteStride:i.byteStride,rowByteLength:i.rowByteLength,bufferLayout:i.bufferLayout}),this._gpuVector}evaluateSync(e,t={}){if(this._destroyed)throw new Error(`GPUVectorEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;const n=this.gpuDataEvaluators.map(n=>n.evaluateSync(e,t)),i=n[0],r=n.map(Z),s=t.format??this.format??i.format;return this._gpuVector=new q.M({type:"data",name:t.name??this.id??"vector",format:s,data:r,stride:i.stride,byteStride:i.byteStride,rowByteLength:i.rowByteLength,bufferLayout:i.bufferLayout}),this._gpuVector}destroy(){if(this._ownsGPUDataEvaluators)for(const e of this.gpuDataEvaluators)e.destroy();this._gpuVector=void 0,this._destroyed=!0}toString(){return this.id??this.constructor.name}}function Z(e){const[t,...n]=e.data;if(!t||n.length>0)throw new Error(`GPUVectorEvaluator requires one GPUData chunk for "${e.name}"`);return t}function Y(e){const t=new Set(e.flatMap(J)),n=new Set;for(const t of e)X(t,n);for(const e of n)e.evaluated&&!t.has(e.buffer)&&e.destroy()}function K(e){const t=new Set;return Q(e,t,new Set),Array.from(t)}function Q(e,t,n){if(function(e){return e instanceof j.GL||e instanceof GPUVectorEvaluator}(e))t.add(e);else if(e&&"object"==typeof e&&!n.has(e))if(n.add(e),Array.isArray(e))for(const i of e)Q(i,t,n);else if(function(e){const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(e))for(const i of Object.values(e))Q(i,t,n)}function X(e,t){if(e instanceof GPUVectorEvaluator){for(const n of e.gpuDataEvaluators)X(n,t);return}const n=e.source;if(n)if(n instanceof j.GL)t.has(n)||(t.add(n),X(n,t));else for(const e of n.dependencies)t.has(e)||(t.add(e),X(e,t))}function J(e){return e instanceof j.GL?[e.buffer]:e.gpuVector.data.map(e=>e.buffer instanceof H.kL?e.buffer.buffer:e.buffer)}var ee=n(10924);class AttributeBufferGroups{constructor(e,{id:t,isTransitionAttribute:n}){this.packedBuffers={},this.device=e,this.id=t,this.isTransitionAttribute=n,"webgpu"===this.device.type&&G.add("webgpu",{interleave:ee.C})}hasGroups(e){return"webgpu"===this.device.type&&Object.values(e).some(e=>Boolean(e.settings.bufferGroup))}finalize(){for(const e of Object.values(this.packedBuffers))e.packed.destroy();this.packedBuffers={}}getBufferLayouts(e,t){const n=this._getPackedGroups(e,t,{requireValues:!1,excludeAttributes:{}});return this._getBufferLayouts(e,n,t)}getBindings(e,t,n,i){const r=this._getPackedGroups(e,n,{requireValues:!0,excludeAttributes:i}),s={},o=new Set;for(const e of r.values()){const n=!this.packedBuffers[e.id]||e.attributes.some(e=>Boolean(t[e.id]));s[e.id]=this._getPackedBuffer(e,n);for(const t of e.attributes)o.add(t.id)}return{bufferLayouts:this._getBufferLayouts(e,r,n).filter(t=>!i[t.name]&&!e[t.name]?.settings.isIndexed),buffers:s,groupedAttributeIds:o}}_getPackedGroups(e,t,{requireValues:n,excludeAttributes:i}){const r=new Map;for(const t of Object.values(e)){const e=t.settings.bufferGroup;if(!e)continue;const n=r.get(e)||[];n.push(t),r.set(e,n)}const s=new Map;for(const[e,o]of r){const r=this._getPackedGroup(e,o,t,n,i);r&&s.set(e,r)}return s}_getPackedGroup(e,t,n,i,r){if(t.length<2)return null;const s=t.map(e=>e.getBufferLayout(n)),o=s[0].stepMode,a=Math.max(1,t[0].numInstances),c=i&&t.every(e=>e.isConstant);for(let e=0;e<t.length;e++){const n=t[e],c=n.getAccessor(),l=c.size*c.bytesPerElement;if(r[n.id]||n.settings.isIndexed||n.settings.noAlloc||n.doublePrecision||this.isTransitionAttribute(n.id)||s[e].stepMode!==o||n.numInstances!==t[0].numInstances||0!==(c.offset||0)||0!==(c.vertexOffset||0)||u(c)!==l||i&&(n.isConstant?!n.getConstantValue()||n.getConstantValue().byteLength<l:!ArrayBuffer.isView(n.value)||n.value.byteLength<a*l))return null}const l={},d=[];let h=0;for(let e=0;e<t.length;e++){const n=t[e];h=te(h),l[n.id]=h;for(const t of s[e].attributes||[])d.push({...t,byteOffset:h+(t.byteOffset||0)});h+=u(n.getAccessor())}return h=te(h),{id:e,attributes:t,byteStride:h,byteOffsets:l,rowCount:a,layout:{name:e,byteStride:c?0:h,stepMode:o,attributes:d}}}_getBufferLayouts(e,t,n){const i=[],r=new Set,s=new Set;for(const e of t.values())for(const t of e.attributes)s.add(t.id);for(const o of Object.values(e)){const e=o.settings.bufferGroup,a=e&&t.get(e);a&&s.has(o.id)?r.has(a.id)||(i.push(a.layout),r.add(a.id)):i.push(o.getBufferLayout(n))}return i}_getPackedBuffer(e,t){const n=JSON.stringify({byteStride:e.layout.byteStride,attributes:e.layout.attributes}),i=this.packedBuffers[e.id];if(i&&i.layoutKey===n||(t=!0),t){i&&(i.packed.destroy(),delete this.packedBuffers[e.id]);const t=this._interleavePackedGroup(e);return this.packedBuffers[e.id]={packed:t,layoutKey:n},t.buffer}if(!i)throw new Error(`Attribute buffer group ${e.id} has no packed buffer`);return i.packed.buffer}_interleavePackedGroup(e){const t=function(...e){if(0===e.length)throw new Error("interleave() requires at least one input");return 1===e.length?(0,j.uy)(e[0]):new InterleaveOperation(e.map(j.uy)).output}(...e.attributes.map(t=>this._getInterleaveInput(e,t)));return function(e,t){const n=K(t);for(const t of n)t.evaluateSync(e);Y(n)}(this.device,t),t}_getInterleaveInput(e,t){const n=u(t.getAccessor()),i=e.byteOffsets[t.id];if(ne(`${e.id}.${t.id} rowByteLength`,n),ne(`${e.id}.${t.id} groupByteOffset`,i),t.isConstant){const i=t.getConstantValue();if(!i)throw new Error(`Attribute group ${e.id} is missing constant value ${t.id}`);return ne(`${e.id}.${t.id} constant byteOffset`,i.byteOffset),new j.GL({id:t.id,type:"uint32",size:n/4,isConstant:!0,value:new Uint32Array(i.buffer,i.byteOffset,n/Uint32Array.BYTES_PER_ELEMENT)})}const r=t.getBuffer(),s=t.byteOffset,o=t.getAccessor().stride||n;if(ne(`${e.id}.${t.id} byteOffset`,s),ne(`${e.id}.${t.id} stride`,o),!r)throw new Error(`Attribute group ${e.id} cannot interleave missing buffer ${t.id}`);return new j.GL({id:t.id,type:"uint32",size:n/4,offset:s,stride:o,length:e.rowCount,buffer:r})}}function te(e){return 4*Math.ceil(e/4)}function ne(e,t){if(t%4!=0)throw new Error(`Attribute buffer groups require 32-bit alignment: ${e}=${t}`)}var ie=n(82417),re=n(43411),se=n(55795);function oe(e,t=[],n=0){const i=Math.fround(e),r=e-i;return t[n]=i,t[n+1]=r,t}const ae="\nlayout(std140) uniform fp64arithmeticUniforms {\n uniform float ONE;\n uniform float SPLIT;\n} fp64;\n\n/*\nAbout LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n\nThe purpose of this workaround is to prevent shader compilers from\noptimizing away necessary arithmetic operations by swapping their sequences\nor transform the equation to some 'equivalent' form.\n\nThese helpers implement Dekker/Veltkamp-style error tracking. If the compiler\nfolds constants or reassociates the arithmetic, the high/low split can stop\ntracking the rounding error correctly. That failure mode tends to look fine in\nsimple coordinate setup, but then breaks down inside iterative arithmetic such\nas fp64 Mandelbrot loops.\n\nThe method is to multiply an artifical variable, ONE, which will be known to\nthe compiler to be 1 only at runtime. The whole expression is then represented\nas a polynomial with respective to ONE. In the coefficients of all terms, only one a\nand one b should appear\n\nerr = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE\n*/\n\nfloat prevent_fp64_optimization(float value) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n return value + fp64.ONE * 0.0;\n#else\n return value;\n#endif\n}\n\n// Divide float number to high and low floats to extend fraction bits\nvec2 split(float a) {\n // Keep SPLIT as a runtime uniform so the compiler cannot fold the Dekker\n // split into a constant expression and reassociate the recovery steps.\n float split = prevent_fp64_optimization(fp64.SPLIT);\n float t = prevent_fp64_optimization(a * split);\n float temp = t - a;\n float a_hi = t - temp;\n float a_lo = a - a_hi;\n return vec2(a_hi, a_lo);\n}\n\n// Divide float number again when high float uses too many fraction bits\nvec2 split2(vec2 a) {\n vec2 b = split(a.x);\n b.y += a.y;\n return b;\n}\n\n// Special sum operation when a > b\nvec2 quickTwoSum(float a, float b) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float sum = (a + b) * fp64.ONE;\n float err = b - (sum - a) * fp64.ONE;\n#else\n float sum = a + b;\n float err = b - (sum - a);\n#endif\n return vec2(sum, err);\n}\n\n// General sum operation\nvec2 twoSum(float a, float b) {\n float s = (a + b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * fp64.ONE - a) * fp64.ONE;\n float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE + (b - v);\n#else\n float v = s - a;\n float err = (a - (s - v)) + (b - v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSub(float a, float b) {\n float s = (a - b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * fp64.ONE - a) * fp64.ONE;\n float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE - (b + v);\n#else\n float v = s - a;\n float err = (a - (s - v)) - (b + v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSqr(float a) {\n float prod = a * a;\n vec2 a_fp64 = split(a);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float err = ((a_fp64.x * a_fp64.x - prod) * fp64.ONE + 2.0 * a_fp64.x *\n a_fp64.y * fp64.ONE * fp64.ONE) + a_fp64.y * a_fp64.y * fp64.ONE * fp64.ONE * fp64.ONE;\n#else\n float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;\n#endif\n return vec2(prod, err);\n}\n\nvec2 twoProd(float a, float b) {\n float prod = a * b;\n vec2 a_fp64 = split(a);\n vec2 b_fp64 = split(b);\n // twoProd is especially sensitive because mul_fp64 and div_fp64 both depend\n // on the split terms and cross terms staying in the original evaluation\n // order. If the compiler folds or reassociates them, the low part tends to\n // collapse to zero or NaN on some drivers.\n float highProduct = prevent_fp64_optimization(a_fp64.x * b_fp64.x);\n float crossProduct1 = prevent_fp64_optimization(a_fp64.x * b_fp64.y);\n float crossProduct2 = prevent_fp64_optimization(a_fp64.y * b_fp64.x);\n float lowProduct = prevent_fp64_optimization(a_fp64.y * b_fp64.y);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float err1 = (highProduct - prod) * fp64.ONE;\n float err2 = crossProduct1 * fp64.ONE * fp64.ONE;\n float err3 = crossProduct2 * fp64.ONE * fp64.ONE * fp64.ONE;\n float err4 = lowProduct * fp64.ONE * fp64.ONE * fp64.ONE * fp64.ONE;\n#else\n float err1 = highProduct - prod;\n float err2 = crossProduct1;\n float err3 = crossProduct2;\n float err4 = lowProduct;\n#endif\n float err = ((err1 + err2) + err3) + err4;\n return vec2(prod, err);\n}\n\nvec2 sum_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSum(a.x, b.x);\n t = twoSum(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 sub_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSub(a.x, b.x);\n t = twoSub(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 mul_fp64(vec2 a, vec2 b) {\n vec2 prod = twoProd(a.x, b.x);\n // y component is for the error\n prod.y += a.x * b.y;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n prod.y += a.y * b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n return prod;\n}\n\nvec2 div_fp64(vec2 a, vec2 b) {\n float xn = 1.0 / b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n vec2 yn = mul_fp64(a, vec2(xn, 0));\n#else\n vec2 yn = a * xn;\n#endif\n float diff = (sub_fp64(a, mul_fp64(b, yn))).x;\n vec2 prod = twoProd(xn, diff);\n return sum_fp64(yn, prod);\n}\n\nvec2 sqrt_fp64(vec2 a) {\n if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);\n if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);\n\n float x = 1.0 / sqrt(a.x);\n float yn = a.x * x;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n vec2 yn_sqr = twoSqr(yn) * fp64.ONE;\n#else\n vec2 yn_sqr = twoSqr(yn);\n#endif\n float diff = sub_fp64(a, yn_sqr).x;\n vec2 prod = twoProd(x * 0.5, diff);\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n return sum_fp64(split(yn), prod);\n#else\n return sum_fp64(vec2(yn, 0.0), prod);\n#endif\n}\n";const ce={name:"fp64arithmetic",source:"struct Fp64ArithmeticUniforms {\n ONE: f32,\n SPLIT: f32,\n};\n\n@group(0) @binding(auto) var<uniform> fp64arithmetic : Fp64ArithmeticUniforms;\n\n#ifndef LUMA_FP64_F32_INPUT_ONLY\nstruct Fp64Bits {\n sign: u32,\n exponent: i32,\n significand: vec2u,\n isZero: bool,\n isInf: bool,\n isNan: bool,\n};\n#endif\n\n#ifndef LUMA_FP64_PREDICATE_ONLY\nfn fp64_nan(seed: f32) -> f32 {\n let nanBits = 0x7fc00000u | select(0u, 1u, seed < 0.0);\n return bitcast<f32>(nanBits);\n}\n#endif\n\nfn fp64_u64_is_zero(value: vec2u) -> bool {\n return value.x == 0u && value.y == 0u;\n}\n\nfn fp64_u64_compare(a: vec2u, b: vec2u) -> i32 {\n if (a.x != b.x) {\n return select(-1, 1, a.x > b.x);\n }\n if (a.y != b.y) {\n return select(-1, 1, a.y > b.y);\n }\n return 0;\n}\n\nfn fp64_u64_add(a: vec2u, b: vec2u) -> vec2u {\n let low = a.y + b.y;\n let carry = select(0u, 1u, low < a.y);\n return vec2u(a.x + b.x + carry, low);\n}\n\nfn fp64_u64_sub(a: vec2u, b: vec2u) -> vec2u {\n let borrow = select(0u, 1u, a.y < b.y);\n return vec2u(a.x - b.x - borrow, a.y - b.y);\n}\n\nfn fp64_u64_shift_left(value: vec2u, shift: u32) -> vec2u {\n if (shift == 0u) {\n return value;\n }\n if (shift < 32u) {\n return vec2u((value.x << shift) | (value.y >> (32u - shift)), value.y << shift);\n }\n if (shift == 32u) {\n return vec2u(value.y, 0u);\n }\n if (shift < 64u) {\n return vec2u(value.y << (shift - 32u), 0u);\n }\n return vec2u(0u);\n}\n\nfn fp64_u64_shift_right(value: vec2u, shift: u32) -> vec2u {\n if (shift == 0u) {\n return value;\n }\n if (shift < 32u) {\n return vec2u(value.x >> shift, (value.y >> shift) | (value.x << (32u - shift)));\n }\n if (shift == 32u) {\n return vec2u(0u, value.x);\n }\n if (shift < 64u) {\n return vec2u(0u, value.x >> (shift - 32u));\n }\n return vec2u(0u);\n}\n\nfn fp64_u64_get_bit(value: vec2u, bitIndex: u32) -> bool {\n if (bitIndex >= 64u) {\n return false;\n }\n if (bitIndex >= 32u) {\n return ((value.x >> (bitIndex - 32u)) & 1u) != 0u;\n }\n return ((value.y >> bitIndex) & 1u) != 0u;\n}\n\nfn fp64_u64_has_bits_below(value: vec2u, bitCount: u32) -> bool {\n if (bitCount == 0u) {\n return false;\n }\n if (bitCount >= 64u) {\n return !fp64_u64_is_zero(value);\n }\n if (bitCount > 32u) {\n let highBitCount = bitCount - 32u;\n let highMask = (1u << highBitCount) - 1u;\n return value.y != 0u || (value.x & highMask) != 0u;\n }\n if (bitCount == 32u) {\n return value.y != 0u;\n }\n let lowMask = (1u << bitCount) - 1u;\n return (value.y & lowMask) != 0u;\n}\n\n#ifndef LUMA_FP64_F32_INPUT_ONLY\nfn fp64_u64_shift_right_sticky(value: vec2u, shift: u32) -> vec2u {\n var shifted = fp64_u64_shift_right(value, shift);\n if (fp64_u64_has_bits_below(value, shift)) {\n shifted.y = shifted.y | 1u;\n }\n return shifted;\n}\n#endif\n\nfn fp64_u64_count_leading_zeros(value: vec2u) -> u32 {\n if (value.x != 0u) {\n return countLeadingZeros(value.x);\n }\n return 32u + countLeadingZeros(value.y);\n}\n\nfn fp64_round_shift_right_to_u32(value: vec2u, shift: u32) -> u32 {\n if (shift == 0u) {\n return value.y;\n }\n\n let truncated = fp64_u64_shift_right(value, shift);\n var rounded = truncated.y;\n let guard = fp64_u64_get_bit(value, shift - 1u);\n let hasTrailingBits = fp64_u64_has_bits_below(value, shift - 1u);\n if (guard && (hasTrailingBits || (rounded & 1u) == 1u)) {\n rounded = rounded + 1u;\n }\n return rounded;\n}\n\n#ifndef LUMA_FP64_F32_INPUT_ONLY\nfn fp64_round_shift_right(value: vec2u, shift: u32) -> vec2u {\n if (shift == 0u) {\n return value;\n }\n\n var rounded = fp64_u64_shift_right(value, shift);\n let guard = fp64_u64_get_bit(value, shift - 1u);\n let hasTrailingBits = fp64_u64_has_bits_below(value, shift - 1u);\n if (guard && (hasTrailingBits || (rounded.y & 1u) == 1u)) {\n rounded = fp64_u64_add(rounded, vec2u(0u, 1u));\n }\n return rounded;\n}\n#endif\n\nfn fp64_make_f32_bits_from_u64(sign: u32, significand: vec2u, baseExponent: i32) -> u32 {\n if (fp64_u64_is_zero(significand)) {\n return sign << 31u;\n }\n\n let leadingZeros = fp64_u64_count_leading_zeros(significand);\n let mostSignificantBit = 63u - leadingZeros;\n var exponent = baseExponent + i32(mostSignificantBit);\n\n if (exponent > 127) {\n return (sign << 31u) | 0x7f800000u;\n }\n\n if (exponent >= -126) {\n let shift = i32(mostSignificantBit) - 23;\n var significand24: u32;\n if (shift > 0) {\n significand24 = fp64_round_shift_right_to_u32(significand, u32(shift));\n } else {\n significand24 = fp64_u64_shift_left(significand, u32(-shift)).y;\n }\n\n if (significand24 >= 0x1000000u) {\n significand24 = significand24 >> 1u;\n exponent = exponent + 1;\n if (exponent > 127) {\n return (sign << 31u) | 0x7f800000u;\n }\n }\n\n return (sign << 31u) | (u32(exponent + 127) << 23u) | (significand24 & 0x7fffffu);\n }\n\n let scaleExponent = baseExponent + 149;\n var mantissa: u32;\n if (scaleExponent >= 0) {\n mantissa = fp64_u64_shift_left(significand, u32(scaleExponent)).y;\n } else {\n mantissa = fp64_round_shift_right_to_u32(significand, u32(-scaleExponent));\n }\n\n if (mantissa >= 0x800000u) {\n return (sign << 31u) | 0x00800000u;\n }\n return (sign << 31u) | mantissa;\n}\n\n#ifndef LUMA_FP64_F32_INPUT_ONLY\nfn fp64_decode_bits(bits: vec2u) -> Fp64Bits {\n let sign = bits.x >> 31u;\n let exponentBits = (bits.x >> 20u) & 0x7ffu;\n let fractionHigh = bits.x & 0xfffffu;\n let fractionLow = bits.y;\n let fraction = vec2u(fractionHigh, fractionLow);\n\n if (exponentBits == 0x7ffu) {\n let isInf = fp64_u64_is_zero(fraction);\n return Fp64Bits(sign, 0, vec2u(0u), false, isInf, !isInf);\n }\n\n if (exponentBits == 0u) {\n let isZero = fp64_u64_is_zero(fraction);\n return Fp64Bits(sign, -1022, fraction, isZero, false, false);\n }\n\n return Fp64Bits(sign, i32(exponentBits) - 1023, vec2u((1u << 20u) | fractionHigh, fractionLow), false, false, false);\n}\n\nfn fp64_finite_magnitude_compare(a: Fp64Bits, b: Fp64Bits) -> i32 {\n if (a.exponent != b.exponent) {\n return select(-1, 1, a.exponent > b.exponent);\n }\n return fp64_u64_compare(a.significand, b.significand);\n}\n#endif\n\n#ifndef LUMA_FP64_F32_INPUT_ONLY\nstruct Fp64RawF32Bits {\n sign: u32,\n baseExponent: i32,\n significand: u32,\n isZero: bool,\n isInf: bool,\n isNan: bool,\n};\n\n// Decode an f32 as (-1)^sign * significand * 2^baseExponent. This shared\n// integer representation lets normalization remain independent of the\n// selected double-single arithmetic implementation.\nfn fp64_decode_raw_f32_bits(bits: u32) -> Fp64RawF32Bits {\n let sign = bits >> 31u;\n let exponentBits = (bits >> 23u) & 0xffu;\n let fraction = bits & 0x7fffffu;\n\n if (exponentBits == 0xffu) {\n return Fp64RawF32Bits(sign, 0, 0u, false, fraction == 0u, fraction != 0u);\n }\n if (exponentBits == 0u) {\n return Fp64RawF32Bits(sign, -149, fraction, fraction == 0u, false, false);\n }\n return Fp64RawF32Bits(\n sign,\n i32(exponentBits) - 150,\n 0x800000u | fraction,\n false,\n false,\n false\n );\n}\n\nfn fp64_raw_f32_magnitude_compare(aBits: u32, bBits: u32) -> i32 {\n let aMagnitude = aBits & 0x7fffffffu;\n let bMagnitude = bBits & 0x7fffffffu;\n if (aMagnitude == bMagnitude) {\n return 0;\n }\n return select(-1, 1, aMagnitude > bMagnitude);\n}\n\nfn fp64_make_raw_residual_f32_bits(\n exactSign: u32,\n exactMagnitude: vec2u,\n exactBaseExponent: i32,\n highBits: u32\n) -> u32 {\n if (fp64_u64_is_zero(exactMagnitude)) {\n return 0u;\n }\n\n let high = fp64_decode_raw_f32_bits(highBits);\n if (high.isInf || high.isNan) {\n return 0u;\n }\n if (high.isZero) {\n return fp64_make_f32_bits_from_u64(exactSign, exactMagnitude, exactBaseExponent);\n }\n\n let commonBaseExponent = min(exactBaseExponent, high.baseExponent);\n let exactShift = exactBaseExponent - commonBaseExponent;\n let highShift = high.baseExponent - commonBaseExponent;\n if (exactShift >= 64 || highShift >= 64) {\n return 0u;\n }\n\n let exactAligned = fp64_u64_shift_left(exactMagnitude, u32(exactShift));\n let highAligned = fp64_u64_shift_left(vec2u(0u, high.significand), u32(highShift));\n let comparison = fp64_u64_compare(exactAligned, highAligned);\n if (comparison == 0) {\n return 0u;\n }\n\n var residualSign = exactSign;\n var residualMagnitude: vec2u;\n if (comparison > 0) {\n residualMagnitude = fp64_u64_sub(exactAligned, highAligned);\n } else {\n residualSign = exactSign ^ 1u;\n residualMagnitude = fp64_u64_sub(highAligned, exactAligned);\n }\n return fp64_make_f32_bits_from_u64(\n residualSign,\n residualMagnitude,\n commonBaseExponent\n );\n}\n\nfn fp64_split_raw_accumulator_bits(\n sign: u32,\n magnitude: vec2u,\n baseExponent: i32\n) -> vec2u {\n if (fp64_u64_is_zero(magnitude)) {\n return vec2u(0u);\n }\n let highBits = fp64_make_f32_bits_from_u64(sign, magnitude, baseExponent);\n let rawLowBits = fp64_make_raw_residual_f32_bits(sign, magnitude, baseExponent, highBits);\n let lowBits = select(rawLowBits, 0u, (rawLowBits & 0x7fffffffu) == 0u);\n if ((highBits & 0x7fffffffu) == 0u && (lowBits & 0x7fffffffu) == 0u) {\n return vec2u(0u);\n }\n return vec2u(highBits, lowBits);\n}\n#endif\n\n#ifndef LUMA_FP64_F32_INPUT_ONLY\n// Round an arithmetic accumulator to binary64 before splitting it. The\n// aligned add/subtract paths retain three guard bits plus a sticky bit, which\n// is sufficient for round-to-nearest-even at the binary64 boundary.\nfn fp64_split_binary64_accumulator_bits(\n sign: u32,\n magnitude: vec2u,\n baseExponent: i32\n) -> vec2u {\n if (fp64_u64_is_zero(magnitude)) {\n return vec2u(0u);\n }\n\n let mostSignificantBit = 63u - fp64_u64_count_leading_zeros(magnitude);\n let exponent = baseExponent + i32(mostSignificantBit);\n if (exponent > 1023) {\n return vec2u((sign << 31u) | 0x7f800000u, 0u);\n }\n\n var roundedMagnitude = magnitude;\n var roundedBaseExponent = baseExponent;\n if (exponent >= -1022) {\n if (mostSignificantBit > 52u) {\n let shift = mostSignificantBit - 52u;\n roundedMagnitude = fp64_round_shift_right(magnitude, shift);\n roundedBaseExponent = baseExponent + i32(shift);\n }\n } else {\n let shift = -1074 - baseExponent;\n if (shift > 0) {\n roundedMagnitude = fp64_round_shift_right(magnitude, u32(shift));\n roundedBaseExponent = -1074;\n }\n }\n\n if (fp64_u64_is_zero(roundedMagnitude)) {\n return vec2u(0u);\n }\n return fp64_split_raw_accumulator_bits(sign, roundedMagnitude, roundedBaseExponent);\n}\n#endif\n\n#ifndef LUMA_FP64_PREDICATE_ONLY\nfn fp64_add_raw_f32_bits(aBits: u32, bBits: u32) -> vec2u {\n let a = fp64_decode_raw_f32_bits(aBits);\n let b = fp64_decode_raw_f32_bits(bBits);\n\n if (a.isNan || b.isNan) {\n return vec2u(0x7fc00000u, 0u);\n }\n if (a.isInf || b.isInf) {\n if (a.isInf && b.isInf && a.sign != b.sign) {\n return vec2u(0x7fc00000u, 0u);\n }\n return select(vec2u(bBits, 0u), vec2u(aBits, 0u), a.isInf);\n }\n if (a.isZero && b.isZero) {\n return vec2u(0u);\n }\n if (a.isZero) {\n return vec2u(bBits, 0u);\n }\n if (b.isZero) {\n return vec2u(aBits, 0u);\n }\n\n let exponentDifference = abs(a.baseExponent - b.baseExponent);\n if (exponentDifference > 25) {\n if (fp64_raw_f32_magnitude_compare(aBits, bBits) >= 0) {\n return vec2u(aBits, bBits);\n }\n return vec2u(bBits, aBits);\n }\n\n let commonBaseExponent = min(a.baseExponent, b.baseExponent);\n let aMagnitude = fp64_u64_shift_left(\n vec2u(0u, a.significand),\n u32(a.baseExponent - commonBaseExponent)\n );\n let bMagnitude = fp64_u64_shift_left(\n vec2u(0u, b.significand),\n u32(b.baseExponent - commonBaseExponent)\n );\n\n var resultSign = a.sign;\n var resultMagnitude: vec2u;\n if (a.sign == b.sign) {\n resultMagnitude = fp64_u64_add(aMagnitude, bMagnitude);\n } else {\n let comparison = fp64_u64_compare(aMagnitude, bMagnitude);\n if (comparison == 0) {\n return vec2u(0u);\n }\n if (comparison > 0) {\n resultMagnitude = fp64_u64_sub(aMagnitude, bMagnitude);\n } else {\n resultSign = b.sign;\n resultMagnitude = fp64_u64_sub(bMagnitude, aMagnitude);\n }\n }\n\n return fp64_split_raw_accumulator_bits(\n resultSign,\n resultMagnitude,\n commonBaseExponent\n );\n}\n#endif\n\n#ifndef LUMA_FP64_F32_INPUT_ONLY\nfn fp64_add_aligned_magnitudes_to_fp64_bits(\n sign: u32,\n larger: Fp64Bits,\n smaller: Fp64Bits\n) -> vec2u {\n let largeSignificand = fp64_u64_shift_left(larger.significand, 3u);\n let smallSignificand = fp64_u64_shift_right_sticky(\n fp64_u64_shift_left(smaller.significand, 3u),\n u32(larger.exponent - smaller.exponent)\n );\n let resultSignificand = fp64_u64_add(largeSignificand, smallSignificand);\n return fp64_split_binary64_accumulator_bits(\n sign,\n resultSignificand,\n larger.exponent - 55\n );\n}\n\nfn fp64_sub_aligned_magnitudes_to_fp64_bits(\n sign: u32,\n larger: Fp64Bits,\n smaller: Fp64Bits\n) -> vec2u {\n let largeSignificand = fp64_u64_shift_left(larger.significand, 3u);\n let smallSignificand = fp64_u64_shift_right_sticky(\n fp64_u64_shift_left(smaller.significand, 3u),\n u32(larger.exponent - smaller.exponent)\n );\n let resultSignificand = fp64_u64_sub(largeSignificand, smallSignificand);\n return fp64_split_binary64_accumulator_bits(\n sign,\n resultSignificand,\n larger.exponent - 55\n );\n}\n\nfn fp64_add_aligned_magnitudes_to_f32_bits(sign: u32, larger: Fp64Bits, smaller: Fp64Bits) -> u32 {\n let largeSignificand = fp64_u64_shift_left(larger.significand, 3u);\n let smallSignificand = fp64_u64_shift_right_sticky(\n fp64_u64_shift_left(smaller.significand, 3u),\n u32(larger.exponent - smaller.exponent)\n );\n let resultSignificand = fp64_u64_add(largeSignificand, smallSignificand);\n return fp64_make_f32_bits_from_u64(sign, resultSignificand, larger.exponent - 55);\n}\n\nfn fp64_sub_aligned_magnitudes_to_f32_bits(sign: u32, larger: Fp64Bits, smaller: Fp64Bits) -> u32 {\n let largeSignificand = fp64_u64_shift_left(larger.significand, 3u);\n let smallSignificand = fp64_u64_shift_right_sticky(\n fp64_u64_shift_left(smaller.significand, 3u),\n u32(larger.exponent - smaller.exponent)\n );\n let resultSignificand = fp64_u64_sub(largeSignificand, smallSignificand);\n return fp64_make_f32_bits_from_u64(sign, resultSignificand, larger.exponent - 55);\n}\n\n// Subtract two raw binary64 values and round the exact result once to f32.\n// The input words are canonical high/low words: .x contains sign/exponent/high\n// fraction bits, and .y contains the low 32 fraction bits.\nfn sub_fp64u32_to_f32_bits(aBits: vec2u, bBits: vec2u) -> u32 {\n let a = fp64_decode_bits(aBits);\n let b = fp64_decode_bits(bBits);\n let bSubtractionSign = b.sign ^ 1u;\n\n if (a.isNan || b.isNan) {\n return 0x7fc00000u;\n }\n if (a.isInf && b.isInf) {\n if (a.sign == bSubtractionSign) {\n return (a.sign << 31u) | 0x7f800000u;\n }\n return 0x7fc00000u;\n }\n if (a.isInf) {\n return (a.sign << 31u) | 0x7f800000u;\n }\n if (b.isInf) {\n return (bSubtractionSign << 31u) | 0x7f800000u;\n }\n if (a.isZero && b.isZero) {\n return select(0u, 0x80000000u, a.sign == 1u && b.sign == 0u);\n }\n\n let magnitudeComparison = fp64_finite_magnitude_compare(a, b);\n if (a.sign == bSubtractionSign) {\n if (magnitudeComparison >= 0) {\n return fp64_add_aligned_magnitudes_to_f32_bits(a.sign, a, b);\n }\n return fp64_add_aligned_magnitudes_to_f32_bits(a.sign, b, a);\n }\n\n if (magnitudeComparison == 0) {\n return 0u;\n }\n if (magnitudeComparison > 0) {\n return fp64_sub_aligned_magnitudes_to_f32_bits(a.sign, a, b);\n }\n return fp64_sub_aligned_magnitudes_to_f32_bits(bSubtractionSign, b, a);\n}\n\nfn sub_fp64u32_to_f32(aBits: vec2u, bBits: vec2u) -> f32 {\n return bitcast<f32>(sub_fp64u32_to_f32_bits(aBits, bBits));\n}\n\n// Subtract two raw binary64 values, round once to binary64, then split the\n// result into normalized f32 limbs. Finite results must fit within the f32\n// exponent range; larger magnitudes map to infinity and smaller magnitudes\n// map to zero. The input words use canonical high/low word order.\nfn sub_fp64u32_to_fp64_bits(aBits: vec2u, bBits: vec2u) -> vec2u {\n let a = fp64_decode_bits(aBits);\n let b = fp64_decode_bits(bBits);\n let bSubtractionSign = b.sign ^ 1u;\n\n if (a.isNan || b.isNan) {\n return vec2u(0x7fc00000u, 0u);\n }\n if (a.isInf && b.isInf) {\n if (a.sign == bSubtractionSign) {\n return vec2u((a.sign << 31u) | 0x7f800000u, 0u);\n }\n return vec2u(0x7fc00000u, 0u);\n }\n if (a.isInf) {\n return vec2u((a.sign << 31u) | 0x7f800000u, 0u);\n }\n if (b.isInf) {\n return vec2u((bSubtractionSign << 31u) | 0x7f800000u, 0u);\n }\n if (a.isZero && b.isZero) {\n return vec2u(0u);\n }\n\n let magnitudeComparison = fp64_finite_magnitude_compare(a, b);\n if (a.sign == bSubtractionSign) {\n if (magnitudeComparison >= 0) {\n return fp64_add_aligned_magnitudes_to_fp64_bits(a.sign, a, b);\n }\n return fp64_add_aligned_magnitudes_to_fp64_bits(a.sign, b, a);\n }\n\n if (magnitudeComparison == 0) {\n return vec2u(0u);\n }\n if (magnitudeComparison > 0) {\n return fp64_sub_aligned_magnitudes_to_fp64_bits(a.sign, a, b);\n }\n return fp64_sub_aligned_magnitudes_to_fp64_bits(bSubtractionSign, b, a);\n}\n\nfn sub_fp64u32_to_fp64(aBits: vec2u, bBits: vec2u) -> vec2f {\n let resultBits = sub_fp64u32_to_fp64_bits(aBits, bBits);\n return vec2f(bitcast<f32>(resultBits.x), bitcast<f32>(resultBits.y));\n}\n#endif\n\n#ifndef LUMA_FP64_PREDICATE_ONLY\nfn fp64_runtime_zero() -> f32 {\n return fp64arithmetic.ONE * 0.0;\n}\n\nfn prevent_fp64_optimization(value: f32) -> f32 {\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n return value + fp64_runtime_zero();\n#else\n return value;\n#endif\n}\n#endif\n\n#ifdef LUMA_FP64_INTEGER_ARITHMETIC\nstruct Fp64F32Bits {\n sign: u32,\n baseExponent: i32,\n significand: u32,\n isZero: bool,\n isInf: bool,\n isNan: bool,\n};\n\n// Decode an f32 as (-1)^sign * significand * 2^baseExponent.\nfn fp64_decode_f32_bits(bits: u32) -> Fp64F32Bits {\n let sign = bits >> 31u;\n let exponentBits = (bits >> 23u) & 0xffu;\n let fraction = bits & 0x7fffffu;\n\n if (exponentBits == 0xffu) {\n return Fp64F32Bits(sign, 0, 0u, false, fraction == 0u, fraction != 0u);\n }\n if (exponentBits == 0u) {\n return Fp64F32Bits(sign, -149, fraction, fraction == 0u, false, false);\n }\n return Fp64F32Bits(sign, i32(exponentBits) - 150, 0x800000u | fraction, false, false, false);\n}\n\nfn fp64_f32_magnitude_compare(aBits: u32, bBits: u32) -> i32 {\n let aMagnitude = aBits & 0x7fffffffu;\n let bMagnitude = bBits & 0x7fffffffu;\n if (aMagnitude == bMagnitude) {\n return 0;\n }\n return select(-1, 1, aMagnitude > bMagnitude);\n}\n\nfn fp64_make_residual_f32_bits(\n exactSign: u32,\n exactMagnitude: vec2u,\n exactBaseExponent: i32,\n highBits: u32\n) -> u32 {\n if (fp64_u64_is_zero(exactMagnitude)) {\n return 0u;\n }\n\n let high = fp64_decode_f32_bits(highBits);\n if (high.isInf || high.isNan) {\n return exactSign << 31u;\n }\n if (high.isZero) {\n return fp64_make_f32_bits_from_u64(exactSign, exactMagnitude, exactBaseExponent);\n }\n\n let commonBaseExponent = min(exactBaseExponent, high.baseExponent);\n let exactShift = exactBaseExponent - commonBaseExponent;\n let highShift = high.baseExponent - commonBaseExponent;\n\n // A normal two-sum/two-product residual never needs a shift this large.\n // This guard gives deterministic underflow behavior outside that contract.\n if (exactShift >= 64 || highShift >= 64) {\n return exactSign << 31u;\n }\n\n let exactAligned = fp64_u64_shift_left(exactMagnitude, u32(exactShift));\n let highAligned = fp64_u64_shift_left(vec2u(0u, high.significand), u32(highShift));\n let comparison = fp64_u64_compare(exactAligned, highAligned);\n if (comparison == 0) {\n return 0u;\n }\n\n var residualSign = exactSign;\n var residualMagnitude: vec2u;\n if (comparison > 0) {\n residualMagnitude = fp64_u64_sub(exactAligned, highAligned);\n } else {\n residualSign = exactSign ^ 1u;\n residualMagnitude = fp64_u64_sub(highAligned, exactAligned);\n }\n return fp64_make_f32_bits_from_u64(\n residualSign,\n residualMagnitude,\n commonBaseExponent\n );\n}\n\nfn fp64_split_accumulator_bits(\n sign: u32,\n magnitude: vec2u,\n baseExponent: i32\n) -> vec2u {\n let highBits = fp64_make_f32_bits_from_u64(sign, magnitude, baseExponent);\n let lowBits = fp64_make_residual_f32_bits(sign, magnitude, baseExponent, highBits);\n return vec2u(highBits, lowBits);\n}\n\nfn fp64_two_sum_integer_bits(aBits: u32, bBits: u32) -> vec2u {\n let a = fp64_decode_f32_bits(aBits);\n let b = fp64_decode_f32_bits(bBits);\n\n if (a.isNan || b.isNan) {\n return vec2u(0x7fc00000u, 0u);\n }\n if (a.isInf || b.isInf) {\n if (a.isInf && b.isInf && a.sign != b.sign) {\n return vec2u(0x7fc00000u, 0u);\n }\n return select(vec2u(bBits, 0u), vec2u(aBits, 0u), a.isInf);\n }\n if (a.isZero && b.isZero) {\n return vec2u((a.sign & b.sign) << 31u, 0u);\n }\n if (a.isZero) {\n return vec2u(bBits, 0u);\n }\n if (b.isZero) {\n return vec2u(aBits, 0u);\n }\n\n let exponentDifference = select(\n b.baseExponent - a.baseExponent,\n a.baseExponent - b.baseExponent,\n a.baseExponent >= b.baseExponent\n );\n\n // Beyond half an ulp, rounding cannot change the larger operand. Returning\n // the smaller operand intact also avoids an unbounded integer alignment.\n // At a power-of-two boundary the spacing below the larger operand is half\n // the spacing above it, so an opposite-sign gap-25 operand can still change\n // the rounded high limb. Gap 26 is the first universally safe early-out.\n if (exponentDifference > 25) {\n if (fp64_f32_magnitude_compare(aBits, bBits) >= 0) {\n return vec2u(aBits, bBits);\n }\n return vec2u(bBits, aBits);\n }\n\n let commonBaseExponent = min(a.baseExponent, b.baseExponent);\n let aMagnitude = fp64_u64_shift_left(\n vec2u(0u, a.significand),\n u32(a.baseExponent - commonBaseExponent)\n );\n let bMagnitude = fp64_u64_shift_left(\n vec2u(0u, b.significand),\n u32(b.baseExponent - commonBaseExponent)\n );\n\n var resultSign = a.sign;\n var resultMagnitude: vec2u;\n if (a.sign == b.sign) {\n resultMagnitude = fp64_u64_add(aMagnitude, bMagnitude);\n } else {\n let comparison = fp64_u64_compare(aMagnitude, bMagnitude);\n if (comparison == 0) {\n return vec2u(0u, 0u);\n }\n if (comparison > 0) {\n resultMagnitude = fp64_u64_sub(aMagnitude, bMagnitude);\n } else {\n resultSign = b.sign;\n resultMagnitude = fp64_u64_sub(bMagnitude, aMagnitude);\n }\n }\n\n return fp64_split_accumulator_bits(resultSign, resultMagnitude, commonBaseExponent);\n}\n\nfn fp64_two_sum_integer(a: f32, b: f32) -> vec2f {\n let resultBits = fp64_two_sum_integer_bits(bitcast<u32>(a), bitcast<u32>(b));\n return vec2f(bitcast<f32>(resultBits.x), bitcast<f32>(resultBits.y));\n}\n\nfn fp64_multiply_significands(a: u32, b: u32) -> vec2u {\n let aLow = a & 0xffffu;\n let aHigh = a >> 16u;\n let bLow = b & 0xffffu;\n let bHigh = b >> 16u;\n let lowProduct = aLow * bLow;\n let crossProduct = aLow * bHigh + aHigh * bLow;\n let highProduct = aHigh * bHigh;\n\n var result = vec2u(0u, lowProduct);\n result = fp64_u64_add(\n result,\n fp64_u64_shift_left(vec2u(0u, crossProduct), 16u)\n );\n result = fp64_u64_add(result, vec2u(highProduct, 0u));\n return result;\n}\n\nfn fp64_two_prod_integer_bits(aBits: u32, bBits: u32) -> vec2u {\n let a = fp64_decode_f32_bits(aBits);\n let b = fp64_decode_f32_bits(bBits);\n let resultSign = a.sign ^ b.sign;\n\n if (a.isNan || b.isNan || ((a.isZero || b.isZero) && (a.isInf || b.isInf))) {\n return vec2u(0x7fc00000u, 0u);\n }\n if (a.isInf || b.isInf) {\n return vec2u((resultSign << 31u) | 0x7f800000u, resultSign << 31u);\n }\n if (a.isZero || b.isZero) {\n return vec2u(resultSign << 31u, resultSign << 31u);\n }\n\n let magnitude = fp64_multiply_significands(a.significand, b.significand);\n return fp64_split_accumulator_bits(\n resultSign,\n magnitude,\n a.baseExponent + b.baseExponent\n );\n}\n\nfn fp64_two_prod_integer(a: f32, b: f32) -> vec2f {\n let resultBits = fp64_two_prod_integer_bits(bitcast<u32>(a), bitcast<u32>(b));\n return vec2f(bitcast<f32>(resultBits.x), bitcast<f32>(resultBits.y));\n}\n\nfn fp64_round_add_integer(a: f32, b: f32) -> f32 {\n return fp64_two_sum_integer(a, b).x;\n}\n\nfn fp64_round_mul_integer(a: f32, b: f32) -> f32 {\n return fp64_two_prod_integer(a, b).x;\n}\n\n#ifndef LUMA_FP64_PREDICATE_ONLY\nfn fp64_f32_finite_exponent(value: Fp64F32Bits) -> i32 {\n let mostSignificantBit = 31u - countLeadingZeros(value.significand);\n return value.baseExponent + i32(mostSignificantBit);\n}\n\nfn fp64_scale_f32_integer(value: f32, exponent: i32) -> f32 {\n let decoded = fp64_decode_f32_bits(bitcast<u32>(value));\n if (decoded.isZero || decoded.isInf || decoded.isNan) {\n return value;\n }\n let resultBits = fp64_make_f32_bits_from_u64(\n decoded.sign,\n vec2u(0u, decoded.significand),\n decoded.baseExponent + exponent\n );\n return bitcast<f32>(resultBits);\n}\n\n// Divide normalized significands so the hardware operation cannot overflow,\n// underflow, or flush a subnormal result. Reapply the exponent with integer\n// packing, which also produces subnormal correction limbs without relying on\n// floating-point arithmetic to preserve them.\nfn fp64_divide_f32_integer(aValue: f32, bValue: f32) -> f32 {\n let a = fp64_decode_f32_bits(bitcast<u32>(aValue));\n let b = fp64_decode_f32_bits(bitcast<u32>(bValue));\n if (a.isZero || b.isZero || a.isInf || b.isInf || a.isNan || b.isNan) {\n return aValue / bValue;\n }\n\n let aMostSignificantBit = 31u - countLeadingZeros(a.significand);\n let bMostSignificantBit = 31u - countLeadingZeros(b.significand);\n let normalizedABits = fp64_make_f32_bits_from_u64(\n a.sign,\n vec2u(0u, a.significand),\n -i32(aMostSignificantBit)\n );\n let normalizedBBits = fp64_make_f32_bits_from_u64(\n b.sign,\n vec2u(0u, b.significand),\n -i32(bMostSignificantBit)\n );\n let normalizedQuotient = bitcast<f32>(normalizedABits) / bitcast<f32>(normalizedBBits);\n let quotient = fp64_decode_f32_bits(bitcast<u32>(normalizedQuotient));\n let exponentShift =\n a.baseExponent + i32(aMostSignificantBit) -\n b.baseExponent - i32(bMostSignificantBit);\n let quotientBits = fp64_make_f32_bits_from_u64(\n quotient.sign,\n vec2u(0u, quotient.significand),\n quotient.baseExponent + exponentShift\n );\n return bitcast<f32>(quotientBits);\n}\n#endif\n\n#ifndef LUMA_FP64_PREDICATE_ONLY\nfn split(a: f32) -> vec2f {\n let aBits = bitcast<u32>(a);\n let decoded = fp64_decode_f32_bits(aBits);\n if (decoded.isZero || decoded.isInf || decoded.isNan) {\n return vec2f(a, 0.0);\n }\n\n var roundedHigh = decoded.significand >> 12u;\n let remainder = decoded.significand & 0xfffu;\n if (remainder > 0x800u || (remainder == 0x800u && (roundedHigh & 1u) == 1u)) {\n roundedHigh = roundedHigh + 1u;\n }\n var highMagnitude = vec2u(0u, roundedHigh << 12u);\n var highBits = fp64_make_f32_bits_from_u64(\n decoded.sign,\n highMagnitude,\n decoded.baseExponent\n );\n // Rounding the high limb of a maximum-exponent value can overflow even\n // though the original value is finite. Truncate only in that boundary case\n // so split remains an exact finite decomposition.\n if (fp64_decode_f32_bits(highBits).isInf) {\n roundedHigh = decoded.significand >> 12u;\n highMagnitude = vec2u(0u, roundedHigh << 12u);\n highBits = fp64_make_f32_bits_from_u64(\n decoded.sign,\n highMagnitude,\n decoded.baseExponent\n );\n }\n let lowBits = fp64_make_residual_f32_bits(\n decoded.sign,\n vec2u(0u, decoded.significand),\n decoded.baseExponent,\n highBits\n );\n return vec2f(bitcast<f32>(highBits), bitcast<f32>(lowBits));\n}\n\nfn split2(a: vec2f) -> vec2f {\n var result = split(a.x);\n result.y = fp64_round_add_integer(result.y, a.y);\n return result;\n}\n#endif\n\n#ifndef LUMA_FP64_PREDICATE_ONLY\nfn quickTwoSum(a: f32, b: f32) -> vec2f {\n return fp64_two_sum_integer(a, b);\n}\n#endif\n\nfn twoSum(a: f32, b: f32) -> vec2f {\n return fp64_two_sum_integer(a, b);\n}\n\nfn twoSub(a: f32, b: f32) -> vec2f {\n let bBits = bitcast<u32>(b) ^ 0x80000000u;\n let resultBits = fp64_two_sum_integer_bits(bitcast<u32>(a), bBits);\n return vec2f(bitcast<f32>(resultBits.x), bitcast<f32>(resultBits.y));\n}\n\n#ifndef LUMA_FP64_PREDICATE_ONLY\nfn twoSqr(a: f32) -> vec2f {\n return fp64_two_prod_integer(a, a);\n}\n\nfn twoProd(a: f32, b: f32) -> vec2f {\n return fp64_two_prod_integer(a, b);\n}\n#endif\n\nfn sum_fp64(a: vec2f, b: vec2f) -> vec2f {\n var sum = fp64_two_sum_integer(a.x, b.x);\n let lowSum = fp64_two_sum_integer(a.y, b.y);\n sum.y = fp64_round_add_integer(sum.y, lowSum.x);\n sum = fp64_two_sum_integer(sum.x, sum.y);\n sum.y = fp64_round_add_integer(sum.y, lowSum.y);\n return fp64_two_sum_integer(sum.x, sum.y);\n}\n\nfn sub_fp64(a: vec2f, b: vec2f) -> vec2f {\n let negatedB = vec2f(\n bitcast<f32>(bitcast<u32>(b.x) ^ 0x80000000u),\n bitcast<f32>(bitcast<u32>(b.y) ^ 0x80000000u)\n );\n return sum_fp64(a, negatedB);\n}\n\nfn mul_fp64(a: vec2f, b: vec2f) -> vec2f {\n var product = fp64_two_prod_integer(a.x, b.x);\n let crossProduct1 = fp64_round_mul_integer(a.x, b.y);\n product.y = fp64_round_add_integer(product.y, crossProduct1);\n product = fp64_two_sum_integer(product.x, product.y);\n let crossProduct2 = fp64_round_mul_integer(a.y, b.x);\n product.y = fp64_round_add_integer(product.y, crossProduct2);\n return fp64_two_sum_integer(product.x, product.y);\n}\n\n#ifndef LUMA_FP64_PREDICATE_ONLY\nfn fp64_scale_fp64_integer(value: vec2f, exponent: i32) -> vec2f {\n let high = fp64_scale_f32_integer(value.x, exponent);\n let low = fp64_scale_f32_integer(value.y, exponent);\n return sum_fp64(vec2f(high, 0.0), vec2f(low, 0.0));\n}\n\nfn fp64_div_fp64_normalized(a: vec2f, b: vec2f) -> vec2f {\n let quotientHigh = fp64_divide_f32_integer(a.x, b.x);\n var quotient = vec2f(quotientHigh, 0.0);\n\n let remainder = sub_fp64(a, mul_fp64(b, quotient));\n let quotientLow = fp64_divide_f32_integer(remainder.x, b.x);\n quotient = sum_fp64(quotient, vec2f(quotientLow, 0.0));\n\n let secondRemainder = sub_fp64(a, mul_fp64(b, quotient));\n let correction = fp64_divide_f32_integer(secondRemainder.x, b.x);\n return sum_fp64(quotient, vec2f(correction, 0.0));\n}\n\nfn div_fp64(a: vec2f, b: vec2f) -> vec2f {\n let decodedA = fp64_decode_f32_bits(bitcast<u32>(a.x));\n let decodedB = fp64_decode_f32_bits(bitcast<u32>(b.x));\n if (\n decodedA.isZero || decodedB.isZero ||\n decodedA.isInf || decodedB.isInf ||\n decodedA.isNan || decodedB.isNan\n ) {\n return fp64_div_fp64_normalized(a, b);\n }\n\n let exponentA = fp64_f32_finite_exponent(decodedA);\n let exponentB = fp64_f32_finite_exponent(decodedB);\n // Correct the quotient near unity so b * q and the remainder stay clear of\n // both f32 underflow and overflow. The exponent difference is applied once.\n let normalizedA = fp64_scale_fp64_integer(a, -exponentA);\n let normalizedB = fp64_scale_fp64_integer(b, -exponentB);\n let normalizedQuotient = fp64_div_fp64_normalized(normalizedA, normalizedB);\n return fp64_scale_fp64_integer(normalizedQuotient, exponentA - exponentB);\n}\n\nfn fp64_sqrt_fp64_normalized(a: vec2f) -> vec2f {\n let estimate = sqrt(a.x);\n let difference = sub_fp64(a, fp64_two_prod_integer(estimate, estimate)).x;\n let denominator = fp64_round_add_integer(estimate, estimate);\n let correction = fp64_divide_f32_integer(difference, denominator);\n return sum_fp64(vec2f(estimate, 0.0), vec2f(correction, 0.0));\n}\n\nfn sqrt_fp64(a: vec2f) -> vec2f {\n let decoded = fp64_decode_f32_bits(bitcast<u32>(a.x));\n let decodedLow = fp64_decode_f32_bits(bitcast<u32>(a.y));\n if (decoded.isZero && decodedLow.isZero) {\n return vec2f(0.0, 0.0);\n }\n if (decoded.sign == 1u) {\n let nanValue = fp64_nan(a.x);\n return vec2f(nanValue, nanValue);\n }\n\n if (decoded.isInf || decoded.isNan) {\n return fp64_sqrt_fp64_normalized(a);\n }\n let exponent = fp64_f32_finite_exponent(decoded);\n // An even scale lets the final square-root rescale use an integer exponent.\n let evenExponent = exponent - (exponent & 1);\n let normalizedA = fp64_scale_fp64_integer(a, -evenExponent);\n let normalizedRoot = fp64_sqrt_fp64_normalized(normalizedA);\n return fp64_scale_fp64_integer(normalizedRoot, evenExponent / 2);\n}\n#endif\n\n#else\nfn split(a: f32) -> vec2f {\n let splitValue = prevent_fp64_optimization(fp64arithmetic.SPLIT + fp64_runtime_zero());\n let t = prevent_fp64_optimization(a * splitValue);\n let temp = prevent_fp64_optimization(t - a);\n let aHi = prevent_fp64_optimization(t - temp);\n let aLo = prevent_fp64_optimization(a - aHi);\n return vec2f(aHi, aLo);\n}\n\nfn split2(a: vec2f) -> vec2f {\n var b = split(a.x);\n b.y = b.y + a.y;\n return b;\n}\n\nfn quickTwoSum(a: f32, b: f32) -> vec2f {\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let sum = prevent_fp64_optimization((a + b) * fp64arithmetic.ONE);\n let err = prevent_fp64_optimization(b - (sum - a) * fp64arithmetic.ONE);\n#else\n let sum = prevent_fp64_optimization(a + b);\n let err = prevent_fp64_optimization(b - (sum - a));\n#endif\n return vec2f(sum, err);\n}\n\nfn twoSum(a: f32, b: f32) -> vec2f {\n let s = prevent_fp64_optimization(a + b);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);\n let err =\n prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE) +\n prevent_fp64_optimization(b - v);\n#else\n let v = prevent_fp64_optimization(s - a);\n let err = prevent_fp64_optimization(a - (s - v)) + prevent_fp64_optimization(b - v);\n#endif\n return vec2f(s, err);\n}\n\nfn twoSub(a: f32, b: f32) -> vec2f {\n let s = prevent_fp64_optimization(a - b);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);\n let err =\n prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE) -\n prevent_fp64_optimization(b + v);\n#else\n let v = prevent_fp64_optimization(s - a);\n let err = prevent_fp64_optimization(a - (s - v)) - prevent_fp64_optimization(b + v);\n#endif\n return vec2f(s, err);\n}\n\nfn twoSqr(a: f32) -> vec2f {\n let prod = prevent_fp64_optimization(a * a);\n let aFp64 = split(a);\n let highProduct = prevent_fp64_optimization(aFp64.x * aFp64.x);\n let crossProduct = prevent_fp64_optimization(2.0 * aFp64.x * aFp64.y);\n let lowProduct = prevent_fp64_optimization(aFp64.y * aFp64.y);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let err =\n (prevent_fp64_optimization(highProduct - prod) * fp64arithmetic.ONE +\n crossProduct * fp64arithmetic.ONE * fp64arithmetic.ONE) +\n lowProduct * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;\n#else\n let err = ((prevent_fp64_optimization(highProduct - prod) + crossProduct) + lowProduct);\n#endif\n return vec2f(prod, err);\n}\n\nfn twoProd(a: f32, b: f32) -> vec2f {\n let prod = prevent_fp64_optimization(a * b);\n let aFp64 = split(a);\n let bFp64 = split(b);\n let highProduct = prevent_fp64_optimization(aFp64.x * bFp64.x);\n let crossProduct1 = prevent_fp64_optimization(aFp64.x * bFp64.y);\n let crossProduct2 = prevent_fp64_optimization(aFp64.y * bFp64.x);\n let lowProduct = prevent_fp64_optimization(aFp64.y * bFp64.y);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let err1 = (highProduct - prod) * fp64arithmetic.ONE;\n let err2 = crossProduct1 * fp64arithmetic.ONE * fp64arithmetic.ONE;\n let err3 = crossProduct2 * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;\n let err4 =\n lowProduct *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE;\n#else\n let err1 = highProduct - prod;\n let err2 = crossProduct1;\n let err3 = crossProduct2;\n let err4 = lowProduct;\n#endif\n let err12InputA = prevent_fp64_optimization(err1);\n let err12InputB = prevent_fp64_optimization(err2);\n let err12 = prevent_fp64_optimization(err12InputA + err12InputB);\n let err123InputA = prevent_fp64_optimization(err12);\n let err123InputB = prevent_fp64_optimization(err3);\n let err123 = prevent_fp64_optimization(err123InputA + err123InputB);\n let err1234InputA = prevent_fp64_optimization(err123);\n let err1234InputB = prevent_fp64_optimization(err4);\n let err = prevent_fp64_optimization(err1234InputA + err1234InputB);\n return vec2f(prod, err);\n}\n\nfn sum_fp64(a: vec2f, b: vec2f) -> vec2f {\n var s = twoSum(a.x, b.x);\n let t = twoSum(a.y, b.y);\n s.y = prevent_fp64_optimization(s.y + t.x);\n s = quickTwoSum(s.x, s.y);\n s.y = prevent_fp64_optimization(s.y + t.y);\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nfn sub_fp64(a: vec2f, b: vec2f) -> vec2f {\n var s = twoSub(a.x, b.x);\n let t = twoSub(a.y, b.y);\n s.y = prevent_fp64_optimization(s.y + t.x);\n s = quickTwoSum(s.x, s.y);\n s.y = prevent_fp64_optimization(s.y + t.y);\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nfn mul_fp64(a: vec2f, b: vec2f) -> vec2f {\n var prod = twoProd(a.x, b.x);\n let crossProduct1 = prevent_fp64_optimization(a.x * b.y);\n prod.y = prevent_fp64_optimization(prod.y + crossProduct1);\n#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n let crossProduct2 = prevent_fp64_optimization(a.y * b.x);\n prod.y = prevent_fp64_optimization(prod.y + crossProduct2);\n#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n return prod;\n}\n\n#ifndef LUMA_FP64_PREDICATE_ONLY\nfn div_fp64(a: vec2f, b: vec2f) -> vec2f {\n let xn = prevent_fp64_optimization(1.0 / b.x);\n let yn = mul_fp64(a, vec2f(xn, fp64_runtime_zero()));\n let diff = prevent_fp64_optimization(sub_fp64(a, mul_fp64(b, yn)).x);\n let prod = twoProd(xn, diff);\n return sum_fp64(yn, prod);\n}\n\nfn sqrt_fp64(a: vec2f) -> vec2f {\n if (a.x == 0.0 && a.y == 0.0) {\n return vec2f(0.0, 0.0);\n }\n if (a.x < 0.0) {\n let nanValue = fp64_nan(a.x);\n return vec2f(nanValue, nanValue);\n }\n\n let x = prevent_fp64_optimization(1.0 / sqrt(a.x));\n let yn = prevent_fp64_optimization(a.x * x);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let ynSqr = twoSqr(yn) * fp64arithmetic.ONE;\n#else\n let ynSqr = twoSqr(yn);\n#endif\n let diff = prevent_fp64_optimization(sub_fp64(a, ynSqr).x);\n let prod = twoProd(prevent_fp64_optimization(x * 0.5), diff);\n#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND\n return sum_fp64(split(yn), prod);\n#else\n return sum_fp64(vec2f(yn, 0.0), prod);\n#endif\n}\n#endif\n#endif\n\n#ifndef LUMA_FP64_PREDICATE_ONLY\nfn fp64_f32_bits_is_nan(bits: u32) -> bool {\n return (bits & 0x7fffffffu) > 0x7f800000u;\n}\n\nfn fp64_f32_bits_is_inf(bits: u32) -> bool {\n return (bits & 0x7fffffffu) == 0x7f800000u;\n}\n\nfn fp64_compare_f32_bits(aBits: u32, bBits: u32) -> i32 {\n let aMagnitude = aBits & 0x7fffffffu;\n let bMagnitude = bBits & 0x7fffffffu;\n if (aMagnitude == 0u && bMagnitude == 0u) {\n return 0;\n }\n let aSign = aBits >> 31u;\n let bSign = bBits >> 31u;\n if (aSign != bSign) {\n return select(1, -1, aSign == 1u);\n }\n if (aMagnitude == bMagnitude) {\n return 0;\n }\n let magnitudeComparison = select(-1, 1, aMagnitude > bMagnitude);\n return select(magnitudeComparison, -magnitudeComparison, aSign == 1u);\n}\n\n// Normalize an arbitrary pair of finite f32 limbs with integer accumulation.\n// This is independent of LUMA_FP64_INTEGER_ARITHMETIC and canonicalizes every\n// representation of zero to vec2f(+0.0, +0.0).\nfn normalize_fp64(value: vec2f) -> vec2f {\n let resultBits = fp64_add_raw_f32_bits(bitcast<u32>(value.x), bitcast<u32>(value.y));\n return vec2f(bitcast<f32>(resultBits.x), bitcast<f32>(resultBits.y));\n}\n\nfn is_nan_fp64(value: vec2f) -> bool {\n let normalized = normalize_fp64(value);\n return fp64_f32_bits_is_nan(bitcast<u32>(normalized.x)) ||\n fp64_f32_bits_is_nan(bitcast<u32>(normalized.y));\n}\n\nfn is_finite_fp64(value: vec2f) -> bool {\n let normalized = normalize_fp64(value);\n let highBits = bitcast<u32>(normalized.x);\n let lowBits = bitcast<u32>(normalized.y);\n return !fp64_f32_bits_is_nan(highBits) && !fp64_f32_bits_is_nan(lowBits) &&\n !fp64_f32_bits_is_inf(highBits) && !fp64_f32_bits_is_inf(lowBits);\n}\n\n// Returns -1, 0, or 1. NaN is unordered and returns 0; call is_nan_fp64 or\n// is_finite_fp64 first when 0 must mean a finite zero.\nfn sign_fp64(value: vec2f) -> i32 {\n let normalized = normalize_fp64(value);\n let highBits = bitcast<u32>(normalized.x);\n let lowBits = bitcast<u32>(normalized.y);\n if (fp64_f32_bits_is_nan(highBits) || fp64_f32_bits_is_nan(lowBits)) {\n return 0;\n }\n if ((highBits & 0x7fffffffu) != 0u) {\n return select(1, -1, (highBits >> 31u) == 1u);\n }\n if ((lowBits & 0x7fffffffu) != 0u) {\n return select(1, -1, (lowBits >> 31u) == 1u);\n }\n return 0;\n}\n\n// Compares double-single values and returns -1, 0, or 1. NaN is unordered\n// and returns 0; callers that require equality semantics must first check\n// is_nan_fp64 or is_finite_fp64.\nfn compare_fp64(a: vec2f, b: vec2f) -> i32 {\n let normalizedA = normalize_fp64(a);\n let normalizedB = normalize_fp64(b);\n let aHighBits = bitcast<u32>(normalizedA.x);\n let aLowBits = bitcast<u32>(normalizedA.y);\n let bHighBits = bitcast<u32>(normalizedB.x);\n let bLowBits = bitcast<u32>(normalizedB.y);\n if (fp64_f32_bits_is_nan(aHighBits) || fp64_f32_bits_is_nan(aLowBits) ||\n fp64_f32_bits_is_nan(bHighBits) || fp64_f32_bits_is_nan(bLowBits)) {\n return 0;\n }\n let highComparison = fp64_compare_f32_bits(aHighBits, bHighBits);\n if (highComparison != 0) {\n return highComparison;\n }\n return fp64_compare_f32_bits(aLowBits, bLowBits);\n}\n#endif\n",fs:ae,vs:ae,defaultUniforms:{ONE:1,SPLIT:4097},uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:oe,fp64LowPart:function(e){return e-Math.fround(e)},fp64ifyMatrix4:function(e){const t=new Float32Array(32);for(let n=0;n<4;++n)for(let i=0;i<4;++i){const r=4*n+i;oe(e[4*i+n],t,2*r)}return t}};function le(e){const{source:t,target:n,start:i=0,size:r,getData:s}=e,o=e.end||n.length,a=t.length,c=o-i;if(a>c)return void n.set(t.subarray(0,c),i);if(n.set(t,i),!s)return;let l=a;for(;l<c;){const e=s(l,t);for(let t=0;t<r;t++)n[i+l]=e[t]||0,l++}}function ue(e){switch(e){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`No defined attribute type for size "${e}"`)}}function de(e){switch(e){case 1:return"float32";case 2:return"float32x2";case 3:return"float32x3";case 4:return"float32x4";default:throw new Error("invalid type size")}}function he(e){e.push(e.shift())}function fe({device:e,source:t,target:n}){return(!n||n.byteLength<t.byteLength)&&(n?.destroy(),n=e.createBuffer({byteLength:t.byteLength,usage:t.usage})),n}function pe({device:e,buffer:t,attribute:n,fromLength:i,toLength:r,fromStartIndices:s,getData:o=e=>e}){const a=n.isDoublePrecisionBuffer?2:1,c=n.size*a,l=n.byteOffset,u=n.settings.bytesPerElement<4?l/n.settings.bytesPerElement*4:l,d=n.startIndices,h=s&&d,f=n.isConstant;if(!h&&t&&i>=r)return t;const p=n.value instanceof Float64Array?Float32Array:n.value.constructor,g=f?n.value:new p(n.getBuffer().readSyncWebGL(l,r*p.BYTES_PER_ELEMENT).buffer);if(n.settings.normalized&&!f){const e=o;o=(t,i)=>n.normalizeConstant(e(t,i))}const m=f?(e,t)=>o(g,t):(e,t)=>o(g.subarray(e,e+c),t),v=t?new Float32Array(t.readSyncWebGL(u,4*i).buffer):new Float32Array(0),y=new Float32Array(r);return function({source:e,target:t,size:n,getData:i,sourceStartIndices:r,targetStartIndices:s}){if(!r||!s)return le({source:e,target:t,size:n,getData:i}),t;let o=0,a=0;const c=i&&((e,t)=>i(e+a,t)),l=Math.min(r.length,s.length);for(let i=1;i<l;i++){const l=r[i]*n,u=s[i]*n;le({source:e.subarray(o,l),target:t,start:a,end:u,size:n,getData:c}),o=l,a=u}a<t.length&&le({source:[],target:t,start:a,size:n,getData:c})}({source:v,target:y,sourceStartIndices:s,targetStartIndices:d,size:c,getData:m}),(!t||t.byteLength<y.byteLength+u)&&(t?.destroy(),t=e.createBuffer({byteLength:y.byteLength+u,usage:35050})),t.write(y,u),t}var ge=n(2357);class GPUTransitionBase{constructor({device:e,attribute:t,timeline:n}){this.buffers=[],this.currentLength=0,this.device=e,this.transition=new ge.A(n),this.attribute=t,this.attributeInTransition=function(e){const{device:t,settings:n,value:i}=e,r=new Attribute(t,n);return r.setData({value:i instanceof Float64Array?new Float64Array(0):new Float32Array(0),normalized:n.normalized}),r}(t),this.currentStartIndices=t.startIndices}get inProgress(){return this.transition.inProgress}start(e,t,n=1/0){this.settings=e,this.currentStartIndices=this.attribute.startIndices,this.currentLength=function(e,t){const{settings:n,value:i,size:r}=e,s=e.isDoublePrecisionBuffer?2:1;let o=0;const{shaderAttributes:a}=e.settings;if(a)for(const e of Object.values(a))o=Math.max(o,e.vertexOffset??0);return(n.noAlloc?i.length:(t+o)*r)*s}(this.attribute,t),this.transition.start({...e,duration:n})}update(){const e=this.transition.update();return e&&this.onUpdate(),e}setBuffer(e){const{stride:t}=this.attributeInTransition.getAccessor();this.attributeInTransition.setData({buffer:e,normalized:this.attribute.settings.normalized,value:this.attributeInTransition.value,stride:t})}cancel(){this.transition.cancel()}delete(){this.cancel();for(const e of this.buffers)e.destroy();this.buffers.length=0}}const me={name:"interpolation",vs:"layout(std140) uniform interpolationUniforms {\n float time;\n} interpolation;\n",uniformTypes:{time:"f32"}},ve="#version 300 es\n#define SHADER_NAME interpolation-transition-vertex-shader\n\nin ATTRIBUTE_TYPE aFrom;\nin ATTRIBUTE_TYPE aTo;\nout ATTRIBUTE_TYPE vCurrent;\n\nvoid main(void) {\n vCurrent = mix(aFrom, aTo, interpolation.time);\n gl_Position = vec4(0.0);\n}\n",ye="#version 300 es\n#define SHADER_NAME interpolation-transition-vertex-shader\n\nin ATTRIBUTE_TYPE aFrom;\nin ATTRIBUTE_TYPE aFrom64Low;\nin ATTRIBUTE_TYPE aTo;\nin ATTRIBUTE_TYPE aTo64Low;\nout ATTRIBUTE_TYPE vCurrent;\nout ATTRIBUTE_TYPE vCurrent64Low;\n\nvec2 mix_fp64(vec2 a, vec2 b, float x) {\n vec2 range = sub_fp64(b, a);\n return sum_fp64(a, mul_fp64(range, vec2(x, 0.0)));\n}\n\nvoid main(void) {\n for (int i=0; i<ATTRIBUTE_SIZE; i++) {\n vec2 value = mix_fp64(vec2(aFrom[i], aFrom64Low[i]), vec2(aTo[i], aTo64Low[i]), interpolation.time);\n vCurrent[i] = value.x;\n vCurrent64Low[i] = value.y;\n }\n gl_Position = vec4(0.0);\n}\n";function be(e){return e.isDoublePrecisionBuffer}const _e={name:"spring",vs:"layout(std140) uniform springUniforms {\n float damping;\n float stiffness;\n} spring;\n",uniformTypes:{damping:"f32",stiffness:"f32"}},xe="#version 300 es\n#define SHADER_NAME spring-transition-vertex-shader\n\n#define EPSILON 0.00001\n\nin ATTRIBUTE_TYPE aPrev;\nin ATTRIBUTE_TYPE aCur;\nin ATTRIBUTE_TYPE aTo;\nout ATTRIBUTE_TYPE vNext;\nout float vIsTransitioningFlag;\n\nATTRIBUTE_TYPE getNextValue(ATTRIBUTE_TYPE cur, ATTRIBUTE_TYPE prev, ATTRIBUTE_TYPE dest) {\n ATTRIBUTE_TYPE velocity = cur - prev;\n ATTRIBUTE_TYPE delta = dest - cur;\n ATTRIBUTE_TYPE force = delta * spring.stiffness;\n ATTRIBUTE_TYPE resistance = velocity * spring.damping;\n return force - resistance + velocity + cur;\n}\n\nvoid main(void) {\n bool isTransitioning = length(aCur - aPrev) > EPSILON || length(aTo - aCur) > EPSILON;\n vIsTransitioningFlag = isTransitioning ? 1.0 : 0.0;\n\n vNext = getNextValue(aCur, aPrev, aTo);\n gl_Position = vec4(0, 0, 0, 1);\n gl_PointSize = 100.0;\n}\n",we="#version 300 es\n#define SHADER_NAME spring-transition-is-transitioning-fragment-shader\n\nin float vIsTransitioningFlag;\n\nout vec4 fragColor;\n\nvoid main(void) {\n if (vIsTransitioningFlag == 0.0) {\n discard;\n }\n fragColor = vec4(1.0);\n}";const Pe={interpolation:class GPUInterpolationTransition extends GPUTransitionBase{constructor({device:e,attribute:t,timeline:n}){super({device:e,attribute:t,timeline:n}),this.type="interpolation",this.hasUpdated=!1,this.transform=function(e,t){const n=t.size,i=ue(n),r=de(n),s=t.getBufferLayout();if(be(t))return new se.p(e,{vs:ye,bufferLayout:[{name:"aFrom",byteStride:8*n,attributes:[{attribute:"aFrom",format:r,byteOffset:0},{attribute:"aFrom64Low",format:r,byteOffset:4*n}]},{name:"aTo",byteStride:8*n,attributes:[{attribute:"aTo",format:r,byteOffset:0},{attribute:"aTo64Low",format:r,byteOffset:4*n}]}],modules:[ce,me],defines:{ATTRIBUTE_TYPE:i,ATTRIBUTE_SIZE:n},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0});return new se.p(e,{vs:ve,bufferLayout:[{name:"aFrom",format:r},{name:"aTo",format:s.attributes[0].format}],modules:[me],defines:{ATTRIBUTE_TYPE:i},varyings:["vCurrent"],disableWarnings:!0})}(e,t)}start(e,t){const n=this.currentLength,i=this.currentStartIndices;if(super.start(e,t,e.duration),e.duration<=0)return void this.transition.cancel();const{buffers:r,attribute:s}=this;this.hasUpdated&&he(r),this.hasUpdated=!1,r[0]=pe({device:this.device,buffer:r[0],attribute:s,fromLength:n,toLength:this.currentLength,fromStartIndices:i,getData:e.enter}),r[1]=fe({device:this.device,source:r[0],target:r[1]}),this.setBuffer(r[1]);const{transform:o}=this,a=o.model;let c=Math.floor(this.currentLength/s.size);be(s)&&(c/=2),a.setVertexCount(c),s.isConstant?(a.setAttributes({aFrom:r[0]}),a.setConstantAttributes({aTo:s.value})):a.setAttributes({aFrom:r[0],aTo:s.getBuffer()}),o.transformFeedback.setBuffers({vCurrent:r[1]})}onUpdate(){const{duration:e,easing:t}=this.settings,{time:n}=this.transition;let i=n/e;t&&(i=t(i));const{model:r}=this.transform,s={time:i};r.shaderInputs.setProps({interpolation:s}),this.transform.run({discard:!0}),this.hasUpdated=!0}delete(){super.delete(),this.transform.destroy()}},spring:class GPUSpringTransition extends GPUTransitionBase{constructor({device:e,attribute:t,timeline:n}){super({device:e,attribute:t,timeline:n}),this.type="spring",this.texture=function(e){return e.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}(e),this.framebuffer=function(e,t){return e.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[t]})}(e,this.texture),this.transform=function(e,t){const n=ue(t.size),i=de(t.size);return new se.p(e,{vs:xe,fs:we,bufferLayout:[{name:"aPrev",format:i},{name:"aCur",format:i},{name:"aTo",format:t.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[_e],defines:{ATTRIBUTE_TYPE:n},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}(e,t)}start(e,t){const n=this.currentLength,i=this.currentStartIndices;super.start(e,t);const{buffers:r,attribute:s}=this;for(let t=0;t<2;t++)r[t]=pe({device:this.device,buffer:r[t],attribute:s,fromLength:n,toLength:this.currentLength,fromStartIndices:i,getData:e.enter});r[2]=fe({device:this.device,source:r[0],target:r[2]}),this.setBuffer(r[1]);const{model:o}=this.transform;o.setVertexCount(Math.floor(this.currentLength/s.size)),s.isConstant?o.setConstantAttributes({aTo:s.value}):o.setAttributes({aTo:s.getBuffer()})}onUpdate(){const{buffers:e,transform:t,framebuffer:n,transition:i}=this,r=this.settings;t.model.setAttributes({aPrev:e[0],aCur:e[1]}),t.transformFeedback.setBuffers({vNext:e[2]});const s={stiffness:r.stiffness,damping:r.damping};t.model.shaderInputs.setProps({spring:s}),t.run({framebuffer:n,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),he(e),this.setBuffer(e[1]);this.device.readPixelsToArrayWebGL(n)[0]>0||i.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}}};class AttributeTransitionManager{constructor(e,{id:t,timeline:n}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=t,this.device=e,this.timeline=n,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(const e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:t,numInstances:n}){this.numInstances=n||1;for(const n in e){const i=e[n],r=i.getTransitionSetting(t);r&&this._updateAttribute(n,i,r)}for(const n in this.transitions){const i=e[n];i&&i.getTransitionSetting(t)||this._removeTransition(n)}}hasAttribute(e){const t=this.transitions[e];return t&&t.inProgress}getAttributes(){const e={};for(const t in this.transitions){const n=this.transitions[t];n.inProgress&&(e[t]=n.attributeInTransition)}return e}run(){if(0===this.numInstances)return!1;for(const e in this.transitions){this.transitions[e].update()&&(this.needsRedraw=!0)}const e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,t,n){const i=this.transitions[e];let r=!i||i.type!==n.type;if(r){i&&this._removeTransition(e);const s=Pe[n.type];s?this.transitions[e]=new s({attribute:t,timeline:this.timeline,device:this.device}):(f.A.error(`unsupported transition type '${n.type}'`)(),r=!1)}(r||t.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(n,this.numInstances))}}const Ce="attributeManager.invalidate";class AttributeManager{constructor(e,{id:t="attribute-manager",stats:n,timeline:i}={}){this.mergeBoundsMemoized=(0,ie.A)(h._Z),this.id=t,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=n,this.attributeTransitionManager=new AttributeTransitionManager(e,{id:`${t}-transitions`,timeline:i}),this.attributeBufferGroups="webgpu"===e.type?new AttributeBufferGroups(e,{id:t,isTransitionAttribute:e=>this.attributeTransitionManager.hasAttribute(e)}):null,Object.seal(this)}finalize(){this.attributeBufferGroups?.finalize();for(const e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){const t=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,t&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(const t of e)void 0!==this.attributes[t]&&(this.attributes[t].delete(),delete this.attributes[t])}invalidate(e,t){const n=this._invalidateTrigger(e,t);(0,re.A)(Ce,this,e,n)}invalidateAll(e){for(const t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);(0,re.A)(Ce,this,"all")}update({data:e,numInstances:t,startIndices:n=null,transitions:i,props:r={},buffers:s={},context:o={}}){let a=!1;(0,re.A)("attributeManager.updateStart",this),this.stats&&this.stats.get("Update Attributes").timeStart();for(const i in this.attributes){const c=this.attributes[i],l=c.settings.accessor;c.startIndices=n,c.numInstances=t,r[i]&&f.A.removed(`props.${i}`,`data.attributes.${i}`)(),c.setExternalBuffer(s[i])||c.setBinaryValue("string"==typeof l?s[l]:void 0,e.startIndices)||"string"==typeof l&&!s[l]&&c.setConstantValue(o,r[l])||c.needsUpdate()&&(a=!0,this._updateAttribute({attribute:c,numInstances:t,data:e,props:r,context:o})),this.needsRedraw=this.needsRedraw||c.needsRedraw()}a&&(0,re.A)("attributeManager.updateEnd",this,t),this.stats&&(this.stats.get("Update Attributes").timeEnd(),a&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:t,transitions:i})}updateTransition(){const{attributeTransitionManager:e}=this,t=e.run();return this.needsRedraw=this.needsRedraw||t,t}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){const t=e.map(e=>this.attributes[e]?.getBounds());return this.mergeBoundsMemoized(t)}getChangedAttributes(e={clearChangedFlags:!1}){const{attributes:t,attributeTransitionManager:n}=this,i={...n.getAttributes()};for(const r in t){const s=t[r];s.needsRedraw(e)&&!n.hasAttribute(r)&&(i[r]=s)}return i}getBufferLayouts(e){return this.hasBufferGroups()?this.attributeBufferGroups.getBufferLayouts(this.getAttributes(),e):Object.values(this.getAttributes()).map(t=>t.getBufferLayout(e))}hasBufferGroups(){return Boolean(this.attributeBufferGroups?.hasGroups(this.attributes))}getBufferGroupBindings(e,t,n={}){return this.attributeBufferGroups?this.attributeBufferGroups.getBindings(this.getAttributes(),e,t,n):{bufferLayouts:this.getBufferLayouts(t),buffers:{},groupedAttributeIds:new Set}}_add(e,t){for(const n in e){const i=e[n],r={...i,id:n,size:(i.isIndexed?1:i.size)||1,...t};this.attributes[n]=new Attribute(this.device,r)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){const e={};for(const t in this.attributes){this.attributes[t].getUpdateTriggers().forEach(n=>{e[n]||(e[n]=[]),e[n].push(t)})}this.updateTriggers=e}_invalidateTrigger(e,t){const{attributes:n,updateTriggers:i}=this,r=i[e];return r&&r.forEach(e=>{const i=n[e];i&&i.setNeedsUpdate(i.id,t)}),r}_updateAttribute(e){const{attribute:t,numInstances:n}=e;if((0,re.A)("attribute.updateStart",t),t.constant)return void t.setConstantValue(e.context,t.value);t.allocate(n)&&(0,re.A)("attribute.allocate",t,n);t.updateBuffer(e)&&(this.needsRedraw=!0,(0,re.A)("attribute.updateEnd",t,n))}}var Se=n(54901);class CPUInterpolationTransition extends ge.A{get value(){return this._value}_onUpdate(){const{time:e,settings:{fromValue:t,toValue:n,duration:i,easing:r}}=this,s=r(e/i);this._value=(0,Se.Cc)(t,n,s)}}const Le=1e-5;function Ae(e,t,n,i,r){const s=t-e;return(n-t)*r+-s*i+s+t}function Ee(e,t){if(Array.isArray(e)){let n=0;for(let i=0;i<e.length;i++){const r=e[i]-t[i];n+=r*r}return Math.sqrt(n)}return Math.abs(e-t)}class CPUSpringTransition extends ge.A{get value(){return this._currValue}_onUpdate(){const{fromValue:e,toValue:t,damping:n,stiffness:i}=this.settings,{_prevValue:r=e,_currValue:s=e}=this;let o=function(e,t,n,i,r){if(Array.isArray(n)){const s=[];for(let o=0;o<n.length;o++)s[o]=Ae(e[o],t[o],n[o],i,r);return s}return Ae(e,t,n,i,r)}(r,s,t,n,i);const a=Ee(o,t),c=Ee(o,s);a<Le&&c<Le&&(o=t,this.end()),this._prevValue=s,this._currValue=o}}const Te={interpolation:CPUInterpolationTransition,spring:CPUSpringTransition};class UniformTransitionManager{constructor(e){this.transitions=new Map,this.timeline=e}get active(){return this.transitions.size>0}add(e,t,n,i){const{transitions:r}=this;if(r.has(e)){const n=r.get(e),{value:i=n.settings.fromValue}=n;t=i,this.remove(e)}if(!(i=x(i)))return;const s=Te[i.type];if(!s)return void f.A.error(`unsupported transition type '${i.type}'`)();const o=new s(this.timeline);o.start({...i,fromValue:t,toValue:n}),r.set(e,o)}remove(e){const{transitions:t}=this;t.has(e)&&(t.get(e).cancel(),t.delete(e))}update(){const e={};for(const[t,n]of this.transitions)n.update(),e[t]=n.value,n.inProgress||this.remove(t);return e}clear(){for(const e of this.transitions.keys())this.remove(e)}}var Me=n(12897);function Ie(e,t){const n=ke({newProps:e,oldProps:t,propTypes:e[Me.fW],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),i=function(e,t){if(null===t)return"oldProps is null, initial diff";let n=!1;const{dataComparator:i,_dataDiff:r}=e;i?i(e.data,t.data)||(n="Data comparator detected a change"):e.data!==t.data&&(n="A new data container was supplied");n&&r&&(n=r(e.data,t.data)||n);return n}(e,t);let r=!1;return i||(r=function(e,t){if(null===t)return{all:!0};if("all"in e.updateTriggers){if(ze(e,t,"all"))return{all:!0}}const n={};let i=!1;for(const r in e.updateTriggers)if("all"!==r){ze(e,t,r)&&(n[r]=!0,i=!0)}return!!i&&n}(e,t)),{dataChanged:i,propsChanged:n,updateTriggersChanged:r,extensionsChanged:Oe(e,t),transitionsChanged:Be(e,t)}}function Be(e,t){if(!e.transitions)return!1;const n={},i=e[Me.fW];let r=!1;for(const s in e.transitions){const o=i[s],a=o&&o.type;("number"===a||"color"===a||"array"===a)&&Re(e[s],t[s],o)&&(n[s]=!0,r=!0)}return!!r&&n}function ke({newProps:e,oldProps:t,ignoreProps:n={},propTypes:i={},triggerName:r="props"}){if(t===e)return!1;if("object"!=typeof e||null===e)return`${r} changed shallowly`;if("object"!=typeof t||null===t)return`${r} changed shallowly`;for(const s of Object.keys(e))if(!(s in n)){if(!(s in t))return`${r}.${s} added`;const n=Re(e[s],t[s],i[s]);if(n)return`${r}.${s} ${n}`}for(const s of Object.keys(t))if(!(s in n)){if(!(s in e))return`${r}.${s} dropped`;if(!Object.hasOwnProperty.call(e,s)){const n=Re(e[s],t[s],i[s]);if(n)return`${r}.${s} ${n}`}}return!1}function Re(e,t,n){let i=n&&n.equal;return i&&!i(e,t,n)?"changed deeply":i||(i=e&&t&&e.equals,!i||i.call(e,t))?i||t===e?null:"changed shallowly":"changed deeply"}function Oe(e,t){if(null===t)return!0;const n=t.extensions,{extensions:i}=e;if(i===n)return!1;if(!n||!i)return!0;if(i.length!==n.length)return!0;for(let e=0;e<i.length;e++)if(!i[e].equals(n[e]))return!0;return!1}function ze(e,t,n){let i=e.updateTriggers[n];i=i??{};let r=t.updateTriggers[n];r=r??{};return ke({oldProps:r,newProps:i,triggerName:n})}function De(e){if(null===(t=e)||"object"!=typeof t)throw new Error("count(): argument not an object");var t;if("function"==typeof e.count)return e.count();if(Number.isFinite(e.size))return e.size;if(Number.isFinite(e.length))return e.length;if(function(e){return null!==e&&"object"==typeof e&&e.constructor===Object}(e))return Object.keys(e).length;throw new Error("count(): argument not a container")}var Fe=n(66540),Ne=n(74334),$e=n(69502),Ue=n(39426),Ve=n(82859),Ge=n(45249);const je=[0,0,0];function We(e,t,n=!1){const i=t.projectPosition(e);if(n&&t instanceof $e.A){const[n,r,s=0]=e,o=t.getDistanceScales([n,r]);i[2]=s*o.unitsPerMeter[2]}return i}function He(e,{viewport:t,modelMatrix:n,coordinateSystem:i,coordinateOrigin:r,offsetMode:s}){let[o,a,c=0]=e;switch(n&&([o,a,c]=Ue.Z0([],[o,a,c,1],n)),i){case"default":return He(e,{viewport:t,modelMatrix:n,coordinateSystem:t.isGeospatial?"lnglat":"cartesian",coordinateOrigin:r,offsetMode:s});case"lnglat":return We([o,a,c],t,s);case"lnglat-offsets":return We([o+r[0],a+r[1],c+(r[2]||0)],t,s);case"meter-offsets":return We((0,Ge.dT)(r,[o,a,c]),t,s);case"cartesian":return t.isGeospatial?[o+r[0],a+r[1],c+r[2]]:t.projectPosition([o,a,c]);default:throw new Error(`Invalid coordinateSystem: ${i}`)}}var qe=n(93675),Ze=n(80698);const Ye={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Ke={};var Qe=n(7914);const Xe={boolean:{validate:(e,t)=>!0,equal:(e,t,n)=>Boolean(e)===Boolean(t)},number:{validate:(e,t)=>Number.isFinite(e)&&(!("max"in t)||e<=t.max)&&(!("min"in t)||e>=t.min)},color:{validate:(e,t)=>t.optional&&!e||tt(e)&&(3===e.length||4===e.length),equal:(e,t,n)=>(0,Qe.b)(e,t,1)},accessor:{validate(e,t){const n=nt(e);return"function"===n||n===nt(t.value)},equal:(e,t,n)=>"function"==typeof t||(0,Qe.b)(e,t,1)},array:{validate:(e,t)=>t.optional&&!e||tt(e),equal(e,t,n){const{compare:i}=n,r=Number.isInteger(i)?i:i?1:0;return i?(0,Qe.b)(e,t,r):e===t}},object:{equal(e,t,n){if(n.ignore)return!0;const{compare:i}=n,r=Number.isInteger(i)?i:i?1:0;return i?(0,Qe.b)(e,t,r):e===t}},function:{validate:(e,t)=>t.optional&&!e||"function"==typeof e,equal:(e,t,n)=>!n.compare&&!1!==n.ignore||e===t},data:{transform:(e,t,n)=>{if(!e)return e;const{dataTransform:i}=n.props;return i?i(e):"string"==typeof e.shape&&e.shape.endsWith("-table")&&Array.isArray(e.data)?e.data:e}},image:{transform:(e,t,n)=>{const i=n.context;return i&&i.device?function(e,t,n,i){if(n instanceof Ze.g)return n;n.constructor&&"Object"!==n.constructor.name&&(n={data:n});let r=null;n.compressed&&(r={minFilter:"linear",mipmapFilter:n.data.length>1?"nearest":"linear"});const{width:s,height:o}=n.data,a=t.createTexture({...n,sampler:{...Ye,...r,...i},mipLevels:t.getMipLevelCount(s,o)});return"webgl"===t.type?a.generateMipmapsWebGL():"webgpu"===t.type&&t.generateMipmapsWebGPU(a),Ke[a.id]=e,a}(n.id,i.device,e,{...t.parameters,...n.props.textureParameters}):null},release:(e,t,n)=>{var i,r;i=n.id,(r=e)&&r instanceof Ze.g&&Ke[r.id]===i&&(r.delete(),delete Ke[r.id])}}};function Je(e,t){switch(nt(t)){case"object":return et(e,t);case"array":return et(e,{type:"array",value:t,compare:!1});case"boolean":return et(e,{type:"boolean",value:t});case"number":return et(e,{type:"number",value:t});case"function":return et(e,{type:"function",value:t,compare:!0});default:return{name:e,type:"unknown",value:t}}}function et(e,t){return"type"in t?{name:e,...Xe[t.type],...t}:"value"in t?{name:e,type:nt(t.value),...t}:{name:e,type:"object",value:t}}function tt(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function nt(e){return tt(e)?"array":null===e?"null":typeof e}function it(e,t){if(!(e instanceof ct.constructor))return{};let n="_mergedDefaultProps";if(t)for(const e of t){const t=e.constructor;t&&(n+=`:${t.extensionName||t.name}`)}const i=ot(e,n);return i||(e[n]=function(e,t){const n=e.prototype;if(!n)return null;const i=Object.getPrototypeOf(e),r=it(i),s=ot(e,"defaultProps")||{},o=function(e){const t={},n={},i={};for(const[r,s]of Object.entries(e)){const e=s?.deprecatedFor;if(e)i[r]=Array.isArray(e)?e:[e];else{const e=Je(r,s);t[r]=e,n[r]=e.value}}return{propTypes:t,defaultProps:n,deprecatedProps:i}}(s),a=Object.assign(Object.create(null),r,o.defaultProps),c=Object.assign(Object.create(null),r?.[Me.fW],o.propTypes),l=Object.assign(Object.create(null),r?.[Me.uH],o.deprecatedProps);for(const e of t){const t=it(e.constructor);t&&(Object.assign(a,t),Object.assign(c,t[Me.fW]),Object.assign(l,t[Me.uH]))}(function(e,t){const n=function(e){const t=e.componentName;t||f.A.warn(`${e.name}.componentName not specified`)();return t||e.name}(t);Object.defineProperties(e,{id:{writable:!0,value:n}})})(a,e),function(e,t){const n={},i={};for(const e in t){const r=t[e],{name:s,value:o}=r;r.async&&(n[s]=o,i[s]=rt(s))}e[Me.jA]=n,e[Me.YN]={},Object.defineProperties(e,i)}(a,c),function(e,t){for(const n in t)Object.defineProperty(e,n,{enumerable:!1,set(e){const i=`${this.id}: ${n}`;for(const i of t[n])st(this,i)||(this[i]=e);f.A.deprecated(i,t[n].join("/"))()}})}(a,l),a[Me.fW]=c,a[Me.uH]=l,0!==t.length||st(e,"_propTypes")||(e._propTypes=c);return a}(e,t||[]))}function rt(e){return{enumerable:!0,set(t){"string"==typeof t||t instanceof Promise||(0,m.Td)(t)?this[Me.YN][e]=t:this[Me.vf][e]=t},get(){if(this[Me.vf]){if(e in this[Me.vf]){return this[Me.vf][e]||this[Me.jA][e]}if(e in this[Me.YN]){const t=this[Me.r3]&&this[Me.r3].internalState;if(t&&t.hasAsyncProp(e))return t.getAsyncProp(e)||this[Me.jA][e]}}return this[Me.jA][e]}}}function st(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ot(e,t){return st(e,t)&&e[t]}let at=0;class Component{constructor(...e){this.props=function(e,t){let n;for(let e=t.length-1;e>=0;e--){const i=t[e];"extensions"in i&&(n=i.extensions)}const i=it(e.constructor,n),r=Object.create(i);r[Me.r3]=e,r[Me.YN]={},r[Me.vf]={};for(let e=0;e<t.length;++e){const n=t[e];for(const e in n)r[e]=n[e]}return Object.freeze(r),r}(this,e),this.id=this.props.id,this.count=at++}clone(e){const{props:t}=this,n={};for(const e in t[Me.jA])e in t[Me.vf]?n[e]=t[Me.vf][e]:e in t[Me.YN]&&(n[e]=t[Me.YN][e]);return new this.constructor({...t,...n,...e})}}Component.componentName="Component",Component.defaultProps={};const ct=Component,lt=Object.freeze({});class ComponentState{constructor(e){this.component=e,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(const e in this.asyncProps){const t=this.asyncProps[e];t&&t.type&&t.type.release&&t.type.release(t.resolvedValue,t.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||lt}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){const t=this.asyncProps[e];return t&&t.resolvedValue}isAsyncPropLoading(e){if(e){const t=this.asyncProps[e];return Boolean(t&&t.pendingLoadCount>0&&t.pendingLoadCount!==t.resolvedLoadCount)}for(const e in this.asyncProps)if(this.isAsyncPropLoading(e))return!0;return!1}reloadAsyncProp(e,t){this._watchPromise(e,Promise.resolve(t))}setAsyncProps(e){this.component=e[Me.r3]||this.component;const t=e[Me.vf]||{},n=e[Me.YN]||e,i=e[Me.jA]||{};for(const e in t){const n=t[e];this._createAsyncPropData(e,i[e]),this._updateAsyncProp(e,n),t[e]=this.getAsyncProp(e)}for(const e in n){const t=n[e];this._createAsyncPropData(e,i[e]),this._updateAsyncProp(e,t)}}_fetch(e,t){return null}_onResolve(e,t){}_onError(e,t){}_updateAsyncProp(e,t){this._didAsyncInputValueChange(e,t)&&("string"==typeof t&&(t=this._fetch(e,t)),t instanceof Promise?this._watchPromise(e,t):(0,m.Td)(t)?this._resolveAsyncIterable(e,t):this._setPropValue(e,t))}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(const e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,t){const n=this.asyncProps[e];return t!==n.resolvedValue&&t!==n.lastValue&&(n.lastValue=t,!0)}_setPropValue(e,t){this._freezeAsyncOldProps();const n=this.asyncProps[e];n&&(t=this._postProcessValue(n,t),n.resolvedValue=t,n.pendingLoadCount++,n.resolvedLoadCount=n.pendingLoadCount)}_setAsyncPropValue(e,t,n){const i=this.asyncProps[e];i&&n>=i.resolvedLoadCount&&void 0!==t&&(this._freezeAsyncOldProps(),i.resolvedValue=t,i.resolvedLoadCount=n,this.onAsyncPropUpdated(e,t))}_watchPromise(e,t){const n=this.asyncProps[e];if(n){n.pendingLoadCount++;const i=n.pendingLoadCount;t.then(t=>{this.component&&(t=this._postProcessValue(n,t),this._setAsyncPropValue(e,t,i),this._onResolve(e,t))}).catch(t=>{this._onError(e,t)})}}async _resolveAsyncIterable(e,t){if("data"!==e)return void this._setPropValue(e,t);const n=this.asyncProps[e];if(!n)return;n.pendingLoadCount++;const i=n.pendingLoadCount;let r=[],s=0;for await(const n of t){if(!this.component)return;const{dataTransform:t}=this.component.props;r=t?t(n,r):r.concat(n),Object.defineProperty(r,"__diff",{enumerable:!1,value:[{startRow:s,endRow:r.length}]}),s=r.length,this._setAsyncPropValue(e,r,i)}this._onResolve(e,r)}_postProcessValue(e,t){const n=e.type;return n&&this.component&&(n.release&&n.release(e.resolvedValue,n,this.component),n.transform)?n.transform(t,n,this.component):t}_createAsyncPropData(e,t){if(!this.asyncProps[e]){const n=this.component&&this.component.props[Me.fW];this.asyncProps[e]={type:n&&n[e],lastValue:null,resolvedValue:t,pendingLoadCount:0,resolvedLoadCount:0}}}}class LayerState extends ComponentState{constructor({attributeManager:e,layer:t}){super(t),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1,this.disabledPickingIndices=[]}get layer(){return this.component}_fetch(e,t){const n=this.layer,i=n?.props.fetch;return i?i(t,{propName:e,layer:n}):super._fetch(e,t)}_onResolve(e,t){const n=this.layer;if(n){const i=n.props.onDataLoad;"data"===e&&i&&i(t,{propName:e,layer:n})}}_onError(e,t){const n=this.layer;n&&n.raiseError(t,`loading ${e} of ${this.layer}`)}}var ut=n(22662);const dt=2**24-1,ht=Object.freeze([]),ft=(0,ie.A)(({oldViewport:e,viewport:t})=>e.equals(t));let pt=new Uint8ClampedArray(0);function gt(e){return e.rowIndexes||e.pickingColors||e.instancePickingColors}function mt(e){return e.rowIndexes}function vt(e){return e.pickingColors||e.instancePickingColors}const yt={data:{type:"data",value:ht,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:e=>e&&e.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(e,{propName:t,layer:n,loaders:i,loadOptions:r,signal:s})=>{const{resourceManager:o}=n.context;r=r||n.getLoadOptions(),i=i||n.props.loaders,s&&(r={...r,core:{...r?.core,fetch:{...r?.core?.fetch,signal:s}}});let a=o.contains(e);return a||r||(o.add({resourceId:e,data:(0,ut.H)(e,i),persistent:!1}),a=!0),a?o.subscribe({resourceId:e,onChange:e=>n.internalState?.reloadAsyncProp(t,e),consumerId:n.id,requestId:t}):(0,ut.H)(e,i,r)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:"default",coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:e})=>[0,100*-e]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}};class Layer extends ct{constructor(){super(...arguments),this.internalState=null,this.lifecycle=Me.VD.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){(0,g.A)(this.internalState);const t=this.internalState.viewport||this.context.viewport,n=He(e,{viewport:t,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[i,r,s]=(0,Ge.VJ)(n,t.pixelProjectionMatrix);return 2===e.length?[i,r]:[i,r,s]}unproject(e){(0,g.A)(this.internalState);return(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,t){(0,g.A)(this.internalState);return function(e,t){const{viewport:n,coordinateSystem:i,coordinateOrigin:r,modelMatrix:s,fromCoordinateSystem:o,fromCoordinateOrigin:a}=function(e){const{viewport:t,modelMatrix:n,coordinateOrigin:i}=e;let{coordinateSystem:r,fromCoordinateSystem:s,fromCoordinateOrigin:o}=e;return"default"===r&&(r=t.isGeospatial?"lnglat":"cartesian"),void 0===s?s=r:"default"===s&&(s=t.isGeospatial?"lnglat":"cartesian"),void 0===o&&(o=i),{viewport:t,coordinateSystem:r,coordinateOrigin:i,modelMatrix:n,fromCoordinateSystem:s,fromCoordinateOrigin:o}}(t),{autoOffset:c=!0}=t,{geospatialOrigin:l=je,shaderCoordinateOrigin:u=je,offsetMode:d=!1}=c?(0,Ne.ow)(n,i,r):{},h=He(e,{viewport:n,modelMatrix:s,coordinateSystem:o,coordinateOrigin:a,offsetMode:d});if(d){const e=n.projectPosition(l||u);Ve.jb(h,h,e)}return h}(e,{viewport:this.internalState.viewport||this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...t})}get isComposite(){return!1}get isDrawable(){return!0}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return!!this.internalState&&!this.internalState.isAsyncPropLoading()}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){const e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setShaderModuleProps(...e){for(const t of this.getModels())t.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){const{coordinateSystem:e}=this.props;return"default"===e||"lnglat"===e||"cartesian"===e}onHover(e,t){return this.props.onHover&&this.props.onHover(e,t)||!1}onClick(e,t){return this.props.onClick&&this.props.onClick(e,t)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,t=[]){return t[0]=e+1&255,t[1]=e+1>>8&255,t[2]=e+1>>8>>8&255,t}decodePickingColor(e){(0,g.A)(e instanceof Uint8Array);const[t,n,i]=e;return t+256*n+65536*i-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&void 0!==this.state.numInstances?this.state.numInstances:De(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(e){e=(0,Fe.n)(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(const t of this.props.extensions)e=(0,Fe.n)(e,t.getShaders.call(this,t));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){const t=this.getAttributeManager(),{dataChanged:n}=e.changeFlags;if(n&&t)if(Array.isArray(n))for(const e of n)t.invalidateAll(e);else t.invalidateAll();if(t){const{props:n}=e,i=this.internalState.hasPickingBuffer,r=Number.isInteger(n.highlightedObjectIndex)||Boolean(n.pickable)||n.extensions.some(e=>e.getNeedsPickingBuffer.call(this,e));if(i!==r){this.internalState.hasPickingBuffer=r;const e=gt(t.attributes);e&&(r&&e.constant&&(e.constant=!1,t.invalidate(e.id)),e.value||r||(e.constant=!0,e.value=mt(t.attributes)?[qe.Z1]:[0,0,0]))}}}finalizeState(e){for(const e of this.getModels())e.destroy();const t=this.getAttributeManager();t&&t.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(const t of this.getModels())t.draw(e.renderPass)}getPickingInfo({info:e,mode:t,sourceLayer:n}){const{index:i}=e;return i>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[i]),e}raiseError(e,t){t&&(e=new Error(`${t}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return!!this.internalState&&(this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()))}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;const t=this.internalState.viewport;this.internalState.viewport=e,t&&ft({oldViewport:t,viewport:e})||(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){const t=this.getAttributeManager();t&&("all"===e?t.invalidateAll():t.invalidate(e))}updateAttributes(e){let t=!1;for(const n in e)e[n].layoutChanged()&&(t=!0);for(const n of this.getModels())this._setModelAttributes(n,e,t)}_updateAttributes(){const e=this.getAttributeManager();if(!e)return;const t=this.props,n=this.getNumInstances(),i=this.getStartIndices();e.update({data:t.data,numInstances:n,startIndices:i,props:t,transitions:t.transitions,buffers:t.data.attributes,context:this});const r=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(r)}_updateAttributeTransition(){const e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){const{uniformTransitions:e}=this.internalState;if(e.active){const t=e.update(),n=Object.create(this.props);for(const e in t)Object.defineProperty(n,e,{value:t[e]});return n}return this.props}calculateInstancePickingColors(e,{numInstances:t}){if(e.constant)return;const n=Math.floor(pt.length/4);this.internalState.usesPickingColorCache=!0;const i=t>0&&0===pt[0];if(n<t||i){t>dt&&f.A.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),pt=d.A.allocate(pt,t,{size:4,copy:!0,maxCount:Math.max(t,dt)});const e=Math.floor(pt.length/4),r=[0,0,0];for(let t=i?0:n;t<e;t++)this.encodePickingColor(t,r),pt[4*t+0]=r[0],pt[4*t+1]=r[1],pt[4*t+2]=r[2],pt[4*t+3]=0}e.value=pt.subarray(0,4*t)}_setModelAttributes(e,t,n=!1){if(!Object.keys(t).length)return;const i=this.getAttributeManager();if(i?.hasBufferGroups())return void this._setGroupedModelAttributes(e,i,t);if(n){const n=this.getAttributeManager();e.setBufferLayout(n.getBufferLayouts(e)),t=n.getAttributes()}const s=e.userData?.excludeAttributes||{},o={},a={};for(const n in t){if(s[n])continue;const i=t[n].getValue();for(const s in i){const c=i[s];c instanceof r.h?t[n].settings.isIndexed?e.setIndexBuffer(c):o[s]=c:c&&(a[s]=c)}}e.setAttributes(o),e.setConstantAttributes(a)}_setGroupedModelAttributes(e,t,n){const i=e.userData?.excludeAttributes||{},s=t.getBufferGroupBindings(n,e,i);e.setBufferLayout(s.bufferLayouts);const o={...s.buffers},a={},c=t.getAttributes();for(const t in c){if(i[t]||s.groupedAttributeIds.has(t))continue;const n=c[t],l=n.getValue();for(const t in l){const i=l[t];i instanceof r.h?n.settings.isIndexed?e.setIndexBuffer(i):o[t]=i:i&&(a[t]=i)}}e.setAttributes(o),e.setConstantAttributes(a)}disablePickingIndex(e){const t=this.props.data;if(!("attributes"in t))return void this._disablePickingIndex(e);const n=this.getAttributeManager().attributes,i=mt(n),r=vt(n),s=i&&t.attributes&&t.attributes[i.id];if(s&&s.value){const n=s.value;for(let r=0;r<t.length;r++){n[i.getVertexOffset(r)]===e&&this._disablePickingIndex(r)}return}const o=r&&t.attributes&&t.attributes[r.id];if(o&&o.value){const n=o.value,i=this.encodePickingColor(e);for(let e=0;e<t.length;e++){const t=r.getVertexOffset(e);n[t]===i[0]&&n[t+1]===i[1]&&n[t+2]===i[2]&&this._disablePickingIndex(e)}}else this._disablePickingIndex(e)}_disablePickingIndex(e){const t=this.getAttributeManager().attributes,n=mt(t);if(n){const t=n.getVertexOffset(e),i=n.getVertexOffset(e+1),r=new Uint32Array(i-t);return r.fill(qe.Z1),void n.buffer.write(r,t*r.BYTES_PER_ELEMENT)}const i=vt(t);if(!i)return void(this.internalState&&(0,qe.uz)(this.internalState.disabledPickingIndices,e));const r=i.getVertexOffset(e),s=i.getVertexOffset(e+1);i.buffer.write(new Uint8Array(s-r),r)}restorePickingColors(){const e=this.getAttributeManager().attributes,t=gt(e);if(!t)return void(this.internalState&&(this.internalState.disabledPickingIndices.length=0));const n=vt(e);this.internalState.usesPickingColorCache&&n&&n.value.buffer!==pt.buffer&&(n.value=pt.subarray(0,n.value.length)),t.updateSubBuffer({startOffset:0})}_initialize(){(0,g.A)(!this.internalState),(0,re.A)("layer.initialize",this);const e=this._getAttributeManager();this.internalState=new LayerState({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(f.A.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new UniformTransitionManager(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(const e of this.props.extensions)e.initializeState.call(this,this.context,e);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){(0,re.A)("layer.matched",this,this===e);const{state:t,internalState:n}=e;this!==e&&(this.internalState=n,this.state=t,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){const e=this.needsUpdate();if((0,re.A)("layer.update",this,e),!e)return;this.context.stats.get("Layer updates").incrementCount();const t=this.props,n=this.context,i=this.internalState,r=n.viewport,s=this._updateUniformTransition();i.propsInTransition=s,n.viewport=i.viewport||r,this.props=s;try{const e=this._getUpdateParams(),t=this.getModels();if(n.device)this.updateState(e);else try{this.updateState(e)}catch(e){}for(const t of this.props.extensions)t.updateState.call(this,e,t);this.setNeedsRedraw(),this._updateAttributes();const i=this.getModels()[0]!==t[0];this._postUpdate(e,i)}finally{n.viewport=r,this.props=t,this._clearChangeFlags(),i.needsUpdate=!1,i.resetOldProps()}}_finalize(){(0,re.A)("layer.finalize",this),this.finalizeState(this.context);for(const e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:t=null,uniforms:n={},parameters:i={}}){this._updateAttributeTransition();const r=this.props,o=this.context;this.props=this.internalState.propsInTransition||r;try{t&&this.setShaderModuleProps(t);const{getPolygonOffset:r}=this.props,a=r&&r(n)||[0,0];o.device instanceof s.WebGLDevice&&o.device.setParametersWebGL({polygonOffset:a});const c=o.device instanceof s.WebGLDevice?null:function(e){const{blendConstant:t,...n}=e;return t?{pipelineParameters:n,renderPassParameters:{blendConstant:t}}:{pipelineParameters:n}}(i);if(function(e,t,n,i){for(const r of e)"webgpu"===r.device.type?(_t(r,t),r.setParameters({...r.parameters,...i?.pipelineParameters})):r.setParameters(n)}(this.getModels(),e,i,c),o.device instanceof s.WebGLDevice)o.device.withParametersWebGL(i,()=>{const r={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:i,context:o};for(const e of this.props.extensions)e.draw.call(this,r,e);this.draw(r)});else{c?.renderPassParameters&&e.setParameters(c.renderPassParameters);const r={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:i,context:o};for(const e of this.props.extensions)e.draw.call(this,r,e);this.draw(r)}}finally{this.props=r}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;const{changeFlags:t}=this.internalState;for(const n in e)if(e[n]){let i=!1;if("dataChanged"===n){const r=e[n],s=t[n];r&&Array.isArray(s)&&(t.dataChanged=Array.isArray(r)?s.concat(r):r,i=!0)}t[n]||(t[n]=e[n],i=!0),i&&(0,re.A)("layer.changeFlag",this,n,e)}const n=Boolean(t.dataChanged||t.updateTriggersChanged||t.propsChanged||t.extensionsChanged);t.propsOrDataChanged=n,t.somethingChanged=n||t.viewportChanged||t.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,t){const n=Ie(e,t);if(n.updateTriggersChanged)for(const e in n.updateTriggersChanged)n.updateTriggersChanged[e]&&this.invalidateAttribute(e);if(n.transitionsChanged)for(const i in n.transitionsChanged)this.internalState.uniformTransitions.add(i,t[i],e[i],e.transitions?.[i]);return this.setChangeFlags(n)}validateProps(){!function(e){const t=e[Me.fW];for(const n in t){const i=t[n],{validate:r}=i;if(r&&!r(e[n],i))throw new Error(`Invalid prop ${n}: ${e[n]}`)}}(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){const t={highlightedObjectColor:e.picked?e.color:null},{highlightColor:n}=this.props;e.picked&&"function"==typeof n&&(t.highlightColor=n(e)),this.setShaderModuleProps({picking:t}),this.setNeedsRedraw()}_getAttributeManager(){const e=this.context;return new AttributeManager(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,t){const{props:n,oldProps:i}=e,r=this.state.model;r?.isInstanced&&r.setInstanceCount(this.getNumInstances());const{autoHighlight:s,highlightedObjectIndex:o,highlightColor:a}=n;if(t||i.autoHighlight!==s||i.highlightedObjectIndex!==o||i.highlightColor!==a){const e={};Array.isArray(a)&&(e.highlightColor=a),(t||i.autoHighlight!==s||o!==i.highlightedObjectIndex)&&(e.highlightedObjectColor=Number.isFinite(o)&&o>=0?this.encodePickingColor(o):null),this.setShaderModuleProps({picking:e})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let t=!1;t=t||this.internalState.needsRedraw&&this.id;const n=this.getAttributeManager(),i=!!n&&n.getNeedsRedraw(e);if(t=t||i,t)for(const e of this.props.extensions)e.onNeedsRedraw.call(this,e);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,t}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}}Layer.defaultProps=yt,Layer.layerName="Layer";const bt=Layer;function _t(e,t){const n=t.props.framebuffer||(t.framebuffer??null);if(!n)return;const i=n.colorAttachments.map(e=>e?.texture?.format??null),r=n.depthStencilAttachment?.texture?.format,s=e;(function(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0})(s.props.colorAttachmentFormats,i)&&s.props.depthStencilAttachmentFormat===r||(s.props.colorAttachmentFormats=i,s.props.depthStencilAttachmentFormat=r,s._setPipelineNeedsUpdate("attachment formats"))}},12897(e,t,n){const i=Symbol.for("component"),r=Symbol.for("propTypes"),s=Symbol.for("deprecatedProps"),o=Symbol.for("asyncPropDefaults"),a=Symbol.for("asyncPropOriginal"),c=Symbol.for("asyncPropResolved");n.d(t,["VD",0,{NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},"YN",0,a,"fW",0,r,"jA",0,o,"r3",0,i,"uH",0,s,"vf",0,c])},46487(e,t,n){const i={name:"color",dependencies:[],source:"\n\n@must_use\nfn deckgl_premultiplied_alpha(fragColor: vec4<f32>) -> vec4<f32> {\n return vec4(fragColor.rgb * fragColor.a, fragColor.a); \n};\n",getUniforms:e=>({})};n.d(t,["A",0,i])},93675(e,t,n){n.d(t,{Z1:()=>o,Ay:()=>h,uz:()=>a});var i=n(55611);const r={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useByteColors:"f32",highlightedObjectColor:"vec3<f32>",highlightColor:"vec4<f32>"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:[0,1,1,1]},vs:"layout(std140) uniform pickingUniforms {\n float isActive;\n float isAttribute;\n float isHighlightActive;\n float useByteColors;\n vec3 highlightedObjectColor;\n vec4 highlightColor;\n} picking;\n\nout vec4 picking_vRGBcolor_Avalid;\n\n// Normalize unsigned byte color to 0-1 range\nvec3 picking_normalizeColor(vec3 color) {\n return picking.useByteColors > 0.5 ? color / 255.0 : color;\n}\n\n// Normalize unsigned byte color to 0-1 range\nvec4 picking_normalizeColor(vec4 color) {\n return picking.useByteColors > 0.5 ? color / 255.0 : color;\n}\n\nbool picking_isColorZero(vec3 color) {\n return dot(color, vec3(1.0)) < 0.00001;\n}\n\nbool picking_isColorValid(vec3 color) {\n return dot(color, vec3(1.0)) > 0.00001;\n}\n\n// Check if this vertex is highlighted \nbool isVertexHighlighted(vec3 vertexColor) {\n vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n return\n bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor));\n}\n\n// Set the current picking color\nvoid picking_setPickingColor(vec3 pickingColor) {\n pickingColor = picking_normalizeColor(pickingColor);\n\n if (bool(picking.isActive)) {\n // Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable\n picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));\n\n if (!bool(picking.isAttribute)) {\n // Stores the picking color so that the fragment shader can render it during picking\n picking_vRGBcolor_Avalid.rgb = pickingColor;\n }\n } else {\n // Do the comparison with selected item color in vertex shader as it should mean fewer compares\n picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor));\n }\n}\n\nvoid picking_setPickingAttribute(float value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.r = value;\n }\n}\n\nvoid picking_setPickingAttribute(vec2 value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.rg = value;\n }\n}\n\nvoid picking_setPickingAttribute(vec3 value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.rgb = value;\n }\n}\n",fs:"layout(std140) uniform pickingUniforms {\n float isActive;\n float isAttribute;\n float isHighlightActive;\n float useByteColors;\n vec3 highlightedObjectColor;\n vec4 highlightColor;\n} picking;\n\nin vec4 picking_vRGBcolor_Avalid;\n\n/*\n * Returns highlight color if this item is selected.\n */\nvec4 picking_filterHighlightColor(vec4 color) {\n // If we are still picking, we don't highlight\n if (picking.isActive > 0.5) {\n return color;\n }\n\n bool selected = bool(picking_vRGBcolor_Avalid.a);\n\n if (selected) {\n // Blend in highlight color based on its alpha value\n float highLightAlpha = picking.highlightColor.a;\n float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);\n float highLightRatio = highLightAlpha / blendedAlpha;\n\n vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio);\n return vec4(blendedRGB, blendedAlpha);\n } else {\n return color;\n }\n}\n\n/*\n * Returns picking color if picking enabled else unmodified argument.\n */\nvec4 picking_filterPickingColor(vec4 color) {\n if (bool(picking.isActive)) {\n if (picking_vRGBcolor_Avalid.a == 0.0) {\n discard;\n }\n return picking_vRGBcolor_Avalid;\n }\n return color;\n}\n\n/*\n * Returns picking color if picking is enabled if not\n * highlight color if this item is selected, otherwise unmodified argument.\n */\nvec4 picking_filterColor(vec4 color) {\n vec4 highlightColor = picking_filterHighlightColor(color);\n return picking_filterPickingColor(highlightColor);\n}\n",getUniforms:function(e={},t){const n={},r=(0,i.eS)(e.useByteColors,!0);if(void 0===e.highlightedObjectColor);else if(null===e.highlightedObjectColor)n.isHighlightActive=!1;else{n.isHighlightActive=!0;const t=e.highlightedObjectColor.slice(0,3);n.highlightedObjectColor=t}e.highlightColor&&(n.highlightColor=(0,i.jI)(e.highlightColor,r));void 0!==e.isActive&&(n.isActive=Boolean(e.isActive),n.isAttribute=Boolean(e.isAttribute));void 0!==e.useByteColors&&(n.useByteColors=Boolean(e.useByteColors));return n}};var s=n(3459);const o=16777215;function a(e,t){10===e.length?s.A.warn("pickMultipleObjects can only exclude 10 previously picked objects for layers without picking buffers")():e.push(t)}function c(e){return e.replace(" vec4 highlightColor;\n} picking;"," vec4 highlightColor;\n float disabledPickingIndexCount;\n vec4 disabledPickingIndices0;\n vec4 disabledPickingIndices1;\n vec4 disabledPickingIndices2;\n} picking;")}function l(e,t){return[e[t]||0,e[t+1]||0,e[t+2]||0,e[t+3]||0]}const u=`vec3 picking_getPickingColorFromIndex(float objectIndex) {\n if (objectIndex < 0.0 || objectIndex >= ${o}.0) {\n return vec3(0.0);\n }\n\n for (int i = 0; i < 10; i++) {\n if (float(i) >= picking.disabledPickingIndexCount) {\n break;\n }\n vec4 disabledIndices = i < 4\n ? picking.disabledPickingIndices0\n : (i < 8 ? picking.disabledPickingIndices1 : picking.disabledPickingIndices2);\n float disabledIndex = disabledIndices[i - (i / 4) * 4];\n if (disabledIndex == objectIndex) {\n return vec3(0.0);\n }\n }\n\n float encodedIndex = objectIndex + 1.0;\n return vec3(\n mod(encodedIndex, 256.0),\n mod(floor(encodedIndex / 256.0), 256.0),\n mod(floor(encodedIndex / 65536.0), 256.0)\n );\n}\n\nvec3 picking_getPickingColorFromIndex(uint objectIndex) {\n return picking_getPickingColorFromIndex(float(objectIndex));\n}\n\nvec3 picking_getPickingColorFromInstanceID() {\n return picking_getPickingColorFromIndex(float(gl_InstanceID));\n}\n\nvoid picking_setPickingColorFromInstanceID() {\n picking_setPickingColor(picking_getPickingColorFromInstanceID());\n}\n`,d=`struct pickingUniforms {\n isActive: f32,\n isAttribute: f32,\n isHighlightActive: f32,\n useByteColors: f32,\n highlightedObjectColor: vec3<f32>,\n highlightColor: vec4<f32>,\n disabledPickingIndexCount: f32,\n disabledPickingIndices0: vec4<f32>,\n disabledPickingIndices1: vec4<f32>,\n disabledPickingIndices2: vec4<f32>,\n};\n\n@group(0) @binding(auto) var<uniform> picking: pickingUniforms;\n\nfn picking_normalizeColor(color: vec3<f32>) -> vec3<f32> {\n return select(color, color / 255.0, picking.useByteColors > 0.5);\n}\n\nfn picking_normalizeColor4(color: vec4<f32>) -> vec4<f32> {\n return select(color, color / 255.0, picking.useByteColors > 0.5);\n}\n\nfn picking_isColorZero(color: vec3<f32>) -> bool {\n return dot(color, vec3<f32>(1.0)) < 0.00001;\n}\n\nfn picking_isColorValid(color: vec3<f32>) -> bool {\n return dot(color, vec3<f32>(1.0)) > 0.00001;\n}\n\nfn picking_getPickingColorFromIndex(objectIndex: u32) -> vec3<f32> {\n if (objectIndex >= ${o}u) {\n return vec3<f32>(0.0);\n }\n\n for (var i = 0; i < 10; i = i + 1) {\n if (f32(i) >= picking.disabledPickingIndexCount) {\n break;\n }\n let disabledIndices = select(\n picking.disabledPickingIndices2,\n select(picking.disabledPickingIndices1, picking.disabledPickingIndices0, i < 4),\n i < 8\n );\n let disabledIndex = disabledIndices[i % 4];\n if (disabledIndex == f32(objectIndex)) {\n return vec3<f32>(0.0);\n }\n }\n\n let encodedIndex = objectIndex + 1u;\n return vec3<f32>(\n f32(encodedIndex % 256u),\n f32((encodedIndex / 256u) % 256u),\n f32((encodedIndex / 65536u) % 256u)\n ) / 255.0;\n}\n`,h={...r,vs:`${c(r.vs)}\n${u}`,fs:c(r.fs),source:d,uniformTypes:{...r.uniformTypes,disabledPickingIndexCount:"f32",disabledPickingIndices0:"vec4<f32>",disabledPickingIndices1:"vec4<f32>",disabledPickingIndices2:"vec4<f32>"},defaultUniforms:{...r.defaultUniforms,useByteColors:!0,disabledPickingIndexCount:0,disabledPickingIndices0:[0,0,0,0],disabledPickingIndices1:[0,0,0,0],disabledPickingIndices2:[0,0,0,0]},getUniforms(e,t){const n=r.getUniforms(e,t),i=e.disabledPickingIndices||[];return n.disabledPickingIndexCount=i.length,n.disabledPickingIndices0=l(i,0),n.disabledPickingIndices1=l(i,4),n.disabledPickingIndices2=l(i,8),n},inject:{"vs:DECKGL_FILTER_GL_POSITION":"\n // for picking depth values\n picking_setPickingAttribute(position.z / position.w);\n ","vs:DECKGL_FILTER_COLOR":"\n picking_setPickingColor(geometry.pickingColor);\n ","fs:DECKGL_FILTER_COLOR":{order:99,injection:"\n // use highlight color if this fragment belongs to the selected object.\n color = picking_filterHighlightColor(color);\n\n // use picking color if rendering to picking FBO.\n color = picking_filterPickingColor(color);\n "}}}},84175(e,t,n){const i={name:"project32",dependencies:[n(4782).A],source:"// Define a structure to hold both the clip-space position and the common position.\nstruct ProjectResult {\n clipPosition: vec4<f32>,\n commonPosition: vec4<f32>,\n};\n\n// This function mimics the GLSL version with the 'out' parameter by returning both values.\nfn project_position_to_clipspace_and_commonspace(\n position: vec3<f32>,\n position64Low: vec3<f32>,\n offset: vec3<f32>\n) -> ProjectResult {\n // Compute the projected position.\n let projectedPosition: vec3<f32> = project_position_vec3_f64(position, position64Low);\n\n // Start with the provided offset.\n var finalOffset: vec3<f32> = offset;\n\n // Get whether a rotation is needed and the rotation matrix.\n let rotationResult = project_needs_rotation(projectedPosition);\n\n // If rotation is needed, update the offset.\n if (rotationResult.needsRotation) {\n finalOffset = rotationResult.transform * offset;\n }\n\n // Compute the common position.\n let commonPosition: vec4<f32> = vec4<f32>(projectedPosition + finalOffset, 1.0);\n\n // Convert to clip-space.\n let clipPosition: vec4<f32> = project_common_position_to_clipspace(commonPosition);\n\n return ProjectResult(clipPosition, commonPosition);\n}\n\n// A convenience overload that returns only the clip-space position.\nfn project_position_to_clipspace(\n position: vec3<f32>,\n position64Low: vec3<f32>,\n offset: vec3<f32>\n) -> vec4<f32> {\n return project_position_to_clipspace_and_commonspace(position, position64Low, offset).clipPosition;\n}\n",vs:"vec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition\n) {\n vec3 projectedPosition = project_position(position, position64Low);\n mat3 rotation;\n if (project_needs_rotation(projectedPosition, rotation)) {\n // offset is specified as ENU\n // when in globe projection, rotate offset so that the ground alighs with the surface of the globe\n offset = rotation * offset;\n }\n commonPosition = vec4(projectedPosition + offset, 1.0);\n return project_common_position_to_clipspace(commonPosition);\n}\n\nvec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset\n) {\n vec4 commonPosition;\n return project_position_to_clipspace(position, position64Low, offset, commonPosition);\n}\n"};n.d(t,["A",0,i])},73281(e,t,n){n.d(t,{A:()=>FlyToInterpolator});var i=n(78715),r=n(54901),s=n(45249);const o={bearing:0,pitch:0,position:[0,0,0]},a={speed:1.2,curve:1.414};class FlyToInterpolator extends i.A{constructor(e={}){super({compare:["longitude","latitude","zoom","bearing","pitch","position"],extract:["width","height","longitude","latitude","zoom","bearing","pitch","position"],required:["width","height","latitude","longitude","zoom"]}),this.opts={...a,...e}}interpolateProps(e,t,n){const i=(0,s.rj)(e,t,n,this.opts);for(const s in o)i[s]=(0,r.Cc)(e[s]||o[s],t[s]||o[s],n);return i}getDuration(e,t){let{transitionDuration:n}=t;return"auto"===n&&(n=(0,s.v7)(e,t,this.opts)),n}}},70053(e,t,n){n.d(t,{A:()=>LinearInterpolator});var i=n(78715),r=n(54901);const s=["longitude","latitude","zoom","bearing","pitch"],o=["longitude","latitude","zoom"];class LinearInterpolator extends i.A{constructor(e={}){const t=Array.isArray(e)?e:e.transitionProps,n=Array.isArray(e)?{}:e;n.transitionProps=Array.isArray(t)?{compare:t,required:t}:t||{compare:s,required:o},super(n.transitionProps),this.opts=n}initializeProps(e,t){const n=super.initializeProps(e,t),{makeViewport:i,around:r}=this.opts;if(i&&r){const s=i(e),o=i(t),a=s.unproject(r);n.start.around=r,Object.assign(n.end,{around:o.project(a),aroundPosition:a,width:t.width,height:t.height})}return n}interpolateProps(e,t,n){const i={};for(const s of this._propsToExtract)i[s]=(0,r.Cc)(e[s]||0,t[s]||0,n);if(t.aroundPosition&&this.opts.makeViewport){const s=this.opts.makeViewport({...t,...i});Object.assign(i,s.panByPosition(t.aroundPosition,(0,r.Cc)(e.around,t.around,n)))}return i}}},78715(e,t,n){n.d(t,{A:()=>TransitionInterpolator});var i=n(54901),r=n(24067);class TransitionInterpolator{constructor(e){const{compare:t,extract:n,required:i}=e;this._propsToCompare=t,this._propsToExtract=n||t,this._requiredProps=i}arePropsEqual(e,t){for(const n of this._propsToCompare)if(!(n in e)||!(n in t)||!(0,i.aI)(e[n],t[n]))return!1;return!0}initializeProps(e,t){const n={},i={};for(const r of this._propsToExtract)(r in e||r in t)&&(n[r]=e[r],i[r]=t[r]);return this._checkRequiredProps(n),this._checkRequiredProps(i),{start:n,end:i}}getDuration(e,t){return t.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(t=>{const n=e[t];(0,r.A)(Number.isFinite(n)||Array.isArray(n),`${t} is required for transition`)})}}},2357(e,t,n){n.d(t,{A:()=>Transition});class Transition{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){if(!this._inProgress)return!1;if(null===this._handle){const{_timeline:e,settings:t}=this;this._handle=e.addChannel({delay:e.getTime(),duration:t.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}}},24067(e,t,n){function i(e,t){if(!e)throw new Error(t||"deck.gl: assertion failed.")}n.d(t,{A:()=>i})},38055(e,t,n){function i(e,t=()=>!0){return Array.isArray(e)?r(e,t,[]):t(e)?[e]:[]}function r(e,t,n){let i=-1;for(;++i<e.length;){const s=e[i];Array.isArray(s)?r(s,t,n):t(s)&&n.push(s)}return n}function s({target:e,source:t,start:n=0,count:i=1}){const r=t.length,s=i*r;let o=0;for(let i=n;o<r;o++)e[i++]=t[o];for(;o<s;)o<s-o?(e.copyWithin(n+o,n,n+o),o*=2):(e.copyWithin(n+o,n,n+s-o),o=s);return e}n.d(t,{B:()=>i,R:()=>s})},53439(e,t,n){n.d(t,{I:()=>a,Td:()=>o,X:()=>s});const i=[],r=[];function s(e,t=0,n=1/0){let s=i;const o={index:-1,data:e,target:[]};return e?"function"==typeof e[Symbol.iterator]?s=e:e.length>0&&(r.length=e.length,s=r):s=i,(t>0||Number.isFinite(n))&&(s=(Array.isArray(s)?s:Array.from(s)).slice(t,n),o.index=t-1),{iterable:s,objectInfo:o}}function o(e){return e&&e[Symbol.asyncIterator]}function a(e,t){const{size:n,stride:i,offset:r,startIndices:s,nested:o}=t,a=e.BYTES_PER_ELEMENT,c=i?i/a:n,l=r?r/a:0,u=Math.floor((e.length-l)/c);return(t,{index:i,target:r})=>{if(!s){const t=i*c+l;for(let i=0;i<n;i++)r[i]=e[t+i];return r}const a=s[i],d=s[i+1]||u;let h;if(o){h=new Array(d-a);for(let t=a;t<d;t++){const i=t*c+l;r=new Array(n);for(let t=0;t<n;t++)r[t]=e[i+t];h[t-a]=r}}else if(c===n)h=e.subarray(a*n+l,d*n+l);else{h=new e.constructor((d-a)*n);let t=0;for(let i=a;i<d;i++){const r=i*c+l;for(let i=0;i<n;i++)h[t++]=e[r+i]}}return h}}},33945(e,t,n){n.d(t,{E9:()=>o,rk:()=>r});const i=/^(?:\d+\.?\d*|\.\d+)$/;function r(e){switch(typeof e){case"number":if(!Number.isFinite(e))throw new Error(`Could not parse position string ${e}`);return{type:"literal",value:e};case"string":try{const t=function(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(/\s/.test(r))n++;else{if("+"!==r&&"-"!==r&&"("!==r&&")"!==r&&"%"!==r){if(a(r)||"."===r){const s=n;let o="."===r;for(n++;n<e.length;){const t=e[n];if(a(t))n++;else{if("."!==t||o)break;o=!0,n++}}const c=e.slice(s,n);if(!i.test(c))throw new Error("Invalid number token");t.push({type:"number",value:parseFloat(c)});continue}if(c(r)){const i=n;for(;n<e.length&&c(e[n]);)n++;const r=e.slice(i,n).toLowerCase();t.push({type:"word",value:r});continue}throw new Error("Invalid token in position string")}t.push({type:"symbol",value:r}),n++}}return t}(e);return new LayoutExpressionParser(t).parseExpression()}catch(t){const n=t instanceof Error?t.message:String(t);throw new Error(`Could not parse position string ${e}: ${n}`)}default:throw new Error(`Could not parse position string ${e}`)}}function s(e,t){switch(e.type){case"literal":return e.value;case"percentage":return Math.round(e.value*t);case"binary":const n=s(e.left,t),i=s(e.right,t);return"+"===e.operator?n+i:n-i;default:throw new Error("Unknown layout expression type")}}function o(e,t){return s(e,t)}class LayoutExpressionParser{constructor(e){this.index=0,this.tokens=e}parseExpression(){const e=this.parseBinaryExpression();if(this.index<this.tokens.length)throw new Error("Unexpected token at end of expression");return e}parseBinaryExpression(){let e=this.parseFactor(),t=this.peek();for(;l(t);){this.index++;const n=this.parseFactor();e={type:"binary",operator:t.value,left:e,right:n},t=this.peek()}return e}parseFactor(){const e=this.peek();if(!e)throw new Error("Unexpected end of expression");if("symbol"===e.type&&"+"===e.value)return this.index++,this.parseFactor();if("symbol"===e.type&&"-"===e.value){this.index++;return{type:"binary",operator:"-",left:{type:"literal",value:0},right:this.parseFactor()}}if("symbol"===e.type&&"("===e.value){this.index++;const e=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return e}if("word"===e.type&&"calc"===e.value){if(this.index++,!this.consumeSymbol("("))throw new Error("Missing opening parenthesis after calc");const e=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return e}if("number"===e.type){this.index++;const t=e.value,n=this.peek();return n&&"symbol"===n.type&&"%"===n.value?(this.index++,{type:"percentage",value:t/100}):n&&"word"===n.type&&"px"===n.value?(this.index++,{type:"literal",value:t}):{type:"literal",value:t}}throw new Error("Unexpected token in expression")}consumeSymbol(e){const t=this.peek();return!(!t||"symbol"!==t.type||t.value!==e)&&(this.index++,!0)}peek(){return this.tokens[this.index]||null}}function a(e){return e>="0"&&e<="9"}function c(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}function l(e){return Boolean(e&&"symbol"===e.type&&("+"===e.value||"-"===e.value))}},44941(e,t,n){n.d(t,{A:()=>Tesselator});var i=n(53439),r=n(23459),s=n(24067),o=n(26839);class Tesselator{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;const{attributes:t={}}=e;this.typedArrayManager=r.A,this.attributes={},this._attributeDefs=t,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);const{data:t,buffers:n={},getGeometry:i,geometryBuffer:r,positionFormat:o,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=t,this.getGeometry=i,this.positionSize=r&&r.size||("XY"===o?2:3),this.buffers=n,this.normalize=c,r&&((0,s.A)(t.startIndices),this.getGeometry=this.getGeometryFromBuffer(r),c||(n.vertexPositions=r)),this.geometryBuffer=n.vertexPositions,Array.isArray(a))for(const e of a)this._rebuildGeometry(e);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:t}){this._rebuildGeometry({startRow:e,endRow:t})}getGeometryFromBuffer(e){const t=e.value||e;return ArrayBuffer.isView(t)?(0,i.I)(t,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,t){const{attributes:n,buffers:i,_attributeDefs:r,typedArrayManager:s}=this;for(const o in r)if(o in i)s.release(n[o]),n[o]=null;else{const i=r[o];i.copy=t,n[o]=s.allocate(n[o],e,i)}}_forEachGeometry(e,t,n){const{data:r,getGeometry:s}=this,{iterable:o,objectInfo:a}=(0,i.X)(r,t,n);for(const t of o){a.index++;e(s?s(t,a):null,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:t,vertexStarts:n,instanceCount:i}=this;const{data:r,geometryBuffer:s}=this,{startRow:a=0,endRow:c=1/0}=e||{},l={};if(e||(t=[0],n=[0]),this.normalize||!s)this._forEachGeometry((e,t)=>{const i=e&&this.normalizeGeometry(e);l[t]=i,n[t+1]=n[t]+(i?this.getGeometrySize(i):0)},a,c),i=n[n.length-1];else if(n=r.startIndices,i=n[r.length]||0,ArrayBuffer.isView(s))i=i||s.length/this.positionSize;else if(s instanceof o.h){const e=4*this.positionSize;i=i||s.byteLength/e}else if(s.buffer){const e=s.stride||4*this.positionSize;i=i||s.buffer.byteLength/e}else if(s.value){const e=s.value,t=s.stride/e.BYTES_PER_ELEMENT||this.positionSize;i=i||e.length/t}this._allocate(i,Boolean(e)),this.indexStarts=t,this.vertexStarts=n,this.instanceCount=i;const u={};this._forEachGeometry((e,r)=>{const s=l[r]||e;u.vertexStart=n[r],u.indexStart=t[r];const o=r<n.length-1?n[r+1]:i;u.geometrySize=o-n[r],u.geometryIndex=r,this.updateGeometryAttributes(s,u)},a,c),this.vertexCount=t[t.length-1]}}},75524(e,t,n){n.d(t,{A:()=>g});var i=n(46554),r=n(69502),s=n(54901),o=n(6540),a=n(60676),c=n(58532),l=n(45249),u=n(24067),d=n(25667),h=n(70053);const f=[[-1/0,-90],[1/0,90]];function p([e,t]){if(Math.abs(t)>90&&(t=90*Math.sign(t)),Number.isFinite(e)){const[n,i]=(0,l.Gw)([e,t]);return[n,(0,s.qE)(i,0,512)]}const[,n]=(0,l.Gw)([0,t]);return[e,(0,s.qE)(n,0,512)]}class MapState extends a.A{constructor(e){const{width:t,height:n,latitude:i,longitude:r,zoom:s,bearing:o=0,pitch:c=0,altitude:l=1.5,position:d=[0,0,0],maxZoom:h=20,minZoom:p=0,maxPitch:g=60,minPitch:m=0,startPanLngLat:v,startZoomLngLat:y,startRotatePos:b,startRotateLngLat:_,startBearing:x,startPitch:w,startZoom:P,normalize:C=!0,rubberBand:S=!1}=e,{[a.y]:L}=e;(0,u.A)(Number.isFinite(r)),(0,u.A)(Number.isFinite(i)),(0,u.A)(Number.isFinite(s));super({width:t,height:n,latitude:i,longitude:r,zoom:s,bearing:o,pitch:c,altitude:l,maxZoom:h,minZoom:p,maxPitch:g,minPitch:m,normalize:C,position:d,maxBounds:e.maxBounds||(C?f:null),maxBoundsPadding:e.maxBoundsPadding||null,rubberBand:S,[a.y]:L},{startPanLngLat:v,startZoomLngLat:y,startRotatePos:b,startRotateLngLat:_,startBearing:x,startPitch:w,startZoom:P},e.makeViewport,e.constraintContext),this.getAltitude=e.getAltitude}panStart({pos:e},t){return this._getUpdatedState({startPanLngLat:this._unproject(e)},t)}pan({pos:e,startPos:t},n){const i=this.getState().startPanLngLat||this._unproject(t);if(!i)return this;const r=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(r,n)}panEnd(e){return this._getUpdatedState({startPanLngLat:null},e)}rotateStart({pos:e}){const t=this.getAltitude?.(e);return this._getUpdatedState({startRotatePos:e,startRotateLngLat:void 0!==t?this._unproject3D(e,t):void 0,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:n=0}){const{startRotatePos:i,startRotateLngLat:r,startBearing:s,startPitch:o}=this.getState();if(!i||void 0===s||void 0===o)return this;let a;if(a=e?this._getNewRotation(e,i,o,s):{bearing:s+t,pitch:o+n},r){const e=this.makeViewport({...this.getViewportProps(),...a}),t="panByPosition3D"in e?"panByPosition3D":"panByPosition";return this._getUpdatedState({...a,...e[t](r,i)})}return this._getUpdatedState(a)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:e},t){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom},t)}zoom({pos:e,startPos:t,scale:n},i){let{startZoom:r,startZoomLngLat:s}=this.getState();return s||(r=this.getViewportProps().zoom,s=this._unproject(t)||this._unproject(e)),s?this._getUpdatedState({zoom:r+Math.log2(n),[a.y]:{position:s,screenPosition:e}},i):this}zoomEnd(e){return this._getUpdatedState({startZoomLngLat:null,startZoom:null},e)}zoomIn(e=2,t){return this._zoomFromCenter(e,t)}zoomOut(e=2,t){return this._zoomFromCenter(1/e,t)}moveLeft(e=100,t){return this._panFromCenter([e,0],t)}moveRight(e=100,t){return this._panFromCenter([-e,0],t)}moveUp(e=100,t){return this._panFromCenter([0,e],t)}moveDown(e=100,t){return this._panFromCenter([0,-e],t)}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){const t=e.getViewportProps(),n={...this.getViewportProps()},{bearing:i,longitude:r}=n;return Math.abs(i-t.bearing)>180&&(n.bearing=i<0?i+360:i-360),Math.abs(r-t.longitude)>180&&(n.longitude=r<0?r+360:r-360),n}applyConstraints(e,t){const n=e,i=n[a.y];delete n[a.y];const{maxPitch:r,minPitch:o,pitch:u,bearing:h,normalize:f,maxBounds:g,rubberBand:m}=e;f&&(h<-180||h>180)&&(e.bearing=(0,d.zi)(h+180,360)-180),e.pitch=(0,s.qE)(u,o,r);const v=this._constrainZoom(e.zoom,e),y=m&&"elastic"===t?.mode;if(e.zoom="preserve"===t?.mode?e.zoom:y?(0,c.GT)(e.zoom,v,1):v,i){const t=this.makeViewport(e);Object.assign(e,t.panByPosition(i.position,i.screenPosition))}if(f&&(e.longitude<-180||e.longitude>180)&&(e.longitude=(0,d.zi)(e.longitude+180,360)-180),g){const n=(0,c.CI)(e.width,e.height,e.maxBoundsPadding),i=this.makeViewport({...e,bearing:0,pitch:0}),r=(0,c.jo)(i,[e.longitude,e.latitude],n),o=p(g[0]),a=p(g[1]),u=2**e.zoom,d=[o[0]+r.left/u,o[1]+r.bottom/u],h=[a[0]-r.right/u,a[1]-r.top/u],f=p([e.longitude,e.latitude]),m=[(0,s.qE)(f[0],d[0],h[0]),(0,s.qE)(f[1],d[1],h[1])],v=f.slice();if(n.width>=0&&(v[0]="preserve"===t?.mode?f[0]:y?(0,c.GT)(f[0],m[0],n.width/2/u):m[0]),n.height>=0&&(v[1]="preserve"===t?.mode?f[1]:y?(0,c.GT)(f[1],m[1],n.height/2/u):m[1]),v[0]!==f[0]||v[1]!==f[1]){const[t,n]=(0,l.iV)(v);v[0]!==f[0]&&(e.longitude=t),v[1]!==f[1]&&(e.latitude=n)}}return e}_constrainZoom(e,t){t||(t=this.getViewportProps());const{maxZoom:n,maxBounds:i}=t,r=null!==i&&t.width>0&&t.height>0;let{minZoom:o}=t;if(r){const e=(0,c.CI)(t.width,t.height,t.maxBoundsPadding),r=p(i[0]),s=p(i[1]),a=s[0]-r[0],l=s[1]-r[1];e.width>0&&Number.isFinite(a)&&a>0&&(o=Math.max(o,Math.log2(e.width/a))),e.height>0&&Number.isFinite(l)&&l>0&&(o=Math.max(o,Math.log2(e.height/l))),o>n&&(o=n)}return(0,s.qE)(e,o,n)}_zoomFromCenter(e,t){const{width:n,height:i}=this.getViewportProps();return this.zoom({pos:[n/2,i/2],scale:e},t)}_panFromCenter(e,t){const{width:n,height:i}=this.getViewportProps();return this.pan({startPos:[n/2,i/2],pos:[n/2+e[0],i/2+e[1]]},t)}_getUpdatedState(e,t){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e,constraintContext:t})}_unproject(e){const t=this.makeViewport(this.getViewportProps());return e&&t.unproject(e)}_unproject3D(e,t){return this.makeViewport(this.getViewportProps()).unproject(e,{targetZ:t})}_getNewRotation(e,t,n,i){const r=e[0]-t[0],o=e[1]-t[1],a=e[1],c=t[1],{width:l,height:u}=this.getViewportProps(),d=r/l;let h=0;o>0?Math.abs(u-c)>5&&(h=o/(c-u)*1.2):o<0&&c>5&&(h=1-a/c),h=(0,s.qE)(h,-1,1);const{minPitch:f,maxPitch:p}=this.getViewportProps();let g=n;return h>0?g=n+h*(p-n):h<0&&(g=n-h*(f-n)),{pitch:g,bearing:i+180*d}}}class MapController extends o.A{constructor(){super(...arguments),this.ControllerState=MapState,this.transition={transitionDuration:300,transitionInterpolator:new h.A({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan",this.rotationPivot="center",this._getAltitude=e=>{if("2d"===this.rotationPivot)return 0;if("3d"===this.rotationPivot&&this.pickPosition){const{x:t,y:n}=this.props,i=this.pickPosition(t+e[0],n+e[1]);if(i&&i.coordinate&&i.coordinate.length>=3)return i.coordinate[2]}}}setProps(e){"rotationPivot"in e&&(this.rotationPivot=e.rotationPivot||"center"),e.getAltitude=this._getAltitude,e.position=e.position||[0,0,0],e.maxBounds=e.maxBounds||(!1===e.normalize?null:f),super.setProps(e)}updateViewport(e,t=null,n={}){const i=e.getState();n.isDragging&&i.startRotateLngLat?n={...n,rotationPivotPosition:i.startRotateLngLat}:!1===n.isDragging&&(n={...n,rotationPivotPosition:void 0}),super.updateViewport(e,t,n)}}class MapView extends i.A{constructor(e={}){super(e)}getViewportType(){return r.A}get ControllerType(){return MapController}}MapView.displayName="MapView";const g=MapView},6299(e,t,n){n.d(t,{A:()=>y});var i=n(46554),r=n(47345),s=n(31886),o=n(54901),a=n(83588),c=n(45249);const l=(new s.k).lookAt({eye:[0,0,1]});function u({width:e,height:t,near:n,far:i,padding:r}){let a=-e/2,c=e/2,l=-t/2,u=t/2;if(r){const{left:n=0,right:i=0,top:s=0,bottom:d=0}=r,h=(0,o.qE)((n+e-i)/2,0,e)-e/2,f=(0,o.qE)((s+t-d)/2,0,t)-t/2;a-=h,c-=h,l+=f,u+=f}return(new s.k).ortho({left:a,right:c,bottom:l,top:u,near:n,far:i})}class OrthographicViewport extends r.A{constructor(e){const{width:t,height:n,near:i=.1,far:r=1e3,zoom:s=0,target:o=[0,0,0],padding:a=null,flipY:c=!0}=e,d=e.zoomX??(Array.isArray(s)?s[0]:s),h=e.zoomY??(Array.isArray(s)?s[1]:s),f=Number.isFinite(e.zoom)?e.zoom:Math.min(d,h),p=Math.pow(2,f);let g;if(d!==f||h!==f){const e=Math.pow(2,d),t=Math.pow(2,h);g={unitsPerMeter:[e/p,t/p,1],metersPerUnit:[p/e,p/t,1]}}super({...e,longitude:void 0,position:o,viewMatrix:l.clone().scale([p,p*(c?-1:1),p]),projectionMatrix:u({width:t||1,height:n||1,padding:a,near:i,far:r}),zoom:f,distanceScales:g}),this.target=o,this.zoomX=d,this.zoomY=h,this.flipY=c}projectFlat([e,t]){const{unitsPerMeter:n}=this.distanceScales;return[e*n[0],t*n[1]]}unprojectFlat([e,t]){const{metersPerUnit:n}=this.distanceScales;return[e*n[0],t*n[1]]}panByPosition(e,t,n){const i=(0,c.xJ)(t,this.pixelUnprojectionMatrix),r=this.projectFlat(e),s=a.WQ([],r,a.ze([],i)),o=a.WQ([],this.center,s);return{target:this.unprojectFlat(o)}}}OrthographicViewport.displayName="OrthographicViewport";const d=OrthographicViewport;var h=n(6540),f=n(60676),p=n(58532),g=n(70053);function m({zoom:e=0,zoomX:t,zoomY:n}){return{zoomX:t=t??(Array.isArray(e)?e[0]:e),zoomY:n=n??(Array.isArray(e)?e[1]:e)}}function v(e,t,n,i,r){const s=e[0][t]+n,a=e[1][t]-i,c=(s+a)/2;return{minimum:s,maximum:a,midpoint:c,settledTarget:Number.isFinite(n)&&Number.isFinite(i)&&s<=a?(0,o.qE)(r,s,a):c}}class OrthographicState extends f.A{constructor(e){const{width:t,height:n,target:i=[0,0,0],zoom:r=0,zoomAxis:s="all",minZoom:o=-1/0,maxZoom:a=1/0,minZoomX:c=o,maxZoomX:l=a,minZoomY:u=o,maxZoomY:d=a,maxBounds:h=null,maxBoundsPadding:p=null,rubberBand:g=!1,startPanPosition:v,startZoomPosition:y,startZoom:b}=e,{[f.y]:_}=e,{zoomX:x,zoomY:w}=m(e);super({width:t,height:n,target:i,zoom:r,zoomX:x,zoomY:w,zoomAxis:s,minZoomX:c,maxZoomX:l,minZoomY:u,maxZoomY:d,maxBounds:h,maxBoundsPadding:p,rubberBand:g,[f.y]:_},{startPanPosition:v,startZoomPosition:y,startZoom:b},e.makeViewport,e.constraintContext)}panStart({pos:e},t){return this._getUpdatedState({startPanPosition:this._unproject(e)},t)}pan({pos:e,startPosition:t},n){const i=this.getState().startPanPosition||t;if(!i)return this;const r=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(r,n)}panEnd(e){return this._getUpdatedState({startPanPosition:null},e)}rotateStart(){return this}rotate(){return this}rotateEnd(){return this}shortestPathFrom(e){e.getViewportProps();return{...this.getViewportProps()}}zoomStart({pos:e},t){const{zoomX:n,zoomY:i}=this.getViewportProps();return this._getUpdatedState({startZoomPosition:this._unproject(e),startZoom:[n,i]},t)}zoom({pos:e,startPos:t,scale:n},i){let{startZoom:r,startZoomPosition:s}=this.getState();if(!s){const{zoomX:n,zoomY:i}=this.getViewportProps();r=[n,i],s=this._unproject(t||e)}if(!s)return this;const o=this._calculateNewZoom({scale:n,startZoom:r});return this._getUpdatedState({...o,[f.y]:{position:s,screenPosition:e}},i)}zoomEnd(e){return this._getUpdatedState({startZoomPosition:null,startZoom:null},e)}zoomIn(e=2,t){return this._getUpdatedState(this._calculateNewZoom({scale:e}),t)}zoomOut(e=2,t){return this._getUpdatedState(this._calculateNewZoom({scale:1/e}),t)}moveLeft(e=50,t){return this._panFromCenter([-e,0],t)}moveRight(e=50,t){return this._panFromCenter([e,0],t)}moveUp(e=50,t){return this._panFromCenter([0,-e],t)}moveDown(e=50,t){return this._panFromCenter([0,e],t)}rotateLeft(e=15){return this}rotateRight(e=15){return this}rotateUp(e=10){return this}rotateDown(e=10){return this}_project(e){return this.makeViewport(this.getViewportProps()).project(e)}_unproject(e){const t=this.makeViewport(this.getViewportProps()),[n,i]=t.unproject(e);return[n,i]}_calculateNewZoom({scale:e,startZoom:t}){const{zoomX:n,zoomY:i,zoomAxis:r}=this.getViewportProps();void 0===t&&(t=[n,i]);const s=Math.log2(e);let[o,a]=t;switch(r){case"X":o+=s;break;case"Y":a+=s;break;default:o+=s,a+=s}return{zoomX:o,zoomY:a}}_panFromCenter(e,t){const{target:n}=this.getViewportProps(),i=this._project(n);return this.pan({startPosition:n,pos:[i[0]+e[0],i[1]+e[1]]},t)}_getUpdatedState(e,t){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e,constraintContext:t})}applyConstraints(e,t){const n=e,i=n[f.y];delete n[f.y];const r=m(e),s=this._constrainZoom(r,e),a=e.rubberBand&&"elastic"===t?.mode,{zoomX:c,zoomY:l}="preserve"===t?.mode?r:a?{zoomX:(0,p.GT)(r.zoomX,s.zoomX,1),zoomY:(0,p.GT)(r.zoomY,s.zoomY,1)}:s;if(e.zoomX=c,e.zoomY=l,i){const t=this.makeViewport({...e,zoomX:c,zoomY:l});Object.assign(e,t.panByPosition(i.position,i.screenPosition))}e.zoom=Array.isArray(e.zoom)||e.zoomX!==e.zoomY?[e.zoomX,e.zoomY]:e.zoomX;const{maxBounds:u,rubberBand:d,target:h}=e;if(u){const n=(0,p.CI)(e.width,e.height,e.maxBoundsPadding),i=this.makeViewport(e),r=(0,p.jo)(i,h,n),s=i.project(h),f=[0,1].map(e=>{const t=h.slice();t[e]+=1;const n=i.project(t)[e]-s[e];return Number.isFinite(n)?n:2**(0===e?c:l)*(0===e?1:-1)}),g=f.map((e,t)=>{const n=0===t?r.left:r.top,i=0===t?r.right:r.bottom,s=Math.abs(e);return e>=0?[n/s,i/s]:[i/s,n/s]}),m=h.slice(),y=[n.width,n.height];for(const[e,[i,r]]of g.entries()){if(y[e]<0)continue;const{minimum:s,maximum:c,midpoint:l,settledTarget:g}=v(u,e,i,r,h[e]);if("preserve"!==t?.mode&&d&&(!Number.isFinite(i)||!Number.isFinite(r))){m[e]=l;continue}const b=d?g:(0,o.qE)(h[e],s,c);m[e]="preserve"===t?.mode?h[e]:a?(0,p.GT)(h[e],b,(0===e?n.width:n.height)/2/Math.abs(f[e])):b}m[0]===h[0]&&m[1]===h[1]||(e.target=m)}return e}_constrainZoom({zoomX:e,zoomY:t},n){n||(n=this.getViewportProps());const{zoomAxis:i,maxZoomX:r,maxZoomY:s,maxBounds:a}=n;let{minZoomX:c,minZoomY:l}=n;if(null!==a&&n.width>0&&n.height>0){const e=(0,p.CI)(n.width,n.height,n.maxBoundsPadding),t=a[0],i=a[1],o=i[0]-t[0],u=i[1]-t[1];e.width>0&&Number.isFinite(o)&&o>0&&(c=Math.max(c,Math.log2(e.width/o)),c>r&&(c=r)),e.height>0&&Number.isFinite(u)&&u>0&&(l=Math.max(l,Math.log2(e.height/u)),l>s&&(l=s))}switch(i){case"X":e=(0,o.qE)(e,c,r);break;case"Y":t=(0,o.qE)(t,l,s);break;default:let n=Math.min(r-e,s-t,0);0===n&&(n=Math.max(c-e,l-t,0)),0!==n&&(e+=n,t+=n)}return{zoomX:e,zoomY:t}}}class OrthographicController extends h.A{constructor(){super(...arguments),this.ControllerState=OrthographicState,this.transition={transitionDuration:300,transitionInterpolator:new g.A(["target","zoomX","zoomY"])},this.dragMode="pan"}setProps(e){Object.assign(e,m(e)),super.setProps(e)}_onMultiPanStart(e){return"pan"===this.multiTouchDrag&&super._onMultiPanStart(e)}_onPanRotate(){return!1}}class OrthographicView extends i.A{constructor(e={}){super(e)}getViewportType(){return d}get ControllerType(){return OrthographicController}}OrthographicView.displayName="OrthographicView";const y=OrthographicView},46554(e,t,n){n.d(t,{A:()=>View});var i=n(33945),r=n(7914);function s(e,t){e=e.slice();for(let n=0;n<t.length;n++){const i=t[n];Number.isFinite(i)&&(e[n]=i)}return e}class View{constructor(e){const{id:t,x:n=0,y:r=0,width:s="100%",height:o="100%",padding:a=null}=e;this.id=t||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=(0,i.rk)(n),this._y=(0,i.rk)(r),this._width=(0,i.rk)(s),this._height=(0,i.rk)(o),this._padding=a&&{left:(0,i.rk)(a.left||0),right:(0,i.rk)(a.right||0),top:(0,i.rk)(a.top||0),bottom:(0,i.rk)(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e||this.constructor===e.constructor&&(0,r.b)(this.props,e.props,2)}clone(e){return new(0,this.constructor)({...this.props,...e})}makeViewport({width:e,height:t,viewState:n}){n=this.filterViewState(n);const i=this.getDimensions({width:e,height:t});if(!i.height||!i.width)return null;return new(this.getViewportType(n))({...n,...this.props,...i})}getViewStateId(){const{viewState:e}=this.props;return"string"==typeof e?e:e?.id||this.id}filterViewState(e){return this.props.viewState&&"object"==typeof this.props.viewState?this.props.viewState.id?function(e,t){const n={...e};for(const e in t)"id"!==e&&(Array.isArray(n[e])&&Array.isArray(t[e])?n[e]=s(n[e],t[e]):n[e]=t[e]);return n}(e,this.props.viewState):this.props.viewState:e}getDimensions({width:e,height:t}){const n={x:(0,i.E9)(this._x,e),y:(0,i.E9)(this._y,t),width:(0,i.E9)(this._width,e),height:(0,i.E9)(this._height,t)};return this._padding&&(n.padding={left:(0,i.E9)(this._padding.left,e),top:(0,i.E9)(this._padding.top,t),right:(0,i.E9)(this._padding.right,e),bottom:(0,i.E9)(this._padding.bottom,t)}),n}get controller(){const e=this.props.controller;return e?!0===e?{type:this.ControllerType}:"function"==typeof e?{type:e}:{type:this.ControllerType,...e}:null}}},91111(e,t,n){n.d(t,{A:()=>R});var i=n(9350),r=n(3459),s=n(40618),o=n(18742);const a={clipBounds:[0,0,1,1],clipByInstance:void 0},c="\nlayout(std140) uniform clipUniforms {\n vec4 bounds;\n} clip;\n\nbool clip_isInBounds(vec2 position) {\n return position.x >= clip.bounds[0] && position.y >= clip.bounds[1] && position.x < clip.bounds[2] && position.y < clip.bounds[3];\n}\n",l={name:"clip",vs:c,uniformTypes:{bounds:"vec4<f32>"}},u={"vs:#decl":"\nout float clip_isVisible;\n","vs:DECKGL_FILTER_GL_POSITION":"\n clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));\n","fs:#decl":"\nin float clip_isVisible;\n","fs:DECKGL_FILTER_COLOR":"\n if (clip_isVisible < 0.5) discard;\n"},d={name:"clip",fs:c,uniformTypes:{bounds:"vec4<f32>"}},h={"vs:#decl":"\nout vec2 clip_commonPosition;\n","vs:DECKGL_FILTER_GL_POSITION":"\n clip_commonPosition = geometry.position.xy;\n","fs:#decl":"\nin vec2 clip_commonPosition;\n","fs:DECKGL_FILTER_COLOR":"\n if (!clip_isInBounds(clip_commonPosition)) discard;\n"};class ClipExtension extends o.A{getShaders(){let e="instancePositions"in this.getAttributeManager().attributes;return void 0!==this.props.clipByInstance&&(e=Boolean(this.props.clipByInstance)),this.state.clipByInstance=e,"webgpu"===this.context.device.type?{}:e?{modules:[l],inject:u}:{modules:[d],inject:h}}draw(){const{clipBounds:e}=this.props,t={};if(this.state.clipByInstance)t.bounds=e;else{const n=this.projectPosition([e[0],e[1],0]),i=this.projectPosition([e[2],e[3],0]);t.bounds=[Math.min(n[0],i[0]),Math.min(n[1],i[1]),Math.max(n[0],i[0]),Math.max(n[1],i[1])]}"webgpu"===this.context.device.type&&(t.enabled=!0,t.mode=this.state.clipByInstance?"instance":"geometry"),this.setShaderModuleProps({clip:t})}}ClipExtension.defaultProps=a,ClipExtension.extensionName="ClipExtension";const f=ClipExtension;var p=n(31886),g=n(56478);function m(e,t,n){switch(e.type){case"Point":return function(e,t,n){const{positions:i}=e,r=y(i,t,n);if(r.length>1)return{type:"MultiPoint",coordinates:r};return{type:"Point",coordinates:r[0]}}(e,t,n);case"LineString":return function(e,t=-1/0,n=1/0){const{positions:i}=e,r=e.pathIndices.value.filter(e=>e>=t&&e<=n);if(!(r.length>2)){return{type:"LineString",coordinates:y(i,r[0],r[1])}}const s=[];for(let e=0;e<r.length-1;e++){const t=y(i,r[e],r[e+1]);s.push(t)}return{type:"MultiLineString",coordinates:s}}(e,t,n);case"Polygon":return v(e,t,n);default:const i=e;throw new Error(`Unsupported geometry type: ${i?.type}`)}}function v(e,t=-1/0,n=1/0){const{positions:i}=e,r=e.polygonIndices.value.filter(e=>e>=t&&e<=n),s=e.primitivePolygonIndices.value.filter(e=>e>=t&&e<=n);if(!(r.length>2)){const e=[];for(let t=0;t<s.length-1;t++){const n=y(i,s[t],s[t+1]);e.push(n)}return{type:"Polygon",coordinates:e}}const o=[];for(let t=0;t<r.length-1;t++){const n=v(e,r[t],r[t+1]).coordinates;o.push(n)}return{type:"MultiPolygon",coordinates:o}}function y(e,t,n){t=t||0,n=n||e.value.length/e.size;const i=[];for(let r=t;r<n;r++){const t=Array();for(let n=r*e.size;n<(r+1)*e.size;n++)t.push(Number(e.value[n]));i.push(t)}return i}function b(e,t){const n=t?.globalFeatureId;return void 0!==n?function(e,t){const n=_(e);for(const e of n){let n=0,i=e.featureIds.value[0];for(let r=0;r<e.featureIds.value.length;r++){const s=e.featureIds.value[r];if(s!==i){if(t===e.globalFeatureIds.value[n])return x(e,n,r);n=r,i=s}}if(t===e.globalFeatureIds.value[n])return x(e,n,e.featureIds.value.length)}throw new Error(`featureId:${t} not found`)}(e,n):function(e,t){const n=_(e,t);return function(e){const t=[];for(const n of e){if(0===n.featureIds.value.length)continue;let e=0,i=n.featureIds.value[0];for(let r=0;r<n.featureIds.value.length;r++){const s=n.featureIds.value[r];s!==i&&(t.push(x(n,e,r)),e=r,i=s)}t.push(x(n,e,n.featureIds.value.length))}return t}(n)}(e,t?.type)}function _(e,t){const n=[];return e.points&&(e.points.type="Point",n.push(e.points)),e.lines&&(e.lines.type="LineString",n.push(e.lines)),e.polygons&&(e.polygons.type="Polygon",n.push(e.polygons)),n}function x(e,t,n){const i=m(e,t,n),r=function(e,t=0){const n=Object.assign({},e.properties[e.featureIds.value[t]]);for(const i in e.numericProps)n[i]=e.numericProps[i].value[t];return n}(e,t),s=function(e,t=0){return e.fields&&e.fields[e.featureIds.value[t]]}(e,t);return{type:"Feature",geometry:i,properties:r,...s}}var w=n(54901);const P={Point:C,MultiPoint:function(e,t,n){return S(e,t,n)},LineString:L,MultiLineString:function(e,t,n){return e.map(e=>L(e,t,n))},Polygon:A,MultiPolygon:function(e,t,n){return e.map(e=>A(e,t,n))}};function C([e,t],[n,i],r){const s=(0,w.Cc)(n[0],i[0],e),o=(0,w.Cc)(n[1],i[1],t);return r.unprojectFlat([s,o])}function S(e,t,n){return e.map(e=>C(e,t,n))}function L(e,t,n){return S(e,t,n)}function A(e,t,n){return e.map(e=>S(e,t,n))}const E=["points","lines","polygons"];function T(e,t,n,i){const r=e.featureIds.value;if(!r.length)return-1;let s=0,o=r[r.length-1]+1;if(i){const t=function(e,t){if(!e.__layers){const t={},{properties:n}=e;for(let e=0;e<n.length;e++){const{layerName:i}=n[e];i&&(t[i]?t[i][1]=e:t[i]=[e,e])}e.__layers=t}return e.__layers[t]}(e,i);if(!t)return-1;s=t[0],o=t[1]+1}let a=-1;if(t in e.numericProps){const i=e.numericProps[t].value.findIndex((e,t)=>e===n&&r[t]>=s&&r[t]<o);return i>=0?e.globalFeatureIds.value[i]:-1}return t?a=M(e.properties,e=>e[t]===n,s,o):e.fields&&(a=M(e.fields,e=>e.id===n,s,o)),a>=0?function(e,t){if(!e.__ids){const t=[],n=e.featureIds.value,i=e.globalFeatureIds.value;for(let e=0;e<n.length;e++)t[n[e]]=i[e];e.__ids=t}return e.__ids[t]}(e,a):-1}function M(e,t,n,i){for(let r=n;r<i;r++)if(t(e[r],r))return r;return-1}var I=n(52337),B=n(36602);const k={...s.A.defaultProps,data:B.cS,onDataLoad:{type:"function",value:null,optional:!0,compare:!1},uniqueIdProperty:"",highlightedFeatureId:null,loaders:[g.f],binary:!0};class MVTLayer extends I.A{initializeState(){super.initializeState();const e=void 0===this.context.viewport.resolution&&this.props.binary;this.setState({binary:e,data:null,tileJSON:null,hoveredFeatureId:null,hoveredFeatureLayerName:null})}get isLoaded(){return Boolean(this.state?.data&&super.isLoaded)}updateState({props:e,oldProps:t,context:n,changeFlags:i}){i.dataChanged&&this._updateTileData(),this.state?.data&&(super.updateState({props:e,oldProps:t,context:n,changeFlags:i}),this._setWGS84PropertyForTiles());const{highlightColor:r}=e;r!==t.highlightColor&&Array.isArray(r)&&this.setState({highlightColor:r})}async _updateTileData(){let e=this.props.data,t=null;if("string"!=typeof e||(0,B.Ar)(e))e&&"object"==typeof e&&"tilejson"in e&&(t=e);else{const{onDataLoad:n,fetch:i}=this.props;this.setState({data:null,tileJSON:null});try{t=await i(e,{propName:"data",layer:this,loaders:[]})}catch(t){this.raiseError(t,"loading TileJSON"),e=null}n&&n(t,{propName:"data",layer:this})}t&&(e=t.tiles),this.setState({data:e,tileJSON:t})}_getTilesetOptions(){const e=super._getTilesetOptions(),t=this.state.tileJSON,{minZoom:n,maxZoom:i}=this.props;return t&&(Number.isFinite(t.minzoom)&&t.minzoom>n&&(e.minZoom=t.minzoom),Number.isFinite(t.maxzoom)&&(!Number.isFinite(i)||t.maxzoom<i)&&(e.maxZoom=t.maxzoom)),e}renderLayers(){return this.state?.data?super.renderLayers():null}getTileData(e){const{data:t,binary:n}=this.state,{index:i,signal:r}=e,s=(0,B.g8)(t,e);if(!s)return Promise.reject("Invalid URL");let o=this.getLoadOptions();const{fetch:a}=this.props;return o={...o,core:{...o?.core,mimeType:"application/x-protobuf"},mvt:{...o?.mvt,shape:n?"binary":"geojson",coordinates:this.context.viewport.resolution?"wgs84":"local",tileIndex:i}},a(s,{propName:"data",layer:this,loadOptions:o,signal:r})}renderSubLayers(e){const{x:t,y:n,z:o}=e.tile.index,a=Math.pow(2,o),c=512/a,l=-c,u=512*t/a,d=512*(1-n/a),h=(new p.k).scale([c,l,1]);e.autoHighlight=!1,this.context.viewport.resolution||(e.modelMatrix=h,e.coordinateOrigin=[u,d,0],e.coordinateSystem=i.rf.CARTESIAN,e.extensions=[...e.extensions||[],new f]);const g=super.renderSubLayers(e);return!this.state.binary||g instanceof s.A||r.A.warn("renderSubLayers() must return GeoJsonLayer when using binary:true")(),g}_updateAutoHighlight(e){const{uniqueIdProperty:t}=this.props,{hoveredFeatureId:n,hoveredFeatureLayerName:i}=this.state,r=e.object;let s=null,o=null;r&&(s=O(r,t),o=z(r));let{highlightColor:a}=this.props;"function"==typeof a&&(a=a(e)),n===s&&i===o||this.setState({highlightColor:a,hoveredFeatureId:s,hoveredFeatureLayerName:o})}_isWGS84(){return Boolean(this.context.viewport.resolution)}getPickingInfo(e){const t=super.getPickingInfo(e);if(this.state.binary&&-1!==t.index){const{data:n}=e.sourceLayer.props;t.object=b(n,{globalFeatureId:t.index})}return t.object&&!this._isWGS84()&&(t.object=F(t.object,t.tile.bbox,this.context.viewport)),t}getSubLayerPropsByTile(e){return{highlightedObjectIndex:this.getHighlightedObjectIndex(e),highlightColor:this.state.highlightColor}}getHighlightedObjectIndex(e){const{hoveredFeatureId:t,hoveredFeatureLayerName:n,binary:i}=this.state,{uniqueIdProperty:r,highlightedFeatureId:s}=this.props,o=e.content,a=D(s);if(!(D(t)||a))return-1;const c=a?s:t;return Array.isArray(o)?o.findIndex(e=>{const t=O(e,r)===c,i=a||z(e)===n;return t&&i}):o&&i?function(e,t,n,i){for(const r of E){const s=e[r]&&T(e[r],t,n,i);if(s>=0)return s}return-1}(o,r,c,a?"":n):-1}_pickObjects(e){const{deck:t,viewport:n}=this.context,i=n.width,r=n.height,s=n.x,o=n.y,a=[this.id];return t.pickObjects({x:s,y:o,width:i,height:r,layerIds:a,maxObjects:e})}getRenderedFeatures(e=null){const t=this._pickObjects(e),n=new Set,i=[];for(const e of t){const t=O(e.object,this.props.uniqueIdProperty);void 0===t?i.push(e.object):n.has(t)||(n.add(t),i.push(e.object))}return i}_setWGS84PropertyForTiles(){const e="dataInWGS84";this.state.tileset.selectedTiles.forEach(t=>{t.hasOwnProperty(e)||Object.defineProperty(t,e,{get:()=>{if(!t.content)return null;if(this.state.binary&&Array.isArray(t.content)&&!t.content.length)return[];const{bbox:e}=t;if(void 0===t._contentWGS84&&(0,B.NV)(e)){const n=this.state.binary?b(t.content):t.content;t._contentWGS84=n.map(t=>F(t,e,this.context.viewport))}return t._contentWGS84}})})}}MVTLayer.layerName="MVTLayer",MVTLayer.defaultProps=k;const R=MVTLayer;function O(e,t){return e.properties&&t?e.properties[t]:"id"in e?e.id:void 0}function z(e){return e.properties?.layerName||null}function D(e){return null!=e&&""!==e}function F(e,t,n){const i={...e,geometry:{type:e.geometry.type}};return Object.defineProperty(i.geometry,"coordinates",{get:()=>{const i=function(e,t,n){const i=[n.projectFlat([t.west,t.north]),n.projectFlat([t.east,t.south])];return{...e,coordinates:P[e.type](e.coordinates,i,n)}}(e.geometry,t,n);return i.coordinates}}),i}},52337(e,t,n){var i=n(59452),r=n(38055),s=n(40618),o=n(86772),a=n(36602),c=n(31886);const l={TilesetClass:o.TL,data:{type:"data",value:[]},dataComparator:a.cS.equal,renderSubLayers:{type:"function",value:e=>new s.A(e)},getTileData:{type:"function",optional:!0,value:null},onViewportLoad:{type:"function",optional:!0,value:null},onTileLoad:{type:"function",value:e=>{}},onTileUnload:{type:"function",value:e=>{}},onTileError:{type:"function",value:e=>console.error(e)},extent:{type:"array",optional:!0,value:null,compare:!0},tileSize:512,maxZoom:null,minZoom:0,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:o.UK,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,visibleMinZoom:null,visibleMaxZoom:null};class TileLayer extends i.A{initializeState(){this.state={tileset:null,isLoaded:!1}}finalizeState(){this.state?.tileset?.finalize()}get isLoaded(){return Boolean(this.state?.tileset?.selectedTiles?.every(e=>e.isLoaded&&(!e.content||!e.layers||e.layers.every(e=>e.isLoaded))))}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({changeFlags:e}){let{tileset:t}=this.state;const n=e.propsOrDataChanged||e.updateTriggersChanged,i=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getTileData);t?n&&(t.setOptions(this._getTilesetOptions()),i?t.reloadAll():t.tiles.forEach(e=>{e.layers=null})):(t=new this.props.TilesetClass(this._getTilesetOptions()),this.setState({tileset:t})),this._updateTileset()}_getTilesetOptions(){const{tileSize:e,maxCacheSize:t,maxCacheByteSize:n,refinementStrategy:i,extent:r,maxZoom:s,minZoom:o,maxRequests:a,debounceTime:c,zoomOffset:l,visibleMinZoom:u,visibleMaxZoom:d}=this.props;return{maxCacheSize:t,maxCacheByteSize:n,maxZoom:s,minZoom:o,tileSize:e,refinementStrategy:i,extent:r,maxRequests:a,debounceTime:c,zoomOffset:l,visibleMinZoom:u,visibleMaxZoom:d,getTileData:this.getTileData.bind(this),onTileLoad:this._onTileLoad.bind(this),onTileError:this._onTileError.bind(this),onTileUnload:this._onTileUnload.bind(this)}}_updateTileset(){const e=this.state.tileset,{zRange:t,modelMatrix:n}=this.props,i=e.update(this.context.viewport,{zRange:t,modelMatrix:n}),{isLoaded:r}=e,s=this.state.isLoaded!==r,o=this.state.frameNumber!==i;r&&(s||o)&&this._onViewportLoad(),o&&this.setState({frameNumber:i}),this.state.isLoaded=r}_onViewportLoad(){const{tileset:e}=this.state,{onViewportLoad:t}=this.props;t&&t(e.selectedTiles)}_onTileLoad(e){this.props.onTileLoad(e),e.layers=null,this.setNeedsUpdate()}_onTileError(e,t){this.props.onTileError(e),t.layers=null,this.setNeedsUpdate()}_onTileUnload(e){this.props.onTileUnload(e)}getTileData(e){const{data:t,getTileData:n,fetch:i}=this.props,{signal:r}=e;return e.url="string"==typeof t||Array.isArray(t)?(0,a.g8)(t,e):null,n?n(e):i&&e.url?i(e.url,{propName:"data",layer:this,signal:r}):null}renderSubLayers(e){return this.props.renderSubLayers(e)}getSubLayerPropsByTile(e){return null}getPickingInfo(e){const t=e.sourceLayer,n=t.props.tile,i=e.info;return i.picked&&(i.tile=n),i.sourceTile=n,i.sourceTileSubLayer=t,i}_updateAutoHighlight(e){e.sourceTileSubLayer.updateAutoHighlight(e)}renderLayers(){const{visibleMinZoom:e,visibleMaxZoom:t,minZoom:n,extent:i}=this.props,s=this.context.viewport.zoom;if(null!=e&&s<e||null!=t&&s>t||null!=n&&!i&&s<n){for(const e of this.state.tileset.tiles)e.layers=null;return[]}return this.state.tileset.tiles.map(e=>{const t=this.getSubLayerPropsByTile(e);if(e.isLoaded||e.content)if(e.layers)t&&e.layers[0]&&Object.keys(t).some(n=>e.layers[0].props[n]!==t[n])&&(e.layers=e.layers.map(e=>e.clone(t)));else{const n=this.renderSubLayers({...this.props,...this.getSubLayerProps({id:e.id,updateTriggers:this.props.updateTriggers}),data:e.content,_offset:0,tile:e});e.layers=(0,r.B)(n,Boolean).map(n=>n.clone({tile:e,...t}))}else;return e.layers})}filterSubLayer({layer:e,cullRect:t}){const{tile:n}=e.props,{modelMatrix:i}=this.props;return this.state.tileset.isTileVisible(n,t,i?new c.k(i):null)}}TileLayer.defaultProps=l,TileLayer.layerName="TileLayer";const u=TileLayer;n.d(t,["A",0,u])},86772(e,t,n){n.d(t,{UK:()=>d,TL:()=>Tileset2D});var i=n(30568);const r={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0};class RequestScheduler{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...r,...e},this.stats=new i.A({id:this.props.id}),this.stats.get("Queued Requests"),this.stats.get("Active Requests"),this.stats.get("Cancelled Requests"),this.stats.get("Queued Requests Ever"),this.stats.get("Active Requests Ever")}setProps(e){void 0!==e.throttleRequests&&(this.props.throttleRequests=e.throttleRequests),void 0!==e.maxRequests&&(this.props.maxRequests=e.maxRequests),void 0!==e.debounceTime&&(this.props.debounceTime=e.debounceTime)}scheduleRequest(e,t=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);const n={handle:e,priority:0,getPriority:t},i=new Promise(e=>(n.resolve=e,n));return this.requestQueue.push(n),this.requestMap.set(e,i),this._issueNewRequests(),i}_issueRequest(e){const{handle:t,resolve:n}=e;let i=!1;const r=()=>{i||(i=!0,this.requestMap.delete(t),this.activeRequestCount--,null===this.updateTimer&&(this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),0)))};return this.activeRequestCount++,n?n({done:r}):Promise.resolve({done:r})}_issueNewRequests(){null!==this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){null!==this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=null;const e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(0!==e){this._updateAllRequests();for(let t=0;t<e;++t){const e=this.requestQueue.shift();e&&this._issueRequest(e)}}}_updateAllRequests(){const e=this.requestQueue;for(let t=0;t<e.length;++t){const n=e[t];this._updateRequest(n)||(e.splice(t,1),this.requestMap.delete(n.handle),t--)}e.sort((e,t)=>e.priority-t.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),!(e.priority<0)||(e.resolve(null),!1)}}var s=n(31886),o=n(54901);class Tile2DHeader{constructor(e){this.index=e,this.isVisible=!1,this.isSelected=!1,this.parent=null,this.children=[],this.content=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(e){this._bbox||(this._bbox=e,this.boundingBox="west"in e?[[e.west,e.south],[e.east,e.north]]:[[e.left,e.top],[e.right,e.bottom]])}get data(){return this.isLoading&&this._loader?this._loader.then(()=>this.data):this.content}get isLoaded(){return this._isLoaded&&!this._needsReload}get isLoading(){return Boolean(this._loader)&&!this._isCancelled}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){const e=this.content?this.content.byteLength:0;return Number.isFinite(e)||console.error("byteLength not defined in tile data"),e}async _loadData({getData:e,getRequestPriority:t,requestScheduler:n,onLoad:i,onError:r}){const{index:s,id:o,bbox:a,userData:c,zoom:l}=this,u=this._loaderId;this._abortController=new AbortController;const{signal:d}=this._abortController,h=await n.scheduleRequest(this,t);if(!h)return void(this._isCancelled=!0);if(this._isCancelled)return void h.done();let f,p=null;try{p=await e({index:s,id:o,bbox:a,userData:c,zoom:l,signal:d})}catch(e){f=e||!0}finally{h.done()}u===this._loaderId&&(this._loader=void 0,this.content=p,!this._isCancelled||p?(this._isLoaded=!0,this._isCancelled=!1,f?r(f,this):i(this)):this._isLoaded=!1)}loadData(e){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this._loaderId++,this._loader=this._loadData(e),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._abortController?.abort())}}var a=n(36602);function c(e,t){if(e===t)return!0;if(Array.isArray(e)){const n=e.length;if(!t||t.length!==n)return!1;for(let i=0;i<n;i++)if(e[i]!==t[i])return!1;return!0}return!1}const l="never",u="no-overlap",d="best-available",h=1e8,f=99999999,p={[d]:function(e){for(const t of e)t.state=0;for(const t of e)t.isSelected&&!m(t)&&v(t);for(const t of e)t.isVisible=Boolean(2&t.state)},[u]:function(e){for(const t of e)t.state=0;for(const t of e)t.isSelected&&m(t);const t=Array.from(e).sort((e,t)=>e.zoom-t.zoom);for(const e of t)if(e.isVisible=Boolean(2&e.state),e.children&&(e.isVisible||1&e.state))for(const t of e.children)t.state=1;else e.isSelected&&v(e)},[l]:()=>{}},g={extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:"best-available",zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,visibleMinZoom:null,visibleMaxZoom:null,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{}};class Tileset2D{constructor(e){this._getCullBounds=function(e){let t,n={};return i=>{for(const r in i)if(!c(i[r],n[r])){t=e(i),n=i;break}return t}}(a.ws),this.opts={...g,...e},this.setOptions(this.opts),this.onTileLoad=e=>{this.opts.onTileLoad?.(e),null!==this.opts.maxCacheByteSize&&(this._cacheByteSize+=e.byteLength,this._resizeCache())},this._requestScheduler=new RequestScheduler({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._viewport=null,this._zRange=null,this._selectedTiles=null,this._frameNumber=0,this._modelMatrix=new s.k,this._modelMatrixInverse=new s.k}get tiles(){return this._tiles}get selectedTiles(){return this._selectedTiles}get isLoaded(){return null!==this._selectedTiles&&this._selectedTiles.every(e=>e.isLoaded)}get needsReload(){return null!==this._selectedTiles&&this._selectedTiles.some(e=>e.needsReload)}setOptions(e){Object.assign(this.opts,e),Number.isFinite(e.maxZoom)&&(this._maxZoom=Math.floor(e.maxZoom)),Number.isFinite(e.minZoom)&&(this._minZoom=Math.ceil(e.minZoom)),this._viewport=null}finalize(){for(const e of this._cache.values())e.isLoading&&e.abort();this._cache.clear(),this._tiles=[],this._selectedTiles=null}reloadAll(){for(const e of this._cache.keys()){const t=this._cache.get(e);this._selectedTiles&&this._selectedTiles.includes(t)?t.setNeedsReload():this._cache.delete(e)}}update(e,{zRange:t,modelMatrix:n}={zRange:null,modelMatrix:null}){const i=n?new s.k(n):new s.k,r=!i.equals(this._modelMatrix);if(this._viewport&&e.equals(this._viewport)&&(0,o.aI)(this._zRange,t)&&!r)this.needsReload&&(this._selectedTiles=this._selectedTiles.map(e=>this._getTile(e.index,!0)));else{r&&(this._modelMatrixInverse=i.clone().invert(),this._modelMatrix=i),this._viewport=e,this._zRange=t;const n=this.getTileIndices({viewport:e,maxZoom:this._maxZoom,minZoom:this._minZoom,zRange:t,modelMatrix:this._modelMatrix,modelMatrixInverse:this._modelMatrixInverse});this._selectedTiles=n.map(e=>this._getTile(e,!0)),this._dirty&&this._rebuildTree()}const a=this.updateTileStates();return this._pruneRequests(),this._dirty&&this._resizeCache(),a&&this._frameNumber++,this._frameNumber}isTileVisible(e,t,n){if(!e.isVisible)return!1;if(t&&this._viewport){const i=this._getCullBounds({viewport:this._viewport,z:this._zRange,cullRect:t});let{bbox:r}=e;for(const[e,t,o,c]of i){let i;if("west"in r)i=r.west<o&&r.east>e&&r.south<c&&r.north>t;else{if(n&&!s.k.IDENTITY.equals(n)){const[e,t,i,s]=(0,a.Ww)([r.left,r.top,r.right,r.bottom],n);r={left:e,top:t,right:i,bottom:s}}const l=Math.min(r.top,r.bottom),u=Math.max(r.top,r.bottom);i=r.left<o&&r.right>e&&l<c&&u>t}if(i)return!0}return!1}return!0}getTileIndices({viewport:e,maxZoom:t,minZoom:n,zRange:i,modelMatrix:r,modelMatrixInverse:s}){const{tileSize:o,extent:c,zoomOffset:l,visibleMinZoom:u,visibleMaxZoom:d}=this.opts;return(0,a.Om)({viewport:e,maxZoom:t,minZoom:n,zRange:i,tileSize:o,extent:c,modelMatrix:r,modelMatrixInverse:s,zoomOffset:l,visibleMinZoom:u,visibleMaxZoom:d})}getTileId(e){return`${e.x}-${e.y}-${e.z}`}getTileZoom(e){return e.z}getTileMetadata(e){const{tileSize:t}=this.opts;return{bbox:(0,a.bR)(this._viewport,e.x,e.y,e.z,t)}}getParentIndex(e){return{x:Math.floor(e.x/2),y:Math.floor(e.y/2),z:e.z-1}}updateTileStates(){const e=this.opts.refinementStrategy||d,t=new Array(this._cache.size);let n=0;for(const e of this._cache.values())t[n++]=e.isVisible,e.isSelected=!1,e.isVisible=!1;for(const e of this._selectedTiles)e.isSelected=!0,e.isVisible=!0;("function"==typeof e?e:p[e])(Array.from(this._cache.values())),n=0;for(const e of this._cache.values())if(t[n++]!==e.isVisible)return!0;return!1}_getRequestPriority(e){if(!e.isSelected&&!e.isVisible)return-1;const t=this._getTileDistancePriority(e);return e.isSelected?0+t:h+t}_getTileDistancePriority(e){const{width:t,height:n}=this._viewport||{};if(!this._viewport||!t||!n)return 0;try{const i=this._getTileScreenCorners(e.bbox),r=[t/2,n/2];if(4===i.length){if(this._isPointInPolygon(r,i))return 0;const e=i.reduce((e,t,n)=>{const s=i[(n+1)%i.length];return Math.min(e,this._getPointToSegmentDistanceSquared(r,t,s))},Number.MAX_SAFE_INTEGER);return Math.min(e,f)}}catch{}return f}_getTileScreenCorners(e){return("west"in e?[[e.west,e.south],[e.east,e.south],[e.east,e.north],[e.west,e.north]]:[[e.left,e.top],[e.right,e.top],[e.right,e.bottom],[e.left,e.bottom]]).map(e=>this._viewport.project(e)).filter(([e,t])=>Number.isFinite(e)&&Number.isFinite(t))}_isPointInPolygon(e,t){let n=!1;const[i,r]=e;for(let e=0,s=t.length-1;e<t.length;s=e++){const[o,a]=t[e],[c,l]=t[s];a>r!=l>r&&i<(c-o)*(r-a)/(l-a)+o&&(n=!n)}return n}_getPointToSegmentDistanceSquared(e,t,n){const[i,r]=e,[s,o]=t,[a,c]=n,l=a-s,u=c-o,d=l*l+u*u,h=d?Math.max(0,Math.min(1,((i-s)*l+(r-o)*u)/d)):0,f=i-(s+h*l),p=r-(o+h*u);return f*f+p*p}_pruneRequests(){const{maxRequests:e=0}=this.opts,t=[];let n=0;for(const e of this._cache.values())e.isLoading&&(n++,e.isSelected||e.isVisible||t.push(e));for(;e>0&&n>e&&t.length>0;){t.shift().abort(),n--}}_rebuildTree(){const{_cache:e}=this;for(const t of e.values())t.parent=null,t.children&&(t.children.length=0);for(const t of e.values()){const e=this._getNearestAncestor(t);t.parent=e,e?.children&&e.children.push(t)}}_resizeCache(){const{_cache:e,opts:t}=this,n=t.maxCacheSize??(null!==t.maxCacheByteSize?1/0:5*this.selectedTiles.length),i=t.maxCacheByteSize??1/0;if(e.size>n||this._cacheByteSize>i){for(const[r,s]of e)if(s.isVisible||s.isSelected||(this._cacheByteSize-=null!==t.maxCacheByteSize?s.byteLength:0,e.delete(r),this.opts.onTileUnload?.(s)),e.size<=n&&this._cacheByteSize<=i)break;this._rebuildTree(),this._dirty=!0}this._dirty&&(this._tiles=Array.from(this._cache.values()).sort((e,t)=>e.zoom-t.zoom),this._dirty=!1)}_getTile(e,t){const n=this.getTileId(e);let i=this._cache.get(n),r=!1;return!i&&t?(i=new Tile2DHeader(e),Object.assign(i,this.getTileMetadata(i.index)),Object.assign(i,{id:n,zoom:this.getTileZoom(i.index)}),r=!0,this._cache.set(n,i),this._dirty=!0):i&&i.needsReload&&(r=!0),i&&r&&i.loadData({getData:this.opts.getTileData,getRequestPriority:this._getRequestPriority.bind(this),requestScheduler:this._requestScheduler,onLoad:this.onTileLoad,onError:this.opts.onTileError}),i}_getNearestAncestor(e){const{_minZoom:t=0}=this;let n=e.index;for(;this.getTileZoom(n)>t;){n=this.getParentIndex(n);const e=this._getTile(n);if(e)return e}return null}}function m(e){let t=e;for(;t;){if(t.isLoaded||t.content)return t.state|=2,!0;t=t.parent}return!1}function v(e){for(const t of e.children)t.isLoaded||t.content?t.state|=2:v(t)}},36602(e,t,n){n.d(t,{ws:()=>Qe,Om:()=>rt,g8:()=>Ke,NV:()=>ot,Ar:()=>st,uY:()=>et,bR:()=>nt,Ww:()=>Ye,cS:()=>Ze});var i=n(31886),r=n(82859),s=n(39426),o=n(45249),a=n(47345),c=n(9350),l=n(25667);const u=Math.PI/180,d=180/Math.PI,h=6370972,f=256;function p(){const e=4018225162502676e-20,t=Math.PI/180*f;return{unitsPerMeter:[e,e,e],unitsPerMeter2:[0,0,0],metersPerUnit:[24886.609375,24886.609375,24886.609375],unitsPerDegree:[t,t,e],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/t,1/t,24886.609375]}}class GlobeViewport extends a.A{constructor(e={}){const{longitude:t=0,bearing:n=0,pitch:r=0,zoom:s=0,nearZMultiplier:a=.5,farZMultiplier:c=1,resolution:l=10}=e;let{latitude:d=0,height:h,altitude:f=1.5,fovy:g}=e;d=Math.max(Math.min(d,90),-90),h=h||1,g?f=(0,o.wZ)(g):g=(0,o.Os)(f);const v=Math.max(Math.min(d,o.aH),-o.aH),y=Math.pow(2,s-m(v)),b=r*u,_=e.nearZ??a,x=e.farZ??(f+512*y/h/Math.max(Math.cos(b),.1))*c,w=(new i.k).lookAt({eye:[0,-f,0],up:[0,0,1]}).rotateX(-b).rotateY(-n*u).rotateX(d*u).rotateZ(-t*u).scale(y/h);super({...e,height:h,viewMatrix:w,longitude:t,latitude:d,zoom:s,distanceScales:p(),fovy:g,focalDistance:f,near:_,far:x}),this.scale=y,this.latitude=d,this.longitude=t,this.bearing=n,this.pitch=r,this.fovy=g,this.resolution=l}get projectionMode(){return c.Kx.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(e={}){const t={targetZ:e.z||0},n=this.unproject([0,this.height/2],t),i=this.unproject([this.width/2,0],t),r=this.unproject([this.width,this.height/2],t),s=this.unproject([this.width/2,this.height],t);return r[0]<this.longitude&&(r[0]+=360),n[0]>this.longitude&&(n[0]-=360),[Math.min(n[0],r[0],i[0],s[0]),Math.min(n[1],r[1],i[1],s[1]),Math.max(n[0],r[0],i[0],s[0]),Math.max(n[1],r[1],i[1],s[1])]}_getRayToGlobe(e,{topLeft:t=!0,targetZ:n}={}){const[i,s]=e,o=t?s:this.height-s,{pixelUnprojectionMatrix:a}=this,c=v(a,[i,o,-1,1]),l=v(a,[i,o,1,1]),u=((n||0)/h+1)*f,d=r.uE(r.jb([],c,l)),p=r.uE(c),g=r.uE(l);return{rayStartPosition:c,rayEndPosition:l,radius:u,rayLengthSquared:d,rayStartDistanceSquared:p,distanceToCenterSquared:4*((4*p*g-(d-p-g)**2)/16)/d}}_getRayDistanceToGlobeCenterRatio(e,t){const{distanceToCenterSquared:n,radius:i}=this._getRayToGlobe(e,t);return Math.sqrt(Math.max(0,n))/i}getZoomAnchorStrength(e){const t=this._getRayDistanceToGlobeCenterRatio(e);if(t>1.15)return 0;return 1-.65*Math.max(0,Math.min(1,(t-.75)/.25))}unproject(e,{topLeft:t=!0,targetZ:n}={}){const[i,s,o]=e,a=t?s:this.height-s,{pixelUnprojectionMatrix:c}=this;let l;if(Number.isFinite(o))l=v(c,[i,a,o,1]);else{const{rayStartPosition:i,rayEndPosition:s,radius:o,rayLengthSquared:a,rayStartDistanceSquared:c,distanceToCenterSquared:u}=this._getRayToGlobe(e,{topLeft:t,targetZ:n}),d=(Math.sqrt(c-u)-Math.sqrt(Math.max(0,o*o-u)))/Math.sqrt(a);l=r.Cc([],i,s,d)}const[u,d,h]=this.unprojectPosition(l);return Number.isFinite(o)?[u,d,h]:Number.isFinite(n)?[u,d,n]:[u,d]}projectPosition(e){const[t,n,i=0]=e,r=t*u,s=n*u,o=Math.cos(s),a=(i/h+1)*f;return[Math.sin(r)*o*a,-Math.cos(r)*o*a,Math.sin(s)*a]}unprojectPosition(e){const[t,n,i]=e,s=r.Il(e),o=Math.asin(i/s);return[Math.atan2(t,-n)*d,o*d,(s/f-1)*h]}projectFlat(e){return e}unprojectFlat(e){return e}panByPosition(e,t,n){if(!n){const n=this.getZoomAnchorStrength(t);if(0===n)return{longitude:this.longitude,latitude:this.latitude};const i=this.unproject(t),r=(0,l.zi)(e[0]-i[0]+180,360)-180;return{longitude:this.longitude+r*n,latitude:Math.max(Math.min(this.latitude+(e[1]-i[1])*n,90),-90)}}const[i,r,s]=e,o=.25/Math.pow(2,this.zoom-m(this.latitude)),a=i+o*(n[0]-t[0]);let c=r-o*(n[1]-t[1]);c=Math.max(Math.min(c,90),-90);const u={longitude:a,latitude:c,zoom:s-m(r)};return u.zoom+=m(u.latitude),u}}GlobeViewport.displayName="GlobeViewport";const g=GlobeViewport;function m(e,t){t&&(e=Math.max(Math.min(e,o.aH),-o.aH));const n=Math.PI*Math.cos(e*Math.PI/180);return Math.log2(n)}function v(e,t){const n=s.Z0([],t,e);return s.hs(n,n,1/n[3]),n}var y=n(69502),b=n(87597);const _=-1,x=0,w=1,P=new b.P,C=new b.P;class AxisAlignedBoundingBox{constructor(e=[0,0,0],t=[0,0,0],n){n=n||P.copy(e).add(t).scale(.5),this.center=new b.P(n),this.halfDiagonal=new b.P(t).subtract(this.center),this.minimum=new b.P(e),this.maximum=new b.P(t)}clone(){return new AxisAlignedBoundingBox(this.minimum,this.maximum,this.center)}equals(e){return this===e||Boolean(e)&&this.minimum.equals(e.minimum)&&this.maximum.equals(e.maximum)}transform(e){return this.center.transformAsPoint(e),this.halfDiagonal.transform(e),this.minimum.transform(e),this.maximum.transform(e),this}intersectPlane(e){const{halfDiagonal:t}=this,n=C.from(e.normal),i=t.x*Math.abs(n.x)+t.y*Math.abs(n.y)+t.z*Math.abs(n.z),r=this.center.dot(n)+e.distance;return r-i>0?w:r+i<0?_:x}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=P.from(e).subtract(this.center),{halfDiagonal:n}=this;let i,r=0;return i=Math.abs(t.x)-n.x,i>0&&(r+=i*i),i=Math.abs(t.y)-n.y,i>0&&(r+=i*i),i=Math.abs(t.z)-n.z,i>0&&(r+=i*i),r}}var S=n(90218);const L=new b.P,A=new b.P;class BoundingSphere{constructor(e=[0,0,0],t=0){this.radius=-0,this.center=new b.P,this.fromCenterRadius(e,t)}fromCenterRadius(e,t){return this.center.from(e),this.radius=t,this}fromCornerPoints(e,t){return t=L.from(t),this.center=(new b.P).from(e).add(t).scale(.5),this.radius=this.center.distance(t),this}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new BoundingSphere(this.center,this.radius)}union(e){const t=this.center,n=this.radius,i=e.center,r=e.radius,s=L.copy(i).subtract(t),o=s.magnitude();if(n>=o+r)return this.clone();if(r>=o+n)return e.clone();const a=.5*(n+o+r);return A.copy(s).scale((-n+a)/o).add(t),this.center.copy(A),this.radius=a,this}expand(e){const t=L.from(e).subtract(this.center).magnitude();return t>this.radius&&(this.radius=t),this}transform(e){this.center.transform(e);const t=S.IL(L,e);return this.radius=Math.max(t[0],Math.max(t[1],t[2]))*this.radius,this}distanceSquaredTo(e){const t=this.distanceTo(e);return t*t}distanceTo(e){const t=L.from(e).subtract(this.center);return Math.max(0,t.len()-this.radius)}intersectPlane(e){const t=this.center,n=this.radius,i=e.normal.dot(t)+e.distance;return i<-n?_:i<n?x:w}}var E=n(46022),T=n(73731),M=n(68225),I=n(50741);function B(e,t,n){const i=t[0],r=t[1],s=t[2],o=t[3],a=t[4],c=t[5],l=t[6],u=t[7],d=t[8],h=n[0],f=n[1],p=n[2],g=n[3],m=n[4],v=n[5],y=n[6],b=n[7],_=n[8];return e[0]=h*i+f*o+p*l,e[1]=h*r+f*a+p*u,e[2]=h*s+f*c+p*d,e[3]=g*i+m*o+v*l,e[4]=g*r+m*a+v*u,e[5]=g*s+m*c+v*d,e[6]=y*i+b*o+_*l,e[7]=y*r+b*a+_*u,e[8]=y*s+b*c+_*d,e}function k(e,t,n){const i=n[0],r=n[1];return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=r*t[3],e[4]=r*t[4],e[5]=r*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}var R,O=n(83588);!function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL1ROW0=3]="COL1ROW0",e[e.COL1ROW1=4]="COL1ROW1",e[e.COL1ROW2=5]="COL1ROW2",e[e.COL2ROW0=6]="COL2ROW0",e[e.COL2ROW1=7]="COL2ROW1",e[e.COL2ROW2=8]="COL2ROW2"}(R||(R={}));const z=Object.freeze([1,0,0,0,1,0,0,0,1]);class Matrix3 extends E.u{static get IDENTITY(){return function(){F||(F=new Matrix3,Object.freeze(F));return F}()}static get ZERO(){return function(){D||(D=new Matrix3([0,0,0,0,0,0,0,0,0]),Object.freeze(D));return D}()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return R}constructor(e,...t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):t.length>0?this.copy([e,...t]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(z)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){const n=t[0],i=t[1],r=t[2],s=t[3],o=n+n,a=i+i,c=r+r,l=n*o,u=i*o,d=i*a,h=r*o,f=r*a,p=r*c,g=s*o,m=s*a,v=s*c;e[0]=1-d-p,e[3]=u-v,e[6]=h+m,e[1]=u+v,e[4]=1-l-p,e[7]=f-g,e[2]=h-m,e[5]=f+g,e[8]=1-l-d}(this,e),this.check()}set(e,t,n,i,r,s,o,a,c){return this[0]=e,this[1]=t,this[2]=n,this[3]=i,this[4]=r,this[5]=s,this[6]=o,this[7]=a,this[8]=c,this.check()}setRowMajor(e,t,n,i,r,s,o,a,c){return this[0]=e,this[1]=i,this[2]=o,this[3]=t,this[4]=r,this[5]=a,this[6]=n,this[7]=s,this[8]=c,this.check()}determinant(){return function(e){const t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*(l*s-o*c)+n*(-l*r+o*a)+i*(c*r-s*a)}(this)}transpose(){return function(e,t){if(e===t){const n=t[1],i=t[2],r=t[5];e[1]=t[3],e[2]=t[6],e[3]=n,e[5]=t[7],e[6]=i,e[7]=r}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8]}(this,this),this.check()}invert(){return function(e,t){const n=t[0],i=t[1],r=t[2],s=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8],d=u*o-a*l,h=-u*s+a*c,f=l*s-o*c;let p=n*d+i*h+r*f;p&&(p=1/p,e[0]=d*p,e[1]=(-u*i+r*l)*p,e[2]=(a*i-r*o)*p,e[3]=h*p,e[4]=(u*n-r*c)*p,e[5]=(-a*n+r*s)*p,e[6]=f*p,e[7]=(-l*n+i*c)*p,e[8]=(o*n-i*s)*p)}(this,this),this.check()}multiplyLeft(e){return B(this,e,this),this.check()}multiplyRight(e){return B(this,this,e),this.check()}rotate(e){return function(e,t,n){const i=t[0],r=t[1],s=t[2],o=t[3],a=t[4],c=t[5],l=t[6],u=t[7],d=t[8],h=Math.sin(n),f=Math.cos(n);e[0]=f*i+h*o,e[1]=f*r+h*a,e[2]=f*s+h*c,e[3]=f*o-h*i,e[4]=f*a-h*r,e[5]=f*c-h*s,e[6]=l,e[7]=u,e[8]=d}(this,this,e),this.check()}scale(e){return Array.isArray(e)?k(this,this,e):k(this,this,[e,e]),this.check()}translate(e){return function(e,t,n){const i=t[0],r=t[1],s=t[2],o=t[3],a=t[4],c=t[5],l=t[6],u=t[7],d=t[8],h=n[0],f=n[1];e[0]=i,e[1]=r,e[2]=s,e[3]=o,e[4]=a,e[5]=c,e[6]=h*i+f*o+l,e[7]=h*r+f*a+u,e[8]=h*s+f*c+d}(this,this,e),this.check()}transform(e,t){let n;switch(e.length){case 2:n=(0,O.ei)(t||[-0,-0],e,this);break;case 3:n=(0,r.ei)(t||[-0,-0,-0],e,this);break;case 4:n=(0,M.vE)(t||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return(0,T.qk)(n,e.length),n}transformVector(e,t){return this.transform(e,t)}transformVector2(e,t){return this.transform(e,t)}transformVector3(e,t){return this.transform(e,t)}}let D,F=null;var N=n(58073),$=n(54272),U=n(54901);let V;class Vector4 extends $.M{static get ZERO(){return V||(V=new Vector4(0,0,0,0),Object.freeze(V)),V}constructor(e=0,t=0,n=0,i=0){super(-0,-0,-0,-0),(0,U.cy)(e)&&1===arguments.length?this.copy(e):(U.$W.debug&&((0,T.ws)(e),(0,T.ws)(t),(0,T.ws)(n),(0,T.ws)(i)),this[0]=e,this[1]=t,this[2]=n,this[3]=i)}set(e,t,n,i){return this[0]=e,this[1]=t,this[2]=n,this[3]=i,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}fromObject(e){return U.$W.debug&&((0,T.ws)(e.x),(0,T.ws)(e.y),(0,T.ws)(e.z),(0,T.ws)(e.w)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e.w=this[3],e}get ELEMENTS(){return 4}get z(){return this[2]}set z(e){this[2]=(0,T.ws)(e)}get w(){return this[3]}set w(e){this[3]=(0,T.ws)(e)}transform(e){return(0,r.Z0)(this,this,e),this.check()}transformByMatrix3(e){return(0,M.vE)(this,this,e),this.check()}transformByMatrix2(e){return(0,M.Cg)(this,this,e),this.check()}transformByQuaternion(e){return(0,r.gL)(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}}function G(){const e=new I.tb(4);return I.tb!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function j(e,t,n){n*=.5;const i=Math.sin(n);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(n),e}function W(e,t,n){const i=t[0],r=t[1],s=t[2],o=t[3],a=n[0],c=n[1],l=n[2],u=n[3];return e[0]=i*u+o*a+r*l-s*c,e[1]=r*u+o*c+s*a-i*l,e[2]=s*u+o*l+i*c-r*a,e[3]=o*u-i*a-r*c-s*l,e}function H(e,t,n,i){const r=t[0],s=t[1],o=t[2],a=t[3];let c,l,u,d,h,f=n[0],p=n[1],g=n[2],m=n[3];return c=r*f+s*p+o*g+a*m,c<0&&(c=-c,f=-f,p=-p,g=-g,m=-m),1-c>I.p8?(l=Math.acos(c),h=Math.sin(l),u=Math.sin((1-i)*l)/h,d=Math.sin(i*l)/h):(u=1-i,d=i),e[0]=u*r+d*f,e[1]=u*s+d*p,e[2]=u*o+d*g,e[3]=u*a+d*m,e}function q(e,t){const n=t[0]+t[4]+t[8];let i;if(n>0)i=Math.sqrt(n+1),e[3]=.5*i,i=.5/i,e[0]=(t[5]-t[7])*i,e[1]=(t[6]-t[2])*i,e[2]=(t[1]-t[3])*i;else{let n=0;t[4]>t[0]&&(n=1),t[8]>t[3*n+n]&&(n=2);const r=(n+1)%3,s=(n+2)%3;i=Math.sqrt(t[3*n+n]-t[3*r+r]-t[3*s+s]+1),e[n]=.5*i,i=.5/i,e[3]=(t[3*r+s]-t[3*s+r])*i,e[r]=(t[3*r+n]+t[3*n+r])*i,e[s]=(t[3*s+n]+t[3*n+s])*i}return e}s.o8,s.fA,s.C,s.hZ;const Z=s.WQ,Y=s.hs,K=s.Om,Q=s.Cc,X=s.Bw,J=s.m3,ee=s.S8;s.t2;const te=function(){const e=r.vt(),t=r.fA(1,0,0),n=r.fA(0,1,0);return function(i,s,o){const a=r.Om(s,o);return a<-.999999?(r.$A(e,t,s),r.Il(e)<1e-6&&r.$A(e,n,s),r.S8(e,e),j(i,e,Math.PI),i):a>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(r.$A(e,s,o),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=1+a,ee(i,i))}}(),ne=(function(){const e=G(),t=G()}(),function(){const e=function(){const e=new I.tb(9);return I.tb!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}()}(),[0,0,0,1]);class Quaternion extends N.a{constructor(e=0,t=0,n=0,i=1){super(-0,-0,-0,-0),Array.isArray(e)&&1===arguments.length?this.copy(e):this.set(e,t,n,i)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,t,n,i){return this[0]=e,this[1]=t,this[2]=n,this[3]=i,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return q(this,e),this.check()}fromAxisRotation(e,t){return j(this,e,t),this.check()}identity(){var e;return(e=this)[0]=0,e[1]=0,e[2]=0,e[3]=1,this.check()}setAxisAngle(e,t){return this.fromAxisRotation(e,t)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=(0,T.ws)(e)}get y(){return this[1]}set y(e){this[1]=(0,T.ws)(e)}get z(){return this[2]}set z(e){this[2]=(0,T.ws)(e)}get w(){return this[3]}set w(e){this[3]=(0,T.ws)(e)}len(){return X(this)}lengthSquared(){return J(this)}dot(e){return K(this,e)}rotationTo(e,t){return te(this,e,t),this.check()}add(e){return Z(this,this,e),this.check()}calculateW(){return function(e,t){const n=t[0],i=t[1],r=t[2];e[0]=n,e[1]=i,e[2]=r,e[3]=Math.sqrt(Math.abs(1-n*n-i*i-r*r))}(this,this),this.check()}conjugate(){var e,t;return t=this,(e=this)[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],this.check()}invert(){return function(e,t){const n=t[0],i=t[1],r=t[2],s=t[3],o=n*n+i*i+r*r+s*s,a=o?1/o:0;e[0]=-n*a,e[1]=-i*a,e[2]=-r*a,e[3]=s*a}(this,this),this.check()}lerp(e,t,n){return void 0===n?this.lerp(this,e,t):(Q(this,e,t,n),this.check())}multiplyRight(e){return W(this,this,e),this.check()}multiplyLeft(e){return W(this,e,this),this.check()}normalize(){const e=this.len(),t=e>0?1/e:0;return this[0]=this[0]*t,this[1]=this[1]*t,this[2]=this[2]*t,this[3]=this[3]*t,0===e&&(this[3]=1),this.check()}rotateX(e){return function(e,t,n){n*=.5;const i=t[0],r=t[1],s=t[2],o=t[3],a=Math.sin(n),c=Math.cos(n);e[0]=i*c+o*a,e[1]=r*c+s*a,e[2]=s*c-r*a,e[3]=o*c-i*a}(this,this,e),this.check()}rotateY(e){return function(e,t,n){n*=.5;const i=t[0],r=t[1],s=t[2],o=t[3],a=Math.sin(n),c=Math.cos(n);e[0]=i*c-s*a,e[1]=r*c+o*a,e[2]=s*c+i*a,e[3]=o*c-r*a}(this,this,e),this.check()}rotateZ(e){return function(e,t,n){n*=.5;const i=t[0],r=t[1],s=t[2],o=t[3],a=Math.sin(n),c=Math.cos(n);e[0]=i*c+r*a,e[1]=r*c-i*a,e[2]=s*c+o*a,e[3]=o*c-s*a}(this,this,e),this.check()}scale(e){return Y(this,this,e),this.check()}slerp(e,t,n){let i,r,s;switch(arguments.length){case 1:({start:i=ne,target:r,ratio:s}=e);break;case 2:i=this,r=e,s=t;break;default:i=e,r=t,s=n}return H(this,i,r,s),this.check()}transformVector4(e,t=new Vector4){return(0,s.gL)(t,e,this),(0,T.qk)(t,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,t){return this.setAxisAngle(e,t)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}}const ie=new b.P,re=new b.P,se=new b.P,oe=new b.P,ae=new b.P,ce=new b.P,le=new b.P,ue=0,de=1,he=2,fe=3,pe=4,ge=5,me=6,ve=7,ye=8;class OrientedBoundingBox{constructor(e=[0,0,0],t=[0,0,0,0,0,0,0,0,0]){this.center=(new b.P).from(e),this.halfAxes=new Matrix3(t)}get halfSize(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2);return[new b.P(e).len(),new b.P(t).len(),new b.P(n).len()]}get quaternion(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2),i=new b.P(e).normalize(),r=new b.P(t).normalize(),s=new b.P(n).normalize();return(new Quaternion).fromMatrix3(new Matrix3([...i,...r,...s]))}fromCenterHalfSizeQuaternion(e,t,n){const i=new Quaternion(n),r=(new Matrix3).fromQuaternion(i);return r[0]=r[0]*t[0],r[1]=r[1]*t[0],r[2]=r[2]*t[0],r[3]=r[3]*t[1],r[4]=r[4]*t[1],r[5]=r[5]*t[1],r[6]=r[6]*t[2],r[7]=r[7]*t[2],r[8]=r[8]*t[2],this.center=(new b.P).from(e),this.halfAxes=r,this}clone(){return new OrientedBoundingBox(this.center,this.halfAxes)}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.halfAxes.equals(e.halfAxes)}getBoundingSphere(e=new BoundingSphere){const t=this.halfAxes,n=t.getColumn(0,se),i=t.getColumn(1,oe),r=t.getColumn(2,ae),s=ie.copy(n).add(i).add(r);return e.center.copy(this.center),e.radius=s.magnitude(),e}intersectPlane(e){const t=this.center,n=e.normal,i=this.halfAxes,r=n.x,s=n.y,o=n.z,a=Math.abs(r*i[ue]+s*i[de]+o*i[he])+Math.abs(r*i[fe]+s*i[pe]+o*i[ge])+Math.abs(r*i[me]+s*i[ve]+o*i[ye]),c=n.dot(t)+e.distance;return c<=-a?_:c>=a?w:x}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=re.from(e).subtract(this.center),n=this.halfAxes,i=n.getColumn(0,se),r=n.getColumn(1,oe),s=n.getColumn(2,ae),o=i.magnitude(),a=r.magnitude(),c=s.magnitude();i.normalize(),r.normalize(),s.normalize();let l,u=0;return l=Math.abs(t.dot(i))-o,l>0&&(u+=l*l),l=Math.abs(t.dot(r))-a,l>0&&(u+=l*l),l=Math.abs(t.dot(s))-c,l>0&&(u+=l*l),u}computePlaneDistances(e,t,n=[-0,-0]){let i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;const s=this.center,o=this.halfAxes,a=o.getColumn(0,se),c=o.getColumn(1,oe),l=o.getColumn(2,ae),u=ce.copy(a).add(c).add(l).add(s),d=le.copy(u).subtract(e);let h=t.dot(d);return i=Math.min(h,i),r=Math.max(h,r),u.copy(s).add(a).add(c).subtract(l),d.copy(u).subtract(e),h=t.dot(d),i=Math.min(h,i),r=Math.max(h,r),u.copy(s).add(a).subtract(c).add(l),d.copy(u).subtract(e),h=t.dot(d),i=Math.min(h,i),r=Math.max(h,r),u.copy(s).add(a).subtract(c).subtract(l),d.copy(u).subtract(e),h=t.dot(d),i=Math.min(h,i),r=Math.max(h,r),s.copy(u).subtract(a).add(c).add(l),d.copy(u).subtract(e),h=t.dot(d),i=Math.min(h,i),r=Math.max(h,r),s.copy(u).subtract(a).add(c).subtract(l),d.copy(u).subtract(e),h=t.dot(d),i=Math.min(h,i),r=Math.max(h,r),s.copy(u).subtract(a).subtract(c).add(l),d.copy(u).subtract(e),h=t.dot(d),i=Math.min(h,i),r=Math.max(h,r),s.copy(u).subtract(a).subtract(c).subtract(l),d.copy(u).subtract(e),h=t.dot(d),i=Math.min(h,i),r=Math.max(h,r),n[0]=i,n[1]=r,n}transform(e){this.center.transformAsPoint(e);const t=this.halfAxes.getColumn(0,se);t.transformAsPoint(e);const n=this.halfAxes.getColumn(1,oe);n.transformAsPoint(e);const i=this.halfAxes.getColumn(2,ae);return i.transformAsPoint(e),this.halfAxes=new Matrix3([...t,...n,...i]),this}getTransform(){throw new Error("not implemented")}}var be=n(4990);const _e=new b.P,xe=new b.P;class Plane{constructor(e=[0,0,1],t=0){this.normal=new b.P,this.distance=-0,this.fromNormalDistance(e,t)}fromNormalDistance(e,t){return(0,be.v)(Number.isFinite(t)),this.normal.from(e).normalize(),this.distance=t,this}fromPointNormal(e,t){e=_e.from(e),this.normal.from(t).normalize();const n=-this.normal.dot(e);return this.distance=n,this}fromCoefficients(e,t,n,i){return this.normal.set(e,t,n),(0,be.v)((0,U.aI)(this.normal.len(),1)),this.distance=i,this}clone(){return new Plane(this.normal,this.distance)}equals(e){return(0,U.aI)(this.distance,e.distance)&&(0,U.aI)(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){const t=xe.copy(this.normal).transformAsVector(e).normalize(),n=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(n,t)}projectPointOntoPlane(e,t=[0,0,0]){const n=_e.from(e),i=this.getPointDistance(n),r=xe.copy(this.normal).scale(i);return n.subtract(r).to(t)}}const we=[new b.P([1,0,0]),new b.P([0,1,0]),new b.P([0,0,1])],Pe=new b.P,Ce=new b.P;class CullingVolume{constructor(e=[]){this.planes=e}fromBoundingSphere(e){this.planes.length=2*we.length;const t=e.center,n=e.radius;let i=0;for(const e of we){let r=this.planes[i],s=this.planes[i+1];r||(r=this.planes[i]=new Plane),s||(s=this.planes[i+1]=new Plane);const o=Pe.copy(e).scale(-n).add(t);r.fromPointNormal(o,e);const a=Pe.copy(e).scale(n).add(t),c=Ce.copy(e).negate();s.fromPointNormal(a,c),i+=2}return this}computeVisibility(e){let t=w;for(const n of this.planes){switch(e.intersectPlane(n)){case _:return _;case x:t=x}}return t}computeVisibilityWithPlaneMask(e,t){if((0,be.v)(Number.isFinite(t),"parentPlaneMask is required."),t===CullingVolume.MASK_OUTSIDE||t===CullingVolume.MASK_INSIDE)return t;let n=CullingVolume.MASK_INSIDE;const i=this.planes;for(let r=0;r<this.planes.length;++r){const s=r<31?1<<r:0;if(r<31&&0===(t&s))continue;const o=i[r],a=e.intersectPlane(o);if(a===_)return CullingVolume.MASK_OUTSIDE;a===x&&(n|=s)}return n}}CullingVolume.MASK_OUTSIDE=4294967295,CullingVolume.MASK_INSIDE=0,CullingVolume.MASK_INDETERMINATE=2147483647;new b.P,new b.P,new b.P,new b.P,new b.P;new b.P,new b.P,new b.P,new b.P,new b.P,new b.P,new b.P,new b.P,new b.P,new b.P,new b.P,new b.P;const Se=new Matrix3,Le=new Matrix3,Ae=new Matrix3,Ee=new Matrix3,Te=new Matrix3;function Me(e,t={}){let n=0,i=0;const r=Le,s=Ae;r.identity(),s.copy(e);const o=1e-20*function(e){let t=0;for(let n=0;n<9;++n){const i=e[n];t+=i*i}return Math.sqrt(t)}(s);for(;i<10&&ke(s)>o;)Re(s,Ee),Te.copy(Ee).transpose(),s.multiplyRight(Ee),s.multiplyLeft(Te),r.multiplyRight(Ee),++n>2&&(++i,n=0);return t.unitary=r.toTarget(t.unitary),t.diagonal=s.toTarget(t.diagonal),t}const Ie=[1,0,0],Be=[2,2,1];function ke(e){let t=0;for(let n=0;n<3;++n){const i=e[Se.getElementIndex(Be[n],Ie[n])];t+=2*i*i}return Math.sqrt(t)}function Re(e,t){let n=0,i=1;for(let t=0;t<3;++t){const r=Math.abs(e[Se.getElementIndex(Be[t],Ie[t])]);r>n&&(i=t,n=r)}const r=Ie[i],s=Be[i];let o=1,a=0;if(Math.abs(e[Se.getElementIndex(s,r)])>1e-15){const t=(e[Se.getElementIndex(s,s)]-e[Se.getElementIndex(r,r)])/2/e[Se.getElementIndex(s,r)];let n;n=t<0?-1/(-t+Math.sqrt(1+t*t)):1/(t+Math.sqrt(1+t*t)),o=1/Math.sqrt(1+n*n),a=n*o}return Matrix3.IDENTITY.to(t),t[Se.getElementIndex(r,r)]=t[Se.getElementIndex(s,s)]=o,t[Se.getElementIndex(s,r)]=a,t[Se.getElementIndex(r,s)]=-a,t}const Oe=new b.P,ze=new b.P,De=new b.P,Fe=new b.P,Ne=new b.P,$e=new Matrix3,Ue={diagonal:new Matrix3,unitary:new Matrix3};const Ve=512,Ge=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],je=Ge.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),We=je.concat([[.25,.5],[.75,.5]]);class OSMNode{constructor(e,t,n){this.x=e,this.y=t,this.z=n}get children(){if(!this._children){const e=2*this.x,t=2*this.y,n=this.z+1;this._children=[new OSMNode(e,t,n),new OSMNode(e,t+1,n),new OSMNode(e+1,t,n),new OSMNode(e+1,t+1,n)]}return this._children}update(e){const{viewport:t,cullingVolume:n,elevationBounds:i,minZ:r,maxZ:s,bounds:o,offset:a,project:c}=e,l=this.getBoundingVolume(i,a,c);if(o&&!this.insideBounds(o))return!1;if(n.computeVisibility(l)<0)return!1;if(c&&this.beyondHorizon(t.cameraPosition,c,i[1]))return!1;if(!this.childVisible){let{z:e}=this;if(e<s&&e>=r){const n=l.distanceTo(t.cameraPosition)*t.scale/t.height;e+=Math.floor(Math.log2(n))}if(e>=s)return this.selected=!0,!0}this.selected=!1,this.childVisible=!0;for(const t of this.children)t.update(e);return!0}getSelected(e=[]){if(this.selected&&e.push(this),this._children)for(const t of this._children)t.getSelected(e);return e}beyondHorizon(e,t,n){const i=e[0],r=e[1],s=e[2],o=Math.sqrt(i*i+r*r+s*s),a=180*Math.atan2(i,-r)/Math.PI,c=180*Math.asin(s/o)/Math.PI,[l,u]=et(this.x,this.y,this.z),[d,h]=et(this.x+1,this.y+1,this.z),f=(l+d)/2,p=f+((a-f+540)%360-180),g=t([Math.max(l,Math.min(p,d)),Math.max(h,Math.min(c,u)),n]);return g[0]*i+g[1]*r+g[2]*s<=g[0]*g[0]+g[1]*g[1]+g[2]*g[2]}insideBounds([e,t,n,i]){const r=Math.pow(2,this.z),s=Ve/r;return this.x*s<n&&this.y*s<i&&(this.x+1)*s>e&&(this.y+1)*s>t}getBoundingVolume(e,t,n){if(n){const t=this.z<1?We:this.z<2?je:Ge,i=[];for(const r of t){const t=et(this.x+r[0],this.y+r[1],this.z);t[2]=e[0],i.push(n(t)),e[0]!==e[1]&&(t[2]=e[1],i.push(n(t)))}return function(e,t=new OrientedBoundingBox){if(!e||0===e.length)return t.halfAxes=new Matrix3([0,0,0,0,0,0,0,0,0]),t.center=new b.P,t;const n=e.length,i=new b.P(0,0,0);for(const t of e)i.add(t);const r=1/n;i.multiplyByScalar(r);let s=0,o=0,a=0,c=0,l=0,u=0;for(const t of e){const e=Oe.copy(t).subtract(i);s+=e.x*e.x,o+=e.x*e.y,a+=e.x*e.z,c+=e.y*e.y,l+=e.y*e.z,u+=e.z*e.z}s*=r,o*=r,a*=r,c*=r,l*=r,u*=r;const d=$e;d[0]=s,d[1]=o,d[2]=a,d[3]=o,d[4]=c,d[5]=l,d[6]=a,d[7]=l,d[8]=u;const{unitary:h}=Me(d,Ue),f=t.halfAxes.copy(h);let p=f.getColumn(0,De),g=f.getColumn(1,Fe),m=f.getColumn(2,Ne),v=-Number.MAX_VALUE,y=-Number.MAX_VALUE,_=-Number.MAX_VALUE,x=Number.MAX_VALUE,w=Number.MAX_VALUE,P=Number.MAX_VALUE;for(const t of e)Oe.copy(t),v=Math.max(Oe.dot(p),v),y=Math.max(Oe.dot(g),y),_=Math.max(Oe.dot(m),_),x=Math.min(Oe.dot(p),x),w=Math.min(Oe.dot(g),w),P=Math.min(Oe.dot(m),P);p=p.multiplyByScalar(.5*(x+v)),g=g.multiplyByScalar(.5*(w+y)),m=m.multiplyByScalar(.5*(P+_)),t.center.copy(p).add(g).add(m);const C=ze.set(v-x,y-w,_-P).multiplyByScalar(.5),S=new Matrix3([C[0],0,0,0,C[1],0,0,0,C[2]]);return t.halfAxes.multiplyRight(S),t}(i)}const i=Math.pow(2,this.z),r=Ve/i,s=this.x*r+t*Ve,o=Ve-(this.y+1)*r;return new AxisAlignedBoundingBox([s,o,e[0]],[s+r,o+r,e[1]])}}const He=512,qe=[-1/0,-1/0,1/0,1/0],Ze={type:"object",value:null,validate:(e,t)=>t.optional&&null===e||"string"==typeof e||Array.isArray(e)&&e.every(e=>"string"==typeof e),equal:(e,t)=>{if(e===t)return!0;if(!Array.isArray(e)||!Array.isArray(t))return!1;const n=e.length;if(n!==t.length)return!1;for(let i=0;i<n;i++)if(e[i]!==t[i])return!1;return!0}};function Ye(e,t){const n=[t.transformAsPoint([e[0],e[1]]),t.transformAsPoint([e[2],e[1]]),t.transformAsPoint([e[0],e[3]]),t.transformAsPoint([e[2],e[3]])];return[Math.min(...n.map(e=>e[0])),Math.min(...n.map(e=>e[1])),Math.max(...n.map(e=>e[0])),Math.max(...n.map(e=>e[1]))]}function Ke(e,t){if(!e||!e.length)return null;const{index:n,id:i}=t;if(Array.isArray(e)){e=e[r=i,Math.abs(r.split("").reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0))%e.length]}var r;let s=e;for(const e of Object.keys(n)){const t=new RegExp(`{${e}}`,"g");s=s.replace(t,String(n[e]))}return Number.isInteger(n.y)&&Number.isInteger(n.z)&&(s=s.replace(/\{-y\}/g,String(Math.pow(2,n.z)-n.y-1))),s}function Qe({viewport:e,z:t,cullRect:n}){return(e.subViewports||[e]).map(e=>Xe(e,t||0,n))}function Xe(e,t,n){if(!Array.isArray(t)){const i=n.x-e.x,r=n.y-e.y,{width:s,height:o}=n,a={targetZ:t},c=e.unproject([i,r],a),l=e.unproject([i+s,r],a),u=e.unproject([i,r+o],a),d=e.unproject([i+s,r+o],a);return[Math.min(c[0],l[0],u[0],d[0]),Math.min(c[1],l[1],u[1],d[1]),Math.max(c[0],l[0],u[0],d[0]),Math.max(c[1],l[1],u[1],d[1])]}const i=Xe(e,t[0],n),r=Xe(e,t[1],n);return[Math.min(i[0],r[0]),Math.min(i[1],r[1]),Math.max(i[2],r[2]),Math.max(i[3],r[3])]}function Je(e,t){return Math.pow(2,e)*He/t}function et(e,t,n){const i=Je(n,He),r=e/i*360-180,s=Math.PI-2*Math.PI*t/i;return[r,180/Math.PI*Math.atan(.5*(Math.exp(s)-Math.exp(-s)))]}function tt(e,t,n,i){const r=Je(n,i);return[e/r*He,t/r*He]}function nt(e,t,n,i,r=512){if(e.isGeospatial){const[e,r]=et(t,n,i),[s,o]=et(t+1,n+1,i);return{west:e,north:r,east:s,south:o}}const[s,o]=tt(t,n,i,r),[a,c]=tt(t+1,n+1,i,r);return{left:s,top:o,right:a,bottom:c}}function it(e,t,n,i,r){const s=function(e,t,n){let i;if(t&&2===t.length){const[n,r]=t,s=e.getBounds({z:n}),o=e.getBounds({z:r});i=[Math.min(s[0],o[0]),Math.min(s[1],o[1]),Math.max(s[2],o[2]),Math.max(s[3],o[3])]}else i=e.getBounds();return e.isGeospatial?[Math.max(i[0],n[0]),Math.max(i[1],n[1]),Math.min(i[2],n[2]),Math.min(i[3],n[3])]:[Math.max(Math.min(i[0],n[2]),n[0]),Math.max(Math.min(i[1],n[3]),n[1]),Math.min(Math.max(i[2],n[0]),n[2]),Math.min(Math.max(i[3],n[1]),n[3])]}(e,null,i),o=Je(t,n),[a,c,l,u]=function(e,t,n){if(n)return Ye(e,n).map(e=>e*t/He);return e.map(e=>e*t/He)}(s,o,r),d=[];for(let e=Math.floor(a);e<l;e++)for(let n=Math.floor(c);n<u;n++)d.push({x:e,y:n,z:t});return d}function rt({viewport:e,maxZoom:t,minZoom:n,zRange:i,extent:r,tileSize:s=512,modelMatrix:a,modelMatrixInverse:c,zoomOffset:l=0,visibleMinZoom:u,visibleMaxZoom:d}){let h=e.isGeospatial?Math.round(e.zoom+Math.log2(He/s)+l):Math.ceil(e.zoom+l);if("number"==typeof n&&Number.isFinite(n)&&h<n){if(!r)return[];h=n}if("number"==typeof t&&Number.isFinite(t)&&h>t&&(h=t),null!=u&&e.zoom<u)return[];if(null!=d&&e.zoom>d)return[];let f=r;return a&&c&&r&&!e.isGeospatial&&(f=Ye(r,a)),e.isGeospatial?function(e,t,n,i){const r=e instanceof g?e.projectPosition:null,s=Object.values(e.getFrustumPlanes()).map(({normal:e,distance:t})=>new Plane(e.clone().negate(),t)),a=new CullingVolume(s),c=e.distanceScales.unitsPerMeter[2],l=n&&n[0]*c||0,u=n&&n[1]*c||0,d=e instanceof y.A&&e.pitch<=60?t:0;if(i){const[e,t,n,r]=i,s=(0,o.Gw)([e,r]),a=(0,o.Gw)([n,t]);i=[s[0],Ve-s[1],a[0],Ve-a[1]]}const h=new OSMNode(0,0,0),f={viewport:e,project:r,cullingVolume:a,elevationBounds:[l,u],minZ:d,maxZ:t,bounds:i,offset:0};if(h.update(f),e instanceof y.A&&e.subViewports&&e.subViewports.length>1){for(f.offset=-1;h.update(f)&&!(--f.offset<-3););for(f.offset=1;h.update(f)&&!(++f.offset>3););}return h.getSelected()}(e,h,i,r):it(e,h,s,f||qe,c)}function st(e){return/(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))/.test(e)}function ot(e){return Number.isFinite(e.west)&&Number.isFinite(e.north)&&Number.isFinite(e.east)&&Number.isFinite(e.south)}},83362(e,t,n){n.d(t,{A:()=>m});var i=n(45069),r=n(46487),s=n(84175),o=n(93675),a=n(36077),c=n(45249),l=n(54901);const u=new Uint32Array([0,2,1,0,3,2]),d=new Float32Array([0,1,0,0,1,0,1,1]);function h(e,t){if(!t)return function(e){const t=new Float64Array(12);for(let n=0;n<e.length;n++)t[3*n+0]=e[n][0],t[3*n+1]=e[n][1],t[3*n+2]=e[n][2]||0;return{vertexCount:6,positions:t,indices:u,texCoords:d}}(e);const n=Math.max(Math.abs(e[0][0]-e[3][0]),Math.abs(e[1][0]-e[2][0])),i=Math.max(Math.abs(e[1][1]-e[0][1]),Math.abs(e[2][1]-e[3][1])),r=Math.ceil(n/t)+1,s=Math.ceil(i/t)+1,o=(r-1)*(s-1)*6,a=new Uint32Array(o),c=new Float32Array(r*s*2),l=new Float64Array(r*s*3);let h=0,p=0;for(let t=0;t<r;t++){const n=t/(r-1);for(let i=0;i<s;i++){const r=i/(s-1),o=f(e,n,r);l[3*h+0]=o[0],l[3*h+1]=o[1],l[3*h+2]=o[2]||0,c[2*h+0]=n,c[2*h+1]=1-r,t>0&&i>0&&(a[p++]=h-s,a[p++]=h-s-1,a[p++]=h-1,a[p++]=h-s,a[p++]=h-1,a[p++]=h),h++}}return{vertexCount:o,positions:l,indices:a,texCoords:c}}function f(e,t,n){return(0,l.Cc)((0,l.Cc)(e[0],e[1],n),(0,l.Cc)(e[3],e[2],n),t)}const p="layout(std140) uniform bitmapUniforms {\n vec4 bounds;\n float coordinateConversion;\n float desaturate;\n vec3 tintColor;\n vec4 transparentColor;\n} bitmap;\n",g={name:"bitmap",source:"\nstruct BitmapUniforms {\n bounds: vec4<f32>,\n coordinateConversion: f32,\n desaturate: f32,\n tintColor: vec3<f32>,\n transparentColor: vec4<f32>,\n};\n\n@group(0) @binding(auto) var<uniform> bitmap: BitmapUniforms;\n@group(0) @binding(auto) var bitmapTexture: texture_2d<f32>;\n@group(0) @binding(auto) var bitmapTextureSampler: sampler;\n",vs:p,fs:p,uniformTypes:{bounds:"vec4<f32>",coordinateConversion:"f32",desaturate:"f32",tintColor:"vec3<f32>",transparentColor:"vec4<f32>"}};class BitmapLayer extends i.A{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME bitmap-layer-vertex-shader\n\nin vec2 texCoords;\nin vec3 positions;\nin vec3 positions64Low;\n\nout vec2 vTexCoord;\nout vec2 vTexPos;\n\nconst vec3 pickingColor = vec3(1.0, 0.0, 0.0);\n\nvoid main(void) {\n geometry.worldPosition = positions;\n geometry.uv = texCoords;\n geometry.pickingColor = pickingColor;\n\n gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position);\n DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n\n vTexCoord = texCoords;\n\n if (bitmap.coordinateConversion < -0.5) {\n vTexPos = geometry.position.xy + project.commonOrigin.xy;\n } else if (bitmap.coordinateConversion > 0.5) {\n vTexPos = geometry.worldPosition.xy;\n }\n\n vec4 color = vec4(0.0);\n DECKGL_FILTER_COLOR(color, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME bitmap-layer-fragment-shader\n\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D bitmapTexture;\n\nin vec2 vTexCoord;\nin vec2 vTexPos;\n\nout vec4 fragColor;\n\n/* projection utils */\nconst float TILE_SIZE = 512.0;\nconst float PI = 3.1415926536;\nconst float WORLD_SCALE = TILE_SIZE / PI / 2.0;\n\n// from degrees to Web Mercator\nvec2 lnglat_to_mercator(vec2 lnglat) {\n float x = lnglat.x;\n float y = clamp(lnglat.y, -89.9, 89.9);\n return vec2(\n radians(x) + PI,\n PI + log(tan(PI * 0.25 + radians(y) * 0.5))\n ) * WORLD_SCALE;\n}\n\n// from Web Mercator to degrees\nvec2 mercator_to_lnglat(vec2 xy) {\n xy /= WORLD_SCALE;\n return degrees(vec2(\n xy.x - PI,\n atan(exp(xy.y - PI)) * 2.0 - PI * 0.5\n ));\n}\n/* End projection utils */\n\n// apply desaturation\nvec3 color_desaturate(vec3 color) {\n float luminance = (color.r + color.g + color.b) * 0.333333333;\n return mix(color, vec3(luminance), bitmap.desaturate);\n}\n\n// apply tint\nvec3 color_tint(vec3 color) {\n return color * bitmap.tintColor;\n}\n\n// blend with background color\nvec4 apply_opacity(vec3 color, float alpha) {\n if (bitmap.transparentColor.a == 0.0) {\n return vec4(color, alpha);\n }\n float blendedAlpha = alpha + bitmap.transparentColor.a * (1.0 - alpha);\n float highLightRatio = alpha / blendedAlpha;\n vec3 blendedRGB = mix(bitmap.transparentColor.rgb, color, highLightRatio);\n return vec4(blendedRGB, blendedAlpha);\n}\n\nvec2 getUV(vec2 pos) {\n return vec2(\n (pos.x - bitmap.bounds[0]) / (bitmap.bounds[2] - bitmap.bounds[0]),\n (pos.y - bitmap.bounds[3]) / (bitmap.bounds[1] - bitmap.bounds[3])\n );\n}\n\n\nvec3 packUVsIntoRGB(vec2 uv) {\n // Extract the top 8 bits. We want values to be truncated down so we can add a fraction\n vec2 uv8bit = floor(uv * 256.);\n\n // Calculate the normalized remainders of u and v parts that do not fit into 8 bits\n // Scale and clamp to 0-1 range\n vec2 uvFraction = fract(uv * 256.);\n vec2 uvFraction4bit = floor(uvFraction * 16.);\n\n // Remainder can be encoded in blue channel, encode as 4 bits for pixel coordinates\n float fractions = uvFraction4bit.x + uvFraction4bit.y * 16.;\n\n return vec3(uv8bit, fractions) / 255.;\n}\n\n\nvoid main(void) {\n vec2 uv = vTexCoord;\n if (bitmap.coordinateConversion < -0.5) {\n vec2 lnglat = mercator_to_lnglat(vTexPos);\n uv = getUV(lnglat);\n } else if (bitmap.coordinateConversion > 0.5) {\n vec2 commonPos = lnglat_to_mercator(vTexPos);\n uv = getUV(commonPos);\n }\n vec4 bitmapColor = texture(bitmapTexture, uv);\n\n fragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * layer.opacity);\n\n geometry.uv = uv;\n DECKGL_FILTER_COLOR(fragColor, geometry);\n\n if (bool(picking.isActive) && !bool(picking.isAttribute)) {\n // Since instance information is not used, we can use picking color for pixel index\n fragColor.rgb = packUVsIntoRGB(uv);\n }\n}\n",source:"struct Attributes {\n @location(0) positions: vec3<f32>,\n @location(1) positions64Low: vec3<f32>,\n @location(2) texCoords: vec2<f32>,\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n @location(0) vTexCoord: vec2<f32>,\n @location(1) vTexPos: vec2<f32>,\n @location(2) pickingColor: vec3<f32>,\n @location(3) pickingDepth: f32,\n};\n\n// from degrees to Web Mercator\nfn lnglat_to_mercator(lnglat: vec2<f32>) -> vec2<f32> {\n let x = lnglat.x;\n let y = clamp(lnglat.y, -89.9, 89.9);\n return vec2<f32>(\n radians(x) + PI,\n PI + log(tan(PI * 0.25 + radians(y) * 0.5))\n ) * WORLD_SCALE;\n}\n\n// from Web Mercator to degrees\nfn mercator_to_lnglat(xy: vec2<f32>) -> vec2<f32> {\n let position = xy / WORLD_SCALE;\n return degrees(vec2<f32>(\n position.x - PI,\n atan(exp(position.y - PI)) * 2.0 - PI * 0.5\n ));\n}\n\nfn color_desaturate(colorValue: vec3<f32>) -> vec3<f32> {\n let luminance = (colorValue.r + colorValue.g + colorValue.b) * 0.333333333;\n return mix(colorValue, vec3<f32>(luminance), bitmap.desaturate);\n}\n\nfn color_tint(colorValue: vec3<f32>) -> vec3<f32> {\n return colorValue * bitmap.tintColor;\n}\n\nfn apply_opacity(colorValue: vec3<f32>, alpha: f32) -> vec4<f32> {\n if (bitmap.transparentColor.a == 0.0) {\n return vec4<f32>(colorValue, alpha);\n }\n let blendedAlpha = alpha + bitmap.transparentColor.a * (1.0 - alpha);\n let highLightRatio = alpha / blendedAlpha;\n let blendedRGB = mix(bitmap.transparentColor.rgb, colorValue, highLightRatio);\n return vec4<f32>(blendedRGB, blendedAlpha);\n}\n\nfn getUV(position: vec2<f32>) -> vec2<f32> {\n return vec2<f32>(\n (position.x - bitmap.bounds[0]) / (bitmap.bounds[2] - bitmap.bounds[0]),\n (position.y - bitmap.bounds[3]) / (bitmap.bounds[1] - bitmap.bounds[3])\n );\n}\n\n// Pack the top 12 bits of two normalized floats into three 8-bit values.\nfn packUVsIntoRGB(uv: vec2<f32>) -> vec3<f32> {\n let uv8bit = floor(uv * 256.0);\n let uvFraction = fract(uv * 256.0);\n let uvFraction4bit = floor(uvFraction * 16.0);\n let fractions = uvFraction4bit.x + uvFraction4bit.y * 16.0;\n return vec3<f32>(uv8bit, fractions) / 255.0;\n}\n\n@vertex\nfn vertexMain(attributes: Attributes) -> Varyings {\n var output: Varyings;\n geometry.worldPosition = attributes.positions;\n geometry.uv = attributes.texCoords;\n geometry.pickingColor = picking_getPickingColorFromIndex(0u);\n\n let projectedPosition = project_position_to_clipspace_and_commonspace(\n attributes.positions,\n attributes.positions64Low,\n vec3<f32>(0.0)\n );\n geometry.position = projectedPosition.commonPosition;\n output.position = projectedPosition.clipPosition;\n output.vTexCoord = attributes.texCoords;\n output.vTexPos = vec2<f32>(0.0);\n output.pickingColor = geometry.pickingColor;\n output.pickingDepth = output.position.z / output.position.w;\n\n if (bitmap.coordinateConversion < -0.5) {\n output.vTexPos = geometry.position.xy + project.commonOrigin.xy;\n } else if (bitmap.coordinateConversion > 0.5) {\n output.vTexPos = geometry.worldPosition.xy;\n }\n\n return output;\n}\n\n@fragment\nfn fragmentMain(input: Varyings) -> @location(0) vec4<f32> {\n var uv = input.vTexCoord;\n if (bitmap.coordinateConversion < -0.5) {\n uv = getUV(mercator_to_lnglat(input.vTexPos));\n } else if (bitmap.coordinateConversion > 0.5) {\n uv = getUV(lnglat_to_mercator(input.vTexPos));\n }\n\n let bitmapColor = textureSample(bitmapTexture, bitmapTextureSampler, uv);\n var fragColor = apply_opacity(\n color_tint(color_desaturate(bitmapColor.rgb)),\n bitmapColor.a * layer.opacity\n );\n\n geometry.uv = uv;\n\n if (picking.isActive > 0.5) {\n if (picking.isAttribute > 0.5) {\n return vec4<f32>(input.pickingDepth, 0.0, 0.0, 1.0);\n }\n return vec4<f32>(packUVsIntoRGB(uv), 1.0);\n }\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(input.pickingColor - highlightedObjectColor))) {\n let highLightAlpha = picking.highlightColor.a;\n let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);\n if (blendedAlpha > 0.0) {\n let highLightRatio = highLightAlpha / blendedAlpha;\n fragColor = vec4<f32>(\n mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),\n blendedAlpha\n );\n } else {\n fragColor = vec4<f32>(fragColor.rgb, 0.0);\n }\n }\n }\n\n return deckgl_premultiplied_alpha(fragColor);\n}\n",modules:[r.A,s.A,o.Ay,g]})}initializeState(){const e=!0;this.getAttributeManager().add({indices:{size:1,isIndexed:!0,update:e=>e.value=this.state.mesh.indices,noAlloc:e},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:e=>e.value=this.state.mesh.positions,noAlloc:e},texCoords:{size:2,update:e=>e.value=this.state.mesh.texCoords,noAlloc:e}})}updateState({props:e,oldProps:t,changeFlags:n}){const i=this.getAttributeManager();if(n.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),i.invalidateAll()),e.bounds!==t.bounds){const e=this.state.mesh,t=this._createMesh();this.state.model.setVertexCount(t.vertexCount);for(const n in t)e&&e[n]!==t[n]&&i.invalidate(n);this.setState({mesh:t,...this._getCoordinateUniforms()})}else e._imageCoordinateSystem!==t._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(e){const{image:t}=this.props,n=e.info;if(!n.color||!t)return n.bitmap=null,n;const{width:i,height:r}=t;n.index=0;const s=function(e){const[t,n,i]=e;return[(t+(15&i)/16)/256,(n+(240&i)/256)/256]}(n.color);return n.bitmap={size:{width:i,height:r},uv:s,pixel:[Math.floor(s[0]*i),Math.floor(s[1]*r)]},n}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(e){super._updateAutoHighlight({...e,color:this.encodePickingColor(0)})}_createMesh(){const{bounds:e}=this.props;let t=e;return v(e)&&(t=[[e[0],e[1]],[e[0],e[3]],[e[2],e[3]],[e[2],e[1]]]),h(t,this.context.viewport.resolution)}_getModel(){const e="webgpu"===this.context.device.type?this.getAttributeManager().getBufferLayouts({isInstanced:!1}).filter(e=>"indices"!==e.name):this.getAttributeManager().getBufferLayouts();return new a.K(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:e,topology:"triangle-list",isInstanced:!1})}draw(e){const{shaderModuleProps:t}=e,{model:n,coordinateConversion:i,bounds:r,disablePicking:s}=this.state,{image:o,desaturate:a,transparentColor:c,tintColor:l}=this.props;if((!t.picking.isActive||!s)&&o&&n){const e={bitmapTexture:o,bounds:r,coordinateConversion:i,desaturate:a,tintColor:l.slice(0,3).map(e=>e/255),transparentColor:c.map(e=>e/255)};n.shaderInputs.setProps({bitmap:e}),n.draw(this.context.renderPass)}}_getCoordinateUniforms(){let{_imageCoordinateSystem:e}=this.props;if("default"!==e){const{bounds:t}=this.props;if(!v(t))throw new Error("_imageCoordinateSystem only supports rectangular bounds");const n=this.context.viewport.resolution?"lnglat":"cartesian";if(e="lnglat"===e?"lnglat":"cartesian","lnglat"===e&&"cartesian"===n)return{coordinateConversion:-1,bounds:t};if("cartesian"===e&&"lnglat"===n){const e=(0,c.Gw)([t[0],t[1]]),n=(0,c.Gw)([t[2],t[3]]);return{coordinateConversion:1,bounds:[e[0],e[1],n[0],n[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}}BitmapLayer.layerName="BitmapLayer",BitmapLayer.defaultProps={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:"default",desaturate:{type:"number",min:0,max:1,value:0},transparentColor:{type:"color",value:[0,0,0,0]},tintColor:{type:"color",value:[255,255,255]},textureParameters:{type:"object",ignore:!0,value:null}};const m=BitmapLayer;function v(e){return Number.isFinite(e[0])}},40618(e,t,n){n.d(t,{A:()=>Me});var i=n.cw(function(e,t){function n(e,t,n){n=n||2;var r,o,a,c,l,h,f,g=t&&t.length,m=g?t[0]*n:e.length,v=i(e,0,m,n,!0),y=[];if(!v||v.next===v.prev)return y;if(g&&(v=function(e,t,n,r){var s,o,a,c=[];for(s=0,o=t.length;s<o;s++)(a=i(e,t[s]*r,s<o-1?t[s+1]*r:e.length,r,!1))===a.next&&(a.steiner=!0),c.push(p(a));for(c.sort(u),s=0;s<c.length;s++)n=d(c[s],n);return n}(e,t,v,n)),e.length>80*n){r=a=e[0],o=c=e[1];for(var b=n;b<m;b+=n)(l=e[b])<r&&(r=l),(h=e[b+1])<o&&(o=h),l>a&&(a=l),h>c&&(c=h);f=0!==(f=Math.max(a-r,c-o))?32767/f:0}return s(v,y,n,r,o,f,0),y}function i(e,t,n,i,r){var s,o;if(r===A(e,t,n,i)>0)for(s=t;s<n;s+=i)o=C(s,e[s],e[s+1],o);else for(s=n-i;s>=t;s-=i)o=C(s,e[s],e[s+1],o);return o&&y(o,o.next)&&(S(o),o=o.next),o}function r(e,t){if(!e)return e;t||(t=e);var n,i=e;do{if(n=!1,i.steiner||!y(i,i.next)&&0!==v(i.prev,i,i.next))i=i.next;else{if(S(i),(i=t=i.prev)===i.next)break;n=!0}}while(n||i!==t);return t}function s(e,t,n,i,u,d,h){if(e){!h&&d&&function(e,t,n,i){var r=e;do{0===r.z&&(r.z=f(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){var t,n,i,r,s,o,a,c,l=1;do{for(n=e,e=null,s=null,o=0;n;){for(o++,i=n,a=0,t=0;t<l&&(a++,i=i.nextZ);t++);for(c=l;a>0||c>0&&i;)0!==a&&(0===c||!i||n.z<=i.z)?(r=n,n=n.nextZ,a--):(r=i,i=i.nextZ,c--),s?s.nextZ=r:e=r,r.prevZ=s,s=r;n=i}s.nextZ=null,l*=2}while(o>1)}(r)}(e,i,u,d);for(var p,g,m=e;e.prev!==e.next;)if(p=e.prev,g=e.next,d?a(e,i,u,d):o(e))t.push(p.i/n|0),t.push(e.i/n|0),t.push(g.i/n|0),S(e),e=g.next,m=g.next;else if((e=g)===m){h?1===h?s(e=c(r(e),t,n),t,n,i,u,d,2):2===h&&l(e,t,n,i,u,d):s(r(e),t,n,i,u,d,1);break}}}function o(e){var t=e.prev,n=e,i=e.next;if(v(t,n,i)>=0)return!1;for(var r=t.x,s=n.x,o=i.x,a=t.y,c=n.y,l=i.y,u=r<s?r<o?r:o:s<o?s:o,d=a<c?a<l?a:l:c<l?c:l,h=r>s?r>o?r:o:s>o?s:o,f=a>c?a>l?a:l:c>l?c:l,p=i.next;p!==t;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&g(r,a,s,c,o,l,p.x,p.y)&&v(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function a(e,t,n,i){var r=e.prev,s=e,o=e.next;if(v(r,s,o)>=0)return!1;for(var a=r.x,c=s.x,l=o.x,u=r.y,d=s.y,h=o.y,p=a<c?a<l?a:l:c<l?c:l,m=u<d?u<h?u:h:d<h?d:h,y=a>c?a>l?a:l:c>l?c:l,b=u>d?u>h?u:h:d>h?d:h,_=f(p,m,t,n,i),x=f(y,b,t,n,i),w=e.prevZ,P=e.nextZ;w&&w.z>=_&&P&&P.z<=x;){if(w.x>=p&&w.x<=y&&w.y>=m&&w.y<=b&&w!==r&&w!==o&&g(a,u,c,d,l,h,w.x,w.y)&&v(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,P.x>=p&&P.x<=y&&P.y>=m&&P.y<=b&&P!==r&&P!==o&&g(a,u,c,d,l,h,P.x,P.y)&&v(P.prev,P,P.next)>=0)return!1;P=P.nextZ}for(;w&&w.z>=_;){if(w.x>=p&&w.x<=y&&w.y>=m&&w.y<=b&&w!==r&&w!==o&&g(a,u,c,d,l,h,w.x,w.y)&&v(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;P&&P.z<=x;){if(P.x>=p&&P.x<=y&&P.y>=m&&P.y<=b&&P!==r&&P!==o&&g(a,u,c,d,l,h,P.x,P.y)&&v(P.prev,P,P.next)>=0)return!1;P=P.nextZ}return!0}function c(e,t,n){var i=e;do{var s=i.prev,o=i.next.next;!y(s,o)&&b(s,i,i.next,o)&&w(s,o)&&w(o,s)&&(t.push(s.i/n|0),t.push(i.i/n|0),t.push(o.i/n|0),S(i),S(i.next),i=e=o),i=i.next}while(i!==e);return r(i)}function l(e,t,n,i,o,a){var c=e;do{for(var l=c.next.next;l!==c.prev;){if(c.i!==l.i&&m(c,l)){var u=P(c,l);return c=r(c,c.next),u=r(u,u.next),s(c,t,n,i,o,a,0),void s(u,t,n,i,o,a,0)}l=l.next}c=c.next}while(c!==e)}function u(e,t){return e.x-t.x}function d(e,t){var n=function(e,t){var n,i=t,r=e.x,s=e.y,o=-1/0;do{if(s<=i.y&&s>=i.next.y&&i.next.y!==i.y){var a=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=r&&a>o&&(o=a,n=i.x<i.next.x?i:i.next,a===r))return n}i=i.next}while(i!==t);if(!n)return null;var c,l=n,u=n.x,d=n.y,f=1/0;i=n;do{r>=i.x&&i.x>=u&&r!==i.x&&g(s<d?r:o,s,u,d,s<d?o:r,s,i.x,i.y)&&(c=Math.abs(s-i.y)/(r-i.x),w(i,e)&&(c<f||c===f&&(i.x>n.x||i.x===n.x&&h(n,i)))&&(n=i,f=c)),i=i.next}while(i!==l);return n}(e,t);if(!n)return t;var i=P(n,e);return r(i,i.next),r(n,n.next)}function h(e,t){return v(e.prev,e,t.prev)<0&&v(t.next,e,e.next)<0}function f(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function p(e){var t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function g(e,t,n,i,r,s,o,a){return(r-o)*(t-a)>=(e-o)*(s-a)&&(e-o)*(i-a)>=(n-o)*(t-a)&&(n-o)*(s-a)>=(r-o)*(i-a)}function m(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&b(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(w(e,t)&&w(t,e)&&function(e,t){var n=e,i=!1,r=(e.x+t.x)/2,s=(e.y+t.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)&&(v(e.prev,e,t.prev)||v(e,t.prev,t))||y(e,t)&&v(e.prev,e,e.next)>0&&v(t.prev,t,t.next)>0)}function v(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function y(e,t){return e.x===t.x&&e.y===t.y}function b(e,t,n,i){var r=x(v(e,t,n)),s=x(v(e,t,i)),o=x(v(n,i,e)),a=x(v(n,i,t));return r!==s&&o!==a||(!(0!==r||!_(e,n,t))||(!(0!==s||!_(e,i,t))||(!(0!==o||!_(n,e,i))||!(0!==a||!_(n,t,i)))))}function _(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function x(e){return e>0?1:e<0?-1:0}function w(e,t){return v(e.prev,e,e.next)<0?v(e,t,e.next)>=0&&v(e,e.prev,t)>=0:v(e,t,e.prev)<0||v(e,e.next,t)<0}function P(e,t){var n=new L(e.i,e.x,e.y),i=new L(t.i,t.x,t.y),r=e.next,s=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function C(e,t,n,i){var r=new L(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function S(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function L(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function A(e,t,n,i){for(var r=0,s=t,o=n-i;s<n;s+=i)r+=(e[o]-e[s])*(e[s+1]+e[o+1]),o=s;return r}e.exports=n,e.exports.default=n,n.deviation=function(e,t,n,i){var r=t&&t.length,s=r?t[0]*n:e.length,o=Math.abs(A(e,0,s,n));if(r)for(var a=0,c=t.length;a<c;a++){var l=t[a]*n,u=a<c-1?t[a+1]*n:e.length;o-=Math.abs(A(e,l,u,n))}var d=0;for(a=0;a<i.length;a+=3){var h=i[a]*n,f=i[a+1]*n,p=i[a+2]*n;d+=Math.abs((e[h]-e[p])*(e[f+1]-e[h+1])-(e[h]-e[f])*(e[p+1]-e[h+1]))}return 0===o&&0===d?0:Math.abs((d-o)/o)},n.flatten=function(e){for(var t=e[0][0].length,n={vertices:[],holes:[],dimensions:t},i=0,r=0;r<e.length;r++){for(var s=0;s<e[r].length;s++)for(var o=0;o<t;o++)n.vertices.push(e[r][s][o]);r>0&&(i+=e[r-1].length,n.holes.push(i))}return n}}),r=n(59452);function s({data:e,getIndex:t,dataRange:n,replace:i}){const{startRow:r=0,endRow:s=1/0}=n,o=e.length;let a=o,c=o;for(let n=0;n<o;n++){const i=t(e[n]);if(a>n&&i>=r&&(a=n),i>=s){c=n;break}}let l=a;const u=c-a!==i.length?e.slice(c):void 0;for(let t=0;t<i.length;t++)e[l++]=i[t];if(u){for(let t=0;t<u.length;t++)e[l++]=u[t];e.length=l}return{startRow:a,endRow:a+i.length}}var o=n(91638),a=n(45069),c=n(84175),l=n(46487),u=n(93675),d=n(9350),h=n(36077),f=n(25337);const p="layout(std140) uniform scatterplotUniforms {\n float radiusScale;\n float radiusMinPixels;\n float radiusMaxPixels;\n float lineWidthScale;\n float lineWidthMinPixels;\n float lineWidthMaxPixels;\n float stroked;\n float filled;\n bool antialiasing;\n bool billboard;\n highp int radiusUnits;\n highp int lineWidthUnits;\n} scatterplot;\n",g={name:"scatterplot",vs:p,fs:p,source:"",uniformTypes:{radiusScale:"f32",radiusMinPixels:"f32",radiusMaxPixels:"f32",lineWidthScale:"f32",lineWidthMinPixels:"f32",lineWidthMaxPixels:"f32",stroked:"f32",filled:"f32",antialiasing:"f32",billboard:"f32",radiusUnits:"i32",lineWidthUnits:"i32"}},m="// Main shaders\n\nstruct ScatterplotUniforms {\n radiusScale: f32,\n radiusMinPixels: f32,\n radiusMaxPixels: f32,\n lineWidthScale: f32,\n lineWidthMinPixels: f32,\n lineWidthMaxPixels: f32,\n stroked: f32,\n filled: i32,\n antialiasing: i32,\n billboard: i32,\n radiusUnits: i32,\n lineWidthUnits: i32,\n};\n\n@group(0) @binding(0) var<uniform> scatterplot: ScatterplotUniforms;\n\nstruct Attributes {\n @builtin(instance_index) instanceIndex : u32,\n @builtin(vertex_index) vertexIndex : u32,\n @location(0) positions: vec3<f32>,\n @location(1) instancePositions: vec3<f32>,\n @location(2) instancePositions64Low: vec3<f32>,\n @location(3) instanceRadius: f32,\n @location(4) instanceLineWidths: f32,\n @location(5) instanceFillColors: vec4<f32>,\n @location(6) instanceLineColors: vec4<f32>,\n @location(7) instancePixelOffset: vec2<f32>,\n PICKING_COLOR_ATTRIBUTE\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n @location(0) vFillColor: vec4<f32>,\n @location(1) vLineColor: vec4<f32>,\n @location(2) unitPosition: vec2<f32>,\n @location(3) innerUnitRadius: f32,\n @location(4) outerRadiusPixels: f32,\n @location(5) pickingColor: vec3<f32>,\n @location(6) clipCoordinates: vec2<f32>,\n};\n\n@vertex\nfn vertexMain(attributes: Attributes) -> Varyings {\n var varyings: Varyings;\n\n // Draw an inline geometry constant array clip space triangle to verify that rendering works.\n // var positions = array<vec2<f32>, 3>(vec2(0.0, 0.5), vec2(-0.5, -0.5), vec2(0.5, -0.5));\n // if (attributes.instanceIndex == 0) {\n // varyings.position = vec4<f32>(positions[attributes.vertexIndex], 0.0, 1.0);\n // return varyings;\n // }\n\n geometry.worldPosition = attributes.instancePositions;\n\n // Multiply out radius and clamp to limits\n varyings.outerRadiusPixels = clamp(\n project_unit_size_to_pixel(scatterplot.radiusScale * attributes.instanceRadius, scatterplot.radiusUnits),\n scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels\n );\n\n // Multiply out line width and clamp to limits\n let lineWidthPixels = clamp(\n project_unit_size_to_pixel(scatterplot.lineWidthScale * attributes.instanceLineWidths, scatterplot.lineWidthUnits),\n scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels\n );\n\n // outer radius needs to offset by half stroke width\n varyings.outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0;\n // Expand geometry to accommodate edge smoothing\n // WGSL selects the second value when the condition is true, so keep the antialiased path second.\n let edgePadding = select(\n 1.0,\n (varyings.outerRadiusPixels + SMOOTH_EDGE_RADIUS) / varyings.outerRadiusPixels,\n scatterplot.antialiasing != 0\n );\n\n // position on the containing square in [-1, 1] space\n varyings.unitPosition = edgePadding * attributes.positions.xy;\n geometry.uv = varyings.unitPosition;\n geometry.pickingColor = PICKING_COLOR_VALUE;\n\n varyings.innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / varyings.outerRadiusPixels;\n\n if (scatterplot.billboard != 0) {\n let projectedPosition = project_position_to_clipspace_and_commonspace(\n attributes.instancePositions,\n attributes.instancePositions64Low,\n vec3<f32>(0.0)\n );\n geometry.position = projectedPosition.commonPosition;\n varyings.position = projectedPosition.clipPosition;\n // DECKGL_FILTER_GL_POSITION(varyings.position, geometry);\n var offset = edgePadding * attributes.positions * varyings.outerRadiusPixels;\n offset = vec3<f32>(offset.xy + attributes.instancePixelOffset, offset.z);\n // DECKGL_FILTER_SIZE(offset, geometry);\n let clipPixels = project_pixel_size_to_clipspace(offset.xy);\n varyings.position = vec4<f32>(varyings.position.x + clipPixels.x, varyings.position.y + clipPixels.y, varyings.position.z, varyings.position.w);\n geometry.position = vec4<f32>(\n geometry.position.xy + project_pixel_size_vec2(offset.xy),\n geometry.position.zw\n );\n } else {\n var offset = edgePadding * attributes.positions * project_pixel_size_float(varyings.outerRadiusPixels);\n offset = vec3<f32>(offset.xy + project_pixel_size_vec2(attributes.instancePixelOffset), offset.z);\n // DECKGL_FILTER_SIZE(offset, geometry);\n let projectedPosition = project_position_to_clipspace_and_commonspace(\n attributes.instancePositions,\n attributes.instancePositions64Low,\n offset\n );\n geometry.position = projectedPosition.commonPosition;\n varyings.position = projectedPosition.clipPosition;\n // DECKGL_FILTER_GL_POSITION(varyings.position, geometry);\n }\n\n varyings.clipCoordinates = geometry.position.xy;\n clip_filterPosition(&varyings.position, geometry.worldPosition.xy);\n\n // Apply opacity to instance color, or return instance picking color\n varyings.vFillColor = vec4<f32>(attributes.instanceFillColors.rgb, attributes.instanceFillColors.a * layer.opacity);\n // DECKGL_FILTER_COLOR(varyings.vFillColor, geometry);\n varyings.vLineColor = vec4<f32>(attributes.instanceLineColors.rgb, attributes.instanceLineColors.a * layer.opacity);\n // DECKGL_FILTER_COLOR(varyings.vLineColor, geometry);\n varyings.pickingColor = geometry.pickingColor;\n\n return varyings;\n}\n\n@fragment\nfn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {\n // var geometry: Geometry;\n // geometry.uv = unitPosition;\n\n let distToCenter = length(varyings.unitPosition) * varyings.outerRadiusPixels;\n let inCircle = select(\n step(distToCenter, varyings.outerRadiusPixels),\n smoothedge(distToCenter, varyings.outerRadiusPixels),\n scatterplot.antialiasing != 0\n );\n\n if (inCircle == 0.0) {\n discard;\n }\n\n var fragColor: vec4<f32>;\n\n if (scatterplot.stroked != 0) {\n let isLine = select(\n step(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter),\n smoothedge(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter),\n scatterplot.antialiasing != 0\n );\n\n if (scatterplot.filled != 0) {\n fragColor = mix(varyings.vFillColor, varyings.vLineColor, isLine);\n } else {\n if (isLine == 0.0) {\n discard;\n }\n fragColor = vec4<f32>(varyings.vLineColor.rgb, varyings.vLineColor.a * isLine);\n }\n } else if (scatterplot.filled == 0) {\n discard;\n } else {\n fragColor = varyings.vFillColor;\n }\n\n fragColor.a *= inCircle;\n\n clip_filterColor(varyings.clipCoordinates);\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(varyings.pickingColor)) {\n discard;\n }\n return vec4<f32>(varyings.pickingColor, 1.0);\n }\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {\n let highLightAlpha = picking.highlightColor.a;\n let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);\n if (blendedAlpha > 0.0) {\n let highLightRatio = highLightAlpha / blendedAlpha;\n fragColor = vec4<f32>(\n mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),\n blendedAlpha\n );\n } else {\n fragColor = vec4<f32>(fragColor.rgb, 0.0);\n }\n }\n }\n\n // Apply premultiplied alpha as required by transparent canvas\n fragColor = deckgl_premultiplied_alpha(fragColor);\n\n return fragColor;\n // return vec4<f32>(0, 0, 1, 1);\n}\n";function v(e){return m.replace("PICKING_COLOR_ATTRIBUTE",e?"@location(8) rowIndexes: u32,":"").replace("PICKING_COLOR_VALUE",e?"picking_getPickingColorFromIndex(attributes.rowIndexes)":"picking_getPickingColorFromIndex(attributes.instanceIndex)")}var y=n(86402);const b=[0,0,0,255],_={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:e=>e.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:b},getLineColor:{type:"accessor",value:b},getLineWidth:{type:"accessor",value:1},getPixelOffset:{type:"accessor",value:[0,0]},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}};class ScatterplotLayer extends a.A{getShaders(){const e=Boolean(this.props.data?.attributes?.rowIndexes);return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME scatterplot-layer-vertex-shader\nin vec3 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin float instanceRadius;\nin float instanceLineWidths;\nin vec4 instanceFillColors;\nin vec4 instanceLineColors;\n#ifdef USE_ROW_INDEXES\nin float rowIndexes;\n#endif\nin vec2 instancePixelOffset;\nout vec4 vFillColor;\nout vec4 vLineColor;\nout vec2 unitPosition;\nout float innerUnitRadius;\nout float outerRadiusPixels;\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\nouterRadiusPixels = clamp(\nproject_size_to_pixel(scatterplot.radiusScale * instanceRadius, scatterplot.radiusUnits),\nscatterplot.radiusMinPixels, scatterplot.radiusMaxPixels\n);\nfloat lineWidthPixels = clamp(\nproject_size_to_pixel(scatterplot.lineWidthScale * instanceLineWidths, scatterplot.lineWidthUnits),\nscatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels\n);\nouterRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0;\nfloat edgePadding = scatterplot.antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0;\nunitPosition = edgePadding * positions.xy;\ngeometry.uv = unitPosition;\n#ifdef USE_ROW_INDEXES\ngeometry.pickingColor = picking_getPickingColorFromIndex(rowIndexes);\n#else\ngeometry.pickingColor = picking_getPickingColorFromInstanceID();\n#endif\ninnerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / outerRadiusPixels;\nif (scatterplot.billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = edgePadding * positions * outerRadiusPixels;\noffset.xy += instancePixelOffset;\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels);\noffset.xy += project_pixel_size(instancePixelOffset);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nvFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vFillColor, geometry);\nvLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vLineColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME scatterplot-layer-fragment-shader\nprecision highp float;\nin vec4 vFillColor;\nin vec4 vLineColor;\nin vec2 unitPosition;\nin float innerUnitRadius;\nin float outerRadiusPixels;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = unitPosition;\nfloat distToCenter = length(unitPosition) * outerRadiusPixels;\nfloat inCircle = scatterplot.antialiasing ?\nsmoothedge(distToCenter, outerRadiusPixels) :\nstep(distToCenter, outerRadiusPixels);\nif (inCircle == 0.0) {\ndiscard;\n}\nif (scatterplot.stroked > 0.5) {\nfloat isLine = scatterplot.antialiasing ?\nsmoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) :\nstep(innerUnitRadius * outerRadiusPixels, distToCenter);\nif (scatterplot.filled > 0.5) {\nfragColor = mix(vFillColor, vLineColor, isLine);\n} else {\nif (isLine == 0.0) {\ndiscard;\n}\nfragColor = vec4(vLineColor.rgb, vLineColor.a * isLine);\n}\n} else if (scatterplot.filled < 0.5) {\ndiscard;\n} else {\nfragColor = vFillColor;\n}\nfragColor.a *= inCircle;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:v(e),defines:e?{USE_ROW_INDEXES:!0}:{},modules:[c.A,l.A,u.Ay,g,..."webgpu"===this.context.device.type?[y.A]:[]]})}initializeState(){const e=this.props.data?.attributes?.rowIndexes?{rowIndexes:{size:1,type:"uint32",noAlloc:!0}}:{};this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1,bufferGroup:"scatterplot-instance-data"},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255],bufferGroup:"scatterplot-instance-data"},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255],bufferGroup:"scatterplot-instance-data"},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1,bufferGroup:"scatterplot-instance-data"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset",bufferGroup:"scatterplot-instance-data"},...e})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{radiusUnits:t,radiusScale:n,radiusMinPixels:i,radiusMaxPixels:r,stroked:s,filled:o,billboard:a,antialiasing:c,lineWidthUnits:l,lineWidthScale:u,lineWidthMinPixels:h,lineWidthMaxPixels:f}=this.props,p={stroked:s,filled:o,billboard:a,antialiasing:c,radiusUnits:d.p5[t],radiusScale:n,radiusMinPixels:i,radiusMaxPixels:r,lineWidthUnits:d.p5[l],lineWidthScale:u,lineWidthMinPixels:h,lineWidthMaxPixels:f},g=this.state.model;g.shaderInputs.setProps({scatterplot:p}),g.draw(this.context.renderPass)}_getModel(){return new h.K(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new f.V({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array([-1,-1,0,1,-1,0,-1,1,0,1,1,0])}}}),isInstanced:!0})}}ScatterplotLayer.defaultProps=_,ScatterplotLayer.layerName="ScatterplotLayer";const x=ScatterplotLayer;var w=n(65981),P=n(56802);const C=0,S={rgba8unorm:4,rgba16float:8,rgba32float:16},L={...S},A={useByteColors:"f32"},E={useByteColors:!0},T=(Uint32Array.BYTES_PER_ELEMENT,M("colors"),M("floatColors"));I("colors");function M(e){return`layout(std140) uniform ${e}Uniforms {\n float useByteColors;\n} ${e};\n\nvec3 ${e}_normalize(vec3 inputColor) {\n return ${e}.useByteColors > 0.5 ? inputColor / 255.0 : inputColor;\n}\n\nvec4 ${e}_normalize(vec4 inputColor) {\n return ${e}.useByteColors > 0.5 ? inputColor / 255.0 : inputColor;\n}\n\nvec4 ${e}_premultiplyAlpha(vec4 inputColor) {\n return vec4(inputColor.rgb * inputColor.a, inputColor.a);\n}\n\nvec4 ${e}_unpremultiplyAlpha(vec4 inputColor) {\n return inputColor.a > 0.0 ? vec4(inputColor.rgb / inputColor.a, inputColor.a) : vec4(0.0);\n}\n\nvec4 ${e}_premultiply_alpha(vec4 inputColor) {\n return ${e}_premultiplyAlpha(inputColor);\n}\n\nvec4 ${e}_unpremultiply_alpha(vec4 inputColor) {\n return ${e}_unpremultiplyAlpha(inputColor);\n}\n`}function I(e){return`struct ${e}Uniforms {\n useByteColors: f32\n};\n\n@group(0) @binding(auto) var<uniform> ${e} : ${e}Uniforms;\n\nfn ${e}_normalize(inputColor: vec3<f32>) -> vec3<f32> {\n return select(inputColor, inputColor / 255.0, ${e}.useByteColors > 0.5);\n}\n\nfn ${e}_normalize4(inputColor: vec4<f32>) -> vec4<f32> {\n return select(inputColor, inputColor / 255.0, ${e}.useByteColors > 0.5);\n}\n\nfn ${e}_premultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> {\n return vec4<f32>(inputColor.rgb * inputColor.a, inputColor.a);\n}\n\nfn ${e}_unpremultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> {\n return select(\n vec4<f32>(0.0),\n vec4<f32>(inputColor.rgb / inputColor.a, inputColor.a),\n inputColor.a > 0.0\n );\n}\n\nfn ${e}_premultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {\n return ${e}_premultiplyAlpha(inputColor);\n}\n\nfn ${e}_unpremultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {\n return ${e}_unpremultiplyAlpha(inputColor);\n}\n`}const B={name:"floatColors",props:{},uniforms:{},vs:T,fs:T,source:I("floatColors"),uniformTypes:A,defaultUniforms:E};var k=n(29651);const R="precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct SpotLight {\n vec3 color;\n vec3 position;\n vec3 direction;\n vec3 attenuation;\n vec2 coneCos;\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nstruct UniformLight {\n vec3 color;\n vec3 position;\n vec3 direction;\n vec3 attenuation;\n vec2 coneCos;\n};\n\nlayout(std140) uniform lightingUniforms {\n int enabled;\n int directionalLightCount;\n int pointLightCount;\n int spotLightCount;\n vec3 ambientColor;\n UniformLight lights[5];\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n UniformLight light = lighting.lights[index];\n return PointLight(light.color, light.position, light.attenuation);\n}\n\nSpotLight lighting_getSpotLight(int index) {\n UniformLight light = lighting.lights[lighting.pointLightCount + index];\n return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n UniformLight light =\n lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];\n return DirectionalLight(light.color, light.direction);\n}\n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\nfloat getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) {\n vec3 light_direction = normalize(positionWorldspace - spotLight.position);\n float coneFactor = smoothstep(\n spotLight.coneCos.y,\n spotLight.coneCos.x,\n dot(normalize(spotLight.direction), light_direction)\n );\n float distanceAttenuation = getPointLightAttenuation(\n PointLight(spotLight.color, spotLight.position, spotLight.attenuation),\n distance(spotLight.position, positionWorldspace)\n );\n return distanceAttenuation / max(coneFactor, 0.0001);\n}\n\n// #endif\n";var O=n(55611);const z={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3<f32>",lights:[{color:"vec3<f32>",position:"vec3<f32>",direction:"vec3<f32>",attenuation:"vec3<f32>",coneCos:"vec2<f32>"},5]},defaultUniforms:$(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:"// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nconst MAX_LIGHTS: i32 = 5;\n\nstruct AmbientLight {\n color: vec3<f32>,\n};\n\nstruct PointLight {\n color: vec3<f32>,\n position: vec3<f32>,\n attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct SpotLight {\n color: vec3<f32>,\n position: vec3<f32>,\n direction: vec3<f32>,\n attenuation: vec3<f32>,\n coneCos: vec2<f32>,\n};\n\nstruct DirectionalLight {\n color: vec3<f32>,\n direction: vec3<f32>,\n};\n\nstruct UniformLight {\n color: vec3<f32>,\n position: vec3<f32>,\n direction: vec3<f32>,\n attenuation: vec3<f32>,\n coneCos: vec2<f32>,\n};\n\nstruct lightingUniforms {\n enabled: i32,\n directionalLightCount: i32,\n pointLightCount: i32,\n spotLightCount: i32,\n ambientColor: vec3<f32>,\n lights: array<UniformLight, 5>,\n};\n\n@group(2) @binding(auto) var<uniform> lighting : lightingUniforms;\n\nfn lighting_getPointLight(index: i32) -> PointLight {\n let light = lighting.lights[index];\n return PointLight(light.color, light.position, light.attenuation);\n}\n\nfn lighting_getSpotLight(index: i32) -> SpotLight {\n let light = lighting.lights[lighting.pointLightCount + index];\n return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);\n}\n\nfn lighting_getDirectionalLight(index: i32) -> DirectionalLight {\n let light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];\n return DirectionalLight(light.color, light.direction);\n}\n\nfn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\nfn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>) -> f32 {\n let lightDirection = normalize(positionWorldspace - spotLight.position);\n let coneFactor = smoothstep(\n spotLight.coneCos.y,\n spotLight.coneCos.x,\n dot(normalize(spotLight.direction), lightDirection)\n );\n let distanceAttenuation = getPointLightAttenuation(\n PointLight(spotLight.color, spotLight.position, spotLight.attenuation),\n distance(spotLight.position, positionWorldspace)\n );\n return distanceAttenuation / max(coneFactor, 0.0001);\n}\n",vs:R,fs:R,getUniforms:function(e,t={}){if(!(e=e?{...e}:e))return $();e.lights&&(e={...e,...F(e.lights),lights:void 0});const{useByteColors:n,ambientLight:i,pointLights:r,spotLights:s,directionalLights:o}=e||{};if(!(i||r&&r.length>0||s&&s.length>0||o&&o.length>0))return{...$(),enabled:0};const a={...$(),...D({useByteColors:n,ambientLight:i,pointLights:r,spotLights:s,directionalLights:o})};void 0!==e.enabled&&(a.enabled=e.enabled?1:0);return a}};function D({useByteColors:e,ambientLight:t,pointLights:n=[],spotLights:i=[],directionalLights:r=[]}){const s=U();let o=0,a=0,c=0,l=0;for(const t of n){if(o>=5)break;s[o]={...s[o],color:N(t,e),position:t.position,attenuation:t.attenuation||[1,0,0]},o++,a++}for(const t of i){if(o>=5)break;s[o]={...s[o],color:N(t,e),position:t.position,direction:t.direction,attenuation:t.attenuation||[1,0,0],coneCos:V(t)},o++,c++}for(const t of r){if(o>=5)break;s[o]={...s[o],color:N(t,e),direction:t.direction},o++,l++}return n.length+i.length+r.length>5&&k.R.warn("MAX_LIGHTS exceeded, truncating to 5")(),{ambientColor:N(t,e),directionalLightCount:l,pointLightCount:a,spotLightCount:c,lights:s}}function F(e){const t={pointLights:[],spotLights:[],directionalLights:[]};for(const n of e||[])switch(n.type){case"ambient":t.ambientLight=n;break;case"directional":t.directionalLights?.push(n);break;case"point":t.pointLights?.push(n);break;case"spot":t.spotLights?.push(n)}return t}function N(e={},t){const{color:n=[0,0,0],intensity:i=1}=e;return(0,O.sC)(n,(0,O.eS)(t,!0)).map(e=>e*i)}function $(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:U()}}function U(){return Array.from({length:5},()=>({color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}))}function V(e){const t=e.innerConeAngle??0,n=e.outerConeAngle??Math.PI/4;return[Math.cos(t),Math.cos(n)]}const G="layout(std140) uniform phongMaterialUniforms {\n uniform bool unlit;\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n",j="struct phongMaterialUniforms {\n unlit: u32,\n ambient: f32,\n diffuse: f32,\n shininess: f32,\n specularColor: vec3<f32>,\n};\n\n@group(3) @binding(auto) var<uniform> phongMaterial : phongMaterialUniforms;\n\nfn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, view_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> {\n let halfway_direction: vec3<f32> = normalize(light_direction + view_direction);\n var lambertian: f32 = dot(light_direction, normal_worldspace);\n var specular: f32 = 0.0;\n if (lambertian > 0.0) {\n let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, phongMaterial.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (\n lambertian * phongMaterial.diffuse * surfaceColor +\n specular * floatColors_normalize(phongMaterial.specularColor)\n ) * color;\n}\n\nfn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {\n var lightColor: vec3<f32> = surfaceColor;\n\n if (phongMaterial.unlit != 0u) {\n return surfaceColor;\n }\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n let view_direction: vec3<f32> = normalize(cameraPosition - position_worldspace);\n lightColor = phongMaterial.ambient * surfaceColor * lighting.ambientColor;\n\n for (var i: i32 = 0; i < lighting.pointLightCount; i++) {\n let pointLight: PointLight = lighting_getPointLight(i);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getPointLightAttenuation(\n pointLight,\n distance(light_position_worldspace, position_worldspace)\n );\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n pointLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.spotLightCount; i++) {\n let spotLight: SpotLight = lighting_getSpotLight(i);\n let light_position_worldspace: vec3<f32> = spotLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n spotLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n } \n \n return lightColor;\n}\n\nfn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32>{\n var lightColor = vec3<f32>(0, 0, 0);\n let surfaceColor = vec3<f32>(0, 0, 0);\n\n if (lighting.enabled != 0) {\n let view_direction = normalize(cameraPosition - position_worldspace);\n\n for (var i: i32 = 0; i < lighting.pointLightCount; i++) {\n let pointLight: PointLight = lighting_getPointLight(i);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getPointLightAttenuation(\n pointLight,\n distance(light_position_worldspace, position_worldspace)\n );\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n pointLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.spotLightCount; i++) {\n let spotLight: SpotLight = lighting_getSpotLight(i);\n let light_position_worldspace: vec3<f32> = spotLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n spotLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n return lightColor;\n}\n",W={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:"layout(std140) uniform phongMaterialUniforms {\n uniform bool unlit;\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, material.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * material.diffuse * surfaceColor + specular * floatColors_normalize(material.specularColor)) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (material.unlit) {\n return surfaceColor;\n }\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = material.ambient * surfaceColor * lighting.ambientColor;\n\n for (int i = 0; i < lighting.pointLightCount; i++) {\n PointLight pointLight = lighting_getPointLight(i);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace));\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);\n }\n\n for (int i = 0; i < lighting.spotLightCount; i++) {\n SpotLight spotLight = lighting_getSpotLight(i);\n vec3 light_position_worldspace = spotLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n float light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, spotLight.color / light_attenuation);\n }\n\n for (int i = 0; i < lighting.directionalLightCount; i++) {\n DirectionalLight directionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n \n return lightColor;\n}\n".replace("phongMaterial","gouraudMaterial"),fs:G.replace("phongMaterial","gouraudMaterial"),source:j.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[z,B],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:[38.25,38.25,38.25]},getUniforms:e=>({...W.defaultUniforms,...e})};i();var H=n(18135);const q=H.rJ.CLOCKWISE,Z=H.rJ.COUNTER_CLOCKWISE,Y={isClosed:!0};function K(e){return"positions"in e?e.positions:e}function Q(e){return"holeIndices"in e?e.holeIndices:null}function X(e,t,n,i,r){let s=t;const o=n.length;for(let t=0;t<o;t++)for(let r=0;r<i;r++)e[s++]=n[t][r]||0;if(!function(e){const t=e[0],n=e[e.length-1];return t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]}(n))for(let t=0;t<i;t++)e[s++]=n[0][t]||0;return Y.start=t,Y.end=s,Y.size=i,(0,H.UD)(e,r,Y),s}function J(e,t,n,i,r=0,s,o){const a=(s=s||n.length)-r;if(a<=0)return t;let c=t;for(let t=0;t<a;t++)e[c++]=n[r+t];if(!function(e,t,n,i){for(let r=0;r<t;r++)if(e[n+r]!==e[i-t+r])return!1;return!0}(n,i,r,s))for(let t=0;t<i;t++)e[c++]=n[r+t];return Y.start=t,Y.end=c,Y.size=i,(0,H.UD)(e,o,Y),c}function ee(e,t){!function(e){if(e=e&&e.positions||e,!Array.isArray(e)&&!ArrayBuffer.isView(e))throw new Error("invalid polygon")}(e);const n=[],i=[];if("positions"in e){const{positions:r,holeIndices:s}=e;if(s){let e=0;for(let o=0;o<=s.length;o++)e=J(n,e,r,t,s[o-1],s[o],0===o?q:Z),i.push(e);return i.pop(),{positions:n,holeIndices:i}}e=r}if(!function(e){return Array.isArray(e[0])}(e))return J(n,0,e,t,0,n.length,q),n;if(!function(e){return e.length>=1&&e[0].length>=2&&Number.isFinite(e[0][0])}(e)){let r=0;for(const[s,o]of e.entries())r=X(n,r,o,t,0===s?q:Z),i.push(r);return i.pop(),{positions:n,holeIndices:i}}return X(n,0,e,t,q),n}function te(e,t,n){const i=e.length/3;let r=0;for(let s=0;s<i;s++){const o=(s+1)%i;r+=e[3*s+t]*e[3*o+n],r-=e[3*o+t]*e[3*s+n]}return Math.abs(r/2)}function ne(e,t,n,i){const r=e.length/3;for(let s=0;s<r;s++){const r=3*s,o=e[r+0],a=e[r+1],c=e[r+2];e[r+t]=o,e[r+n]=a,e[r+i]=c}}var ie=n(44941),re=n(18584),se=n(6423);class PolygonTesselator extends ie.A{constructor(e){const{fp64:t,IndexType:n=Uint32Array}=e;super({...e,attributes:{positions:{size:3,type:t?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:n,size:1}}})}get(e){const{attributes:t}=this;return"indices"===e?t.indices&&t.indices.subarray(0,this.vertexCount):t[e]}updateGeometry(e){super.updateGeometry(e);const t=this.buffers.indices;if(t)this.vertexCount=(t.value||t).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(e){if(this.normalize){const t=ee(e,this.positionSize);return this.opts.resolution?(0,re.w)(K(t),Q(t),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?(0,se.E)(K(t),Q(t),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):t}return e}getGeometrySize(e){if(oe(e)){let t=0;for(const n of e)t+=this.getGeometrySize(n);return t}return K(e).length/this.positionSize}getGeometryFromBuffer(e){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(e):null}updateGeometryAttributes(e,t){if(e&&oe(e))for(const n of e){const e=this.getGeometrySize(n);t.geometrySize=e,this.updateGeometryAttributes(n,t),t.vertexStart+=e,t.indexStart=this.indexStarts[t.geometryIndex+1]}else{const n=e;this._updateIndices(n,t),this._updatePositions(n,t),this._updateVertexValid(n,t)}}_updateIndices(e,{geometryIndex:t,vertexStart:n,indexStart:r}){const{attributes:s,indexStarts:o,typedArrayManager:a}=this;let c=s.indices;if(!c||!e)return;let l=r;const u=function(e,t,n,r){let s=Q(e);s&&(s=s.map(e=>e/t));let o=K(e);const a=r&&3===t;if(n){const e=o.length;o=o.slice();const i=[];for(let r=0;r<e;r+=t){i[0]=o[r],i[1]=o[r+1],a&&(i[2]=o[r+2]);const e=n(i);o[r]=e[0],o[r+1]=e[1],a&&(o[r+2]=e[2])}}if(a){const e=te(o,0,1),t=te(o,0,2),i=te(o,1,2);if(!e&&!t&&!i)return[];e>t&&e>i||(t>i?(n||(o=o.slice()),ne(o,0,2,1)):(n||(o=o.slice()),ne(o,2,0,1)))}return i()(o,s,t)}(e,this.positionSize,this.opts.preproject,this.opts.full3d);c=a.allocate(c,r+u.length,{copy:!0});for(let e=0;e<u.length;e++)c[l++]=u[e]+n;o[t+1]=r+u.length,s.indices=c}_updatePositions(e,{vertexStart:t,geometrySize:n}){const{attributes:{positions:i},positionSize:r}=this;if(!i||!e)return;const s=K(e);for(let e=t,o=0;o<n;e++,o++){const t=s[o*r],n=s[o*r+1],a=r>2?s[o*r+2]:0;i[3*e]=t,i[3*e+1]=n,i[3*e+2]=a}}_updateVertexValid(e,{vertexStart:t,geometrySize:n}){const{positionSize:i}=this,r=this.attributes.vertexValid,s=e&&Q(e);if(e&&e.edgeTypes?r.set(e.edgeTypes,t):r.fill(1,t,t+n),s)for(let e=0;e<s.length;e++)r[t+s[e]/i-1]=0;r[t+n-1]=0}}function oe(e){return Array.isArray(e)&&e.length>0&&!Number.isFinite(e[0])}const ae="layout(std140) uniform solidPolygonUniforms {\n bool extruded;\n bool isWireframe;\n float elevationScale;\n} solidPolygon;\n",ce={name:"solidPolygon",source:"struct SolidPolygonUniforms {\n extruded: f32,\n isWireframe: f32,\n elevationScale: f32,\n};\n\n@group(0) @binding(auto) var<uniform> solidPolygon: SolidPolygonUniforms;\n",vs:ae,fs:ae,uniformTypes:{extruded:"f32",isWireframe:"f32",elevationScale:"f32"}},le="in vec4 fillColors;\nin vec4 lineColors;\nin float rowIndexes;\nout vec4 vColor;\nstruct PolygonProps {\nvec3 positions;\nvec3 positions64Low;\nvec3 normal;\nfloat elevations;\n};\nvec3 project_offset_normal(vec3 vector) {\nif (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\nproject.coordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) {\nreturn normalize(vector * project.commonUnitsPerWorldUnit);\n}\nreturn project_normal(vector);\n}\nvoid calculatePosition(PolygonProps props) {\nvec3 pos = props.positions;\nvec3 pos64Low = props.positions64Low;\nvec3 normal = props.normal;\nvec4 colors = solidPolygon.isWireframe ? lineColors : fillColors;\ngeometry.worldPosition = props.positions;\ngeometry.pickingColor = picking_getPickingColorFromIndex(rowIndexes);\nif (solidPolygon.extruded) {\npos.z += props.elevations * solidPolygon.elevationScale;\n}\ngl_Position = project_position_to_clipspace(pos, pos64Low, vec3(0.), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nif (solidPolygon.extruded) {\n#ifdef IS_SIDE_VERTEX\nnormal = project_offset_normal(normal);\n#else\nnormal = project_normal(normal);\n#endif\ngeometry.normal = normal;\nvec3 lightColor = lighting_getLightColor(colors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\nvColor = vec4(lightColor, colors.a * layer.opacity);\n} else {\nvColor = vec4(colors.rgb, colors.a * layer.opacity);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",ue=`#version 300 es\n#define SHADER_NAME solid-polygon-layer-vertex-shader\nin vec3 vertexPositions;\nin vec3 vertexPositions64Low;\nin float elevations;\n${le}\nvoid main(void) {\nPolygonProps props;\nprops.positions = vertexPositions;\nprops.positions64Low = vertexPositions64Low;\nprops.elevations = elevations;\nprops.normal = vec3(0.0, 0.0, 1.0);\ncalculatePosition(props);\n}\n`,de=`#version 300 es\n#define SHADER_NAME solid-polygon-layer-vertex-shader-side\n#define IS_SIDE_VERTEX\nin vec2 positions;\nin vec3 vertexPositions;\nin vec3 nextVertexPositions;\nin vec3 vertexPositions64Low;\nin vec3 nextVertexPositions64Low;\nin float elevations;\nin float instanceVertexValid;\n${le}\nvoid main(void) {\nif(instanceVertexValid < 0.5){\ngl_Position = vec4(0.);\nreturn;\n}\nPolygonProps props;\nvec3 pos;\nvec3 pos64Low;\nvec3 nextPos;\nvec3 nextPos64Low;\n#if RING_WINDING_ORDER_CW == 1\npos = vertexPositions;\npos64Low = vertexPositions64Low;\nnextPos = nextVertexPositions;\nnextPos64Low = nextVertexPositions64Low;\n#else\npos = nextVertexPositions;\npos64Low = nextVertexPositions64Low;\nnextPos = vertexPositions;\nnextPos64Low = vertexPositions64Low;\n#endif\nprops.positions = mix(pos, nextPos, positions.x);\nprops.positions64Low = mix(pos64Low, nextPos64Low, positions.x);\nprops.normal = vec3(\npos.y - nextPos.y + (pos64Low.y - nextPos64Low.y),\nnextPos.x - pos.x + (nextPos64Low.x - pos64Low.x),\n0.0);\nprops.elevations = elevations * positions.y;\ncalculatePosition(props);\n}\n`;function he(e,t){return"top"===e?"fn project_offset_normal(vector: vec3<f32>) -> vec3<f32> {\n if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) {\n return normalize(vector * project.commonUnitsPerWorldUnit);\n }\n return project_normal(vector);\n}\n\nfn apply_polygon_color(\n colors: vec4<f32>,\n normal: vec3<f32>,\n position: vec4<f32>\n) -> vec4<f32> {\n if (solidPolygon.extruded > 0.5) {\n let lightColor = lighting_getLightColor2(\n colors.rgb,\n project.cameraPosition,\n position.xyz,\n normal\n );\n return vec4<f32>(lightColor, colors.a * layer.opacity);\n }\n return vec4<f32>(colors.rgb, colors.a * layer.opacity);\n}\n\n\nstruct Attributes {\n @location(0) vertexPositions: vec3<f32>,\n @location(1) vertexPositions64Low: vec3<f32>,\n @location(2) elevations: f32,\n @location(3) fillColors: vec4<f32>,\n @location(4) lineColors: vec4<f32>,\n @location(5) rowIndexes: u32,\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n @location(0) vColor: vec4<f32>,\n @location(1) pickingColor: vec3<f32>,\n @location(2) clipCoordinates: vec2<f32>,\n};\n\n@vertex\nfn vertexMain(attributes: Attributes) -> Varyings {\n var outp: Varyings;\n\n var pos = attributes.vertexPositions;\n if (solidPolygon.extruded > 0.5) {\n pos.z += attributes.elevations * solidPolygon.elevationScale;\n }\n\n geometry.worldPosition = attributes.vertexPositions;\n geometry.pickingColor = picking_getPickingColorFromIndex(attributes.rowIndexes);\n\n let projectedPosition = project_position_to_clipspace_and_commonspace(\n pos,\n attributes.vertexPositions64Low,\n vec3<f32>(0.0)\n );\n geometry.position = projectedPosition.commonPosition;\n outp.position = projectedPosition.clipPosition;\n\n let normal = project_normal(vec3<f32>(0.0, 0.0, 1.0));\n geometry.normal = normal;\n\n let colors = select(\n attributes.fillColors,\n attributes.lineColors,\n solidPolygon.isWireframe > 0.5\n );\n outp.vColor = apply_polygon_color(colors, normal, geometry.position);\n outp.pickingColor = geometry.pickingColor;\n\n outp.clipCoordinates = geometry.position.xy;\n clip_filterPosition(&outp.position, geometry.worldPosition.xy);\n\n return outp;\n}\n\n@fragment\nfn fragmentMain(inp: Varyings) -> @location(0) vec4<f32> {\n geometry.uv = vec2<f32>(0.0, 0.0);\n\n clip_filterColor(inp.clipCoordinates);\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(inp.pickingColor)) {\n discard;\n }\n return vec4<f32>(inp.pickingColor, 1.0);\n }\n\n var fragColor = inp.vColor;\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(inp.pickingColor - highlightedObjectColor))) {\n let highLightAlpha = picking.highlightColor.a;\n let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);\n if (blendedAlpha > 0.0) {\n let highLightRatio = highLightAlpha / blendedAlpha;\n fragColor = vec4<f32>(\n mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),\n blendedAlpha\n );\n } else {\n fragColor = vec4<f32>(fragColor.rgb, 0.0);\n }\n }\n }\n\n return deckgl_premultiplied_alpha(fragColor);\n}\n\n":function(e){return`const RING_WINDING_ORDER_CW: bool = ${e?"true":"false"};\n\nfn project_offset_normal(vector: vec3<f32>) -> vec3<f32> {\n if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) {\n return normalize(vector * project.commonUnitsPerWorldUnit);\n }\n return project_normal(vector);\n}\n\nfn apply_polygon_color(\n colors: vec4<f32>,\n normal: vec3<f32>,\n position: vec4<f32>\n) -> vec4<f32> {\n if (solidPolygon.extruded > 0.5) {\n let lightColor = lighting_getLightColor2(\n colors.rgb,\n project.cameraPosition,\n position.xyz,\n normal\n );\n return vec4<f32>(lightColor, colors.a * layer.opacity);\n }\n return vec4<f32>(colors.rgb, colors.a * layer.opacity);\n}\n\n\nstruct Attributes {\n @location(0) positions: vec2<f32>,\n @location(1) vertexPositions: vec3<f32>,\n @location(2) vertexPositions64Low: vec3<f32>,\n @location(3) nextVertexPositions: vec3<f32>,\n @location(4) nextVertexPositions64Low: vec3<f32>,\n @location(5) vertexValid: f32,\n @location(6) elevations: f32,\n @location(7) fillColors: vec4<f32>,\n @location(8) lineColors: vec4<f32>,\n @location(9) rowIndexes: u32,\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n @location(0) vColor: vec4<f32>,\n @location(1) pickingColor: vec3<f32>,\n @location(2) clipCoordinates: vec2<f32>,\n};\n\n@vertex\nfn vertexMain(attributes: Attributes) -> Varyings {\n var outp: Varyings;\n outp.position = vec4<f32>(0.0);\n outp.vColor = vec4<f32>(0.0);\n outp.pickingColor = picking_getPickingColorFromIndex(attributes.rowIndexes);\n outp.clipCoordinates = vec2<f32>(0.0);\n\n if (attributes.vertexValid < 0.5) {\n return outp;\n }\n\n let pos = select(attributes.nextVertexPositions, attributes.vertexPositions, RING_WINDING_ORDER_CW);\n let pos64Low = select(\n attributes.nextVertexPositions64Low,\n attributes.vertexPositions64Low,\n RING_WINDING_ORDER_CW\n );\n let nextPos = select(attributes.vertexPositions, attributes.nextVertexPositions, RING_WINDING_ORDER_CW);\n let nextPos64Low = select(\n attributes.vertexPositions64Low,\n attributes.nextVertexPositions64Low,\n RING_WINDING_ORDER_CW\n );\n\n let position = mix(pos, nextPos, attributes.positions.x);\n let position64Low = mix(pos64Low, nextPos64Low, attributes.positions.x);\n\n var worldPosition = position;\n if (solidPolygon.extruded > 0.5) {\n worldPosition.z += attributes.elevations * attributes.positions.y * solidPolygon.elevationScale;\n }\n\n geometry.worldPosition = position;\n geometry.pickingColor = picking_getPickingColorFromIndex(attributes.rowIndexes);\n\n let projectedPosition = project_position_to_clipspace_and_commonspace(\n worldPosition,\n position64Low,\n vec3<f32>(0.0)\n );\n geometry.position = projectedPosition.commonPosition;\n outp.position = projectedPosition.clipPosition;\n\n let normal = project_offset_normal(vec3<f32>(\n pos.y - nextPos.y + (pos64Low.y - nextPos64Low.y),\n nextPos.x - pos.x + (nextPos64Low.x - pos64Low.x),\n 0.0\n ));\n geometry.normal = normal;\n\n let colors = select(\n attributes.fillColors,\n attributes.lineColors,\n solidPolygon.isWireframe > 0.5\n );\n outp.vColor = apply_polygon_color(colors, normal, geometry.position);\n outp.pickingColor = geometry.pickingColor;\n\n outp.clipCoordinates = geometry.position.xy;\n clip_filterPosition(&outp.position, geometry.worldPosition.xy);\n\n return outp;\n}\n\n@fragment\nfn fragmentMain(inp: Varyings) -> @location(0) vec4<f32> {\n geometry.uv = vec2<f32>(0.0, 0.0);\n\n clip_filterColor(inp.clipCoordinates);\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(inp.pickingColor)) {\n discard;\n }\n return vec4<f32>(inp.pickingColor, 1.0);\n }\n\n var fragColor = inp.vColor;\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(inp.pickingColor - highlightedObjectColor))) {\n let highLightAlpha = picking.highlightColor.a;\n let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);\n if (blendedAlpha > 0.0) {\n let highLightRatio = highLightAlpha / blendedAlpha;\n fragColor = vec4<f32>(\n mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),\n blendedAlpha\n );\n } else {\n fragColor = vec4<f32>(fragColor.rgb, 0.0);\n }\n }\n }\n\n return deckgl_premultiplied_alpha(fragColor);\n}\n\n`}(t)}const fe=[0,0,0,255],pe={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:e=>e.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:fe},getLineColor:{type:"accessor",value:fe},material:!0},ge={enter:(e,t)=>t.length?t.subarray(t.length-e.length):e};class SolidPolygonLayer extends a.A{getShaders(e){const t=this.props._normalize||"CCW"!==this.props._windingOrder?1:0;return super.getShaders({vs:"top"===e?ue:de,fs:"#version 300 es\n#define SHADER_NAME solid-polygon-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nout vec4 fragColor;\nvoid main(void) {\nfragColor = vColor;\ngeometry.uv = vec2(0.);\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:he(e,Boolean(t)),defines:{RING_WINDING_ORDER_CW:t},modules:[c.A,l.A,W,u.Ay,ce,..."webgpu"===this.context.device.type?[y.A]:[]]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){const{viewport:e}=this.context;let{coordinateSystem:t}=this.props;const{_full3d:n}=this.props;let i;e.isGeospatial&&"default"===t&&(t="lnglat"),"lnglat"===t&&(i=n?e.projectPosition.bind(e):e.projectFlat.bind(e)),this.setState({numInstances:0,polygonTesselator:new PolygonTesselator({preproject:i,fp64:this.use64bitPositions(),IndexType:Uint32Array})});const r=this.getAttributeManager(),s=!0,o="webgpu"===this.context.device.type;r.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:s},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:ge,accessor:"getPolygon",update:this.calculatePositions,noAlloc:s,shaderAttributes:{nextVertexPositions:{vertexOffset:1}}},[o?"vertexValid":"instanceVertexValid"]:{size:1,type:o?"float32":"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:s},elevations:{size:1,stepMode:"dynamic",transition:ge,accessor:"getElevation",bufferGroup:"solid-polygon-instance-data"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:ge,accessor:"getFillColor",defaultValue:fe,bufferGroup:"solid-polygon-instance-data"},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:ge,accessor:"getLineColor",defaultValue:fe,bufferGroup:"solid-polygon-instance-data"},rowIndexes:{size:1,type:"uint32",stepMode:"dynamic",accessor:(e,{index:t})=>e&&e.__source?e.__source.index:t,bufferGroup:"solid-polygon-instance-data"}})}getPickingInfo(e){const t=super.getPickingInfo(e),{index:n}=t,i=this.props.data;return i[0]&&i[0].__source&&(t.object=i.find(e=>e.__source.index===n)),t}disablePickingIndex(e){const t=this.props.data;if(t[0]&&t[0].__source)for(let n=0;n<t.length;n++)t[n].__source.index===e&&this._disablePickingIndex(n);else super.disablePickingIndex(e)}draw({uniforms:e}){const{extruded:t,filled:n,wireframe:i,elevationScale:r}=this.props,{topModel:s,sideModel:o,wireframeModel:a,polygonTesselator:c}=this.state,l={extruded:Boolean(t),elevationScale:r,isWireframe:!1};a&&i&&(a.setInstanceCount(c.instanceCount-1),a.shaderInputs.setProps({solidPolygon:{...l,isWireframe:!0}}),a.draw(this.context.renderPass)),o&&n&&(o.setInstanceCount(c.instanceCount-1),o.shaderInputs.setProps({solidPolygon:l}),o.draw(this.context.renderPass)),s&&n&&(s.setVertexCount(c.vertexCount),s.shaderInputs.setProps({solidPolygon:l}),s.draw(this.context.renderPass))}updateState(e){super.updateState(e),this.updateGeometry(e);const{props:t,oldProps:n,changeFlags:i}=e,r=this.getAttributeManager();(i.extensionsChanged||t.filled!==n.filled||t.extruded!==n.extruded)&&(this.state.models?.forEach(e=>e.destroy()),this.setState(this._getModels()),r.invalidateAll())}updateGeometry({props:e,oldProps:t,changeFlags:n}){if(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getPolygon)){const{polygonTesselator:t}=this.state,i=e.data.attributes||{};t.updateGeometry({data:e.data,normalize:e._normalize,geometryBuffer:i.getPolygon,buffers:i,getGeometry:e.getPolygon,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:n.dataChanged,full3d:e._full3d}),this.setState({numInstances:t.instanceCount,startIndices:t.vertexStarts}),n.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){const{id:e,filled:t,extruded:n}=this.props;let i,r,s;if(t){const t=this.getShaders("top");t.defines={...t.defines,NON_INSTANCED_MODEL:1};let n=this.getAttributeManager().getBufferLayouts({isInstanced:!1});"webgpu"===this.context.device.type&&(n=n.filter(e=>"indices"!==e.name&&"vertexValid"!==e.name&&"instanceVertexValid"!==e.name&&"nextVertexPositions"!==e.name)),i=new h.K(this.context.device,{...t,id:`${e}-top`,topology:"triangle-list",bufferLayout:n,isIndexed:!0,userData:{excludeAttributes:{vertexValid:!0,instanceVertexValid:!0,nextVertexPositions:!0}}})}if(n){let t=this.getAttributeManager().getBufferLayouts({isInstanced:!0});"webgpu"===this.context.device.type&&(t=t.filter(e=>"indices"!==e.name)),r=new h.K(this.context.device,{...this.getShaders("side"),id:`${e}-side`,bufferLayout:t,geometry:new f.V({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),s=new h.K(this.context.device,{...this.getShaders("side"),id:`${e}-wireframe`,bufferLayout:t,geometry:new f.V({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[r,s,i].filter(Boolean),topModel:i,sideModel:r,wireframeModel:s}}calculateIndices(e){const{polygonTesselator:t}=this.state;e.startIndices=t.indexStarts,e.value=t.get("indices")}calculatePositions(e){const{polygonTesselator:t}=this.state;e.startIndices=t.vertexStarts,e.value=t.get("positions")}calculateVertexValid(e){const t=this.props.data.attributes?.instanceVertexValid?.value,n="webgpu"===this.context.device.type&&t?t:this.state.polygonTesselator.get("vertexValid");e.value="webgpu"===this.context.device.type&&n?Float32Array.from(n):n}}SolidPolygonLayer.defaultProps=pe,SolidPolygonLayer.layerName="SolidPolygonLayer";const me=SolidPolygonLayer,ve={circle:{type:x,props:{filled:"filled",stroked:"stroked",lineWidthMaxPixels:"lineWidthMaxPixels",lineWidthMinPixels:"lineWidthMinPixels",lineWidthScale:"lineWidthScale",lineWidthUnits:"lineWidthUnits",pointRadiusMaxPixels:"radiusMaxPixels",pointRadiusMinPixels:"radiusMinPixels",pointRadiusScale:"radiusScale",pointRadiusUnits:"radiusUnits",pointAntialiasing:"antialiasing",pointBillboard:"billboard",getFillColor:"getFillColor",getLineColor:"getLineColor",getLineWidth:"getLineWidth",getPointRadius:"getRadius"}},icon:{type:o.A,props:{iconAtlas:"iconAtlas",iconMapping:"iconMapping",iconSizeMaxPixels:"sizeMaxPixels",iconSizeMinPixels:"sizeMinPixels",iconSizeScale:"sizeScale",iconSizeUnits:"sizeUnits",iconAlphaCutoff:"alphaCutoff",iconBillboard:"billboard",getIcon:"getIcon",getIconAngle:"getAngle",getIconColor:"getColor",getIconPixelOffset:"getPixelOffset",getIconSize:"getSize"}},text:{type:w.A,props:{textSizeMaxPixels:"sizeMaxPixels",textSizeMinPixels:"sizeMinPixels",textSizeScale:"sizeScale",textSizeUnits:"sizeUnits",textBackground:"background",textBackgroundPadding:"backgroundPadding",textFontFamily:"fontFamily",textFontWeight:"fontWeight",textLineHeight:"lineHeight",textMaxWidth:"maxWidth",textOutlineColor:"outlineColor",textOutlineWidth:"outlineWidth",textWordBreak:"wordBreak",textCharacterSet:"characterSet",textBillboard:"billboard",textFontSettings:"fontSettings",getText:"getText",getTextAngle:"getAngle",getTextColor:"getColor",getTextPixelOffset:"getPixelOffset",getTextSize:"getSize",getTextAnchor:"getTextAnchor",getTextAlignmentBaseline:"getAlignmentBaseline",getTextBackgroundColor:"getBackgroundColor",getTextBorderColor:"getBorderColor",getTextBorderWidth:"getBorderWidth"}}},ye={type:P.A,props:{lineWidthUnits:"widthUnits",lineWidthScale:"widthScale",lineWidthMinPixels:"widthMinPixels",lineWidthMaxPixels:"widthMaxPixels",lineJointRounded:"jointRounded",lineCapRounded:"capRounded",lineMiterLimit:"miterLimit",lineBillboard:"billboard",lineAntialiasing:"antialiasing",getLineColor:"getColor",getLineWidth:"getWidth"}},be={type:me,props:{extruded:"extruded",filled:"filled",wireframe:"wireframe",elevationScale:"elevationScale",material:"material",_full3d:"_full3d",getElevation:"getElevation",getFillColor:"getFillColor",getLineColor:"getLineColor"}};function _e({type:e,props:t}){const n={};for(const i in t)n[i]=e.defaultProps[t[i]];return n}function xe(e,t,n="getPosition"){const{transitions:i,updateTriggers:r}=e.props,s={updateTriggers:{},transitions:i&&{[n]:i.geometry}};for(const n in t){const o=t[n];let a=e.props[n];n.startsWith("get")&&(a=e.getSubLayerAccessor(a),s.updateTriggers[o]=r[n],i&&(s.transitions[o]=i[n])),s[o]=a}return s}var we=n(3459);function Pe(e,t,n={}){const i={pointFeatures:[],lineFeatures:[],polygonFeatures:[],polygonOutlineFeatures:[]},{startRow:r=0,endRow:s=e.length}=n;for(let n=r;n<s;n++){const r=e[n],{geometry:s}=r;if(s)if("GeometryCollection"===s.type){we.A.assert(Array.isArray(s.geometries),"GeoJSON does not have geometries array");const{geometries:e}=s;for(let s=0;s<e.length;s++){Ce(e[s],i,t,r,n)}}else Ce(s,i,t,r,n)}return i}function Ce(e,t,n,i,r){const{type:s,coordinates:o}=e,{pointFeatures:a,lineFeatures:c,polygonFeatures:l,polygonOutlineFeatures:u}=t;if(function(e,t){let n=Se[e];we.A.assert(n,`Unknown GeoJSON type ${e}`);for(;t&&--n>0;)t=t[0];return t&&Number.isFinite(t[0])}(s,o))switch(s){case"Point":a.push(n({geometry:e},i,r));break;case"MultiPoint":o.forEach(e=>{a.push(n({geometry:{type:"Point",coordinates:e}},i,r))});break;case"LineString":c.push(n({geometry:e},i,r));break;case"MultiLineString":o.forEach(e=>{c.push(n({geometry:{type:"LineString",coordinates:e}},i,r))});break;case"Polygon":l.push(n({geometry:e},i,r)),o.forEach(e=>{u.push(n({geometry:{type:"LineString",coordinates:e}},i,r))});break;case"MultiPolygon":o.forEach(e=>{l.push(n({geometry:{type:"Polygon",coordinates:e}},i,r)),e.forEach(e=>{u.push(n({geometry:{type:"LineString",coordinates:e}},i,r))})})}else we.A.warn(`${s} coordinates are malformed`)()}const Se={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4};function Le(e){return e.geometry.coordinates}function Ae(e){const t={points:{},lines:{},polygons:{},polygonsOutline:{}},{points:n,lines:i,polygons:r}=e,s=function(e){const t={points:null,lines:null,polygons:null};for(const n in t){const i=e[n].globalFeatureIds.value;t[n]=new Uint32Array(i)}return t}(e);t.points.data={length:n.positions.value.length/n.positions.size,attributes:{...n.attributes,getPosition:n.positions,rowIndexes:{size:1,type:"uint32",value:s.points}},properties:n.properties,numericProps:n.numericProps,featureIds:n.featureIds},t.lines.data={length:i.pathIndices.value.length-1,startIndices:i.pathIndices.value,attributes:{...i.attributes,getPath:i.positions,rowIndexes:{size:1,type:"uint32",value:s.lines}},properties:i.properties,numericProps:i.numericProps,featureIds:i.featureIds},t.lines._pathType="open";const o=r.positions.value.length/r.positions.size,a=Array(o).fill(1);for(const e of r.primitivePolygonIndices.value)a[e-1]=0;return t.polygons.data={length:r.polygonIndices.value.length-1,startIndices:r.polygonIndices.value,attributes:{...r.attributes,getPolygon:r.positions,instanceVertexValid:{size:1,value:new Uint16Array(a)},rowIndexes:{size:1,type:"uint32",value:s.polygons}},properties:r.properties,numericProps:r.numericProps,featureIds:r.featureIds},t.polygons._normalize=!1,r.triangles&&(t.polygons.data.attributes.indices=r.triangles.value),t.polygonsOutline.data={length:r.primitivePolygonIndices.value.length-1,startIndices:r.primitivePolygonIndices.value,attributes:{...r.attributes,getPath:r.positions,rowIndexes:{size:1,type:"uint32",value:s.polygons}},properties:r.properties,numericProps:r.numericProps,featureIds:r.featureIds},t.polygonsOutline._pathType="open",t}const Ee=["points","linestrings","polygons"],Te={..._e(ve.circle),..._e(ve.icon),..._e(ve.text),..._e(ye),..._e(be),stroked:!0,filled:!0,extruded:!1,wireframe:!1,_full3d:!1,iconAtlas:{type:"object",value:null},iconMapping:{type:"object",value:{}},getIcon:{type:"accessor",value:e=>e.properties.icon},getText:{type:"accessor",value:e=>e.properties.text},pointType:"circle",getRadius:{deprecatedFor:"getPointRadius"}};class GeoJsonLayer extends r.A{initializeState(){this.state={layerProps:{},features:{},featuresDiff:{}}}updateState({props:e,changeFlags:t}){if(!t.dataChanged)return;const{data:n}=this.props,i=n&&"points"in n&&"polygons"in n&&"lines"in n;this.setState({binary:i}),i?this._updateStateBinary({props:e,changeFlags:t}):this._updateStateJSON({props:e,changeFlags:t})}_updateStateBinary({props:e,changeFlags:t}){const n=Ae(e.data);this.setState({layerProps:n})}_updateStateJSON({props:e,changeFlags:t}){const n=function(e){if(Array.isArray(e))return e;switch(we.A.assert(e.type,"GeoJSON does not have type"),e.type){case"Feature":return[e];case"FeatureCollection":return we.A.assert(Array.isArray(e.features),"GeoJSON does not have features array"),e.features;default:return[{geometry:e}]}}(e.data),i=this.getSubLayerRow.bind(this);let r={};const o={};if(Array.isArray(t.dataChanged)){const e=this.state.features;for(const t in e)r[t]=e[t].slice(),o[t]=[];for(const a of t.dataChanged){const t=Pe(n,i,a);for(const n in e)o[n].push(s({data:r[n],getIndex:e=>e.__source.index,dataRange:a,replace:t[n]}))}}else r=Pe(n,i);const a=function(e,t){const n={points:{},lines:{},polygons:{},polygonsOutline:{}},{pointFeatures:i,lineFeatures:r,polygonFeatures:s,polygonOutlineFeatures:o}=e;return n.points.data=i,n.points._dataDiff=t.pointFeatures&&(()=>t.pointFeatures),n.points.getPosition=Le,n.lines.data=r,n.lines._dataDiff=t.lineFeatures&&(()=>t.lineFeatures),n.lines.getPath=Le,n.polygons.data=s,n.polygons._dataDiff=t.polygonFeatures&&(()=>t.polygonFeatures),n.polygons.getPolygon=Le,n.polygonsOutline.data=o,n.polygonsOutline._dataDiff=t.polygonOutlineFeatures&&(()=>t.polygonOutlineFeatures),n.polygonsOutline.getPath=Le,n}(r,o);this.setState({features:r,featuresDiff:o,layerProps:a})}getPickingInfo(e){const t=super.getPickingInfo(e),{index:n,sourceLayer:i}=t;return t.featureType=Ee.find(e=>i.id.startsWith(`${this.id}-${e}-`)),n>=0&&i.id.startsWith(`${this.id}-points-text`)&&this.state.binary&&(t.index=this.props.data.points.globalFeatureIds.value[n]),t}_updateAutoHighlight(e){const t=`${this.id}-points-`,n="points"===e.featureType;for(const i of this.getSubLayers())i.id.startsWith(t)===n&&i.updateAutoHighlight(e)}_renderPolygonLayer(){const{extruded:e,wireframe:t}=this.props,{layerProps:n}=this.state,i="polygons-fill",r=this.shouldRenderSubLayer(i,n.polygons?.data)&&this.getSubLayerClass(i,be.type);if(r){const s=xe(this,be.props,"getPolygon"),o=e&&t;return o||delete s.getLineColor,s.updateTriggers.lineColors=o,new r(s,this.getSubLayerProps({id:i,updateTriggers:s.updateTriggers}),n.polygons)}return null}_renderLineLayers(){const{extruded:e,stroked:t}=this.props,{layerProps:n}=this.state,i="polygons-stroke",r="linestrings",s=!e&&t&&this.shouldRenderSubLayer(i,n.polygonsOutline?.data)&&this.getSubLayerClass(i,ye.type),o=this.shouldRenderSubLayer(r,n.lines?.data)&&this.getSubLayerClass(r,ye.type);if(s||o){const e=xe(this,ye.props,"getPath");return[s&&new s(e,this.getSubLayerProps({id:i,updateTriggers:e.updateTriggers}),n.polygonsOutline),o&&new o(e,this.getSubLayerProps({id:r,updateTriggers:e.updateTriggers}),n.lines)]}return null}_renderPointLayers(){const{pointType:e}=this.props,{layerProps:t,binary:n}=this.state;let{highlightedObjectIndex:i}=this.props;!n&&Number.isFinite(i)&&(i=t.points.data.findIndex(e=>e.__source.index===i));const r=new Set(e.split("+")),s=[];for(const e of r){const r=`points-${e}`,o=ve[e],a=o&&this.shouldRenderSubLayer(r,t.points?.data)&&this.getSubLayerClass(r,o.type);if(a){const c=xe(this,o.props);let l=t.points;if("text"===e&&n){const{rowIndexes:e,...t}=l.data.attributes;l={...l,data:{...l.data,attributes:t}}}s.push(new a(c,this.getSubLayerProps({id:r,updateTriggers:c.updateTriggers,highlightedObjectIndex:i}),l))}}return s}renderLayers(){const{extruded:e}=this.props,t=this._renderPolygonLayer();return[!e&&t,this._renderLineLayers(),this._renderPointLayers(),e&&t]}getSubLayerAccessor(e){const{binary:t}=this.state;return t&&"function"==typeof e?(t,n)=>{const{data:i,index:r}=n,s=function(e,t){if(!e)return null;const n="startIndices"in e?e.startIndices[t]:t,i=e.featureIds.value[n];return-1!==n?function(e,t,n){const i={properties:{...e.properties[t]}};for(const t in e.numericProps)i.properties[t]=e.numericProps[t].value[n];return i}(e,i,n):null}(i,r);return e(s,n)}:super.getSubLayerAccessor(e)}}GeoJsonLayer.layerName="GeoJsonLayer",GeoJsonLayer.defaultProps=Te;const Me=GeoJsonLayer},91638(e,t,n){n.d(t,{A:()=>L});var i=n(45069),r=n(84175),s=n(46487),o=n(93675),a=n(9350),c=n(3459),l=n(36077),u=n(25337);const d="layout(std140) uniform iconUniforms {\n float sizeScale;\n vec2 iconsTextureDim;\n float sizeBasis;\n float sizeMinPixels;\n float sizeMaxPixels;\n bool billboard;\n highp int sizeUnits;\n float alphaCutoff;\n} icon;\n",h={name:"icon",vs:d,fs:d,uniformTypes:{sizeScale:"f32",iconsTextureDim:"vec2<f32>",sizeBasis:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",billboard:"f32",sizeUnits:"i32",alphaCutoff:"f32"}},f='struct IconUniforms {\n sizeScale: f32,\n iconsTextureDim: vec2<f32>,\n sizeBasis: f32,\n sizeMinPixels: f32,\n sizeMaxPixels: f32,\n billboard: i32,\n sizeUnits: i32,\n alphaCutoff: f32\n};\n\n@group(0) @binding(auto) var<uniform> icon: IconUniforms;\n@group(0) @binding(auto) var iconsTexture : texture_2d<f32>;\n@group(0) @binding(auto) var iconsTextureSampler : sampler;\n\nfn rotate_by_angle(vertex: vec2<f32>, angle_deg: f32) -> vec2<f32> {\n let angle_radian = angle_deg * PI / 180.0;\n let c = cos(angle_radian);\n let s = sin(angle_radian);\n let rotation = mat2x2<f32>(vec2<f32>(c, s), vec2<f32>(-s, c));\n return rotation * vertex;\n}\n\nstruct Attributes {\n @builtin(instance_index) instanceIndex : u32,\n @location(0) positions: vec2<f32>,\n\n @location(1) instancePositions: vec3<f32>,\n @location(2) instancePositions64Low: vec3<f32>,\n @location(3) instanceSizes: f32,\n @location(4) instanceAngles: f32,\n @location(5) instanceColors: vec4<f32>,\n @location(6) instanceIconFrames: vec4<f32>,\n @location(7) instanceColorModes: f32,\n @location(8) instanceOffsets: vec2<f32>,\n @location(9) instancePixelOffset: vec2<f32>,\n PICKING_COLOR_ATTRIBUTE\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n\n @location(0) vColorMode: f32,\n @location(1) vColor: vec4<f32>,\n @location(2) vTextureCoords: vec2<f32>,\n @location(3) uv: vec2<f32>,\n @location(4) pickingColor: vec3<f32>,\n};\n\n@vertex\nfn vertexMain(inp: Attributes) -> Varyings {\n // write geometry fields used by filters + FS\n geometry.worldPosition = inp.instancePositions;\n geometry.uv = inp.positions;\n geometry.pickingColor = PICKING_COLOR_VALUE;\n\n var outp: Varyings;\n outp.uv = inp.positions;\n\n let iconSize = inp.instanceIconFrames.zw;\n\n // convert size in meters to pixels, then clamp\n let sizePixels = clamp(\n project_unit_size_to_pixel(inp.instanceSizes * icon.sizeScale, icon.sizeUnits),\n icon.sizeMinPixels, icon.sizeMaxPixels\n );\n\n // scale icon height to match instanceSize\n let iconConstraint = select(iconSize.y, iconSize.x, icon.sizeBasis == 0.0);\n let instanceScale = select(sizePixels / iconConstraint, 0.0, iconConstraint == 0.0);\n\n // scale and rotate vertex in "pixel" units; then add per-instance pixel offset\n var pixelOffset = inp.positions / 2.0 * iconSize + inp.instanceOffsets;\n pixelOffset = rotate_by_angle(pixelOffset, inp.instanceAngles) * instanceScale;\n pixelOffset = pixelOffset + inp.instancePixelOffset;\n pixelOffset.y = pixelOffset.y * -1.0;\n\n if (icon.billboard != 0) {\n var pos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, vec3<f32>(0.0)); // TODO, &geometry.position);\n // DECKGL_FILTER_GL_POSITION(pos, geometry);\n\n var offset = vec3<f32>(pixelOffset, 0.0);\n // DECKGL_FILTER_SIZE(offset, geometry);\n let clipOffset = project_pixel_size_to_clipspace(offset.xy);\n pos = vec4<f32>(pos.x + clipOffset.x, pos.y + clipOffset.y, pos.z, pos.w);\n outp.position = pos;\n } else {\n var offset_common = vec3<f32>(project_pixel_size_vec2(pixelOffset), 0.0);\n // DECKGL_FILTER_SIZE(offset_common, geometry);\n var pos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, offset_common); // TODO, &geometry.position);\n // DECKGL_FILTER_GL_POSITION(pos, geometry);\n outp.position = pos;\n }\n\n let uvMix = (inp.positions.xy + vec2<f32>(1.0, 1.0)) * 0.5;\n outp.vTextureCoords = mix(inp.instanceIconFrames.xy, inp.instanceIconFrames.xy + iconSize, uvMix) / icon.iconsTextureDim;\n\n outp.vColor = inp.instanceColors;\n // DECKGL_FILTER_COLOR(outp.vColor, geometry);\n\n outp.vColorMode = inp.instanceColorModes;\n outp.pickingColor = geometry.pickingColor;\n\n return outp;\n}\n\n@fragment\nfn fragmentMain(inp: Varyings) -> @location(0) vec4<f32> {\n // expose to deck.gl filter hooks\n geometry.uv = inp.uv;\n\n let texColor = textureSample(iconsTexture, iconsTextureSampler, inp.vTextureCoords);\n\n // if colorMode == 0, use pixel color from the texture\n // if colorMode == 1 (or picking), use texture as transparency mask\n let rgb = mix(texColor.rgb, inp.vColor.rgb, inp.vColorMode);\n let a = texColor.a * layer.opacity * inp.vColor.a;\n\n if (a < icon.alphaCutoff) {\n discard;\n }\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(inp.pickingColor)) {\n discard;\n }\n return vec4<f32>(inp.pickingColor, 1.0);\n }\n\n var fragColor = deckgl_premultiplied_alpha(vec4<f32>(rgb, a));\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(inp.pickingColor - highlightedObjectColor))) {\n let highLightAlpha = picking.highlightColor.a;\n let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);\n if (blendedAlpha > 0.0) {\n let highLightRatio = highLightAlpha / blendedAlpha;\n fragColor = vec4<f32>(\n mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),\n blendedAlpha\n );\n } else {\n fragColor = vec4<f32>(fragColor.rgb, 0.0);\n }\n }\n }\n\n return fragColor;\n}\n';function p(e){return f.replace("PICKING_COLOR_ATTRIBUTE",e?"@location(10) rowIndexes: u32,":"").replace("PICKING_COLOR_VALUE",e?"picking_getPickingColorFromIndex(inp.rowIndexes)":"picking_getPickingColorFromIndex(inp.instanceIndex)")}var g=n(22662),m=n(53439);const v=()=>{},y={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},b={x:0,y:0,width:0,height:0};function _(e,t,n,i){const r=Math.min(n/t.width,i/t.height),s=Math.floor(t.width*r),o=Math.floor(t.height*r);return 1===r?{image:t,width:s,height:o}:(e.canvas.height=o,e.canvas.width=s,e.clearRect(0,0,s,o),e.drawImage(t,0,0,t.width,t.height,0,0,s,o),{image:e.canvas,width:s,height:o})}function x(e){return e&&(e.id||e.url)}function w(e){const{device:t}=e;"webgl"===t.type?e.generateMipmapsWebGL():"webgpu"===t.type&&t.generateMipmapsWebGPU(e)}function P(e,t,n){for(let i=0;i<t.length;i++){const{icon:r,xOffset:s}=t[i];e[x(r)]={...r,x:s,y:n}}}class IconManager{constructor(e,{onUpdate:t=v,onError:n=v}){this._loadOptions=null,this._texture=null,this._externalTexture=null,this._mapping={},this._samplerParameters=null,this._pendingCount=0,this._autoPacking=!1,this._xOffset=0,this._yOffset=0,this._rowHeight=0,this._buffer=4,this._canvasWidth=1024,this._canvasHeight=0,this._canvas=null,this.device=e,this.onUpdate=t,this.onError=n}finalize(){this._texture?.delete()}getTexture(){return this._texture||this._externalTexture}getIconMapping(e){const t=this._autoPacking?x(e):e;return this._mapping[t]||b}setProps({loadOptions:e,autoPacking:t,iconAtlas:n,iconMapping:i,textureParameters:r}){e&&(this._loadOptions=e),void 0!==t&&(this._autoPacking=t),i&&(this._mapping=i),n&&(this._texture?.delete(),this._texture=null,this._externalTexture=n),r&&(this._samplerParameters=r)}get isLoaded(){return 0===this._pendingCount}packIcons(e,t){if(!this._autoPacking||"undefined"==typeof document)return;const n=Object.values(function(e,t,n){if(!e||!t)return null;n=n||{};const i={},{iterable:r,objectInfo:s}=(0,m.X)(e);for(const e of r){s.index++;const r=t(e,s),o=x(r);if(!r)throw new Error("Icon is missing.");if(!r.url)throw new Error("Icon url is missing.");i[o]||n[o]&&r.url===n[o].url||(i[o]={...r,source:e,sourceIndex:s.index})}return i}(e,t,this._mapping)||{});if(n.length>0){const{mapping:e,xOffset:t,yOffset:i,rowHeight:r,canvasHeight:s}=function({icons:e,buffer:t,mapping:n={},xOffset:i=0,yOffset:r=0,rowHeight:s=0,canvasWidth:o}){let a=[];for(let c=0;c<e.length;c++){const l=e[c];if(!n[x(l)]){const{height:e,width:c}=l;i+c+t>o&&(P(n,a,r),i=0,r=s+r+t,s=0,a=[]),a.push({icon:l,xOffset:i}),i=i+c+t,s=Math.max(s,e)}}return a.length>0&&P(n,a,r),{mapping:n,rowHeight:s,xOffset:i,yOffset:r,canvasWidth:o,canvasHeight:(c=s+r+t,Math.pow(2,Math.ceil(Math.log2(c))))};var c}({icons:n,buffer:this._buffer,canvasWidth:this._canvasWidth,mapping:this._mapping,rowHeight:this._rowHeight,xOffset:this._xOffset,yOffset:this._yOffset});this._rowHeight=r,this._mapping=e,this._xOffset=t,this._yOffset=i,this._canvasHeight=s,this._texture||(this._texture=this.device.createTexture({format:"rgba8unorm",data:null,width:this._canvasWidth,height:this._canvasHeight,sampler:this._samplerParameters||y,mipLevels:this.device.getMipLevelCount(this._canvasWidth,this._canvasHeight)})),this._texture.height!==this._canvasHeight&&(this._texture=function(e,t,n,i){const{width:r,height:s,device:o}=e,a=o.createTexture({format:"rgba8unorm",width:t,height:n,sampler:i,mipLevels:o.getMipLevelCount(t,n)}),c=o.createCommandEncoder();c.copyTextureToTexture({sourceTexture:e,destinationTexture:a,width:r,height:s});const l=c.finish();return o.submit(l),w(a),e.destroy(),a}(this._texture,this._canvasWidth,this._canvasHeight,this._samplerParameters||y)),this.onUpdate(!0),this._canvas=this._canvas||document.createElement("canvas"),this._loadIcons(n)}}_loadIcons(e){const t=this._canvas.getContext("2d",{willReadFrequently:!0});for(const n of e)this._pendingCount++,(0,g.H)(n.url,this._loadOptions).then(e=>{const i=x(n),r=this._mapping[i],{x:s,y:o,width:a,height:c}=r,{image:l,width:u,height:d}=_(t,e,a,c),h=s+(a-u)/2,f=o+(c-d)/2;this._texture?.copyExternalImage({image:l,x:h,y:f,width:u,height:d}),r.x=h,r.y=f,r.width=u,r.height=d,this._texture&&w(this._texture),this.onUpdate(u!==a||d!==c)}).catch(e=>{this.onError({url:n.url,source:n.source,sourceIndex:n.sourceIndex,loadOptions:this._loadOptions,error:e})}).finally(()=>{this._pendingCount--})}}const C=[0,0,0,255],S={iconAtlas:{type:"image",value:null,async:!0},iconMapping:{type:"object",value:{},async:!0},sizeScale:{type:"number",value:1,min:0},billboard:!0,sizeUnits:"pixels",sizeBasis:"height",sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},alphaCutoff:{type:"number",value:.05,min:0,max:1},getPosition:{type:"accessor",value:e=>e.position},getIcon:{type:"accessor",value:e=>e.icon},getColor:{type:"accessor",value:C},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},onIconError:{type:"function",value:null,optional:!0},textureParameters:{type:"object",ignore:!0,value:null}};class IconLayer extends i.A{getShaders(){const e=Boolean(this.props.data?.attributes?.rowIndexes);return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME icon-layer-vertex-shader\nin vec2 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin float instanceSizes;\nin float instanceAngles;\nin vec4 instanceColors;\n#ifdef USE_ROW_INDEXES\nin float rowIndexes;\n#endif\nin vec4 instanceIconFrames;\nin float instanceColorModes;\nin vec2 instanceOffsets;\nin vec2 instancePixelOffset;\nout float vColorMode;\nout vec4 vColor;\nout vec2 vTextureCoords;\nout vec2 uv;\nvec2 rotate_by_angle(vec2 vertex, float angle) {\nfloat angle_radian = angle * PI / 180.0;\nfloat cos_angle = cos(angle_radian);\nfloat sin_angle = sin(angle_radian);\nmat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);\nreturn rotationMatrix * vertex;\n}\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.uv = positions;\n#ifdef USE_ROW_INDEXES\ngeometry.pickingColor = picking_getPickingColorFromIndex(rowIndexes);\n#else\ngeometry.pickingColor = picking_getPickingColorFromInstanceID();\n#endif\nuv = positions;\nvec2 iconSize = instanceIconFrames.zw;\nfloat sizePixels = clamp(\nproject_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits),\nicon.sizeMinPixels, icon.sizeMaxPixels\n);\nfloat iconConstraint = icon.sizeBasis == 0.0 ? iconSize.x : iconSize.y;\nfloat instanceScale = iconConstraint == 0.0 ? 0.0 : sizePixels / iconConstraint;\nvec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets;\npixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale;\npixelOffset += instancePixelOffset;\npixelOffset.y *= -1.0;\nif (icon.billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = vec3(pixelOffset, 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);\nDECKGL_FILTER_SIZE(offset_common, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nvTextureCoords = mix(\ninstanceIconFrames.xy,\ninstanceIconFrames.xy + iconSize,\n(positions.xy + 1.0) / 2.0\n) / icon.iconsTextureDim;\nvColor = instanceColors;\nDECKGL_FILTER_COLOR(vColor, geometry);\nvColorMode = instanceColorModes;\n}\n",fs:"#version 300 es\n#define SHADER_NAME icon-layer-fragment-shader\nprecision highp float;\nuniform sampler2D iconsTexture;\nin float vColorMode;\nin vec4 vColor;\nin vec2 vTextureCoords;\nin vec2 uv;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = uv;\nvec4 texColor = texture(iconsTexture, vTextureCoords);\nvec3 color = mix(texColor.rgb, vColor.rgb, vColorMode);\nfloat a = texColor.a * layer.opacity * vColor.a;\nif (a < icon.alphaCutoff) {\ndiscard;\n}\nfragColor = vec4(color, a);\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:p(e),defines:e?{USE_ROW_INDEXES:!0}:{},modules:[r.A,s.A,o.Ay,h]})}initializeState(){this.state={iconManager:new IconManager(this.context.device,{onUpdate:this._onUpdate.bind(this),onError:this._onError.bind(this)})};this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,bufferGroup:"icon-instance-data",accessor:"getSize",defaultValue:1},instanceIconDefs:{size:7,bufferGroup:"icon-instance-data",accessor:"getIcon",transform:this.getInstanceIconDef,shaderAttributes:{instanceOffsets:{size:2,elementOffset:0},instanceIconFrames:{size:4,elementOffset:2},instanceColorModes:{size:1,elementOffset:6}}},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,bufferGroup:"icon-instance-data",accessor:"getColor",defaultValue:C},instanceAngles:{size:1,transition:!0,bufferGroup:"icon-instance-data",accessor:"getAngle"},instancePixelOffset:{size:2,transition:!0,bufferGroup:"icon-instance-data",accessor:"getPixelOffset"},...this.props.data?.attributes?.rowIndexes?{rowIndexes:{size:1,type:"uint32",noAlloc:!0}}:{}})}updateState(e){super.updateState(e);const{props:t,oldProps:n,changeFlags:i}=e,r=this.getAttributeManager(),{iconAtlas:s,iconMapping:o,data:a,getIcon:c,textureParameters:l}=t,{iconManager:u}=this.state;if("string"==typeof s)return;const d=s||this.internalState.isAsyncPropLoading("iconAtlas");u.setProps({loadOptions:t.loadOptions,autoPacking:!d,iconAtlas:s,iconMapping:d?o:null,textureParameters:l}),d?n.iconMapping!==t.iconMapping&&r.invalidate("getIcon"):(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getIcon))&&u.packIcons(a,c),i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),r.invalidateAll())}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(e){super.finalizeState(e),this.state.iconManager.finalize()}draw({uniforms:e}){this._drawModel(this.state.model)}_drawModel(e){const{sizeScale:t,sizeBasis:n,sizeMinPixels:i,sizeMaxPixels:r,sizeUnits:s,billboard:o,alphaCutoff:c}=this.props,{iconManager:l}=this.state,u=l.getTexture();if(u){const l={iconsTexture:u,iconsTextureDim:[u.width,u.height],sizeUnits:a.p5[s],sizeScale:t,sizeBasis:"height"===n?1:0,sizeMinPixels:i,sizeMaxPixels:r,billboard:o,alphaCutoff:c};e.shaderInputs.setProps({icon:l}),e.draw(this.context.renderPass)}}_getModel(e=this.props.id){return new l.K(this.context.device,{...this.getShaders(),id:e,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new u.V({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([-1,-1,1,-1,-1,1,1,1])}}}),isInstanced:!0})}_onUpdate(e){e?(this.getAttributeManager()?.invalidate("getIcon"),this.setNeedsUpdate()):this.setNeedsRedraw()}_onError(e){const t=this.getCurrentLayer()?.props.onIconError;t?t(e):c.A.error(e.error.message)()}getInstanceIconDef(e){const{x:t,y:n,width:i,height:r,mask:s,anchorX:o=i/2,anchorY:a=r/2}=this.state.iconManager.getIconMapping(e);return[i/2-o,r/2-a,t,n,i,r,s?1:0]}}IconLayer.defaultProps=S,IconLayer.layerName="IconLayer";const L=IconLayer},56802(e,t,n){n.d(t,{A:()=>P});var i=n(45069),r=n(84175),s=n(46487),o=n(93675),a=n(69502),c=n(4782),l=n(9350),u=n(25337),d=n(36077),h=n(44941),f=n(18584),p=n(6423);class PathTesselator extends h.A{constructor(e){super({...e,attributes:{positions:{size:3,padding:18,initialize:!0,type:e.fp64?Float64Array:Float32Array},segmentTypes:{size:1,type:e.isWebGPU?Float32Array:Uint8ClampedArray}}})}get(e){return this.attributes[e]}getPathSegmentIndices(e){const t=this.attributes.segmentTypes,n=this.vertexStarts[e],i=Math.min(this.vertexStarts[e+1]??this.instanceCount,this.instanceCount),r=[];for(let e=n;e<i-1;e++)4&t[e]||r.push(e);return r.length&&4&t[n]&&r.unshift(r.pop()),r}getGeometryFromBuffer(e){return this.normalize||this.opts.isWebGPU?super.getGeometryFromBuffer(e):null}normalizeGeometry(e){return this.normalize?function(e,t,n,i){let r;if(Array.isArray(e[0])){const n=e.length*t;r=new Array(n);for(let n=0;n<e.length;n++)for(let i=0;i<t;i++)r[n*t+i]=e[n][i]||0}else r=e;return n?(0,f.M)(r,{size:t,gridResolution:n}):i?(0,p.I)(r,{size:t}):r}(e,this.positionSize,this.opts.resolution,this.opts.wrapLongitude):e}getGeometrySize(e){if(g(e)){let t=0;for(const n of e)t+=this.getGeometrySize(n);return t}const t=this.getPathLength(e);return t<2?0:this.isClosed(e)?t<3?0:t+2:t}updateGeometryAttributes(e,t){if(0!==t.geometrySize)if(e&&g(e))for(const n of e){const e=this.getGeometrySize(n);t.geometrySize=e,this.updateGeometryAttributes(n,t),t.vertexStart+=e}else this._updateSegmentTypes(e,t),this._updatePositions(e,t)}_updateSegmentTypes(e,t){const n=this.attributes.segmentTypes,i=!!e&&this.isClosed(e),{vertexStart:r,geometrySize:s}=t;n.fill(0,r,r+s),i?(n[r]=4,n[r+s-2]=4):(n[r]+=1,n[r+s-2]+=2),n[r+s-1]=4}_updatePositions(e,t){const{positions:n}=this.attributes;if(!n||!e)return;const{vertexStart:i,geometrySize:r}=t,s=new Array(3);for(let t=i,o=0;o<r;t++,o++)this.getPointOnPath(e,o,s),n[3*t]=s[0],n[3*t+1]=s[1],n[3*t+2]=s[2]}getPathLength(e){return e.length/this.positionSize}getPointOnPath(e,t,n=[]){const{positionSize:i}=this;t*i>=e.length&&(t+=1-e.length/i);const r=t*i;return n[0]=e[r],n[1]=e[r+1],n[2]=3===i&&e[r+2]||0,n}isClosed(e){if(!this.normalize)return Boolean(this.opts.loop);const{positionSize:t}=this,n=e.length-t;return e[0]===e[n]&&e[1]===e[n+1]&&(2===t||e[2]===e[n+2])}}function g(e){return Array.isArray(e[0])}const m="layout(std140) uniform pathUniforms {\n float widthScale;\n float widthMinPixels;\n float widthMaxPixels;\n float jointType;\n float capType;\n float miterLimit;\n bool billboard;\n highp int widthUnits;\n} path;\n",v={name:"path",source:"struct PathUniforms {\n widthScale: f32,\n widthMinPixels: f32,\n widthMaxPixels: f32,\n jointType: f32,\n capType: f32,\n miterLimit: f32,\n billboard: f32,\n widthUnits: i32,\n};\n\n@group(0) @binding(auto)\nvar<uniform> path: PathUniforms;\n",vs:m,fs:m,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}};var y=n(86402);const b=[0,0,0,255],_={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},antialiasing:!1,billboard:!1,_pathType:null,getPath:{type:"accessor",value:e=>e.path},getColor:{type:"accessor",value:b},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},x={enter:(e,t)=>t.length?t.subarray(t.length-e.length):e};function w(e,t){return e===t||Boolean(e&&t&&e.length===t.length&&e.every((e,n)=>e===t[n]))}class PathLayer extends i.A{getShaders(){const{antialiasing:e}=this.props;return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME path-layer-vertex-shader\nin vec2 positions;\nin float instanceTypes;\nin vec3 instanceStartPositions;\nin vec3 instanceEndPositions;\nin vec3 instanceLeftPositions;\nin vec3 instanceRightPositions;\nin vec3 instanceLeftPositions64Low;\nin vec3 instanceStartPositions64Low;\nin vec3 instanceEndPositions64Low;\nin vec3 instanceRightPositions64Low;\nin float instanceStrokeWidths;\nin vec4 instanceColors;\nin float rowIndexes;\nuniform float opacity;\nout vec4 vColor;\nout vec2 vCornerOffset;\nout float vMiterLength;\nout vec2 vPathPosition;\nout float vPathLength;\nout float vJointType;\n#ifdef DASH_ENABLED\nout vec2 vPathBounds;\n#endif\nconst float EPSILON = 0.001;\nconst vec3 ZERO_OFFSET = vec3(0.0);\nfloat flipIfTrue(bool flag) {\nreturn -(float(flag) * 2. - 1.);\n}\nvec3 getLineJoinOffset(\nvec3 prevPoint, vec3 currPoint, vec3 nextPoint,\nvec2 width\n#ifdef DASH_ENABLED\n, float sourcePathLength, vec2 sourcePathRange\n#endif\n#ifdef ANTIALIASING\n, float coverageScale\n#endif\n) {\nbool isEnd = positions.x > 0.0;\nfloat sideOfPath = positions.y;\nfloat isJoint = float(sideOfPath == 0.0);\nvec3 deltaA3 = (currPoint - prevPoint);\nvec3 deltaB3 = (nextPoint - currPoint);\nmat3 rotationMatrix;\nbool needsRotation = !path.billboard && project_needs_rotation(currPoint, rotationMatrix);\nif (needsRotation) {\ndeltaA3 = deltaA3 * rotationMatrix;\ndeltaB3 = deltaB3 * rotationMatrix;\n}\nvec2 deltaA = deltaA3.xy / width;\nvec2 deltaB = deltaB3.xy / width;\nfloat lenA = length(deltaA);\nfloat lenB = length(deltaB);\nvec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0);\nvec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0);\nvec2 perpA = vec2(-dirA.y, dirA.x);\nvec2 perpB = vec2(-dirB.y, dirB.x);\nvec2 tangent = dirA + dirB;\ntangent = length(tangent) > 0. ? normalize(tangent) : perpA;\nvec2 miterVec = vec2(-tangent.y, tangent.x);\nvec2 dir = isEnd ? dirA : dirB;\nvec2 perp = isEnd ? perpA : perpB;\nfloat L = isEnd ? lenA : lenB;\n#ifdef DASH_ENABLED\nvec3 currDelta3 = isEnd ? deltaA3 : deltaB3;\nfloat currLength2D = length(currDelta3.xy);\nfloat arcLengthRatio = 1.0;\nfloat pathPositionOffset = 0.0;\nfloat pathLength = L;\nif (path.billboard) {\nfloat visiblePathLength = sourcePathLength * (sourcePathRange.y - sourcePathRange.x);\narcLengthRatio = L > 0.0 ? visiblePathLength / L : 0.0;\npathPositionOffset = sourcePathLength * sourcePathRange.x;\npathLength = sourcePathLength;\n} else if (currLength2D > 0.0) {\narcLengthRatio = length(currDelta3) / currLength2D;\npathLength = L * arcLengthRatio;\n}\n#endif\nfloat sinHalfA = abs(dot(miterVec, perp));\nfloat cosHalfA = abs(dot(dirA, miterVec));\nfloat turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x);\nfloat cornerPosition = sideOfPath * turnDirection;\nfloat miterSize = 1.0 / max(sinHalfA, EPSILON);\nmiterSize = mix(\nmin(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)),\nmiterSize,\nstep(0.0, cornerPosition)\n);\nvec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition))\n* (sideOfPath + isJoint * turnDirection);\nbool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0));\nbool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0));\nbool isCap = isStartCap || isEndCap;\nif (isCap) {\noffsetVec = mix(perp * sideOfPath, dir * path.capType * 4.0 * flipIfTrue(isStartCap), isJoint);\nvJointType = path.capType;\n} else {\nvJointType = path.jointType;\n}\n#ifdef ANTIALIASING\nvec2 coverageOffsetVec = offsetVec * coverageScale;\n#ifdef DASH_ENABLED\nvPathLength = pathLength;\n#else\nvPathLength = L;\n#endif\nvCornerOffset = coverageOffsetVec;\nvMiterLength = dot(vCornerOffset, miterVec * turnDirection);\nvMiterLength = isCap ? isJoint : vMiterLength;\nvec2 offsetFromStartOfPath = coverageOffsetVec + deltaA * float(isEnd);\nvPathPosition = vec2(\ndot(offsetFromStartOfPath, perp),\n#ifdef DASH_ENABLED\npathPositionOffset + dot(offsetFromStartOfPath, dir) * arcLengthRatio\n#else\ndot(offsetFromStartOfPath, dir)\n#endif\n);\ngeometry.uv = vPathPosition;\nfloat isValid = step(instanceTypes, 3.5);\nvec3 offset = vec3(coverageOffsetVec * width * isValid, 0.0);\n#else\n#ifdef DASH_ENABLED\nvPathLength = pathLength;\n#else\nvPathLength = L;\n#endif\nvCornerOffset = offsetVec;\nvMiterLength = dot(vCornerOffset, miterVec * turnDirection);\nvMiterLength = isCap ? isJoint : vMiterLength;\nvec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd);\nvPathPosition = vec2(\ndot(offsetFromStartOfPath, perp),\n#ifdef DASH_ENABLED\npathPositionOffset + dot(offsetFromStartOfPath, dir) * arcLengthRatio\n#else\ndot(offsetFromStartOfPath, dir)\n#endif\n);\ngeometry.uv = vPathPosition;\nfloat isValid = step(instanceTypes, 3.5);\nvec3 offset = vec3(offsetVec * width * isValid, 0.0);\n#endif\nif (needsRotation) {\noffset = rotationMatrix * offset;\n}\nreturn offset;\n}\nvoid clipLine(inout vec4 position, vec4 refPosition) {\nif (position.w < EPSILON) {\nfloat r = (EPSILON - refPosition.w) / (position.w - refPosition.w);\nposition = refPosition + (position - refPosition) * r;\n}\n}\n#ifdef DASH_ENABLED\nvec2 getClippedPathRange(float startW, float endW) {\nbool startClipped = startW < EPSILON;\nbool endClipped = endW < EPSILON;\nif (startClipped && endClipped) {\nreturn vec2(0.0);\n}\nif (startClipped || endClipped) {\nfloat intersection = clamp((EPSILON - startW) / (endW - startW), 0.0, 1.0);\nreturn startClipped ? vec2(intersection, 1.0) : vec2(0.0, intersection);\n}\nreturn vec2(0.0, 1.0);\n}\n#endif\nvoid main() {\ngeometry.pickingColor = picking_getPickingColorFromIndex(rowIndexes);\nvColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity);\nfloat isEnd = positions.x;\nvec3 prevPosition = mix(instanceLeftPositions, instanceStartPositions, isEnd);\nvec3 prevPosition64Low = mix(instanceLeftPositions64Low, instanceStartPositions64Low, isEnd);\nvec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd);\nvec3 currPosition64Low = mix(instanceStartPositions64Low, instanceEndPositions64Low, isEnd);\nvec3 nextPosition = mix(instanceEndPositions, instanceRightPositions, isEnd);\nvec3 nextPosition64Low = mix(instanceEndPositions64Low, instanceRightPositions64Low, isEnd);\ngeometry.worldPosition = currPosition;\nvec2 widthPixels = vec2(clamp(\nproject_size_to_pixel(instanceStrokeWidths * path.widthScale, path.widthUnits),\npath.widthMinPixels, path.widthMaxPixels) / 2.0);\nvec3 width;\nif (path.billboard) {\n#ifdef DASH_ENABLED\nvec4 prevPositionCommon;\nvec4 nextPositionCommon;\nvec4 prevPositionScreen = project_position_to_clipspace(\nprevPosition, prevPosition64Low, ZERO_OFFSET, prevPositionCommon\n);\n#else\nvec4 prevPositionScreen = project_position_to_clipspace(\nprevPosition, prevPosition64Low, ZERO_OFFSET\n);\n#endif\nvec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position);\n#ifdef DASH_ENABLED\nvec4 nextPositionScreen = project_position_to_clipspace(\nnextPosition, nextPosition64Low, ZERO_OFFSET, nextPositionCommon\n);\n#else\nvec4 nextPositionScreen = project_position_to_clipspace(\nnextPosition, nextPosition64Low, ZERO_OFFSET\n);\n#endif\n#ifdef DASH_ENABLED\nvec4 sourcePathStartScreen = mix(currPositionScreen, prevPositionScreen, isEnd);\nvec4 sourcePathEndScreen = mix(nextPositionScreen, currPositionScreen, isEnd);\nvec2 billboardPathRange = getClippedPathRange(\nsourcePathStartScreen.w, sourcePathEndScreen.w\n);\n#endif\nclipLine(prevPositionScreen, currPositionScreen);\nclipLine(nextPositionScreen, currPositionScreen);\nclipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd));\nwidth = vec3(widthPixels, 0.0);\nDECKGL_FILTER_SIZE(width, geometry);\n#ifdef ANTIALIASING\nvec2 coveragePadding = vec2(0.5 / project.devicePixelRatio);\nfloat coverageScale = length(width.xy) > 0.0\n? length(width.xy + coveragePadding) / length(width.xy)\n: 1.0;\n#endif\n#ifdef DASH_ENABLED\nvec3 currentDeltaCommon = isEnd > 0.0\n? geometry.position.xyz - prevPositionCommon.xyz\n: nextPositionCommon.xyz - geometry.position.xyz;\nfloat billboardPathLength = width.x > 0.0\n? length(currentDeltaCommon) * project.scale / (width.x * project.focalDistance)\n: 0.0;\n#endif\nvec3 offset = getLineJoinOffset(\nprevPositionScreen.xyz / prevPositionScreen.w,\ncurrPositionScreen.xyz / currPositionScreen.w,\nnextPositionScreen.xyz / nextPositionScreen.w,\nproject_pixel_size_to_clipspace(width.xy)\n#ifdef DASH_ENABLED\n,\nbillboardPathLength, billboardPathRange\n#endif\n#ifdef ANTIALIASING\n,\ncoverageScale\n#endif\n);\n#ifdef DASH_ENABLED\nvPathBounds = billboardPathLength * billboardPathRange;\n#endif\nDECKGL_FILTER_GL_POSITION(currPositionScreen, geometry);\ngl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w);\n} else {\nprevPosition = project_position(prevPosition, prevPosition64Low);\ncurrPosition = project_position(currPosition, currPosition64Low);\nnextPosition = project_position(nextPosition, nextPosition64Low);\nwidth = vec3(project_pixel_size(widthPixels), 0.0);\nDECKGL_FILTER_SIZE(width, geometry);\n#ifdef ANTIALIASING\nvec2 coveragePadding = project_pixel_size(vec2(0.5 / project.devicePixelRatio));\nfloat coverageScale = length(width.xy) > 0.0\n? length(width.xy + coveragePadding) / length(width.xy)\n: 1.0;\n#endif\nvec3 offset = getLineJoinOffset(\nprevPosition, currPosition, nextPosition, width.xy\n#ifdef DASH_ENABLED\n, 1.0, vec2(0.0, 1.0)\n#endif\n#ifdef ANTIALIASING\n, coverageScale\n#endif\n);\n#ifdef DASH_ENABLED\nvPathBounds = vec2(0.0, vPathLength);\n#endif\ngeometry.position = vec4(currPosition + offset, 1.0);\ngl_Position = project_common_position_to_clipspace(geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME path-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nin vec2 vCornerOffset;\nin float vMiterLength;\nin vec2 vPathPosition;\nin float vPathLength;\nin float vJointType;\n#ifdef DASH_ENABLED\nin vec2 vPathBounds;\n#endif\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = vPathPosition;\n#ifdef ANTIALIASING\n#ifdef DASH_ENABLED\nbool isCorner = vPathPosition.y < vPathBounds.x || vPathPosition.y > vPathBounds.y;\n#else\nbool isCorner = vPathPosition.y < 0.0 || vPathPosition.y > vPathLength;\n#endif\nbool isRound = vJointType > 0.5;\nfloat bodyCoord = abs(vPathPosition.x);\nfloat cornerCoord = length(vCornerOffset);\nfloat bodyPixels = (1.0 - bodyCoord) / max(fwidth(bodyCoord), 1e-6);\nfloat cornerPixels = (1.0 - cornerCoord) / max(fwidth(cornerCoord), 1e-6);\n#ifdef PATH_STYLE_OFFSET\nfloat edgePixels = isRound && isCorner ? min(cornerPixels, bodyPixels) : bodyPixels;\n#else\nfloat edgePixels = isRound && isCorner ? cornerPixels : bodyPixels;\n#endif\nif (edgePixels <= -SMOOTH_EDGE_RADIUS) {\ndiscard;\n}\nif (isCorner) {\nif (!isRound && vMiterLength > path.miterLimit + 1.0) {\ndiscard;\n}\n}\nfragColor = vColor;\nfragColor.a *= smoothedge(0.0, edgePixels);\n#else\n#ifdef DASH_ENABLED\nif (vPathPosition.y < vPathBounds.x || vPathPosition.y > vPathBounds.y) {\n#else\nif (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) {\n#endif\nif (vJointType > 0.5 && length(vCornerOffset) > 1.0) {\ndiscard;\n}\nif (vJointType < 0.5 && vMiterLength > path.miterLimit + 1.0) {\ndiscard;\n}\n}\nfragColor = vColor;\n#endif\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:"const EPSILON: f32 = 0.001;\nconst ZERO_OFFSET: vec3<f32> = vec3<f32>(0.0, 0.0, 0.0);\n\nstruct JoinResult {\n offset: vec3<f32>,\n cornerOffset: vec2<f32>,\n miterLength: f32,\n pathPosition: vec2<f32>,\n pathLength: f32,\n jointType: f32,\n};\n\nstruct Attributes {\n @location(0) positions: vec2<f32>,\n @location(1) instanceTypes: f32,\n @location(2) instanceLeftPositions: vec3<f32>,\n @location(3) instanceStartPositions: vec3<f32>,\n @location(4) instanceEndPositions: vec3<f32>,\n @location(5) instanceRightPositions: vec3<f32>,\n @location(6) instanceLeftPositions64Low: vec3<f32>,\n @location(7) instanceStartPositions64Low: vec3<f32>,\n @location(8) instanceEndPositions64Low: vec3<f32>,\n @location(9) instanceRightPositions64Low: vec3<f32>,\n @location(10) instanceStrokeWidths: f32,\n @location(11) instanceColors: vec4<f32>,\n @location(12) rowIndexes: u32,\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n @location(0) vColor: vec4<f32>,\n @location(1) vCornerOffset: vec2<f32>,\n @location(2) vMiterLength: f32,\n @location(3) vPathPosition: vec2<f32>,\n @location(4) vPathLength: f32,\n @location(5) vJointType: f32,\n // Location 6 is reserved for TripsLayer's injected vTime varying.\n @location(7) clipCoordinates: vec2<f32>,\n#ifdef DASH_ENABLED\n @location(8) vPathBounds: vec2<f32>,\n#endif\n};\n\nfn flipIfTrue(flag: bool) -> f32 {\n return select(1.0, -1.0, flag);\n}\n\nfn clipLine(position: vec4<f32>, refPosition: vec4<f32>) -> vec4<f32> {\n if (position.w < EPSILON) {\n let r = (EPSILON - refPosition.w) / (position.w - refPosition.w);\n return refPosition + (position - refPosition) * r;\n }\n return position;\n}\n\n#ifdef DASH_ENABLED\n// Return the visible interval of the original segment before clipLine moves either endpoint.\nfn getClippedPathRange(startW: f32, endW: f32) -> vec2<f32> {\n let startClipped = startW < EPSILON;\n let endClipped = endW < EPSILON;\n if (startClipped && endClipped) {\n return vec2<f32>(0.0, 0.0);\n }\n if (startClipped || endClipped) {\n let intersection = clamp((EPSILON - startW) / (endW - startW), 0.0, 1.0);\n if (startClipped) {\n return vec2<f32>(intersection, 1.0);\n }\n return vec2<f32>(0.0, intersection);\n }\n return vec2<f32>(0.0, 1.0);\n}\n#endif\n\nfn getLineJoinOffset(\n prevPoint: vec3<f32>,\n currPoint: vec3<f32>,\n nextPoint: vec3<f32>,\n width: vec2<f32>,\n#ifdef DASH_ENABLED\n sourcePathLength: f32,\n sourcePathRange: vec2<f32>,\n#endif\n#ifdef ANTIALIASING\n coverageScale: f32,\n#endif\n positions: vec2<f32>,\n instanceTypes: f32\n) -> JoinResult {\n let isEnd = positions.x > 0.0;\n let sideOfPath = positions.y;\n let isJoint = select(0.0, 1.0, sideOfPath == 0.0);\n\n var deltaA3 = currPoint - prevPoint;\n var deltaB3 = nextPoint - currPoint;\n\n let rotationResult = project_needs_rotation(currPoint);\n if (path.billboard == 0.0 && rotationResult.needsRotation) {\n deltaA3 = rotationResult.transform * deltaA3;\n deltaB3 = rotationResult.transform * deltaB3;\n }\n\n let deltaA = deltaA3.xy / width;\n let deltaB = deltaB3.xy / width;\n\n let lenA = length(deltaA);\n let lenB = length(deltaB);\n\n let dirA = select(vec2<f32>(0.0, 0.0), normalize(deltaA), lenA > 0.0);\n let dirB = select(vec2<f32>(0.0, 0.0), normalize(deltaB), lenB > 0.0);\n\n let perpA = vec2<f32>(-dirA.y, dirA.x);\n let perpB = vec2<f32>(-dirB.y, dirB.x);\n\n var tangent = dirA + dirB;\n tangent = select(perpA, normalize(tangent), length(tangent) > 0.0);\n let miterVec = vec2<f32>(-tangent.y, tangent.x);\n let dir = select(dirB, dirA, isEnd);\n let perp = select(perpB, perpA, isEnd);\n#ifdef DASH_ENABLED\n let segmentLength2D = select(lenB, lenA, isEnd);\n\n // Extrusion happens in the XY plane, so segmentLength2D is a 2D length and pathPosition.y\n // below measures 2D distance along the segment. For a path that also moves in Z the true\n // arc length is longer by this ratio. Scaling pathLength and pathPosition.y by it makes\n // the coordinate measure real 3D distance while leaving the joint tests unchanged, since\n // they compare the two against each other and both are scaled alike. Billboard mode\n // extrudes in clip space, where the perspective divide has already reduced the segment to\n // its screen projection, so its complete common-space length is supplied by the caller.\n // Mirrors path-layer-vertex.glsl.ts.\n let currDelta3 = select(deltaB3, deltaA3, isEnd);\n let currLength2D = length(currDelta3.xy);\n // Do not clamp a valid denominator to EPSILON: high-zoom Web Mercator deltas are often\n // smaller than that in common space, and changing their scale corrupts even flat paths.\n let safeLength2D = select(1.0, currLength2D, currLength2D > 0.0);\n var arcLengthRatio = 1.0;\n var pathPositionOffset = 0.0;\n var pathLength = segmentLength2D;\n if (path.billboard != 0.0) {\n // clipLine may shorten the visible screen-space segment. Preserve the corresponding interval\n // of the complete common-space arclength instead of compressing the full dash period into the\n // visible span. Keep pathLength complete so justification is stable as the camera clips it.\n let visiblePathLength = sourcePathLength * (sourcePathRange.y - sourcePathRange.x);\n arcLengthRatio = 0.0;\n if (segmentLength2D > 0.0) {\n arcLengthRatio = visiblePathLength / segmentLength2D;\n }\n pathPositionOffset = sourcePathLength * sourcePathRange.x;\n pathLength = sourcePathLength;\n } else if (currLength2D > 0.0) {\n arcLengthRatio = length(currDelta3) / safeLength2D;\n pathLength = segmentLength2D * arcLengthRatio;\n }\n#else\n let pathLength = select(lenB, lenA, isEnd);\n#endif\n\n let sinHalfA = abs(dot(miterVec, perp));\n let cosHalfA = abs(dot(dirA, miterVec));\n let turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x);\n let cornerPosition = sideOfPath * turnDirection;\n\n var miterSize = 1.0 / max(sinHalfA, EPSILON);\n miterSize = mix(\n min(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)),\n miterSize,\n step(0.0, cornerPosition)\n );\n\n var offsetVec =\n mix(miterVec * miterSize, perp, step(0.5, cornerPosition)) *\n (sideOfPath + isJoint * turnDirection);\n\n let isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0));\n let isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0));\n let isCap = isStartCap || isEndCap;\n\n var jointType = path.jointType;\n if (isCap) {\n offsetVec = mix(\n perp * sideOfPath,\n dir * path.capType * 4.0 * flipIfTrue(isStartCap),\n isJoint\n );\n jointType = path.capType;\n }\n\n#ifdef ANTIALIASING\n let coverageOffsetVec = offsetVec * coverageScale;\n var miterLength = dot(coverageOffsetVec, miterVec * turnDirection);\n#else\n var miterLength = dot(offsetVec, miterVec * turnDirection);\n#endif\n miterLength = select(miterLength, isJoint, isCap);\n\n#ifdef ANTIALIASING\n let offsetFromStartOfPath = coverageOffsetVec + deltaA * select(0.0, 1.0, isEnd);\n#else\n let offsetFromStartOfPath = offsetVec + deltaA * select(0.0, 1.0, isEnd);\n#endif\n let pathPosition = vec2<f32>(\n dot(offsetFromStartOfPath, perp),\n#ifdef DASH_ENABLED\n pathPositionOffset + dot(offsetFromStartOfPath, dir) * arcLengthRatio\n#else\n dot(offsetFromStartOfPath, dir)\n#endif\n );\n let isValid = step(f32(instanceTypes), 3.5);\n#ifdef ANTIALIASING\n var offset = vec3<f32>(coverageOffsetVec * width * isValid, 0.0);\n#else\n var offset = vec3<f32>(offsetVec * width * isValid, 0.0);\n#endif\n\n if (path.billboard == 0.0 && rotationResult.needsRotation) {\n offset = rotationResult.transform * offset;\n }\n\n#ifdef ANTIALIASING\n return JoinResult(\n offset, coverageOffsetVec, miterLength, pathPosition, pathLength, jointType\n );\n#else\n return JoinResult(offset, offsetVec, miterLength, pathPosition, pathLength, jointType);\n#endif\n}\n\n@vertex\nfn vertexMain(attributes: Attributes) -> Varyings {\n var varyings: Varyings;\n\n geometry.pickingColor = picking_getPickingColorFromIndex(attributes.rowIndexes);\n\n let isEnd = attributes.positions.x;\n\n let prevPosition = mix(attributes.instanceLeftPositions, attributes.instanceStartPositions, isEnd);\n let prevPosition64Low = mix(\n attributes.instanceLeftPositions64Low,\n attributes.instanceStartPositions64Low,\n isEnd\n );\n let currPosition = mix(attributes.instanceStartPositions, attributes.instanceEndPositions, isEnd);\n let currPosition64Low = mix(\n attributes.instanceStartPositions64Low,\n attributes.instanceEndPositions64Low,\n isEnd\n );\n let nextPosition = mix(attributes.instanceEndPositions, attributes.instanceRightPositions, isEnd);\n let nextPosition64Low = mix(\n attributes.instanceEndPositions64Low,\n attributes.instanceRightPositions64Low,\n isEnd\n );\n\n geometry.worldPosition = currPosition;\n\n let widthPixels =\n clamp(\n project_unit_size_to_pixel(attributes.instanceStrokeWidths * path.widthScale, path.widthUnits),\n path.widthMinPixels,\n path.widthMaxPixels\n ) / 2.0;\n\n if (path.billboard != 0.0) {\n#ifdef DASH_ENABLED\n let prevProjection = project_position_to_clipspace_and_commonspace(\n prevPosition, prevPosition64Low, ZERO_OFFSET\n );\n let nextProjection = project_position_to_clipspace_and_commonspace(\n nextPosition, nextPosition64Low, ZERO_OFFSET\n );\n let prevPositionCommon = prevProjection.commonPosition.xyz;\n let nextPositionCommon = nextProjection.commonPosition.xyz;\n var prevPositionScreen = prevProjection.clipPosition;\n var nextPositionScreen = nextProjection.clipPosition;\n#else\n var prevPositionScreen = project_position_to_clipspace(\n prevPosition, prevPosition64Low, ZERO_OFFSET\n );\n var nextPositionScreen = project_position_to_clipspace(\n nextPosition, nextPosition64Low, ZERO_OFFSET\n );\n#endif\n let currProjection = project_position_to_clipspace_and_commonspace(\n currPosition, currPosition64Low, ZERO_OFFSET\n );\n geometry.position = currProjection.commonPosition;\n var currPositionScreen = currProjection.clipPosition;\n#ifdef DASH_ENABLED\n let currPositionCommon = currProjection.commonPosition.xyz;\n let sourcePathStartScreen = mix(currPositionScreen, prevPositionScreen, isEnd);\n let sourcePathEndScreen = mix(nextPositionScreen, currPositionScreen, isEnd);\n let billboardPathRange = getClippedPathRange(\n sourcePathStartScreen.w, sourcePathEndScreen.w\n );\n#endif\n\n prevPositionScreen = clipLine(prevPositionScreen, currPositionScreen);\n nextPositionScreen = clipLine(nextPositionScreen, currPositionScreen);\n currPositionScreen = clipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd));\n\n#ifdef ANTIALIASING\n let coverageScale = select(\n 1.0,\n (widthPixels + 0.5 / project.devicePixelRatio) / max(widthPixels, 1e-6),\n widthPixels > 0.0\n );\n#endif\n#ifdef DASH_ENABLED\n let currentDeltaCommon = select(\n nextPositionCommon - currPositionCommon,\n currPositionCommon - prevPositionCommon,\n isEnd > 0.0\n );\n let billboardPathLength = select(\n 0.0,\n length(currentDeltaCommon) * project.scale / (widthPixels * project.focalDistance),\n widthPixels > 0.0\n );\n#endif\n let join = getLineJoinOffset(\n prevPositionScreen.xyz / prevPositionScreen.w,\n currPositionScreen.xyz / currPositionScreen.w,\n nextPositionScreen.xyz / nextPositionScreen.w,\n project_pixel_size_to_clipspace(vec2<f32>(widthPixels, widthPixels)),\n#ifdef DASH_ENABLED\n billboardPathLength,\n billboardPathRange,\n#endif\n#ifdef ANTIALIASING\n coverageScale,\n#endif\n attributes.positions,\n attributes.instanceTypes\n );\n#ifdef DASH_ENABLED\n // Phase and justification use the complete source segment, while cap and joint coverage\n // must still recognize the endpoints moved by clipLine.\n varyings.vPathBounds = billboardPathLength * billboardPathRange;\n#endif\n\n geometry.uv = join.pathPosition;\n varyings.position = vec4<f32>(\n currPositionScreen.xyz + join.offset * currPositionScreen.w,\n currPositionScreen.w\n );\n varyings.vCornerOffset = join.cornerOffset;\n varyings.vMiterLength = join.miterLength;\n varyings.vPathPosition = join.pathPosition;\n varyings.vPathLength = join.pathLength;\n varyings.vJointType = join.jointType;\n } else {\n let prevPositionCommon = project_position_vec3_f64(prevPosition, prevPosition64Low);\n let currPositionCommon = project_position_vec3_f64(currPosition, currPosition64Low);\n let nextPositionCommon = project_position_vec3_f64(nextPosition, nextPosition64Low);\n\n let width = vec2<f32>(\n project_pixel_size_float(widthPixels),\n project_pixel_size_float(widthPixels)\n );\n#ifdef ANTIALIASING\n let coverageScale = select(\n 1.0,\n (widthPixels + 0.5 / project.devicePixelRatio) / max(widthPixels, 1e-6),\n widthPixels > 0.0\n );\n#endif\n let join = getLineJoinOffset(\n prevPositionCommon,\n currPositionCommon,\n nextPositionCommon,\n width,\n#ifdef DASH_ENABLED\n 1.0,\n vec2<f32>(0.0, 1.0),\n#endif\n#ifdef ANTIALIASING\n coverageScale,\n#endif\n attributes.positions,\n attributes.instanceTypes\n );\n#ifdef DASH_ENABLED\n varyings.vPathBounds = vec2<f32>(0.0, join.pathLength);\n#endif\n\n geometry.position = vec4<f32>(currPositionCommon + join.offset, 1.0);\n geometry.uv = join.pathPosition;\n varyings.position = project_common_position_to_clipspace(geometry.position);\n varyings.vCornerOffset = join.cornerOffset;\n varyings.vMiterLength = join.miterLength;\n varyings.vPathPosition = join.pathPosition;\n varyings.vPathLength = join.pathLength;\n varyings.vJointType = join.jointType;\n }\n\n varyings.clipCoordinates = geometry.position.xy;\n clip_filterPosition(&varyings.position, geometry.worldPosition.xy);\n\n varyings.vColor = vec4<f32>(\n attributes.instanceColors.rgb,\n attributes.instanceColors.a * layer.opacity\n );\n return varyings;\n}\n\n@fragment\nfn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {\n geometry.uv = varyings.vPathPosition;\n\n#ifdef ANTIALIASING\n // Coordinates of the outer silhouette, in units of half-width: rounded joints and caps are\n // bounded by the corner offset, everywhere else by the edge of the stroke. Dividing by the\n // screen-space derivative converts the distance to the boundary into device pixels, which stays\n // correct under perspective foreshortening and under extensions that rescale the stroke.\n#ifdef DASH_ENABLED\n let isCorner =\n varyings.vPathPosition.y < varyings.vPathBounds.x ||\n varyings.vPathPosition.y > varyings.vPathBounds.y;\n#else\n let isCorner = varyings.vPathPosition.y < 0.0 || varyings.vPathPosition.y > varyings.vPathLength;\n#endif\n let isRound = varyings.vJointType > 0.5;\n\n // Distance to the silhouette in device pixels, from the derivative of the coordinate that\n // bounds it. Computed before the discards below: derivatives need uniform control flow and are\n // undefined after a discard in the quad. See dev-docs/RFCs/v9.4/analytic-antialiasing-rfc.md\n let bodyCoord = abs(varyings.vPathPosition.x);\n let cornerCoord = length(varyings.vCornerOffset);\n // Both evaluated so each derivative stays on one field across the corner/body boundary\n let bodyPixels = (1.0 - bodyCoord) / max(fwidth(bodyCoord), 1e-6);\n let cornerPixels = (1.0 - cornerCoord) / max(fwidth(cornerCoord), 1e-6);\n#ifdef PATH_STYLE_OFFSET\n // Rounded corners still intersect the stroke-width envelope. Extensions may remap\n // vPathPosition.x independently of vCornerOffset, as PathStyleExtension does for offsets.\n let edgePixels = select(bodyPixels, min(cornerPixels, bodyPixels), isRound && isCorner);\n#else\n let edgePixels = select(bodyPixels, cornerPixels, isRound && isCorner);\n#endif\n\n // Fragments outside the coverage ramp must not write depth or picking colors.\n if (edgePixels <= -SMOOTH_EDGE_RADIUS) {\n discard;\n }\n\n if (isCorner) {\n if (!isRound && varyings.vMiterLength > path.miterLimit + 1.0) {\n discard;\n }\n }\n\n var color = varyings.vColor;\n\n // Feather one device pixel across the width only, before premultiplication. edgePixels is a\n // signed device-pixel distance and SMOOTH_EDGE_RADIUS is 0.5, so this ramps across one pixel.\n color.a *= smoothedge(0.0, edgePixels);\n#else\n#ifdef DASH_ENABLED\n if (\n varyings.vPathPosition.y < varyings.vPathBounds.x ||\n varyings.vPathPosition.y > varyings.vPathBounds.y\n ) {\n#else\n if (\n varyings.vPathPosition.y < 0.0 ||\n varyings.vPathPosition.y > varyings.vPathLength\n ) {\n#endif\n if (varyings.vJointType > 0.5 && length(varyings.vCornerOffset) > 1.0) {\n discard;\n }\n if (\n varyings.vJointType < 0.5 &&\n varyings.vMiterLength > path.miterLimit + 1.0\n ) {\n discard;\n }\n }\n#endif\n\n // Fragment-layer injections that discard pixels must run after analytic coverage derivatives.\n // See TripsLayer, which rejects fragments outside of the active time window at this anchor.\n // DECKGL_FILTER_COLOR\n clip_filterColor(varyings.clipCoordinates);\n#ifdef ANTIALIASING\n return deckgl_premultiplied_alpha(color);\n#else\n return deckgl_premultiplied_alpha(varyings.vColor);\n#endif\n}\n",defines:e?{ANTIALIASING:1}:{},modules:[r.A,s.A,o.Ay,v,..."webgpu"===this.context.device.type?[y.A]:[]]})}get wrapLongitude(){return!1}getBounds(){return"webgpu"===this.context.device.type?null:this.getAttributeManager()?.getBounds(["vertexPositions"])}getPathProjectionScale(e){const t=this.props.coordinateSystem;if(!Boolean(this.getAttributeManager()?.getAttributes().instanceDashOffsets))return null;if(e instanceof a.A&&e.zoom>=12&&("default"===t||"lnglat"===t||"cartesian"===t)){const n=c.A.getUniforms({viewport:e,coordinateSystem:t,coordinateOrigin:this.props.coordinateOrigin,autoWrapLongitude:this.wrapLongitude});return[e.projectionMode,n.coordinateOrigin[1],n.commonOrigin[1],...n.commonUnitsPerWorldUnit,...n.commonUnitsPerWorldUnit2,n.commonUnitsPerMeter[2]]}const n=function(e){if(e.isGeospatial)return null;const{unitsPerMeter:t}=e.distanceScales;return[t[0],t[1],t[2]]}(e);return n?[e.projectionMode,...n]:[e.projectionMode]}shouldUpdateState(e){const{viewport:t}=this.context;return super.shouldUpdateState(e)||this.state?.tessellationResolution!==t.resolution||!w(this.state?.pathProjectionScale,this.getPathProjectionScale(t))}initializeState(){const e=!0,t="webgpu"===this.context.device.type;this.getAttributeManager().addInstanced({...t?{pathPositions:{size:24,type:"float32",transition:!1,accessor:"getPath",update:this.calculateWebGPUPositions,shaderAttributes:{instanceLeftPositions:{size:3,elementOffset:0},instanceStartPositions:{size:3,elementOffset:3},instanceEndPositions:{size:3,elementOffset:6},instanceRightPositions:{size:3,elementOffset:9},instanceLeftPositions64Low:{size:3,elementOffset:12},instanceStartPositions64Low:{size:3,elementOffset:15},instanceEndPositions64Low:{size:3,elementOffset:18},instanceRightPositions64Low:{size:3,elementOffset:21}},noAlloc:e}}:{vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:x,accessor:"getPath",update:this.calculatePositions,noAlloc:e,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}}},instanceTypes:{size:1,type:t?"float32":"uint8",update:this.calculateSegmentTypes,noAlloc:e},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:!t&&x,defaultValue:1,bufferGroup:"path-instance-data"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:!t&&x,defaultValue:b,bufferGroup:"path-instance-data"},rowIndexes:{size:1,type:"uint32",accessor:(e,{index:t})=>e&&e.__source?e.__source.index:t,bufferGroup:"path-instance-data"}}),this.setState({pathTesselator:new PathTesselator({fp64:this.use64bitPositions(),isWebGPU:t}),tessellationResolution:this.context.viewport.resolution,pathProjectionScale:this.getPathProjectionScale(this.context.viewport)})}updateState(e){super.updateState(e);const{props:t,oldProps:n,changeFlags:i}=e,r=this.getAttributeManager(),{viewport:s}=this.context,o=this.state.tessellationResolution!==s.resolution,a=this.getPathProjectionScale(s),c=!w(this.state.pathProjectionScale,a),l=i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPath)||t._pathType!==n._pathType||t.positionFormat!==n.positionFormat||t.wrapLongitude!==n.wrapLongitude||o;if(i.dataChanged||l){const{pathTesselator:e}=this.state,n=t.data.attributes||{};e.updateGeometry({data:t.data,geometryBuffer:n.getPath,buffers:n,normalize:!t._pathType,loop:"loop"===t._pathType,getGeometry:t.getPath,positionFormat:t.positionFormat,wrapLongitude:t.wrapLongitude,resolution:s.resolution,dataChanged:l?void 0:i.dataChanged}),this.setState({numInstances:e.instanceCount,startIndices:e.vertexStarts,tessellationResolution:s.resolution,pathProjectionScale:a}),!i.dataChanged||l?r.invalidateAll():c&&r.invalidate("instanceDashOffsets")}else c&&(this.setState({pathProjectionScale:a}),r.invalidate("instanceDashOffsets"));(i.extensionsChanged||t.antialiasing!==n.antialiasing)&&(this.state.model?.destroy(),this.state.model=this._getModel(),r.invalidateAll())}getPickingInfo(e){const t=super.getPickingInfo(e),{index:n}=t,i=this.props.data;return i[0]&&i[0].__source&&(t.object=i.find(e=>e.__source.index===n)),t}disablePickingIndex(e){const t=this.props.data;if(t[0]&&t[0].__source)for(let n=0;n<t.length;n++)t[n].__source.index===e&&this._disablePickingIndex(n);else super.disablePickingIndex(e)}draw({uniforms:e}){const{jointRounded:t,capRounded:n,billboard:i,miterLimit:r,widthUnits:s,widthScale:o,widthMinPixels:a,widthMaxPixels:c}=this.props,u=this.state.model,d={jointType:Number(t),capType:Number(n),billboard:i,widthUnits:l.p5[s],widthScale:o,miterLimit:r,widthMinPixels:a,widthMaxPixels:c};u.shaderInputs.setProps({path:d}),u.draw(this.context.renderPass)}_getModel(){return new d.K(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new u.V({topology:"triangle-list",attributes:{indices:new Uint16Array([0,1,2,1,4,2,1,3,4,3,5,4]),positions:{value:new Float32Array([0,0,0,-1,0,1,1,-1,1,1,1,0]),size:2}}}),isInstanced:!0})}calculatePositions(e){const{pathTesselator:t}=this.state;e.startIndices=t.vertexStarts,e.value=t.get("positions")}calculateSegmentTypes(e){const{pathTesselator:t}=this.state;e.startIndices=t.vertexStarts,e.value=t.get("segmentTypes")}calculateWebGPUPositions(e){const{pathTesselator:t}=this.state,n=t.get("positions");if(!n)return void(e.value=null);const i=t.instanceCount,r=new Float32Array(24*i),s=[-1,0,1,2];for(let e=0;e<i;e++){const t=24*e;for(let o=0;o<4;o++){const a=e+s[o],c=t+3*o;for(let e=0;e<3;e++){const t=a>=0&&a<i?n[3*a+e]:0,s=Math.fround(t);r[c+e]=s,r[c+e+12]=t-s}}}e.startIndices=t.vertexStarts,e.value=r}}PathLayer.defaultProps=_,PathLayer.layerName="PathLayer";const P=PathLayer},65981(e,t,n){n.d(t,{A:()=>V});var i=n(59452),r=n(3459),s=n(53439),o=n(91638);const a="layout(std140) uniform sdfUniforms {\n float gamma;\n bool enabled;\n float buffer;\n float outlineBuffer;\n vec4 outlineColor;\n} sdf;\n",c={name:"sdf",vs:a,fs:a,uniformTypes:{gamma:"f32",enabled:"f32",buffer:"f32",outlineBuffer:"f32",outlineColor:"vec4<f32>"}},l={none:0,start:1,center:2,end:3},u={name:"text",vs:`layout(std140) uniform textUniforms {\n highp vec2 cutoffPixels;\n highp ivec2 align;\n highp float fontSize;\n bool flipY;\n} text;\n\n#define ALIGN_MODE_START ${l.start}\n#define ALIGN_MODE_CENTER ${l.center}\n#define ALIGN_MODE_END ${l.end}\n`,getUniforms:({contentCutoffPixels:e=[0,0],contentAlignHorizontal:t="none",contentAlignVertical:n="none",fontSize:i,viewport:r})=>({cutoffPixels:e,align:[l[t],l[n]],fontSize:i,flipY:r?.flipY??!1}),uniformTypes:{cutoffPixels:"vec2<f32>",align:"vec2<i32>",fontSize:"f32",flipY:"f32"}};const d=function({collision:e=!1}={}){return`struct IconUniforms {\n sizeScale: f32,\n iconsTextureDim: vec2<f32>,\n sizeBasis: f32,\n sizeMinPixels: f32,\n sizeMaxPixels: f32,\n billboard: i32,\n sizeUnits: i32,\n alphaCutoff: f32\n};\n\nstruct TextUniforms {\n cutoffPixels: vec2<f32>,\n align: vec2<i32>,\n fontSize: f32,\n flipY: f32\n};\n\nstruct SdfUniforms {\n gamma: f32,\n enabled: f32,\n buffer: f32,\n outlineBuffer: f32,\n outlineColor: vec4<f32>\n};\n\n${e?"struct CollisionUniforms {\n sort: i32,\n enabled: i32\n};\n":""}\n\nconst ALIGN_MODE_START: i32 = 1;\nconst ALIGN_MODE_CENTER: i32 = 2;\nconst ALIGN_MODE_END: i32 = 3;\n\n@group(0) @binding(auto) var<uniform> icon: IconUniforms;\n@group(0) @binding(auto) var<uniform> text: TextUniforms;\n@group(0) @binding(auto) var<uniform> sdf: SdfUniforms;\n${e?"@group(0) @binding(auto) var<uniform> collision: CollisionUniforms;":""}\n@group(0) @binding(auto) var iconsTexture : texture_2d<f32>;\n@group(0) @binding(auto) var iconsTextureSampler : sampler;\n${e?"@group(0) @binding(auto) var collision_texture : texture_2d<f32>;\n":""}\n\nfn rotate_by_angle(vertex: vec2<f32>, angle_deg: f32) -> vec2<f32> {\n let angle_radian = angle_deg * PI / 180.0;\n let c = cos(angle_radian);\n let s = sin(angle_radian);\n let rotation = mat2x2<f32>(vec2<f32>(c, -s), vec2<f32>(s, c));\n return rotation * vertex;\n}\n\nfn get_pixel_offset_from_alignment(\n anchor: f32,\n extent: f32,\n clipStart: f32,\n clipEnd: f32,\n mode: i32\n) -> f32 {\n if (clipEnd < clipStart) {\n return 0.0;\n }\n if (mode == ALIGN_MODE_START) {\n return max(-(anchor + clipStart), 0.0);\n }\n if (mode == ALIGN_MODE_CENTER) {\n let minValue = max(0.0, anchor + clipStart);\n let maxValue = min(extent, anchor + clipEnd);\n if (minValue < maxValue) {\n return (minValue + maxValue) / 2.0 - anchor;\n }\n return 0.0;\n }\n if (mode == ALIGN_MODE_END) {\n return min(extent - (anchor + clipEnd), 0.0);\n }\n return 0.0;\n}\n\n${e?"fn collision_match(texCoords: vec2<f32>, pickingColor: vec3<f32>) -> f32 {\n let textureSize = vec2<i32>(textureDimensions(collision_texture));\n let pixelCoords = clamp(\n vec2<i32>(texCoords * vec2<f32>(textureSize)),\n vec2<i32>(0),\n textureSize - vec2<i32>(1)\n );\n let collisionPickingColor = textureLoad(collision_texture, pixelCoords, 0);\n let delta = dot(abs(collisionPickingColor.rgb - pickingColor), vec3<f32>(1.0));\n return step(delta, 0.001);\n}\n\nfn collision_is_visible(texCoords: vec2<f32>, pickingColor: vec3<f32>) -> f32 {\n if (collision.enabled == 0) {\n return 1.0;\n }\n\n var accumulator = 0.0;\n let stepSize = vec2<f32>(1.0) / project.viewportSize;\n\n for (var i: i32 = -2; i <= 2; i = i + 1) {\n for (var j: i32 = -2; j <= 2; j = j + 1) {\n let delta = vec2<f32>(f32(j), f32(i)) * stepSize;\n accumulator = accumulator + collision_match(texCoords + delta, pickingColor);\n }\n }\n\n return pow(accumulator / 25.0, 2.2);\n}\n":""}\n\nstruct Attributes {\n @location(0) positions: vec2<f32>,\n\n @location(1) instancePositions: vec3<f32>,\n @location(2) instancePositions64Low: vec3<f32>,\n @location(3) instanceSizes: f32,\n @location(4) instanceAngles: f32,\n @location(5) instanceColors: vec4<f32>,\n @location(6) instanceIconFrames: vec4<f32>,\n @location(7) instanceColorModes: f32,\n @location(8) instanceOffsets: vec2<f32>,\n @location(9) instancePixelOffset: vec2<f32>,\n @location(10) rowIndexes: u32,\n @location(11) instanceClipRect: vec4<f32>,\n ${e?"@location(12) collisionPriorities: f32,":""}\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n\n @location(0) vColorMode: f32,\n @location(1) vColor: vec4<f32>,\n @location(2) vTextureCoords: vec2<f32>,\n @location(3) uv: vec2<f32>,\n @location(4) pickingColor: vec3<f32>,\n};\n\n@vertex\nfn vertexMain(inp: Attributes) -> Varyings {\n geometry.worldPosition = inp.instancePositions;\n geometry.uv = inp.positions;\n geometry.pickingColor = picking_getPickingColorFromIndex(inp.rowIndexes);\n\n var outp: Varyings;\n outp.uv = inp.positions;\n\n let iconSize = inp.instanceIconFrames.zw;\n\n let sizePixels = clamp(\n project_unit_size_to_pixel(inp.instanceSizes * icon.sizeScale, icon.sizeUnits),\n icon.sizeMinPixels, icon.sizeMaxPixels\n );\n let instanceScale = sizePixels / text.fontSize;\n\n var pixelOffset = inp.positions / 2.0 * iconSize + inp.instanceOffsets;\n pixelOffset = rotate_by_angle(pixelOffset, inp.instanceAngles) * instanceScale;\n pixelOffset = pixelOffset + inp.instancePixelOffset;\n pixelOffset.y = pixelOffset.y * -1.0;\n\n var pos: vec4<f32>;\n var anchorPosScreen: vec2<f32>;\n if (icon.billboard != 0) {\n pos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, vec3<f32>(0.0));\n anchorPosScreen = pos.xy / pos.w;\n\n let clipOffset = project_pixel_size_to_clipspace(pixelOffset);\n pos = vec4<f32>(pos.x + clipOffset.x, pos.y + clipOffset.y, pos.z, pos.w);\n } else {\n var offsetCommon = vec3<f32>(project_pixel_size_vec2(pixelOffset), 0.0);\n if (text.flipY > 0.5) {\n offsetCommon.y = offsetCommon.y * -1.0;\n }\n let anchorPos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, vec3<f32>(0.0));\n anchorPosScreen = anchorPos.xy / anchorPos.w;\n pos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, offsetCommon);\n }\n\n anchorPosScreen = vec2<f32>(anchorPosScreen.x + 1.0, 1.0 - anchorPosScreen.y) / 2.0 *\n project.viewportSize / project.devicePixelRatio;\n var xy = project_size_vec2(inp.instanceClipRect.xy) * project.scale;\n var wh = project_size_vec2(inp.instanceClipRect.zw) * project.scale;\n\n if (text.flipY > 0.5) {\n xy.y = -xy.y - wh.y;\n }\n if (text.align.x > 0 || text.align.y > 0) {\n let viewportPixels = project.viewportSize / project.devicePixelRatio;\n let scrollPixels = vec2<f32>(\n get_pixel_offset_from_alignment(anchorPosScreen.x, viewportPixels.x, xy.x, xy.x + wh.x, text.align.x),\n -get_pixel_offset_from_alignment(anchorPosScreen.y, viewportPixels.y, -xy.y - wh.y, -xy.y, text.align.y)\n );\n pixelOffset = pixelOffset + scrollPixels;\n let scrollClipOffset = project_pixel_size_to_clipspace(scrollPixels);\n pos.x = pos.x + scrollClipOffset.x;\n pos.y = pos.y + scrollClipOffset.y;\n }\n\n if (inp.instanceClipRect.z >= 0.0) {\n if (pixelOffset.x < xy.x || pixelOffset.x > xy.x + wh.x) {\n pos = vec4<f32>(0.0);\n } else if (text.cutoffPixels.x > 0.0) {\n let viewportWidth = project.viewportSize.x / project.devicePixelRatio;\n let left = max(anchorPosScreen.x + xy.x, 0.0);\n let right = min(anchorPosScreen.x + xy.x + wh.x, viewportWidth);\n if (right - left < text.cutoffPixels.x) {\n pos = vec4<f32>(0.0);\n }\n }\n }\n if (inp.instanceClipRect.w >= 0.0) {\n if (pixelOffset.y < xy.y || pixelOffset.y > xy.y + wh.y) {\n pos = vec4<f32>(0.0);\n } else if (text.cutoffPixels.y > 0.0) {\n let viewportHeight = project.viewportSize.y / project.devicePixelRatio;\n let top = max(anchorPosScreen.y - xy.y - wh.y, 0.0);\n let bottom = min(anchorPosScreen.y - xy.y, viewportHeight);\n if (bottom - top < text.cutoffPixels.y) {\n pos = vec4<f32>(0.0);\n }\n }\n }\n\n ${e?" if (collision.sort != 0) {\n pos.z = -0.001 * inp.collisionPriorities * pos.w;\n }\n ":""}\n\n let uvMix = (inp.positions.xy + vec2<f32>(1.0, 1.0)) * 0.5;\n outp.vTextureCoords = mix(inp.instanceIconFrames.xy, inp.instanceIconFrames.xy + iconSize, uvMix) / icon.iconsTextureDim;\n\n outp.position = pos;\n outp.vColor = inp.instanceColors;\n outp.vColorMode = inp.instanceColorModes;\n outp.pickingColor = picking_getPickingColorFromIndex(inp.rowIndexes);\n\n return outp;\n}\n\n@fragment\nfn fragmentMain(inp: Varyings) -> @location(0) vec4<f32> {\n geometry.uv = inp.uv;\n\n let texColor = textureSample(iconsTexture, iconsTextureSampler, inp.vTextureCoords);\n var alpha = texColor.a;\n var color = inp.vColor;\n\n if (sdf.enabled > 0.5) {\n let distance = alpha;\n alpha = smoothstep(sdf.buffer - sdf.gamma, sdf.buffer + sdf.gamma, distance);\n\n if (sdf.outlineBuffer > 0.0) {\n let inFill = alpha;\n let inBorder = smoothstep(sdf.outlineBuffer - sdf.gamma, sdf.outlineBuffer + sdf.gamma, distance);\n color = mix(sdf.outlineColor, inp.vColor, inFill);\n alpha = inBorder;\n }\n } else if (inp.vColorMode == 0.0) {\n color = texColor;\n }\n\n var a = alpha * color.a * layer.opacity;\n if (a < icon.alphaCutoff) {\n discard;\n }\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(inp.pickingColor)) {\n discard;\n }\n return vec4<f32>(inp.pickingColor, 1.0);\n }\n\n ${e?" let collisionFade = collision_is_visible(inp.position.xy / project.viewportSize, inp.pickingColor);\n a = a * collisionFade;\n if (a <= 0.0001) {\n discard;\n }\n ":""}\n\n var fragColor = deckgl_premultiplied_alpha(vec4<f32>(color.rgb, a));\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(inp.pickingColor - highlightedObjectColor))) {\n let highLightAlpha = picking.highlightColor.a;\n let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);\n if (blendedAlpha > 0.0) {\n let highLightRatio = highLightAlpha / blendedAlpha;\n fragColor = vec4<f32>(\n mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),\n blendedAlpha\n );\n } else {\n fragColor = vec4<f32>(fragColor.rgb, 0.0);\n }\n }\n }\n\n return fragColor;\n}\n`}(),h=.75;class MultiIconLayer extends o.A{getShaders(){const e=super.getShaders();return{...e,modules:[...e.modules,u,c],vs:"#version 300 es\n#define SHADER_NAME multi-icon-layer-vertex-shader\nin vec2 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin float instanceSizes;\nin float instanceAngles;\nin vec4 instanceColors;\nin float rowIndexes;\nin vec4 instanceIconFrames;\nin float instanceColorModes;\nin vec2 instanceOffsets;\nin vec2 instancePixelOffset;\nin vec4 instanceClipRect;\nout float vColorMode;\nout vec4 vColor;\nout vec2 vTextureCoords;\nout vec2 uv;\nvec2 rotate_by_angle(vec2 vertex, float angle) {\nfloat angle_radian = angle * PI / 180.0;\nfloat cos_angle = cos(angle_radian);\nfloat sin_angle = sin(angle_radian);\nmat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);\nreturn rotationMatrix * vertex;\n}\nfloat getPixelOffsetFromAlignment(float anchor, float extent, float clipStart, float clipEnd, int mode) {\nif (clipEnd < clipStart) return 0.0;\nif (mode == ALIGN_MODE_START) {\nreturn max(- (anchor + clipStart), 0.0);\n}\nif (mode == ALIGN_MODE_CENTER) {\nfloat _min = max(0., anchor + clipStart);\nfloat _max = min(extent, anchor + clipEnd);\nreturn _min < _max ? (_min + _max) / 2.0 - anchor : 0.0;\n}\nif (mode == ALIGN_MODE_END) {\nreturn min(extent - (anchor + clipEnd), 0.);\n}\nreturn 0.0;\n}\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.uv = positions;\ngeometry.pickingColor = picking_getPickingColorFromIndex(rowIndexes);\nuv = positions;\nvec2 iconSize = instanceIconFrames.zw;\nfloat sizePixels = clamp(\nproject_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits),\nicon.sizeMinPixels, icon.sizeMaxPixels\n);\nfloat instanceScale = sizePixels / text.fontSize;\nvec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets;\npixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale;\npixelOffset += instancePixelOffset;\npixelOffset.y *= -1.0;\nvec2 anchorPosScreen;\nif (icon.billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nanchorPosScreen = gl_Position.xy / gl_Position.w;\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = vec3(pixelOffset, 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);\nif (text.flipY) {\noffset_common.y *= -1.;\n}\nDECKGL_FILTER_SIZE(offset_common, geometry);\nvec4 anchorPos = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0));\nanchorPosScreen = anchorPos.xy / anchorPos.w;\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nanchorPosScreen = vec2(anchorPosScreen.x + 1.0, 1.0 - anchorPosScreen.y) / 2.0 * project.viewportSize / project.devicePixelRatio;\nvec2 xy = project_size_to_pixel(instanceClipRect.xy);\nvec2 wh = project_size_to_pixel(instanceClipRect.zw);\nif (text.flipY) {\nxy.y = -xy.y - wh.y;\n}\nif (text.align.x > 0 || text.align.y > 0) {\nvec2 viewportPixels = project.viewportSize / project.devicePixelRatio;\nvec2 scrollPixels = vec2(\ngetPixelOffsetFromAlignment(anchorPosScreen.x, viewportPixels.x, xy.x, xy.x + wh.x, text.align.x),\n-getPixelOffsetFromAlignment(anchorPosScreen.y, viewportPixels.y, -xy.y - wh.y, -xy.y, text.align.y)\n);\npixelOffset += scrollPixels;\ngl_Position.xy += project_pixel_size_to_clipspace(scrollPixels);\n}\nif (instanceClipRect.z >= 0.) {\nif (pixelOffset.x < xy.x || pixelOffset.x > xy.x + wh.x) {\ngl_Position = vec4(0.0);\n}\nelse if (text.cutoffPixels.x > 0.) {\nfloat vpWidth = project.viewportSize.x / project.devicePixelRatio;\nfloat l = max(anchorPosScreen.x + xy.x, 0.0);\nfloat r = min(anchorPosScreen.x + xy.x + wh.x, vpWidth);\nif (r - l < text.cutoffPixels.x) {\ngl_Position = vec4(0.0);\n}\n}\n}\nif (instanceClipRect.w >= 0.) {\nif (pixelOffset.y < xy.y || pixelOffset.y > xy.y + wh.y) {\ngl_Position = vec4(0.0);\n}\nelse if (text.cutoffPixels.y > 0.) {\nfloat vpHeight = project.viewportSize.y / project.devicePixelRatio;\nfloat t = max(anchorPosScreen.y - xy.y - wh.y, 0.0);\nfloat b = min(anchorPosScreen.y - xy.y, vpHeight);\nif (b - t < text.cutoffPixels.y) {\ngl_Position = vec4(0.0);\n}\n}\n}\nvTextureCoords = mix(\ninstanceIconFrames.xy,\ninstanceIconFrames.xy + iconSize,\n(positions.xy + 1.0) / 2.0\n) / icon.iconsTextureDim;\nvColor = instanceColors;\nDECKGL_FILTER_COLOR(vColor, geometry);\nvColorMode = instanceColorModes;\n}\n",fs:"#version 300 es\n#define SHADER_NAME multi-icon-layer-fragment-shader\nprecision highp float;\nuniform sampler2D iconsTexture;\nin vec4 vColor;\nin vec2 vTextureCoords;\nin vec2 uv;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = uv;\nif (!bool(picking.isActive)) {\nfloat alpha = texture(iconsTexture, vTextureCoords).a;\nvec4 color = vColor;\nif (sdf.enabled) {\nfloat distance = alpha;\nalpha = smoothstep(sdf.buffer - sdf.gamma, sdf.buffer + sdf.gamma, distance);\nif (sdf.outlineBuffer > 0.0) {\nfloat inFill = alpha;\nfloat inBorder = smoothstep(sdf.outlineBuffer - sdf.gamma, sdf.outlineBuffer + sdf.gamma, distance);\ncolor = mix(sdf.outlineColor, vColor, inFill);\nalpha = inBorder;\n}\n}\nfloat a = alpha * color.a;\nif (a < icon.alphaCutoff) {\ndiscard;\n}\nfragColor = vec4(color.rgb, a * layer.opacity);\n}\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:d}}initializeState(){super.initializeState();const e=this.getAttributeManager();e.attributes.instanceIconDefs.settings.update=this.calculateInstanceIconDefs,e.addInstanced({rowIndexes:{type:"uint32",size:1,bufferGroup:"icon-instance-data",accessor:(e,{index:t})=>t},instanceClipRect:{size:4,bufferGroup:"icon-instance-data",accessor:"getContentBox",defaultValue:[0,0,-1,-1]}})}updateState(e){super.updateState(e);const{props:t,oldProps:n,changeFlags:i}=e,{outlineColor:s}=t;if(i.extensionsChanged){this.state.fillModel?.destroy();const e="webgpu"===this.context.device.type?this._getModel(`${this.props.id}-fill`):void 0;this.setState({fillModel:e,models:e?[this.state.model,e]:[this.state.model]})}if(i.updateTriggersChanged&&(i.updateTriggersChanged.getIcon||i.updateTriggersChanged.getIconOffsets)&&this.getAttributeManager().invalidate("instanceIconDefs"),s!==n.outlineColor){const e=[s[0]/255,s[1]/255,s[2]/255,(s[3]??255)/255];this.setState({outlineColor:e})}!t.sdf&&t.outlineWidth&&r.A.warn(`${this.id}: fontSettings.sdf is required to render outline`)()}draw(e){const{sdf:t,smoothing:n,fontSize:i,outlineWidth:r,contentCutoffPixels:s,contentAlignHorizontal:o,contentAlignVertical:a}=this.props,{outlineColor:c}=this.state,l=r?Math.max(n,h*(1-r)):-1,u=this.state.model,d={buffer:h,outlineBuffer:l,gamma:n,enabled:Boolean(t),outlineColor:c},f={contentCutoffPixels:s,contentAlignHorizontal:o,contentAlignVertical:a,fontSize:i,viewport:this.context.viewport};if(u.shaderInputs.setProps({sdf:d,text:f}),super.draw(e),t&&r){const{iconManager:e}=this.state;if(e.getTexture()){const e=this.state.fillModel||u;e.shaderInputs.setProps({sdf:{...d,outlineBuffer:h},text:f}),this._drawModel(e)}}}calculateInstanceIconDefs(e,{startRow:t,endRow:n}){const{data:i,getIcon:r,getIconOffsets:o}=this.props;let a=e.getVertexOffset(t);const c=e.value,{iterable:l,objectInfo:u}=(0,s.X)(i,t,n);for(const t of l){u.index++;const n=r(t,u),i=o(t,u);if(n){let t=0;for(const r of Array.from(n)){const n=super.getInstanceIconDef(r);n[0]=i[2*t],n[1]+=i[2*t+1],n[6]=1,c.set(n,a),a+=e.size,t++}}}}}MultiIconLayer.defaultProps={getIconOffsets:{type:"accessor",value:e=>e.offsets},getContentBox:{type:"accessor",value:[0,0,-1,-1]},fontSize:1,alphaCutoff:.001,smoothing:.1,outlineWidth:0,outlineColor:{type:"color",value:[0,0,0,255]},contentCutoffPixels:{type:"array",value:[0,0]},contentAlignHorizontal:"none",contentAlignVertical:"none"},MultiIconLayer.layerName="MultiIconLayer";const f=MultiIconLayer,p=1e20,g=new Float64Array(256);for(let e=0;e<256;e++){const t=.5-Math.pow(e/255,1/2.2);g[e]=t*Math.abs(t)}g[255]=-p;class TinySDF{constructor({fontSize:e=24,buffer:t=3,radius:n=8,cutoff:i=.25,fontFamily:r="sans-serif",fontWeight:s="normal",fontStyle:o="normal",lang:a=null}={}){t=this.buffer=Math.round(t),this.radius=n,this.cutoff=i,this.lang=a;const c=this.size=Math.ceil(e)+4*t,l=this._createCanvas(c),u=this.ctx=l.getContext("2d",{willReadFrequently:!0});u.font=`${o} ${s} ${e}px ${r}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",a&&(u.lang=a);const d=(this.maxGlyphDim=c-t)+2*t;this.gridOuter=new Float64Array(d*d),this.gridInner=new Float64Array(d*d),this.f=new Float64Array(d),this.z=new Float64Array(d+1),this.v=new Uint16Array(d)}_createCanvas(e){if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(e,e);const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:i,actualBoundingBoxLeft:r,actualBoundingBoxRight:s}=this.ctx.measureText(e),o=Math.ceil(n),a=Math.floor(-r),c=Math.max(0,Math.min(this.maxGlyphDim,Math.ceil(s)-a)),l=Math.max(0,Math.min(this.maxGlyphDim,o+Math.ceil(i))),u=c+2*this.buffer,d=l+2*this.buffer,h=u*d,f=new Uint8ClampedArray(h),v={data:f,width:u,height:d,glyphWidth:c,glyphHeight:l,glyphTop:o,glyphLeft:a,glyphAdvance:t};if(0===c||0===l)return v;const{ctx:y,buffer:b,gridInner:_,gridOuter:x}=this;y.clearRect(b,b,c,l),y.fillText(e,b-a,b+o);const w=y.getImageData(b,b,c,l);x.fill(p,0,h),_.fill(0,0,h);let P=3;for(let e=0;e<l;e++){let t=(e+b)*u+b;for(let e=0;e<c;e++,P+=4,t++){const e=w.data[P];if(0===e)continue;const n=g[e];x[t]=Math.max(0,n),_[t]=Math.max(0,-n)}}m(x,0,0,u,d,u,this.f,this.v,this.z,b);const C=Math.min(b,1);m(_,b-C,b-C,c+2*C,l+2*C,u,this.f,this.v,this.z);const S=255/this.radius,L=255*(1-this.cutoff);for(let e=0;e<h;e++){const t=Math.sqrt(x[e])-Math.sqrt(_[e]);f[e]=L-S*t}return v}}function m(e,t,n,i,r,s,o,a,c,l=0){for(let u=t+l;u<t+i-l;u++)v(e,n*s+u,s,r,o,a,c);for(let l=n;l<n+r;l++)v(e,l*s+t,1,i,o,a,c)}function v(e,t,n,i,r,s,o){s[0]=0,o[0]=-p,o[1]=p,r[0]=e[t];for(let a=1,c=0;a<i;a++){const i=r[a]=e[t+a*n],l=a*a;let u;do{const e=s[c];u=(i-r[e]+l-e*e)/(a-e)/2}while(u<=o[c]&&--c>-1);c++,s[c]=a,o[c]=u,o[c+1]=p}for(let a=0,c=0;a<i;a++){for(;o[c+1]<a;)c++;const i=s[c],l=a-i;e[t+a*n]=r[i]+l*l}}const y=[];function b(e,t,n,i){let r=0;for(let s=t;s<n;s++){const t=e[s];r+=i[t]?.advance||0}return r}function _(e,t,n,i,r,s){let o=t,a=0;for(let c=t;c<n;c++){const t=b(e,c,c+1,r);a+t>i&&(o<c&&s.push(c),o=c,a=0),a+=t}return a}function x(e,t,n,i,r=0,s){void 0===s&&(s=e.length);const o=[];return"break-all"===t?_(e,r,s,n,i,o):function(e,t,n,i,r,s){let o=t,a=t,c=t,l=0;for(let u=t;u<n;u++)if(" "===e[u]?c=u+1:" "!==e[u+1]&&u+1!==n||(c=u+1),c>a){let t=b(e,a,c,r);l+t>i&&(o<a&&(s.push(a),o=a,l=0),t>i&&(t=_(e,a,c,i,r,s),o=s[s.length-1])),a=c,l+=t}}(e,r,s,n,i,o),o}function w(e,t,n,i,s,o){let a=0,c=0;for(let r=t;r<n;r++){const t=i[e[r]];t&&(c=Math.max(c,t.height))}for(let o=t;o<n;o++){const t=e[o],n=i[t];n?(s[o]=a+n.anchorX,a+=n.advance):(r.A.warn(`Missing character: ${t} (${t.codePointAt(0)})`)(),s[o]=a,a+=32)}o[0]=a,o[1]=c}class LRUCache{constructor(e=5){this._cache={},this._order=[],this.limit=e}get(e){const t=this._cache[e];return t&&(this._deleteOrder(e),this._appendOrder(e)),t}set(e,t){this._cache[e]?(this.delete(e),this._cache[e]=t,this._appendOrder(e)):(Object.keys(this._cache).length===this.limit&&this.delete(this._order[0]),this._cache[e]=t,this._appendOrder(e))}delete(e){this._cache[e]&&(delete this._cache[e],this._deleteOrder(e))}_deleteOrder(e){const t=this._order.indexOf(e);t>=0&&this._order.splice(t,1)}_appendOrder(e){this._order.push(e)}}const P={fontFamily:"Monaco, monospace",fontWeight:"normal",characterSet:function(){const e=[];for(let t=32;t<128;t++)e.push(String.fromCharCode(t));return e}(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1};let C=new LRUCache(3);function S(e,t,n,i){e.font=`${i} ${n}px ${t}`,e.fillStyle="#000",e.textBaseline="alphabetic",e.textAlign="left"}class FontAtlasManager{constructor(){this.props={...P}}get atlas(){return this._atlas}get mapping(){return this._atlas&&this._atlas.mapping}setProps(e={}){Object.assign(this.props,e),e._getFontRenderer&&(this._getFontRenderer=e._getFontRenderer),this._key=this._getKey();const t=function(e,t){let n;n="string"==typeof t?new Set(Array.from(t)):new Set(t);const i=C.get(e);if(!i)return n;for(const e in i.mapping)n.has(e)&&n.delete(e);return n}(this._key,this.props.characterSet),n=C.get(this._key);if(n&&0===t.size)return void(this._atlas!==n&&(this._atlas=n));const i=this._generateFontAtlas(t,n);this._atlas=i,C.set(this._key,i)}_generateFontAtlas(e,t){const{fontFamily:n,fontWeight:i,fontSize:r,buffer:s,sdf:o,radius:a,cutoff:c}=this.props;let l=t&&t.data;l||(l=document.createElement("canvas"),l.width=1024);const u=l.getContext("2d",{willReadFrequently:!0});S(u,n,r,i);const d=e=>function(e,t,n){if(void 0===n){const n=e.measureText("A");return n.fontBoundingBoxAscent?{advance:0,width:0,ascent:Math.ceil(n.fontBoundingBoxAscent),descent:Math.ceil(n.fontBoundingBoxDescent)}:{advance:0,width:0,ascent:.9*t,descent:.3*t}}const i=e.measureText(n);return i.actualBoundingBoxAscent?{advance:i.width,width:Math.ceil(i.actualBoundingBoxRight-i.actualBoundingBoxLeft),ascent:Math.ceil(i.actualBoundingBoxAscent),descent:Math.ceil(i.actualBoundingBoxDescent)}:{advance:i.width,width:i.width,ascent:.9*t,descent:.3*t}}(u,r,e);let h;this._getFontRenderer?h=this._getFontRenderer(this.props):o&&(h={measure:d,draw:L(this.props)});const{mapping:f,canvasHeight:p,xOffset:g,yOffsetMin:m,yOffsetMax:v}=function({characterSet:e,measureText:t,buffer:n,maxCanvasWidth:i,mapping:r={},xOffset:s=0,yOffsetMin:o=0,yOffsetMax:a=0}){let c=s,l=o,u=a;for(const s of e)if(!r[s]){const{advance:e,width:o,ascent:a,descent:d}=t(s),h=a+d;c+o+2*n>i&&(c=0,l=u),r[s]={x:c+n,y:l+n,width:o,height:h,advance:e,anchorX:o/2,anchorY:a},c+=o+2*n,u=Math.max(u,l+h+2*n)}return{mapping:r,xOffset:c,yOffsetMin:l,yOffsetMax:u,canvasHeight:(d=u,Math.pow(2,Math.ceil(Math.log2(d))))};var d}({measureText:e=>h?h.measure(e):d(e),buffer:s,characterSet:e,maxCanvasWidth:1024,...t&&{mapping:t.mapping,xOffset:t.xOffset,yOffsetMin:t.yOffsetMin,yOffsetMax:t.yOffsetMax}});if(l.height!==p){const e=l.height>0?u.getImageData(0,0,l.width,l.height):null;l.height=p,e&&u.putImageData(e,0,0)}if(S(u,n,r,i),h)for(const t of e){const e=f[t],n=e.width,{data:i,left:r=0,top:s=0}=h.draw(t),o=e.x-r,a=e.y-s,c=Math.max(0,Math.round(o)),d=Math.max(0,Math.round(a)),p=Math.min(i.width,l.width-c),g=Math.min(i.height,l.height-d);u.putImageData(i,c,d,0,0,p,g),e.x=c,e.y=d,e.width=p,e.height=g,e.anchorX+=p/2-r-n/2,e.anchorY+=s}else for(const t of e){const e=f[t];u.fillText(t,e.x,e.y+e.anchorY)}const y=h?h.measure():d();return{baselineOffset:(y.ascent-y.descent)/2,xOffset:g,yOffsetMin:m,yOffsetMax:v,mapping:f,data:l,width:l.width,height:l.height}}_getKey(){const{fontFamily:e,fontWeight:t,fontSize:n,buffer:i,sdf:r,radius:s,cutoff:o}=this.props;return r?`${e} ${t} ${n} ${i} ${s} ${o}`:`${e} ${t} ${n} ${i}`}}function L({fontSize:e,buffer:t,radius:n,cutoff:i,fontFamily:r,fontWeight:s}){const o=new TinySDF({fontSize:e,buffer:t,radius:n,cutoff:i,fontFamily:r,fontWeight:`${s}`});return e=>{const{data:n,width:i,height:r}=o.draw(e),s=new ImageData(i,r);return function(e,t){for(let n=0;n<e.length;n++)t.data[4*n+3]=e[n]}(n,s),{data:s,left:t,top:t}}}var A=n(45069),E=n(84175),T=n(46487),M=n(93675),I=n(9350),B=n(25337),k=n(36077);const R="layout(std140) uniform textBackgroundUniforms {\n bool billboard;\n float sizeScale;\n float sizeMinPixels;\n float sizeMaxPixels;\n vec4 borderRadius;\n vec4 padding;\n highp int sizeUnits;\n bool stroked;\n} textBackground;\n",O={name:"textBackground",source:"struct TextBackgroundUniforms {\n billboard: f32,\n sizeScale: f32,\n sizeMinPixels: f32,\n sizeMaxPixels: f32,\n borderRadius: vec4<f32>,\n padding: vec4<f32>,\n sizeUnits: i32,\n stroked: f32,\n};\n\n@group(0) @binding(auto) var<uniform> textBackground: TextBackgroundUniforms;\n",vs:R,fs:R,uniformTypes:{billboard:"f32",sizeScale:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",borderRadius:"vec4<f32>",padding:"vec4<f32>",sizeUnits:"i32",stroked:"f32"}},z={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,fontSize:1,borderRadius:{type:"object",value:0},padding:{type:"array",value:[0,0,0,0]},getPosition:{type:"accessor",value:e=>e.position},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},getBoundingRect:{type:"accessor",value:[0,0,0,0]},getClipRect:{type:"accessor",value:[0,0,-1,-1]},getFillColor:{type:"accessor",value:[0,0,0,255]},getLineColor:{type:"accessor",value:[0,0,0,255]},getLineWidth:{type:"accessor",value:1}};class TextBackgroundLayer extends A.A{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME text-background-layer-vertex-shader\nin vec2 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec4 instanceRects;\nin vec4 instanceClipRect;\nin float instanceSizes;\nin float instanceAngles;\nin vec2 instancePixelOffsets;\nin float instanceLineWidths;\nin vec4 instanceFillColors;\nin vec4 instanceLineColors;\nout vec4 vFillColor;\nout vec4 vLineColor;\nout float vLineWidth;\nout vec2 uv;\nout vec2 dimensions;\nvec2 rotate_by_angle(vec2 vertex, float angle) {\nfloat angle_radian = radians(angle);\nfloat cos_angle = cos(angle_radian);\nfloat sin_angle = sin(angle_radian);\nmat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);\nreturn rotationMatrix * vertex;\n}\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.uv = positions;\ngeometry.pickingColor = picking_getPickingColorFromInstanceID();\nuv = positions;\nvLineWidth = instanceLineWidths;\nfloat sizePixels = clamp(\nproject_size_to_pixel(instanceSizes * textBackground.sizeScale, textBackground.sizeUnits),\ntextBackground.sizeMinPixels, textBackground.sizeMaxPixels\n);\nfloat instanceScale = sizePixels / text.fontSize;\ndimensions = instanceRects.zw * instanceScale + textBackground.padding.xy + textBackground.padding.zw;\nvec2 pixelOffset = (positions * instanceRects.zw + instanceRects.xy) * instanceScale + mix(-textBackground.padding.xy, textBackground.padding.zw, positions);\npixelOffset = rotate_by_angle(pixelOffset, instanceAngles);\npixelOffset += instancePixelOffsets;\npixelOffset.y *= -1.0;\nvec2 xy = project_size_to_pixel(instanceClipRect.xy);\nvec2 wh = project_size_to_pixel(instanceClipRect.zw);\nif (text.flipY) {\nxy.y = -xy.y - wh.y;\n}\nif (instanceClipRect.z >= 0.0) {\ndimensions.x = wh.x;\npixelOffset.x = xy.x + uv.x * wh.x + mix(-textBackground.padding.x, textBackground.padding.z, uv.x);\n}\nif (instanceClipRect.w >= 0.0) {\ndimensions.y = wh.y;\npixelOffset.y = xy.y + uv.y * wh.y + mix(-textBackground.padding.y, textBackground.padding.w, uv.y);\n}\nif (textBackground.billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = vec3(pixelOffset, 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);\nif (text.flipY) {\noffset_common.y *= -1.;\n}\nDECKGL_FILTER_SIZE(offset_common, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nvFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vFillColor, geometry);\nvLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vLineColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME text-background-layer-fragment-shader\nprecision highp float;\nin vec4 vFillColor;\nin vec4 vLineColor;\nin float vLineWidth;\nin vec2 uv;\nin vec2 dimensions;\nout vec4 fragColor;\nfloat round_rect(vec2 p, vec2 size, vec4 radii) {\nvec2 pixelPositionCB = (p - 0.5) * size;\nvec2 sizeCB = size * 0.5;\nfloat maxBorderRadius = min(size.x, size.y) * 0.5;\nvec4 borderRadius = vec4(min(radii, maxBorderRadius));\nborderRadius.xy =\n(pixelPositionCB.x > 0.0) ? borderRadius.xy : borderRadius.zw;\nborderRadius.x = (pixelPositionCB.y > 0.0) ? borderRadius.x : borderRadius.y;\nvec2 q = abs(pixelPositionCB) - sizeCB + borderRadius.x;\nreturn -(min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - borderRadius.x);\n}\nfloat rect(vec2 p, vec2 size) {\nvec2 pixelPosition = p * size;\nreturn min(min(pixelPosition.x, size.x - pixelPosition.x),\nmin(pixelPosition.y, size.y - pixelPosition.y));\n}\nvec4 get_stroked_fragColor(float dist) {\nfloat isBorder = smoothedge(dist, vLineWidth);\nreturn mix(vFillColor, vLineColor, isBorder);\n}\nvoid main(void) {\ngeometry.uv = uv;\nif (textBackground.borderRadius != vec4(0.0)) {\nfloat distToEdge = round_rect(uv, dimensions, textBackground.borderRadius);\nfloat shapeAlpha = smoothedge(-distToEdge, 0.0);\nif (shapeAlpha == 0.0) {\ndiscard;\n}\nif (textBackground.stroked) {\nfragColor = get_stroked_fragColor(distToEdge);\n} else {\nfragColor = vFillColor;\n}\nfragColor.a *= shapeAlpha;\n} else {\nif (textBackground.stroked) {\nfloat distToEdge = rect(uv, dimensions);\nfragColor = get_stroked_fragColor(distToEdge);\n} else {\nfragColor = vFillColor;\n}\n}\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:"struct TextUniforms {\n cutoffPixels: vec2<f32>,\n align: vec2<i32>,\n fontSize: f32,\n flipY: f32,\n};\n\n@group(0) @binding(auto) var<uniform> text: TextUniforms;\n\nfn rotate_by_angle(vertex: vec2<f32>, angle: f32) -> vec2<f32> {\n let angleRadian = radians(angle);\n let cosine = cos(angleRadian);\n let sine = sin(angleRadian);\n let rotationMatrix = mat2x2<f32>(\n vec2<f32>(cosine, -sine),\n vec2<f32>(sine, cosine)\n );\n return rotationMatrix * vertex;\n}\n\nstruct Attributes {\n @builtin(instance_index) instanceIndex: u32,\n @location(0) positions: vec2<f32>,\n @location(1) instancePositions: vec3<f32>,\n @location(2) instancePositions64Low: vec3<f32>,\n @location(3) instanceSizes: f32,\n @location(4) instanceAngles: f32,\n @location(5) instanceRects: vec4<f32>,\n @location(6) instanceClipRect: vec4<f32>,\n @location(7) instancePixelOffsets: vec2<f32>,\n @location(8) instanceFillColors: vec4<f32>,\n @location(9) instanceLineColors: vec4<f32>,\n @location(10) instanceLineWidths: f32,\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n @location(0) vFillColor: vec4<f32>,\n @location(1) vLineColor: vec4<f32>,\n @location(2) vLineWidth: f32,\n @location(3) uv: vec2<f32>,\n @location(4) dimensions: vec2<f32>,\n @location(5) pickingColor: vec3<f32>,\n};\n\n@vertex\nfn vertexMain(attributes: Attributes) -> Varyings {\n geometry.worldPosition = attributes.instancePositions;\n geometry.uv = attributes.positions;\n geometry.pickingColor = picking_getPickingColorFromIndex(attributes.instanceIndex);\n\n var varyings: Varyings;\n varyings.uv = attributes.positions;\n varyings.vLineWidth = attributes.instanceLineWidths;\n\n let sizePixels = clamp(\n project_unit_size_to_pixel(\n attributes.instanceSizes * textBackground.sizeScale,\n textBackground.sizeUnits\n ),\n textBackground.sizeMinPixels,\n textBackground.sizeMaxPixels\n );\n let instanceScale = sizePixels / text.fontSize;\n\n varyings.dimensions = attributes.instanceRects.zw * instanceScale +\n textBackground.padding.xy + textBackground.padding.zw;\n\n var pixelOffset =\n (attributes.positions * attributes.instanceRects.zw + attributes.instanceRects.xy) *\n instanceScale +\n mix(-textBackground.padding.xy, textBackground.padding.zw, attributes.positions);\n pixelOffset = rotate_by_angle(pixelOffset, attributes.instanceAngles);\n pixelOffset = pixelOffset + attributes.instancePixelOffsets;\n pixelOffset.y = pixelOffset.y * -1.0;\n\n var xy = project_size_vec2(attributes.instanceClipRect.xy) * project.scale;\n let wh = project_size_vec2(attributes.instanceClipRect.zw) * project.scale;\n if (text.flipY > 0.5) {\n xy.y = -xy.y - wh.y;\n }\n if (attributes.instanceClipRect.z >= 0.0) {\n varyings.dimensions.x = wh.x;\n pixelOffset.x = xy.x + varyings.uv.x * wh.x + mix(\n -textBackground.padding.x,\n textBackground.padding.z,\n varyings.uv.x\n );\n }\n if (attributes.instanceClipRect.w >= 0.0) {\n varyings.dimensions.y = wh.y;\n pixelOffset.y = xy.y + varyings.uv.y * wh.y + mix(\n -textBackground.padding.y,\n textBackground.padding.w,\n varyings.uv.y\n );\n }\n\n if (textBackground.billboard > 0.5) {\n var position = project_position_to_clipspace(\n attributes.instancePositions,\n attributes.instancePositions64Low,\n vec3<f32>(0.0)\n );\n let clipOffset = project_pixel_size_to_clipspace(pixelOffset);\n position = vec4<f32>(\n position.x + clipOffset.x,\n position.y + clipOffset.y,\n position.z,\n position.w\n );\n varyings.position = position;\n } else {\n var offsetCommon = vec3<f32>(project_pixel_size_vec2(pixelOffset), 0.0);\n if (text.flipY > 0.5) {\n offsetCommon.y = offsetCommon.y * -1.0;\n }\n varyings.position = project_position_to_clipspace(\n attributes.instancePositions,\n attributes.instancePositions64Low,\n offsetCommon\n );\n }\n\n varyings.vFillColor = vec4<f32>(\n attributes.instanceFillColors.rgb,\n attributes.instanceFillColors.a * layer.opacity\n );\n varyings.vLineColor = vec4<f32>(\n attributes.instanceLineColors.rgb,\n attributes.instanceLineColors.a * layer.opacity\n );\n varyings.pickingColor = geometry.pickingColor;\n return varyings;\n}\n\nfn round_rect(point: vec2<f32>, size: vec2<f32>, radii: vec4<f32>) -> f32 {\n let pixelPosition = (point - 0.5) * size;\n let halfSize = size * 0.5;\n let maxBorderRadius = min(size.x, size.y) * 0.5;\n var borderRadius = min(radii, vec4<f32>(maxBorderRadius));\n\n borderRadius = select(borderRadius.zwxy, borderRadius, pixelPosition.x > 0.0);\n let radius = select(borderRadius.y, borderRadius.x, pixelPosition.y > 0.0);\n let q = abs(pixelPosition) - halfSize + radius;\n return -(min(max(q.x, q.y), 0.0) + length(max(q, vec2<f32>(0.0))) - radius);\n}\n\nfn rect(point: vec2<f32>, size: vec2<f32>) -> f32 {\n let pixelPosition = point * size;\n return min(\n min(pixelPosition.x, size.x - pixelPosition.x),\n min(pixelPosition.y, size.y - pixelPosition.y)\n );\n}\n\nfn get_stroked_frag_color(\n distanceToEdge: f32,\n lineWidth: f32,\n fillColor: vec4<f32>,\n lineColor: vec4<f32>\n) -> vec4<f32> {\n let isBorder = smoothedge(distanceToEdge, lineWidth);\n return mix(fillColor, lineColor, isBorder);\n}\n\n@fragment\nfn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {\n geometry.uv = varyings.uv;\n var fragColor: vec4<f32>;\n\n if (any(textBackground.borderRadius != vec4<f32>(0.0))) {\n let distanceToEdge = round_rect(\n varyings.uv,\n varyings.dimensions,\n textBackground.borderRadius\n );\n let shapeAlpha = smoothedge(-distanceToEdge, 0.0);\n if (shapeAlpha == 0.0) {\n discard;\n }\n if (textBackground.stroked > 0.5) {\n fragColor = get_stroked_frag_color(\n distanceToEdge,\n varyings.vLineWidth,\n varyings.vFillColor,\n varyings.vLineColor\n );\n } else {\n fragColor = varyings.vFillColor;\n }\n fragColor.a = fragColor.a * shapeAlpha;\n } else if (textBackground.stroked > 0.5) {\n let distanceToEdge = rect(varyings.uv, varyings.dimensions);\n fragColor = get_stroked_frag_color(\n distanceToEdge,\n varyings.vLineWidth,\n varyings.vFillColor,\n varyings.vLineColor\n );\n } else {\n fragColor = varyings.vFillColor;\n }\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(varyings.pickingColor)) {\n discard;\n }\n return vec4<f32>(varyings.pickingColor, 1.0);\n }\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {\n let highlightAlpha = picking.highlightColor.a;\n let blendedAlpha = highlightAlpha + fragColor.a * (1.0 - highlightAlpha);\n if (blendedAlpha > 0.0) {\n let highlightRatio = highlightAlpha / blendedAlpha;\n fragColor = vec4<f32>(\n mix(fragColor.rgb, picking.highlightColor.rgb, highlightRatio),\n blendedAlpha\n );\n } else {\n fragColor = vec4<f32>(fragColor.rgb, 0.0);\n }\n }\n }\n\n return deckgl_premultiplied_alpha(fragColor);\n}\n",modules:[E.A,T.A,M.Ay,O,u]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,bufferGroup:"text-background-instance-data",accessor:"getSize",defaultValue:1},instanceAngles:{size:1,transition:!0,bufferGroup:"text-background-instance-data",accessor:"getAngle"},instanceRects:{size:4,bufferGroup:"text-background-instance-data",accessor:"getBoundingRect"},instanceClipRect:{size:4,bufferGroup:"text-background-instance-data",accessor:"getClipRect",defaultValue:[0,0,-1,-1]},instancePixelOffsets:{size:2,transition:!0,bufferGroup:"text-background-instance-data",accessor:"getPixelOffset"},instanceFillColors:{size:4,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:4,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,bufferGroup:"text-background-instance-data",accessor:"getLineWidth",defaultValue:1}})}updateState(e){super.updateState(e);const{changeFlags:t}=e;t.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{billboard:t,sizeScale:n,sizeUnits:i,sizeMinPixels:r,sizeMaxPixels:s,getLineWidth:o,fontSize:a}=this.props;let{padding:c,borderRadius:l}=this.props;c.length<4&&(c=[c[0],c[1],c[0],c[1]]),Array.isArray(l)||(l=[l,l,l,l]);const u=this.state.model,d={billboard:t,stroked:Boolean(o),borderRadius:l,padding:c,sizeUnits:I.p5[i],sizeScale:n,sizeMinPixels:r,sizeMaxPixels:s},h={fontSize:a,viewport:this.context.viewport};u.shaderInputs.setProps({textBackground:d,text:h}),u.draw(this.context.renderPass)}_getModel(){return new k.K(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new B.V({topology:"triangle-strip",vertexCount:4,attributes:{positions:{size:2,value:new Float32Array([0,0,1,0,0,1,1,1])}}}),isInstanced:!0})}}TextBackgroundLayer.defaultProps=z,TextBackgroundLayer.layerName="TextBackgroundLayer";const D=TextBackgroundLayer,F={start:1,middle:0,end:-1},N={top:1,center:0,bottom:-1},$=[0,0,0,255],U={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,background:!1,getBackgroundColor:{type:"accessor",value:[255,255,255,255]},getBorderColor:{type:"accessor",value:$},getBorderWidth:{type:"accessor",value:0},backgroundBorderRadius:{type:"object",value:0},backgroundPadding:{type:"array",value:[0,0,0,0]},characterSet:{type:"object",value:P.characterSet},fontFamily:P.fontFamily,fontWeight:P.fontWeight,lineHeight:1,outlineWidth:{type:"number",value:0,min:0},outlineColor:{type:"color",value:$},fontSettings:{type:"object",value:{},compare:1},wordBreak:"break-word",maxWidth:{type:"number",value:-1},contentCutoffPixels:{type:"array",value:[0,0]},contentAlignHorizontal:"none",contentAlignVertical:"none",getText:{type:"accessor",value:e=>e.text},getPosition:{type:"accessor",value:e=>e.position},getColor:{type:"accessor",value:$},getSize:{type:"accessor",value:32},getAngle:{type:"accessor",value:0},getTextAnchor:{type:"accessor",value:"middle"},getAlignmentBaseline:{type:"accessor",value:"center"},getPixelOffset:{type:"accessor",value:[0,0]},getContentBox:{type:"accessor",value:[0,0,-1,-1]},backgroundColor:{deprecatedFor:["background","getBackgroundColor"]}};class TextLayer extends i.A{constructor(){super(...arguments),this.getBoundingRect=(e,t)=>{const{size:[n,i]}=this.transformParagraph(e,t),{getTextAnchor:r,getAlignmentBaseline:s}=this.props;return[(F["function"==typeof r?r(e,t):r]-1)*n/2,(N["function"==typeof s?s(e,t):s]-1)*i/2,n,i]},this.getIconOffsets=(e,t)=>{const{getTextAnchor:n,getAlignmentBaseline:i}=this.props,{x:r,y:s,rowWidth:o,size:[,a]}=this.transformParagraph(e,t),c=F["function"==typeof n?n(e,t):n],l=N["function"==typeof i?i(e,t):i],u=r.length,d=new Array(2*u);let h=0;for(let e=0;e<u;e++)d[h++]=(c-1)*o[e]/2+r[e],d[h++]=(l-1)*a/2+s[e];return d}}initializeState(){this.state={styleVersion:0,fontAtlasManager:new FontAtlasManager},this.props.maxWidth>0&&r.A.once(1,"v8.9 breaking change: TextLayer maxWidth is now relative to text size")()}updateState(e){const{props:t,oldProps:n,changeFlags:i}=e;(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getText))&&this._updateText();(this._updateFontAtlas()||t.lineHeight!==n.lineHeight||t.wordBreak!==n.wordBreak||t.maxWidth!==n.maxWidth)&&this.setState({styleVersion:this.state.styleVersion+1})}getPickingInfo({info:e}){return e.object=e.index>=0?this.props.data[e.index]:null,e}_updateFontAtlas(){const{fontSettings:e,fontFamily:t,fontWeight:n,_getFontRenderer:i}=this.props,{fontAtlasManager:r,characterSet:s}=this.state,o={...e,characterSet:s,fontFamily:t,fontWeight:n,_getFontRenderer:i};if(!r.mapping)return r.setProps(o),!0;for(const e in o)if(o[e]!==r.props[e])return r.setProps(o),!0;return!1}_updateText(){const{data:e,characterSet:t}=this.props,n=e.attributes?.getText;let i,{getText:r}=this.props,o=e.startIndices;const a="auto"===t&&new Set;if(n&&o){const{texts:t,characterCount:s}=function({value:e,length:t,stride:n,offset:i,startIndices:r,characterSet:s}){const o=e.BYTES_PER_ELEMENT,a=n?n/o:1,c=i?i/o:0,l=r[t]||Math.ceil((e.length-c)/a),u=s&&new Set,d=new Array(t);let h=e;if(a>1||c>0){h=new(0,e.constructor)(l);for(let t=0;t<l;t++)h[t]=e[t*a+c]}for(let e=0;e<t;e++){const t=r[e],n=r[e+1]||l,i=h.subarray(t,n);d[e]=String.fromCodePoint.apply(null,i),u&&i.forEach(u.add,u)}if(u)for(const e of u)s.add(String.fromCodePoint(e));return{texts:d,characterCount:l}}({...ArrayBuffer.isView(n)?{value:n}:n,length:e.length,startIndices:o,characterSet:a});i=s,r=(e,{index:n})=>t[n]}else{const{iterable:t,objectInfo:n}=(0,s.X)(e);o=[0],i=0;for(const e of t){n.index++;const t=Array.from(r(e,n)||"");a&&t.forEach(a.add,a),i+=t.length,o.push(i)}}this.setState({getText:r,startIndices:o,numInstances:i,characterSet:a||t})}transformParagraph(e,t){const{fontAtlasManager:n}=this.state,i=n.mapping,{baselineOffset:r}=n.atlas,{fontSize:s}=n.props,o=this.state.getText,{wordBreak:a,lineHeight:c,maxWidth:l}=this.props;return function(e,t,n,i,r,s){const o=Array.from(e),a=o.length,c=new Array(a),l=new Array(a),u=new Array(a),d=("break-word"===i||"break-all"===i)&&isFinite(r)&&r>0,h=[0,0],f=[0,0];let p=0,g=t+n/2,m=0,v=0;for(let e=0;e<=a;e++){const t=o[e];if("\n"!==t&&e!==a||(v=e),v>m){const e=d?x(o,i,r,s,m,v):y;for(let t=0;t<=e.length;t++){const i=0===t?m:e[t-1],r=t<e.length?e[t]:v;w(o,i,r,s,c,f);for(let e=i;e<r;e++)l[e]=g,u[e]=f[0];p++,g+=n,h[0]=Math.max(h[0],f[0])}m=v}"\n"===t&&(c[m]=0,l[m]=0,u[m]=0,m++)}return h[1]=p*n,{x:c,y:l,rowWidth:u,size:h}}(o(e,t)||"",r,c*s,a,l*s,i)}renderLayers(){const{startIndices:e,numInstances:t,getText:n,fontAtlasManager:{atlas:i,mapping:r},styleVersion:s}=this.state,{data:o,_dataDiff:a,getPosition:c,getColor:l,getSize:u,getAngle:d,getPixelOffset:h,getBackgroundColor:p,getBorderColor:g,getBorderWidth:m,getContentBox:v,backgroundBorderRadius:y,backgroundPadding:b,background:_,billboard:x,fontSettings:w,outlineWidth:C,outlineColor:S,sizeScale:L,sizeUnits:A,sizeMinPixels:E,sizeMaxPixels:T,contentCutoffPixels:M,contentAlignHorizontal:I,contentAlignVertical:B,transitions:k,updateTriggers:R}=this.props,O=this.getSubLayerClass("characters",f),z=this.getSubLayerClass("background",D),{fontSize:F}=this.state.fontAtlasManager.props;return[_&&new z({getFillColor:p,getLineColor:g,getLineWidth:m,borderRadius:y,padding:b,getPosition:c,getSize:u,getAngle:d,getPixelOffset:h,getClipRect:v,billboard:x,sizeScale:L,sizeUnits:A,sizeMinPixels:E,sizeMaxPixels:T,fontSize:F,transitions:k&&{getPosition:k.getPosition,getAngle:k.getAngle,getSize:k.getSize,getFillColor:k.getBackgroundColor,getLineColor:k.getBorderColor,getLineWidth:k.getBorderWidth,getPixelOffset:k.getPixelOffset}},this.getSubLayerProps({id:"background",updateTriggers:{getPosition:R.getPosition,getAngle:R.getAngle,getSize:R.getSize,getFillColor:R.getBackgroundColor,getLineColor:R.getBorderColor,getLineWidth:R.getBorderWidth,getPixelOffset:R.getPixelOffset,getBoundingRect:{getText:R.getText,getTextAnchor:R.getTextAnchor,getAlignmentBaseline:R.getAlignmentBaseline,styleVersion:s}}}),{data:o.attributes&&o.attributes.background?{length:o.length,attributes:o.attributes.background}:o,_dataDiff:a,autoHighlight:!1,getBoundingRect:this.getBoundingRect}),new O({sdf:w.sdf,smoothing:Number.isFinite(w.smoothing)?w.smoothing:P.smoothing,outlineWidth:C/(w.radius||P.radius),outlineColor:S,iconAtlas:i,iconMapping:r,getPosition:c,getColor:l,getSize:u,getAngle:d,getPixelOffset:h,getContentBox:v,billboard:x,sizeScale:L,sizeUnits:A,sizeMinPixels:E,sizeMaxPixels:T,fontSize:F,contentCutoffPixels:M,contentAlignHorizontal:I,contentAlignVertical:B,transitions:k&&{getPosition:k.getPosition,getAngle:k.getAngle,getColor:k.getColor,getSize:k.getSize,getPixelOffset:k.getPixelOffset,getContentBox:k.getContentBox}},this.getSubLayerProps({id:"characters",updateTriggers:{all:R.getText,getPosition:R.getPosition,getAngle:R.getAngle,getColor:R.getColor,getSize:R.getSize,getPixelOffset:R.getPixelOffset,getContentBox:R.getContentBox,getIconOffsets:{getTextAnchor:R.getTextAnchor,getAlignmentBaseline:R.getAlignmentBaseline,styleVersion:s}}}),{data:o,_dataDiff:a,startIndices:e,numInstances:t,getIconOffsets:this.getIconOffsets,getIcon:n})]}static set fontAtlasCacheLimit(e){!function(e){r.A.assert(Number.isFinite(e)&&e>=3,"Invalid cache limit"),C=new LRUCache(e)}(e)}}TextLayer.defaultProps=U,TextLayer.layerName="TextLayer";const V=TextLayer},86402(e,t,n){const i={name:"clip",source:"struct ClipUniforms {\n enabled: i32,\n mode: i32,\n bounds: vec4<f32>,\n};\n\n@group(2) @binding(auto) var<uniform> clipUniforms: ClipUniforms;\n\nfn clip_isInBounds(coordinates: vec2<f32>) -> bool {\n return coordinates.x >= clipUniforms.bounds.x &&\n coordinates.y >= clipUniforms.bounds.y &&\n coordinates.x < clipUniforms.bounds.z &&\n coordinates.y < clipUniforms.bounds.w;\n}\n\nfn clip_filterPosition(position: ptr<function, vec4<f32>>, instanceCoordinates: vec2<f32>) {\n if (\n clipUniforms.enabled != 0 &&\n clipUniforms.mode == 1 &&\n !clip_isInBounds(instanceCoordinates)\n ) {\n *position = vec4<f32>(2.0, 2.0, 2.0, 1.0);\n }\n}\n\nfn clip_filterColor(geometryCoordinates: vec2<f32>) {\n if (\n clipUniforms.enabled != 0 &&\n clipUniforms.mode == 0 &&\n !clip_isInBounds(geometryCoordinates)\n ) {\n discard;\n }\n}\n",props:{},uniforms:{},bindingLayout:[{name:"clip",group:2}],uniformTypes:{enabled:"i32",mode:"i32",bounds:"vec4<f32>"},defaultUniforms:{enabled:0,mode:0,bounds:[0,0,1,1]},getUniforms(e={}){const t={};return void 0!==e.enabled&&(t.enabled=e.enabled?1:0),void 0!==e.mode&&(t.mode="instance"===e.mode?1:0),void 0!==e.bounds&&(t.bounds=e.bounds),t}};n.d(t,["A",0,i])},22662(e,t,n){n.d(t,{H:()=>ce});var i=n(25925),r=n(90405);let s="";const o={};class FetchError extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response}const a=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,c=/^([-\w.]+\/[-\w.+]+)/;function l(e,t){return e.toLowerCase()===t.toLowerCase()}function u(e){const t=a.exec(e);return t?t[1]:""}var d=n(28071);function h(e){if((0,i.Sv)(e))return e.url;if((0,i.qf)(e)){return("name"in e?e.name:"")||""}return"string"==typeof e?e:""}function f(e){if((0,i.Sv)(e)){const t=e.headers.get("content-type")||"",n=(0,d.S3)(e.url);return function(e){const t=c.exec(e);return t?t[1]:e}(t)||u(n)}return(0,i.qf)(e)?e.type||"":"string"==typeof e?u(e):""}async function p(e){if((0,i.Sv)(e))return e;const t={},n=function(e){if((0,i.Sv)(e))return e.headers["content-length"]||-1;if((0,i.qf)(e))return e.size;return"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);n>=0&&(t["content-length"]=String(n));const r=h(e),s=f(e);s&&(t["content-type"]=s);const o=await async function(e){const t=5;if("string"==typeof e)return`data:,${e.slice(0,t)}`;if(e instanceof Blob){const t=e.slice(0,5);return await new Promise(e=>{const n=new FileReader;n.onload=t=>e(t?.target?.result),n.readAsDataURL(t)})}if(e instanceof ArrayBuffer){return`data:base64,${function(e){let t="";const n=new Uint8Array(e);for(let e=0;e<n.byteLength;e++)t+=String.fromCharCode(n[e]);return btoa(t)}(e.slice(0,t))}`}return null}(e);o&&(t["x-first-bytes"]=o),"string"==typeof e&&(e=(new TextEncoder).encode(e));const a=new Response(e,{headers:t});return Object.defineProperty(a,"url",{value:r}),a}async function g(e){if(!e.ok){const t=await async function(e){const t=(0,d.E1)(e.url);let n=`Failed to fetch resource (${e.status}) ${e.statusText}: ${t}`;n=n.length>100?`${n.slice(0,100)}...`:n;const i={reason:e.statusText,url:e.url,response:e};try{const t=e.headers.get("Content-Type");i.reason=!e.bodyUsed&&t?.includes("application/json")?await e.json():await e.text()}catch(e){}return new FetchError(n,i)}(e);throw t}}async function m(e,t){if("string"==typeof e){const n=function(e){for(const t in o)if(e.startsWith(t)){const n=o[t];e=e.replace(t,n)}return e.startsWith("http://")||e.startsWith("https://")||(e=`${s}${e}`),e}(e);return function(e){return!function(e){return e.startsWith("http:")||e.startsWith("https:")}(e)&&!function(e){return e.startsWith("data:")}(e)}(n)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(n,t):await fetch(n,t)}return await p(e)}var v=n(51253);function y(e,t){const n=(0,v.pp)(),r=e||n,s=r.fetch??r.core?.fetch;return"function"==typeof s?s:(0,i.Gv)(s)?e=>m(e,s):t?.fetch?t?.fetch:m}function b(e,t){return _(e||{},t)}function _(e,t,n=0){if(n>3)return t;const i={...e};for(const[e,r]of Object.entries(t))r&&"object"==typeof r&&!Array.isArray(r)?i[e]=_(i[e]||{},t[e],n+1):i[e]=t[e];return i}"undefined"!=typeof self&&self,"undefined"!=typeof window&&window,"undefined"!=typeof globalThis&&globalThis,"undefined"!=typeof document&&document;const x="object"!=typeof process||"[object process]"!==String(process)||process.browser,w="undefined"!=typeof window&&void 0!==window.orientation,P="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);P&&parseFloat(P[1]);class NodeWorker{terminate(){}}function C(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}const S=new Map;function L(e){C(e.source&&!e.url||!e.source&&e.url);let t=S.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return A((t=e,`try {\n importScripts('${t}');\n} catch (error) {\n console.error(error);\n throw error;\n}`));var t}(e.url),S.set(e.url,t)),e.source&&(t=A(e.source),S.set(e.source,t))),C(t),t}function A(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function E(e,t=!0,n){const i=n||new Set;if(e){if(T(e))i.add(e);else if(T(e.buffer))i.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const n in e)E(e[n],t,i)}else;return void 0===n?Array.from(i):[]}function T(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}const M=()=>{};class WorkerThread{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return"undefined"!=typeof Worker&&x||void 0!==NodeWorker&&!x}constructor(e){const{name:t,source:n,url:i}=e;C(n||i),this.name=t,this.source=n,this.url=i,this.onMessage=M,this.onError=e=>console.log(e),this.worker=x?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=M,this.onError=M,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||E(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=L({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url){const t=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,n=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";e=new NodeWorker(t,{eval:!1,type:n})}else{if(!this.source)throw new Error("no worker");e=new NodeWorker(this.source,{eval:!0})}return e.on("message",e=>{this.onMessage(e)}),e.on("error",e=>{this.onError(e)}),e.on("exit",e=>{}),e}}class WorkerJob{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((e,t)=>{this._resolve=e,this._reject=t})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){C(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){C(this.isRunning),this.isRunning=!1,this._reject(e)}}class WorkerPool{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return WorkerThread.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e,t=(e,t,n)=>e.done(n),n=(e,t)=>e.error(t)){const i=new Promise(i=>(this.jobQueue.push({name:e,onMessage:t,onError:n,onStart:i}),this));return this._startQueuedJob(),await i}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const n=new WorkerJob(t.name,e);e.onMessage=e=>t.onMessage(n,e.type,e.payload),e.onError=e=>t.onError(n,e),t.onStart(n);try{await n.result}catch(e){console.error(`Worker exception: ${e}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!x||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;const e=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new WorkerThread({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return w?this.maxMobileConcurrency:this.maxConcurrency}}const I={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}};class WorkerFarm{props;workerPools=new Map;static _workerFarm;static isSupported(){return WorkerThread.isSupported()}static getWorkerFarm(e={}){return WorkerFarm._workerFarm=WorkerFarm._workerFarm||new WorkerFarm({}),WorkerFarm._workerFarm.setProps(e),WorkerFarm._workerFarm}constructor(e){this.props={...I},this.setProps(e),this.workerPools=new Map}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(const e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:n,url:i}=e;let r=this.workerPools.get(t);return r||(r=new WorkerPool({name:t,source:n,url:i}),r.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,r)),r}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}async function B(e,t,n,i,r){const s=e.id,o=function(e,t={}){const n=t[e.id]||{},i=x?e.workerFile||`${e.id}-worker.js`:`${e.id}-worker-node.js`;let r=n.workerUrl;if(r||"compression"!==e.id||(r=t.workerUrl),"test"===(t._workerType||t?.core?._workerType)&&(r=x?`modules/${e.module}/dist/${i}`:`modules/${e.module}/src/workers/${e.id}-worker-node.ts`),!r){let t=e.version;"latest"===t&&(t="latest");const n=t?`@${t}`:"";r=`https://unpkg.com/@loaders.gl/${e.module}${n}/dist/${i}`}return C(r),r}(e,n),a=WorkerFarm.getWorkerFarm(n?.core).getWorkerPool({name:s,url:o});(n=JSON.parse(JSON.stringify(n||{})))._workerLoaderId=e.id,i=JSON.parse(JSON.stringify(i||{}));const c=await a.startJob("process-on-worker",k.bind(null,r));c.postMessage("process",{input:t,options:n,context:i});const l=await c.result;return await l.result}async function k(e,t,n,i){switch(n){case"done":t.done(i);break;case"error":t.error(new Error(i.error));break;case"process":const{id:r,input:s,options:o}=i;try{const n=await e(s,o);t.postMessage("done",{id:r,result:n})}catch(e){const n=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:r,error:n})}break;default:console.warn(`parse-with-worker unknown message ${n}`)}}globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.5.4"),globalThis._loadersgl_.version;function R(e){return e&&"object"==typeof e&&e.isBuffer}function O(e){if(R(e))return e;if(e instanceof ArrayBuffer)return e;if((0,i.L8)(e))return D(e);if(ArrayBuffer.isView(e)){const t=e.buffer;return 0===e.byteOffset&&e.byteLength===e.buffer.byteLength?t:t.slice(e.byteOffset,e.byteOffset+e.byteLength)}if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}if(e&&"object"==typeof e&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function z(e){if(e instanceof ArrayBuffer)return e;if((0,i.L8)(e))return D(e);const{buffer:t,byteOffset:n,byteLength:r}=e;return t instanceof ArrayBuffer&&0===n&&r===t.byteLength?t:D(t,n,r)}function D(e,t=0,n=e.byteLength-t){const i=new Uint8Array(e,t,n),r=new Uint8Array(i.length);return r.set(i),r.buffer}function F(...e){return function(e){const t=e.map(e=>e instanceof ArrayBuffer?new Uint8Array(e):e),n=t.reduce((e,t)=>e+t.byteLength,0),i=new Uint8Array(n);let r=0;for(const e of t)i.set(e,r),r+=e.byteLength;return i.buffer}(e)}function N(e){if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e)){const{buffer:t,byteOffset:n,byteLength:i}=e;return $(t,n,i)}return $(e)}function $(e,t=0,n=e.byteLength-t){const i=new Uint8Array(e,t,n),r=new Uint8Array(i.length);return r.set(i),r.buffer}const U=262144;var V=n(47612);function G(e,t){return V.Bd?async function*(e,t){const n=e.getReader();let i;try{for(;;){const e=i||n.read();t?._streamReadAhead&&(i=n.read());const{done:r,value:s}=await e;if(r)return;yield O(s)}}catch(e){n.releaseLock()}}(e,t):async function*(e){for await(const t of e)yield O(t)}(e)}function j(e,t){if("string"==typeof e)return function*(e,t){const n=t?.chunkSize||262144;let i=0;const r=new TextEncoder;for(;i<e.length;){const t=Math.min(e.length-i,n),s=e.slice(i,i+t);i+=t,yield z(r.encode(s))}}(e,t);if(e instanceof ArrayBuffer)return function*(e,t={}){const{chunkSize:n=U}=t;let i=0;for(;i<e.byteLength;){const t=Math.min(e.byteLength-i,n),r=new ArrayBuffer(t),s=new Uint8Array(e,i,t);new Uint8Array(r).set(s),i+=t,yield r}}(e,t);if((0,i.qf)(e))return async function*(e,t){const n=t?.chunkSize||1048576;let i=0;for(;i<e.size;){const t=i+n,r=await e.slice(i,t).arrayBuffer();i=t,yield r}}(e,t);if((0,i.H1)(e))return G(e,t);if((0,i.Sv)(e)){const n=e.body;if(!n)throw new Error("Readable stream not available on Response");return G(n,t)}throw new Error("makeIterator")}const W="Cannot convert supplied data type";function H(e,t,n){if(t.text&&"string"==typeof e)return e;if(R(e)&&(e=e.buffer),(0,i.B1)(e)){const n=function(e){return ArrayBuffer.isView(e)?e:new Uint8Array(e)}(e);if(t.text&&!t.binary){return new TextDecoder("utf8").decode(n)}return O(n)}throw new Error(W)}async function q(e,t,n){if("string"==typeof e||(0,i.B1)(e))return H(e,t);if((0,i.qf)(e)&&(e=await p(e)),(0,i.Sv)(e))return await g(e),t.binary?await e.arrayBuffer():await e.text();if((0,i.H1)(e)&&(e=j(e,n)),(0,i.xZ)(e)||(0,i.Td)(e))return async function(e){const t=[];for await(const n of e)t.push(N(n));return F(...t)}(e);throw new Error(W)}var Z=n(49987);var Y=n(52027),K=n(5223);const Q=/\.([^.]+)$/;function X(e){const t=f(e);return Boolean(t&&(t.startsWith("text/")||"application/json"===t||t.endsWith("+json")))}function J(e,t=[],n,i){if(!ee(e))return null;const s=(0,v.Rf)(n||{});if(s.core||={},t&&!Array.isArray(t))return(0,r.D)(t);let o=[];t&&(o=o.concat(t)),s.core.ignoreRegisteredLoaders||o.push(...(0,K.Ph)()),function(e){for(const t of e)(0,r.D)(t)}(o);const a=function(e,t,n,i){const r=h(e),s=f(e),o=(0,d.S3)(r)||i?.url;let a=null,c="";n?.core?.mimeType&&(a=ne(t,n?.core?.mimeType),c=`match forced by supplied MIME type ${n?.core?.mimeType}`);a=a||function(e,t){const n=t&&Q.exec(t),i=n&&n[1];return i?function(e,t){t=t.toLowerCase();for(const n of e)for(const e of n.extensions)if(e.toLowerCase()===t)return n;return null}(e,i):null}(t,o),c=c||(a?`matched url ${o}`:""),a=a||ne(t,s),c=c||(a?`matched MIME type ${s}`:""),a=a||function(e,t){if(!t)return null;for(const n of e)if("string"==typeof t){if(ie(t,n))return n}else if(ArrayBuffer.isView(t)){if(re(t.buffer,t.byteOffset,n))return n}else if(t instanceof ArrayBuffer){if(re(t,0,n))return n}return null}(t,e),c=c||(a?`matched initial data ${se(e)}`:""),n?.core?.fallbackMimeType&&(a=a||ne(t,n?.core?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${s}`:""));c&&Y.R.log(1,`selectLoader selected ${a?.name}: ${c}.`);return a}(e,o,s,i);if(!a&&!s.core.nothrow)throw new Error(te(e));return a}function ee(e){return!(e instanceof Response&&204===e.status)}function te(e){const t=h(e),n=f(e);let i="No valid loader found (";i+=t?`${Z.iW(t)}, `:"no url provided, ",i+=`MIME type: ${n?`"${n}"`:"not provided"}, `;const r=e?se(e):"";return i+=r?` first bytes: "${r}"`:"first bytes: not available",i+=")",i}function ne(e,t){for(const n of e){if(n.mimeTypes?.some(e=>l(t,e)))return n;if(l(t,`application/x.${n.id}`))return n}return null}function ie(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function re(e,t,n){return(Array.isArray(n.tests)?n.tests:[n.tests]).some(n=>function(e,t,n,r){if((0,i.B1)(r))return function(e,t,n){if(n=n||e.byteLength,e.byteLength<n||t.byteLength<n)return!1;const i=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<i.length;++e)if(i[e]!==r[e])return!1;return!0}(r,e,r.byteLength);switch(typeof r){case"function":return r(z(e));case"string":return r===oe(e,t,r.length);default:return!1}}(e,t,0,n))}function se(e,t=5){if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return oe(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){return oe(e,0,t)}return""}function oe(e,t,n){if(e.byteLength<t+n)return"";const i=new DataView(e);let r="";for(let e=0;e<n;e++)r+=String.fromCharCode(i.getUint8(t+e));return r}async function ae(e,t,n,s){!t||Array.isArray(t)||(0,r.l)(t)||(s=void 0,n=t,t=void 0),n=n||{};const o=h(e=await e),a=function(e,t){if(e&&!Array.isArray(e))return e;let n;if(e&&(n=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];n=n?[...n,...e]:e}return n&&n.length?n:void 0}(t,s),c=await async function(e,t=[],n,r){if(!ee(e))return null;const s=(0,v.Rf)(n||{});if(s.core||={},e instanceof Response&&X(e)){const n=J(await e.clone().text(),t,{...s,core:{...s.core,nothrow:!0}},r);if(n)return n}let o=J(e,t,{...s,core:{...s.core,nothrow:!0}},r);if(o)return o;(0,i.qf)(e)&&(o=J(e=await e.slice(0,10).arrayBuffer(),t,s,r)),!o&&e instanceof Response&&X(e)&&(o=J(await e.clone().text(),t,s,r));if(!o&&!s.core.nothrow)throw new Error(te(e));return o}(e,a,n);if(!c)return null;const l=(0,v.a5)(n,c,a,o);return s=function(e,t,n){if(n)return n;const i={fetch:y(t,e),...e};if(i.url){const e=(0,d.S3)(i.url);i.baseUrl=e,i.queryString=(0,d.by)(i.url),i.filename=Z.iW(e),i.baseUrl=Z.pD(e)}return Array.isArray(i.loaders)||(i.loaders=null),i}({url:o,_parse:ae,loaders:a},l,s||null),await async function(e,t,n,r){if(function(e){C(e,"no worker provided");const t=e.version}(e),n=b(e.options,n),(0,i.Sv)(t)){const{ok:e,redirected:n,status:i,statusText:s,type:o,url:a}=t,c=Object.fromEntries(t.headers.entries());r.response={headers:c,ok:e,redirected:n,status:i,statusText:s,type:o,url:a}}t=await q(t,e,n);const s=e;if(s.parseTextSync&&"string"==typeof t)return s.parseTextSync(t,n,r);if(function(e,t){if(!WorkerFarm.isSupported())return!1;if(!x&&!(t?._nodeWorkers??t?.core?._nodeWorkers))return!1;const n=t?.worker??t?.core?.worker;return Boolean(e.worker&&n)}(e,n))return await B(e,t,n,r,ae);if(s.parseText&&"string"==typeof t)return await s.parseText(t,n,r);if(s.parse)return await s.parse(t,n,r);throw C(!s.parseSync),new Error(`${e.id} loader - no parser found and worker is disabled`)}(c,e,l,s)}async function ce(e,t,n,s){let o,a;Array.isArray(t)||(0,r.l)(t)?(o=t,a=n):(o=[],a=t);const c=y(a);let l=e;if("string"==typeof e&&(l=await c(e)),(0,i.qf)(e)&&(l=await c(e)),"string"==typeof e){const t=(0,v.Rf)(a||{});t.core?.baseUrl||(a={...a,core:{...a?.core,baseUrl:e}})}return Array.isArray(o),await ae(l,o,a)}},5223(e,t,n){n.d(t,{Ph:()=>a,mk:()=>o});var i=n(90405),r=n(51253);const s=()=>{const e=(0,r.K2)();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry};function o(e){const t=s();e=Array.isArray(e)?e:[e];for(const n of e){const e=(0,i.D)(n);t.find(t=>e===t)||t.unshift(e)}}function a(){return s()}},90405(e,t,n){n.d(t,{D:()=>s,l:()=>r});var i=n(94976);function r(e){if(!e)return!1;Array.isArray(e)&&(e=e[0]);return Array.isArray(e?.extensions)}function s(e){let t;return(0,i.v)(e,"null loader"),(0,i.v)(r(e),"invalid loader"),Array.isArray(e)&&(t=e[1],e=e[0],e={...e,options:{...e.options,...t}}),(e?.parseTextSync||e?.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}},51253(e,t,n){n.d(t,{pp:()=>h,K2:()=>d,Rf:()=>p,a5:()=>f});var i=n(25925),r=n(49987);const s=new(n(60776).h)({id:"loaders.gl"});class NullLog{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}var o=n(47612);const a={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new class ConsoleLog{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:o.Bd,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},c={baseUri:"core.baseUrl",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"core.baseUrl",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"core.fetch.keepalive",signal:"core.fetch.signal"};var l=n(28071);const u=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function d(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state||(e._state={}),e._state}function h(){const e=d();return e.globalOptions=e.globalOptions||{...a,core:{...a.core}},p(e.globalOptions)}function f(e,t,n,i){return n=n||[],function(e,t){g(e,null,a,c,t);for(const n of t){const i=e&&e[n.id]||{},r=n.options&&n.options[n.id]||{},s=n.deprecatedOptions&&n.deprecatedOptions[n.id]||{};g(i,n.id,r,s,t)}}(e,n=Array.isArray(n)?n:[n]),p(v(t,e,i))}function p(e){const t=function(e){const t={...e};e.core&&(t.core={...e.core});return t}(e);b(t);for(const e of u)t.core&&void 0!==t.core[e]&&delete t[e];return t.core&&void 0!==t.core._workerType&&delete t._worker,t}function g(e,t,n,r,o){const a=t||"Top level",c=t?`${t}.`:"";for(const l in e){const u=!t&&(0,i.Gv)(e[l]);if(!(l in n)&&!("baseUri"===l&&!t)&&!("workerUrl"===l&&t))if(l in r)s.level>0&&s.warn(`${a} loader option '${c}${l}' no longer supported, use '${r[l]}'`)();else if(!u&&s.level>0){const e=m(l,o);s.warn(`${a} loader option '${c}${l}' not recognized. ${e}`)()}}}function m(e,t){const n=e.toLowerCase();let i="";for(const r of t)for(const t in r.options){if(e===t)return`Did you mean '${r.id}.${t}'?`;const s=t.toLowerCase();(n.startsWith(s)||s.startsWith(n))&&(i=i||`Did you mean '${r.id}.${t}'?`)}return i}function v(e,t,n){const i=e.options||{},s={...i};i.core&&(s.core={...i.core}),b(s),null===s.core?.log&&(s.core={...s.core,log:new NullLog}),y(s,p(h()));return y(s,p(t)),function(e,t){if(!t)return;const n=void 0!==e.core?.baseUrl;n||(e.core||={},e.core.baseUrl=r.pD((0,l.S3)(t)))}(s,n),function(e){const t=e.core;if(!t)return;for(const n of u)void 0!==t[n]&&(e[n]=t[n])}(s),s}function y(e,t){for(const n in t)if(n in t){const r=t[n];(0,i.aC)(r)&&(0,i.aC)(e[n])?e[n]={...e[n],...t[n]}:e[n]=t[n]}}function b(e){void 0!==e.baseUri&&(e.core||={},void 0===e.core.baseUrl&&(e.core.baseUrl=e.baseUri));for(const t of u)if(void 0!==e[t]){const n=e.core=e.core||{};void 0===n[t]&&(n[t]=e[t])}const t=e._worker;void 0!==t&&(e.core||={},void 0===e.core._workerType&&(e.core._workerType=t))}},28071(e,t,n){n.d(t,{E1:()=>o,S3:()=>s,by:()=>r});const i=/\?.*/;function r(e){const t=e.match(i);return t&&t[0]}function s(e){return e.replace(i,"")}function o(e){if(e.length<50)return e;const t=e.slice(e.length-15);return`${e.substr(0,32)}...${t}`}},94976(e,t,n){function i(e,t){if(!e)throw new Error(t||"loader assertion failed.")}n.d(t,{v:()=>i})},47612(e,t,n){"undefined"!=typeof self&&self,"undefined"!=typeof window&&window,"undefined"!=typeof globalThis&&globalThis,"undefined"!=typeof document&&document;const i=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),r="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);r&&parseFloat(r[1]);n.d(t,["Bd",0,i])},25925(e,t,n){const i=e=>"boolean"==typeof e,r=e=>"function"==typeof e,s=e=>null!==e&&"object"==typeof e;n.d(t,["B1",0,e=>s(e)&&"number"==typeof e.byteLength&&"function"==typeof e.slice,"Gv",0,s,"H1",0,e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||s(e)&&r(e.tee)&&r(e.cancel)&&r(e.getReader))(e)||(e=>s(e)&&r(e.read)&&r(e.pipe)&&i(e.readable))(e),"L8",0,e=>"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer,"Sv",0,e=>"undefined"!=typeof Response&&e instanceof Response||s(e)&&r(e.arrayBuffer)&&r(e.text)&&r(e.json),"Td",0,e=>Boolean(e)&&r(e[Symbol.asyncIterator]),"aC",0,e=>s(e)&&e.constructor==={}.constructor,"qf",0,e=>"undefined"!=typeof Blob&&e instanceof Blob,"xZ",0,e=>Boolean(e)&&r(e[Symbol.iterator])])},49987(e,t,n){function i(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):e}function r(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}n.d(t,{iW:()=>i,pD:()=>r})},62069(e,t,n){n.d(t,{Jc:()=>r,gO:()=>s,h0:()=>o});var i=n(29651);function r(e,t,n){const r=e.bindings.find(e=>e.name===t||`${e.name.toLocaleLowerCase()}uniforms`===t.toLocaleLowerCase());return r||n?.ignoreWarnings||i.R.warn(`Binding ${t} not set: Not found in shader layout.`)(),r||null}function s(e,t){if(!t)return{};if(function(e){const t=Object.keys(e);return t.length>0&&t.every(e=>/^\d+$/.test(e))}(t)){const e=t;return Object.fromEntries(Object.entries(e).map(([e,t])=>[Number(e),{...t}]))}const n={};for(const[i,s]of Object.entries(t)){const t=r(e,i),o=t?.group??0;n[o]||={},n[o][i]=s}return n}function o(e){const t={};for(const n of Object.values(e))Object.assign(t,n);return t}},7244(e,t,n){n.d(t,{Ef:()=>c,JO:()=>l,Lv:()=>a,TC:()=>o});var i=n(29651),r=n(65219),s=n(61954);function o(e){return e.attributes?e.attributes.map(e=>e.attribute):[e.name]}function a(e){return Object.fromEntries(e.attributes.map(e=>[e.name,e.location]))}function c(e){let t=1/0;for(const n of e)void 0!==n&&(t=Math.min(t,n));return t}function l(e,t,n){!function(e){for(const t of e)(t.attributes&&t.format||!t.attributes&&!t.format)&&i.R.warn(`BufferLayout ${t.name} must have either 'attributes' or 'format' field`)()}(t);const o=new Map;for(const e of t){const t=u(e);if(e.attributes)for(const n of e.attributes)o.has(n.attribute)||o.set(n.attribute,{bufferName:e.name,stepMode:e.stepMode,vertexFormat:n.format,byteOffset:n.byteOffset,byteStride:t});else e.format&&!o.has(e.name)&&o.set(e.name,{bufferName:e.name,stepMode:e.stepMode,vertexFormat:e.format,byteOffset:0,byteStride:t})}return e.attributes.map(e=>{const t=o.get(e.name);!t&&n?.warnOnMissingBufferLayout&&i.R.warn(`layout for attribute "${e.name}" not present in buffer layout`)();const a=r.Co.getAttributeShaderTypeInfo(e.type),c=t?.vertexFormat||s.E.getCompatibleVertexFormat(a);return{attributeName:e.name,bufferName:t?.bufferName||e.name,location:e.location,vertexFormat:c,byteOffset:t?.byteOffset??0,byteStride:t?.byteStride??s.E.getVertexFormatInfo(c).byteLength,stepMode:t?.stepMode||e.stepMode||(e.name.startsWith("instance")?"instance":"vertex")}}).sort((e,t)=>e.location-t.location)}function u(e){if("number"==typeof e.byteStride)return e.byteStride;if(e.attributes){let t=0;for(const n of e.attributes)t+=s.E.getVertexFormatInfo(n.format).byteLength;return t}return s.E.getVertexFormatInfo(e.format).byteLength}},2021(e,t,n){n.d(t,{P:()=>a});var i=n(29651),r=n(65219),s=n(61954),o=n(7244);function a(e,t){const n={},i=(0,o.JO)(e,t,{warnOnMissingBufferLayout:!0});for(const t of i){const i=c(e,t);n[t.attributeName]=i}return n}function c(e,t){const n=function(e,t){const n=e.attributes.find(e=>e.name===t);n||i.R.warn(`shader layout attribute "${t}" not present in shader`)();return n||null}(e,t.attributeName),o=r.Co.getAttributeShaderTypeInfo(n.type),a=t.vertexFormat,c=s.E.getVertexFormatInfo(a);return{attributeName:t.attributeName,bufferName:t.bufferName,location:n.location,shaderType:n.type,primitiveType:o.primitiveType,shaderComponents:o.components,vertexFormat:a,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:o.integer,stepMode:t.stepMode,byteOffset:t.byteOffset,byteStride:t.byteStride}}},19548(e,t,n){var i=n(29651);const r={id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,featureLevel:void 0,optionalFeatures:[],xrCompatible:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{const[n,r]=e.getDevicePixelSize();i.R.log(1,`${e} resized => ${n}x${r}px`)()},onPositionChange:(e,t)=>{const[n,r]=e.getPosition();i.R.log(1,`${e} repositioned => ${n},${r}`)()},onVisibilityChange:e=>i.R.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>i.R.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:function(e,t){return null!=e?Boolean(e):void 0!==t&&"production"!==t}(i.R.get("debug"),function(){const e=globalThis.process;if(e?.env)return e.env.NODE_ENV}()),debugGPUTime:!1,debugShaders:i.R.get("debug-shaders")||void 0,debugFramebuffers:Boolean(i.R.get("debug-framebuffers")),debugFactories:Boolean(i.R.get("debug-factories")),debugWebGL:Boolean(i.R.get("debug-webgl")),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0};n.d(t,["M",0,r])},77296(e,t,n){n.d(t,{pF:()=>Device,I7:()=>DeviceFeatures,PI:()=>DeviceLimits,zc:()=>h});var i=n(76028),r=n(29651),s=n(74683),o=n(26839),a=n(61954),c=n(42528);var l=n(74520),u=n(19548);class DeviceLimits{}function d(e){if(void 0!==e){if(null===e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e)return e;if(e instanceof Error)return e.message;if(Array.isArray(e))return e.map(d);if("object"==typeof e){if(function(e){return"toString"in e&&"function"==typeof e.toString&&e.toString!==Object.prototype.toString}(e)){const t=String(e);if("[object Object]"!==t)return t}return function(e){return"message"in e&&"type"in e}(e)?function(e){const t="string"==typeof e.type?e.type:"message",n="string"==typeof e.message?e.message:"",i="number"==typeof e.lineNum?e.lineNum:null,r="number"==typeof e.linePos?e.linePos:null;return`${t}${null!==i&&null!==r?` @ ${i}:${r}`:null!==i?` @ ${i}`:""}: ${n}`.trim()}(e):e.constructor?.name||"Object"}return String(e)}}class DeviceFeatures{features;disabledFeatures;constructor(e=[],t){this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}}function h(){if("undefined"==typeof HTMLCanvasElement)return!1;const e=HTMLCanvasElement.prototype;return"layoutSubtree"in e&&"function"==typeof e.requestPaint}class Device{static defaultProps={...u.M};get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}toJSON(){return this.toString()}id;props;userData={};statsManager=i.d;_factories={};timestamp=0;_reused=!1;_moduleData={};wgslLanguageFeatures=new Set;_textureCaps={};_debugGPUTimeQuery=null;constructor(e){this.props={...Device.defaultProps,...e},this.id=this.props.id||(0,s.L)(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return a.E.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return c.vz.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){const n=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(n),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,n=1){const i=Math.max(e,t,n);return 1+Math.floor(Math.log2(i))}isExternalImage(e){return function(e){return"undefined"!=typeof ImageData&&e instanceof ImageData||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement||"undefined"!=typeof VideoFrame&&e instanceof VideoFrame||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas}(e)}getExternalImageSize(e){return function(e){if("undefined"!=typeof ImageData&&e instanceof ImageData||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)return{width:e.width,height:e.height};if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement)return{width:e.naturalWidth,height:e.naturalHeight};if("undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement)return{width:e.videoWidth,height:e.videoHeight};if("undefined"!=typeof VideoFrame&&e instanceof VideoFrame)return{width:e.displayWidth,height:e.displayHeight};throw new Error("Unknown image type")}(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return c.vz.isCompressed(e)}getSupportedCompressedTextureFormats(){const e=[];for(const t of Object.keys((0,l.PU)()))this.isTextureFormatCompressed(t)&&this.isTextureFormatSupported(t)&&e.push(t);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...n){if(!this.props.onError(e,t)){const i=function(e,t){return[d(e),...t.map(d).filter(e=>void 0!==e)].filter(e=>void 0!==e)}(t,n);return r.R.error("webgl"===this.type?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,...i)}return()=>{}}debug(){if(this.props.debug);else{const e="'Type luma.log.set({debug: true}) in console to enable debug breakpoints',\nor create a device with the 'debug: true' prop.";r.R.once(0,e)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}writeBufferViaCommandEncoder(e,t,n,i=0){throw new Error("writeBufferViaCommandEncoder() not implemented")}generateMipmapsWebGPU(e){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(e){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(e,t){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(e,t,n,i,r){throw new Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&Boolean(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return null!==this._debugGPUTimeQuery}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return!0===e.createCanvasContext?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){const t=c.vz.getCapabilities(e),n=e=>("string"==typeof e?this.features.has(e):e)??!0,i=n(t.create);return{format:e,create:i,render:i&&n(t.render),filter:i&&n(t.filter),blend:i&&n(t.blend),store:i&&n(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t={...e};if((e.usage||0)&o.h.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":e.data instanceof Uint8Array&&(t.data=new Uint16Array(e.data),t.indexType="uint16")),!t.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return t}}},26839(e,t,n){n.d(t,{h:()=>Buffer});var i=n(5153);class Buffer extends i.F{static INDEX=16;static VERTEX=32;static UNIFORM=64;static STORAGE=128;static INDIRECT=256;static QUERY_RESOLVE=512;static MAP_READ=1;static MAP_WRITE=2;static COPY_SRC=4;static COPY_DST=8;get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){const n={...t};(t.usage||0)&Buffer.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?n.indexType="uint32":t.data instanceof Uint16Array?n.indexType="uint16":t.data instanceof Uint8Array&&(n.indexType="uint8")),delete n.data,super(e,n,Buffer.defaultProps),this.usage=n.usage||0,this.indexType=n.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}static DEBUG_DATA_MAX_LENGTH=32;debugData=new ArrayBuffer(0);_setDebugData(e,t,n){if(!this.device.props.debug)return;let i,r=null;ArrayBuffer.isView(e)?(r=e,i=e.buffer):i=e;const s=Math.min(e?e.byteLength:n,Buffer.DEBUG_DATA_MAX_LENGTH);if(null===i)this.debugData=new ArrayBuffer(s);else{const e=Math.min(r?.byteOffset||0,i.byteLength),t=Math.max(0,i.byteLength-e),n=Math.min(s,t);this.debugData=new Uint8Array(i,e,n).slice().buffer}}static defaultProps={...i.F.defaultProps,handle:void 0,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0}}},69499(e,t,n){n.d(t,{C:()=>ComputePipeline});var i=n(5153);class ComputePipeline extends i.F{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,t){super(e,t,ComputePipeline.defaultProps),this.shaderLayout=t.shaderLayout}static defaultProps={...i.F.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0}}},22512(e,t,n){n.d(t,{r:()=>RenderPipeline});var i=n(5153);class RenderPipeline extends i.F{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";sharedRenderPipeline=null;get isPending(){return"pending"===this.linkStatus||"pending"===this.vs.compilationStatus||"pending"===this.fs?.compilationStatus}get isErrored(){return"error"===this.linkStatus||"error"===this.vs.compilationStatus||"error"===this.fs?.compilationStatus}constructor(e,t){super(e,t,RenderPipeline.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}static defaultProps={...i.F.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,_uniformBlockLayouts:[],bindings:void 0,bindGroups:void 0}}},5153(e,t,n){n.d(t,{F:()=>Resource});var i=n(74683);const r="GPU Resource Counts",s="Resource Counts",o="GPU Time and Memory",a=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"].flatMap(e=>[`${e} Created`,`${e} Active`]),c=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"].flatMap(e=>[`${e} Created`,`${e} Active`]),l=new WeakMap,u=new WeakMap;class Resource{static defaultProps={id:"undefined",handle:void 0,_isHandleBorrowed:!1,userData:void 0};toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}toJSON(){return this.toString()}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;get ownsHandle(){return(void 0===this.props.handle||null===this.props.handle)&&!this.isHandleBorrowed}get isHandleBorrowed(){return Boolean(this.props._isHandleBorrowed)}constructor(e,t,n){if(!e)throw new Error("no device");this._device=e,this.props=function(e,t){const n={...t};for(const t in e)void 0!==e[t]&&(n[t]=e[t]);return n}(t,n);const r="undefined"!==this.props.id?this.props.id:(0,i.L)(this[Symbol.toStringTag]);this.props.id=r,this.id=r,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(const e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){const e=f(this._device),t=e?p():0,n=[this._device.statsManager.getStats(r),this._device.statsManager.getStats(s)],i=h(this._device);for(const e of n)d(e,i);const o=this.getStatsName();for(const e of n)e.get("Resources Active").decrementCount(),e.get(`${o}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+(p()-t))}trackAllocatedMemory(e,t=this.getStatsName()){const n=f(this._device),i=n?p():0,r=this._device.statsManager.getStats(o);this.allocatedBytes>0&&this.allocatedBytesName&&(r.get("GPU Memory").subtractCount(this.allocatedBytes),r.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),r.get("GPU Memory").addCount(e),r.get(`${t} Memory`).addCount(e),n&&(n.statsBookkeepingCalls=(n.statsBookkeepingCalls||0)+1,n.statsBookkeepingTimeMs=(n.statsBookkeepingTimeMs||0)+(p()-i)),this.allocatedBytes=e,this.allocatedBytesName=t}trackReferencedMemory(e,t=this.getStatsName()){this.trackAllocatedMemory(e,`External ${t}`)}trackDeallocatedMemory(e=this.getStatsName()){if(0===this.allocatedBytes)return void(this.allocatedBytesName=null);const t=f(this._device),n=t?p():0,i=this._device.statsManager.getStats(o);i.get("GPU Memory").subtractCount(this.allocatedBytes),i.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(p()-n)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){const e=this.getStatsName(),t=f(this._device),n=t?p():0,i=[this._device.statsManager.getStats(r),this._device.statsManager.getStats(s)],o=h(this._device);for(const e of i)d(e,o);for(const t of i)t.get("Resources Created").incrementCount(),t.get("Resources Active").incrementCount(),t.get(`${e}s Created`).incrementCount(),t.get(`${e}s Active`).incrementCount();t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(p()-n)),function(e,t){const n=f(e);if(!n||!n.activeDefaultFramebufferAcquireDepth)return;switch(n.transientCanvasResourceCreates=(n.transientCanvasResourceCreates||0)+1,t){case"Texture":n.transientCanvasTextureCreates=(n.transientCanvasTextureCreates||0)+1;break;case"TextureView":n.transientCanvasTextureViewCreates=(n.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":n.transientCanvasSamplerCreates=(n.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":n.transientCanvasFramebufferCreates=(n.transientCanvasFramebufferCreates||0)+1}}(this._device,e)}getStatsName(){return function(e){let t=Object.getPrototypeOf(e);for(;t;){const n=Object.getPrototypeOf(t);if(!n||n===Resource.prototype)return g(t)||e[Symbol.toStringTag]||e.constructor.name;t=n}return e[Symbol.toStringTag]||e.constructor.name}(this)}}function d(e,t){const n=e.stats;let i=!1;for(const r of t)n[r]||(e.get(r),i=!0);const r=Object.keys(n).length,s=l.get(e);if(!i&&s?.orderedStatNames===t&&s.statCount===r)return;const o={};let a=u.get(t);a||(a=new Set(t),u.set(t,a));for(const e of t)n[e]&&(o[e]=n[e]);for(const[e,t]of Object.entries(n))a.has(e)||(o[e]=t);for(const e of Object.keys(n))delete n[e];Object.assign(n,o),l.set(e,{orderedStatNames:t,statCount:r})}function h(e){return"webgl"===e.type?c:a}function f(e){const t=e.userData["cpu-hotspot-profiler"];return t?.enabled?t:null}function p(){return globalThis.performance?.now?.()??Date.now()}function g(e){const t=Object.getOwnPropertyDescriptor(e,Symbol.toStringTag);return"function"==typeof t?.get?t.get.call(e):"string"==typeof t?.value?t.value:null}},89277(e,t,n){n.d(t,{L:()=>Sampler});var i=n(5153);class Sampler extends i.F{static defaultProps={...i.F.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){super(e,t=Sampler.normalizeProps(e,t),Sampler.defaultProps)}static normalizeProps(e,t){return t}}},40720(e,t,n){n.d(t,{M:()=>Shader});var i=n(5153),r=n(29651),s=n(74683);function o(e,t,n,i){if(i?.inlineSource){const i=function(e,t,n){let i="";for(let r=t-2;r<=t;r++){const s=e[r-1];void 0!==s&&(i+=a(s,t,n))}return i}(t,n);return`\n${i}${e.linePos>0?`${" ".repeat(e.linePos+5)}^^^\n`:""}${e.type.toUpperCase()}: ${e.message}\n\n`}const r="error"===e.type?"red":"orange";return i?.html?`<div class='luma-compiler-log-${e.type}' style="color:${r};"><b> ${e.type.toUpperCase()}: ${e.message}</b></div>`:`${e.type.toUpperCase()}: ${e.message}`}function a(e,t,n){const i=n?.html?e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'"):e;return`${function(e,t){let n="";for(let i=e.length;i<t;++i)n+=" ";return n+e}(String(t),4)}: ${i}${n?.html?"<br/>":"\n"}`}class Shader extends i.F{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){super(e,{id:c(t={...t,debugShaders:t.debugShaders||e.props.debugShaders||"errors"}),...t},Shader.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){const e=this.props.debugShaders;switch(e){case"never":return;case"errors":if("success"===this.compilationStatus)return}try{const t=await this.getCompilationInfo();if("warnings"===e&&0===t?.length)return;this._displayShaderLog(t,this.id)}catch(e){r.R.warn(`Shader ${this.id}: failed to fetch compilation info during debug logging`,e)()}}_displayShaderLog(e,t){if("undefined"==typeof document||!document?.createElement)return;const n=t,i=`${this.stage} shader "${n}"`,r=function(e,t,n){let i="";const r=t.split(/\r?\n/),s=e.slice().sort((e,t)=>e.lineNum-t.lineNum);switch(n?.showSourceCode||"no"){case"all":let t=0;for(let e=1;e<=r.length;e++){const c=r[e-1],l=s[t];for(c&&l&&(i+=a(c,e,n));s.length>t&&l.lineNum===e;){const e=s[t++];e&&(i+=o(e,r,e.lineNum,{...n,inlineSource:!1}))}}for(;s.length>t;){const e=s[t++];e&&(i+=o(e,[],0,{...n,inlineSource:!1}))}return i;case"issues":case"no":for(const t of e)i+=o(t,r,t.lineNum,{inlineSource:"no"!==n?.showSourceCode});return i}}(e,this.source,{showSourceCode:"all",html:!0}),s=this.getTranslatedSource(),c=document.createElement("div");c.innerHTML=`<h1>Compilation error in ${i}</h1>\n<div style="display:flex;position:fixed;top:10px;right:20px;gap:2px;">\n<button id="copy">Copy source</button><br/>\n<button id="close">Close</button>\n</div>\n<code><pre>${r}</pre></code>`,s&&(c.innerHTML+=`<br /><h1>Translated Source</h1><br /><br /><code><pre>${s}</pre></code>`),c.style.top="0",c.style.left="0",c.style.background="white",c.style.position="fixed",c.style.zIndex="9999",c.style.maxWidth="100vw",c.style.maxHeight="100vh",c.style.overflowY="auto",document.body.appendChild(c);const l=c.querySelector(".luma-compiler-log-error");l?.scrollIntoView(),c.querySelector("button#close").onclick=()=>{c.remove()},c.querySelector("button#copy").onclick=()=>{navigator.clipboard.writeText(this.source)}}static defaultProps={...i.F.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0}}function c(e){return function(e,t="unnamed"){const n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(e);return n?.[1]??t}(e.source)||e.id||(0,s.L)(`unnamed ${e.stage}-shader`)}},75638(e,t,n){n.d(t,{X:()=>TextureView});var i=n(5153);class TextureView extends i.F{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,TextureView.defaultProps)}static defaultProps={...i.F.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0}}},80698(e,t,n){n.d(t,{g:()=>Texture});var i=n(5153),r=n(89277),s=n(29651),o=n(42528);const a={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"};class Texture extends i.F{static SAMPLE=4;static STORAGE=8;static RENDER=16;static COPY_SRC=1;static COPY_DST=2;static TEXTURE=4;static RENDER_ATTACHMENT=16;dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,t,n){if(super(e,t=Texture.normalizeProps(e,t),Texture.defaultProps),this.dimension=this.props.dimension,this.baseDimension=a[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,"cube"===this.dimension&&(this.depth=6),void 0===this.props.width||void 0===this.props.height)if(e.isExternalImage(t.data)){const n=e.getExternalImageSize(t.data);this.width=n?.width||1,this.height=n?.height||1}else this.width=1,this.height=1,void 0!==this.props.width&&void 0!==this.props.height||s.R.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=n?.byteAlignment||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof r.L?e:this.device.createSampler(e)}copyImageData(e){const{data:t,depth:n,...i}=e;this.writeData(t,{...i,depthOrArrayLayers:i.depthOrArrayLayers??n})}computeMemoryLayout(e={}){const t=this._normalizeTextureReadOptions(e),{width:n=this.width,height:i=this.height,depthOrArrayLayers:r=this.depth}=t,{format:s,byteAlignment:a}=this;return o.vz.computeMemoryLayout({format:s,width:n,height:i,depth:r,byteAlignment:a})}readBuffer(e,t){throw new Error("readBuffer not implemented")}readDataAsync(e){throw new Error("readBuffer not implemented")}writeBuffer(e,t){throw new Error("readBuffer not implemented")}writeData(e,t){throw new Error("readBuffer not implemented")}readDataSyncWebGL(e){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(e,t){const n={...t},{width:i,height:r}=n;return"number"==typeof i&&(n.width=Math.max(1,Math.ceil(i))),"number"==typeof r&&(n.height=Math.max(1,Math.ceil(r))),n}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){const{data:t,depth:n,...i}=e,r=this._normalizeTextureWriteOptions({...i,depthOrArrayLayers:i.depthOrArrayLayers??n});return{data:t,depth:r.depthOrArrayLayers,...r}}_normalizeCopyExternalImageOptions(e){const t=Texture._omitUndefined(e),n=t.mipLevel??0,i=this._getMipLevelSize(n),r=this.device.getExternalImageSize(e.image),s={...Texture.defaultCopyExternalImageOptions,...i,...r,...t};return s.width=Math.min(s.width,i.width-s.x),s.height=Math.min(s.height,i.height-s.y),s.depth=Math.min(s.depth,i.depthOrArrayLayers-s.z),s}_normalizeCopyElementImageOptions(e){const t=Texture._omitUndefined(e),n=t.mipLevel??0,i=this._getMipLevelSize(n),r={...Texture.defaultCopyElementImageOptions,...i,...t};return r.width=Math.min(r.width,i.width-r.x),r.height=Math.min(r.height,i.height-r.y),r.depth=Math.min(r.depth,i.depthOrArrayLayers-r.z),r}_normalizeTextureReadOptions(e){const t=Texture._omitUndefined(e),n=t.mipLevel??0,i=this._getMipLevelSize(n),r={...Texture.defaultTextureReadOptions,...i,...t};return r.width=Math.min(r.width,i.width-r.x),r.height=Math.min(r.height,i.height-r.y),r.depthOrArrayLayers=Math.min(r.depthOrArrayLayers,i.depthOrArrayLayers-r.z),r}_getSupportedColorReadOptions(e){const t=this._normalizeTextureReadOptions(e),n=o.vz.getInfo(this.format);switch(this._validateColorReadAspect(t),this._validateColorReadFormat(n),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return t;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if("all"!==e.aspect)throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(e){const t=Texture._omitUndefined(e),n=t.mipLevel??0,i=this._getMipLevelSize(n),r={...Texture.defaultTextureWriteOptions,...i,...t};r.width=Math.min(r.width,i.width-r.x),r.height=Math.min(r.height,i.height-r.y),r.depthOrArrayLayers=Math.min(r.depthOrArrayLayers,i.depthOrArrayLayers-r.z);const s=o.vz.computeMemoryLayout({format:this.format,width:r.width,height:r.height,depth:r.depthOrArrayLayers,byteAlignment:this.byteAlignment}),a=s.bytesPerPixel*r.width;if(r.bytesPerRow=t.bytesPerRow??s.bytesPerRow,r.rowsPerImage=t.rowsPerImage??r.height,r.bytesPerRow<a)throw new Error(`bytesPerRow (${r.bytesPerRow}) must be at least ${a} for ${this.format}`);if(r.rowsPerImage<r.height)throw new Error(`rowsPerImage (${r.rowsPerImage}) must be at least ${r.height} for ${this.format}`);const c=this.device.getTextureFormatInfo(this.format).bytesPerPixel;if(c&&r.bytesPerRow%c!==0)throw new Error(`bytesPerRow (${r.bytesPerRow}) must be a multiple of bytesPerPixel (${c}) for ${this.format}`);return r}_getMipLevelSize(e){return{width:Math.max(1,this.width>>e),height:"1d"===this.baseDimension?1:Math.max(1,this.height>>e),depthOrArrayLayers:"3d"===this.dimension?Math.max(1,this.depth>>e):this.depth}}getAllocatedByteLength(){let e=0;for(let t=0;t<this.mipLevels;t++){const{width:n,height:i,depthOrArrayLayers:r}=this._getMipLevelSize(t);e+=o.vz.computeMemoryLayout({format:this.format,width:n,height:i,depth:r,byteAlignment:1}).byteLength}return e*this.samples}static _omitUndefined(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}static defaultProps={...i.F.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:Texture.SAMPLE|Texture.RENDER|Texture.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0};static defaultCopyDataOptions={data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"};static defaultCopyExternalImageOptions={image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultCopyElementImageOptions={element:void 0,width:void 0,height:void 0,sourceX:0,sourceY:0,sourceWidth:void 0,sourceHeight:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultTextureReadOptions={x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"};static defaultTextureWriteOptions={byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}}},52009(e,t,n){n.d(t,{N:()=>PipelineFactory});var i=n(69499),r=n(22512),s=n(29651),o=n(74683);class PipelineFactory{static defaultProps={...r.r.defaultProps};static getDefaultPipelineFactory(e){const t=e.getModuleData("@luma.gl/core");return t.defaultPipelineFactory||=new PipelineFactory(e),t.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(e){this.device=e}createRenderPipeline(e){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(e);const t={...r.r.defaultProps,...e},n=this._renderPipelineCache,i=this._hashRenderPipeline(t);let a=n[i]?.resource;if(a)n[i].useCount++,this.device.props.debugFactories&&s.R.log(3,`${this}: ${n[i].resource} reused, count=${n[i].useCount}, (id=${e.id})`)();else{const e="webgl"===this.device.type&&this.device.props._sharePipelines?this.createSharedRenderPipeline(t):void 0;a=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:(0,o.L)("unnamed-cached"),_sharedRenderPipeline:e}),a.hash=i,n[i]={resource:a,useCount:1},this.device.props.debugFactories&&s.R.log(3,`${this}: ${a} created, count=${n[i].useCount}`)()}return a}createComputePipeline(e){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);const t={...i.C.defaultProps,...e},n=this._computePipelineCache,r=this._hashComputePipeline(t);let o=n[r]?.resource;return o?(n[r].useCount++,this.device.props.debugFactories&&s.R.log(3,`${this}: ${n[r].resource} reused, count=${n[r].useCount}, (id=${e.id})`)()):(o=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0}),o.hash=r,n[r]={resource:o,useCount:1},this.device.props.debugFactories&&s.R.log(3,`${this}: ${o} created, count=${n[r].useCount}`)()),o}release(e){if(!this.device.props._cachePipelines)return void e.destroy();const t=this._getCache(e),n=e.hash;t[n].useCount--,0===t[n].useCount?(this._destroyPipeline(e),this.device.props.debugFactories&&s.R.log(3,`${this}: ${e} released and destroyed`)()):t[n].useCount<0?(s.R.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[n].useCount=0):this.device.props.debugFactories&&s.R.log(3,`${this}: ${e} released, count=${t[n].useCount}`)()}createSharedRenderPipeline(e){const t=this._hashSharedRenderPipeline(e);let n=this._sharedRenderPipelineCache[t];if(!n){n={resource:this.device._createSharedRenderPipelineWebGL(e),useCount:0},this._sharedRenderPipelineCache[t]=n}return n.useCount++,n.resource}releaseSharedRenderPipeline(e){if(!e.sharedRenderPipeline)return;const t=this._hashSharedRenderPipeline(e.sharedRenderPipeline.props),n=this._sharedRenderPipelineCache[t];n&&(n.useCount--,0===n.useCount&&(n.resource.destroy(),delete this._sharedRenderPipelineCache[t]))}_destroyPipeline(e){const t=this._getCache(e);return!!this.device.props._destroyPipelines&&(delete t[e.hash],e.destroy(),e instanceof r.r&&this.releaseSharedRenderPipeline(e),!0)}_getCache(e){let t;if(e instanceof i.C&&(t=this._computePipelineCache),e instanceof r.r&&(t=this._renderPipelineCache),!t)throw new Error(`${this}`);if(!t[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return t}_hashComputePipeline(e){const{type:t}=this.device;return`${t}/C/${this._getHash(e.shader.source)}SL${this._getHash(JSON.stringify(e.shaderLayout))}`}_hashRenderPipeline(e){const t=e.vs?this._getHash(e.vs.source):0,n=e.fs?this._getHash(e.fs.source):0,i=this._getWebGLVaryingHash(e),r=this._getHash(JSON.stringify(e.shaderLayout)),s=this._getHash(JSON.stringify(e._uniformBlockLayouts)),o=this._getHash(JSON.stringify(e.bufferLayout)),{type:a}=this.device;if("webgl"===a){const c=this._getHash(JSON.stringify(e.parameters));return`${a}/R/${t}/${n}V${i}T${e.topology}P${c}SL${r}UBL${s}BL${o}`}{const s=this._getHash(JSON.stringify({vertexEntryPoint:e.vertexEntryPoint,fragmentEntryPoint:e.fragmentEntryPoint})),c=this._getHash(JSON.stringify(e.parameters)),l=this._getWebGPUAttachmentHash(e);return`${a}/R/${t}/${n}V${i}T${e.topology}EP${s}P${c}SL${r}BL${o}A${l}`}}_hashSharedRenderPipeline(e){return`webgl/S/${e.vs?this._getHash(e.vs.source):0}/${e.fs?this._getHash(e.fs.source):0}V${this._getWebGLVaryingHash(e)}`}_getHash(e){return void 0===this._hashes[e]&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}_getWebGLVaryingHash(e){const{varyings:t=[],bufferMode:n=null}=e;return this._getHash(JSON.stringify({varyings:t,bufferMode:n}))}_getWebGPUAttachmentHash(e){const t=e.colorAttachmentFormats??[this.device.preferredColorFormat],n=e.depthStencilAttachmentFormat??(e.parameters?.depthWriteEnabled?this.device.preferredDepthFormat:null);return this._getHash(JSON.stringify({colorAttachmentFormats:t,depthStencilAttachmentFormat:n}))}}},83994(e,t,n){n.d(t,{g:()=>ShaderFactory});var i=n(40720),r=n(29651);class ShaderFactory{static defaultProps={...i.M.defaultProps};static getDefaultShaderFactory(e){const t=e.getModuleData("@luma.gl/core");return t.defaultShaderFactory||=new ShaderFactory(e),t.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(e){this.device=e}createShader(e){if(!this.device.props._cacheShaders)return this.device.createShader(e);const t=this._hashShader(e);let n=this._cache[t];if(n)n.useCount++,this.device.props.debugFactories&&r.R.log(3,`${this}: Reusing shader ${n.resource.id} count=${n.useCount}`)();else{const i=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=n={resource:i,useCount:1},this.device.props.debugFactories&&r.R.log(3,`${this}: Created new shader ${i.id}`)()}return n.resource}release(e){if(!this.device.props._cacheShaders)return void e.destroy();const t=this._hashShader(e),n=this._cache[t];if(n)if(n.useCount--,0===n.useCount)this.device.props._destroyShaders&&(delete this._cache[t],n.resource.destroy(),this.device.props.debugFactories&&r.R.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(n.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.device.props.debugFactories&&r.R.log(3,`${this}: Releasing shader ${e.id} count=${n.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}}},69204(e,t,n){n.d(t,{K:()=>UniformStore});var i=n(26839),r=n(29651),s=n(50584);function o(e){return Array.isArray(e)?0===e.length||"number"==typeof e[0]:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}(e)}class UniformBlock{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){const t=e?.shaderLayout.bindings?.find(t=>"uniform"===t.type&&t.name===e?.name);if(!t)throw new Error(e?.name);const n=t;for(const e of n.uniforms||[])this.bindingLayout[e.name]=e}}setUniforms(e){for(const[t,n]of Object.entries(e)){this._setUniform(t,n)&&!this.needsRedraw&&this.setNeedsRedraw(`${this.name}.${t}=${n}`)}}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){return!function(e,t,n=16){if(e===t)return!0;const i=e,r=t;if(!o(i)||!o(r))return!1;if(i.length!==r.length)return!1;const s=Math.min(n,128);if(i.length>s)return!1;for(let e=0;e<i.length;++e)if(r[e]!==i[e])return!1;return!0}(this.uniforms[e],t)&&(this.uniforms[e]=o(n=t)?n.slice():n,this.modifiedUniforms[e]=!0,this.modified=!0,!0);var n}}var a=n(73390);class ShaderBlockWriter{layout;constructor(e){this.layout=e}has(e){return Boolean(this.layout.fields[e])}get(e){const t=this.layout.fields[e];return t?{offset:t.offset,size:t.size}:void 0}getFlatUniformValues(e){const t={};for(const[n,i]of Object.entries(e)){const e=this.layout.uniformTypes[n];e?this._flattenCompositeValue(t,n,e,i):this.layout.fields[n]&&(t[n]=i)}return t}getData(e){const t=(0,a.o)(this.layout.byteLength);new Uint8Array(t,0,this.layout.byteLength).fill(0);const n={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)},i=this.getFlatUniformValues(e);for(const[e,t]of Object.entries(i))this._writeLeafValue(n,e,t);return new Uint8Array(t,0,this.layout.byteLength)}_flattenCompositeValue(e,t,n,i){if(void 0!==i)if("string"==typeof n||this.layout.fields[t])e[t]=i;else{if(Array.isArray(n)){const s=n[0],a=n[1];if(Array.isArray(s))throw new Error(`Nested arrays are not supported for ${t}`);if("string"==typeof s&&o(i))return void this._flattenPackedArray(e,t,s,a,i);if(!Array.isArray(i))return void r.R.warn(`Unsupported uniform array value for ${t}:`,i)();for(let n=0;n<Math.min(i.length,a);n++){const r=i[n];void 0!==r&&this._flattenCompositeValue(e,`${t}[${n}]`,s,r)}return}if((0,s.WC)(n)&&function(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)&&!ArrayBuffer.isView(e)}(i))for(const[r,s]of Object.entries(i)){if(void 0===s)continue;const i=`${t}.${r}`;this._flattenCompositeValue(e,i,n[r],s)}else r.R.warn(`Unsupported uniform value for ${t}:`,i)()}}_flattenPackedArray(e,t,n,i,r){const o=r,a=(0,s.jV)(n,this.layout.layout).components;for(let n=0;n<i;n++){const i=n*a;if(i>=o.length)break;e[`${t}[${n}]`]=1===a?Number(o[i]):c(r,i,i+a)}}_writeLeafValue(e,t,n){const i=this.layout.fields[t];if(!i)return void r.R.warn(`Uniform ${t} not found in layout`)();const{type:s,components:o,columns:a,rows:c,offset:l,columnStride:u}=i,d=e[s];if(1===o)return void(d[l]=Number(n));const h=n;if(1===a){for(let e=0;e<o;e++)d[l+e]=Number(h[e]??0);return}let f=0;for(let e=0;e<a;e++){const t=l+e*u;for(let e=0;e<c;e++)d[t+e]=Number(h[f++]??0)}}}function c(e,t,n){return Array.prototype.slice.call(e,t,n)}class UniformStore{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(e,t){this.device=e;for(const[n,i]of Object.entries(t)){const t=n,r=(0,s.Pr)(i.uniformTypes??{},{layout:i.layout??l(e)}),o=new ShaderBlockWriter(r);this.shaderBlockLayouts.set(t,r),this.shaderBlockWriters.set(t,o);const a=new UniformBlock({name:n});a.setUniforms(o.getFlatUniformValues(i.defaultUniforms||{})),this.uniformBlocks.set(t,a)}}destroy(){for(const e of this.uniformBuffers.values())e.destroy()}setUniforms(e,t){for(const[t,n]of Object.entries(e)){const e=t,i=this.shaderBlockWriters.get(e),r=i?.getFlatUniformValues(n||{});this.uniformBlocks.get(e)?.setUniforms(r||{})}this.updateUniformBuffers(t)}getUniformBufferByteLength(e){const t=this.shaderBlockLayouts.get(e)?.byteLength||0;return Math.max(t,1024)}getUniformBufferData(e){const t=this.uniformBlocks.get(e)?.getAllUniforms()||{},n=this.shaderBlockWriters.get(e);return n?.getData(t)||new Uint8Array(0)}createUniformBuffer(e,t){t&&this.setUniforms(t);const n=this.getUniformBufferByteLength(e),r=this.device.createBuffer({usage:i.h.UNIFORM|i.h.COPY_DST,byteLength:n}),s=this.getUniformBufferData(e);return r.write(s),r}getManagedUniformBuffer(e){if(!this.uniformBuffers.get(e)){const t=this.getUniformBufferByteLength(e),n=this.device.createBuffer({usage:i.h.UNIFORM|i.h.COPY_DST,byteLength:t});this.uniformBuffers.set(e,n)}return this.uniformBuffers.get(e)}updateUniformBuffers(e){let t=!1;for(const n of this.uniformBlocks.keys()){const i=this.updateUniformBuffer(n,e);t||=i}return t&&r.R.log(3,`UniformStore.updateUniformBuffers(): ${t}`)(),t}updateUniformBuffer(e,t){const n=this.uniformBlocks.get(e);let i=this.uniformBuffers.get(e),s=!1;if(i&&n?.needsRedraw){s||=n.needsRedraw;const o=this.getUniformBufferData(e);if(i=this.uniformBuffers.get(e),i&&(t?this.device.writeBufferViaCommandEncoder(t,i,o):i.write(o)),r.R.level>=4){const t=this.uniformBlocks.get(e)?.getAllUniforms();r.R.log(4,`Writing to uniform buffer ${String(e)}`,o,t)()}}return s}}function l(e){return"webgpu"===e.type?"wgsl-uniform":"std140"}},57285(e,t,n){var i=n(68597);const r=new class DataTypeDecoder{getDataTypeInfo(e){return(0,i.vE)(e)}getNormalizedDataType(e){return(0,i.K7)(e)}alignTo(e,t){return(0,i.JP)(e,t)}getDataType(e){return(0,i.h1)(e)}getTypedArrayConstructor(e){return(0,i.Ak)(e)}};n.d(t,["r",0,r])},68597(e,t,n){n.d(t,{JP:()=>o,h1:()=>c,UE:()=>a,vE:()=>r,K7:()=>s,Ak:()=>u,Y0:()=>l});const i=globalThis.Float16Array;function r(e){const t=e.includes("norm"),n=!t&&!e.startsWith("float"),i=e.startsWith("s"),r=d[e],[s,o,a]=r||["uint8 ","i32",1];return{signedType:s,primitiveType:o,byteLength:a,normalized:t,integer:n,signed:i}}function s(e){const t=e;switch(t){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return t}}function o(e,t){switch(t){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}function a(e){const t=ArrayBuffer.isView(e)?e.constructor:e;if(n=t,Boolean(i&&n===i))return"float16";var n;if(t===Uint8ClampedArray)return"uint8";const r=Object.values(d).find(e=>t===e[4]);if(!r)throw new Error(t.name);return r[0]}function c(e){return a(e)}function l(e){if("float16"===e)return i??Uint16Array;const t=d[e];if(!t)throw new Error(e);const[,,,,n]=t;return n}function u(e){return l(e)}const d={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]}},50584(e,t,n){n.d(t,{Pr:()=>s,WC:()=>a,jV:()=>o});var i=n(68597),r=n(65219);function s(e,t={}){const n={...e},r=t.layout??"std140",s={};let o=0;for(const[e,t]of Object.entries(n))o=c(s,e,t,o,r);return o=(0,i.JP)(o,u(n,r)),{layout:r,byteLength:4*o,uniformTypes:n,fields:s}}function o(e,t){const n=(0,r.si)(e),s=(0,r.k0)(n),o=/^mat(\d)x(\d)<.+>$/.exec(n);if(o){const e=Number(o[1]),r=Number(o[2]),a=d(r,n,s.type,t),c=function(e,t,n){return"std140"===n?4:(0,i.JP)(e,t)}(a.size,a.alignment,t);return{alignment:a.alignment,size:e*c,components:e*r,columns:e,rows:r,columnStride:c,shaderType:n,type:s.type}}const a=/^vec(\d)<.+>$/.exec(n);return a?d(Number(a[1]),n,s.type,t):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:n,type:s.type}}function a(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)}function c(e,t,n,r,s){if("string"==typeof n){const a=o(n,s),c=(0,i.JP)(r,a.alignment);return e[t]={offset:c,...a},c+a.size}if(Array.isArray(n)){if(Array.isArray(n[0]))throw new Error(`Nested arrays are not supported for ${t}`);const o=n[0],a=n[1],l=h(o,s),d=(0,i.JP)(r,u(n,s));for(let n=0;n<a;n++)c(e,`${t}[${n}]`,o,d+n*l,s);return d+l*a}if(a(n)){const o=u(n,s);let a=(0,i.JP)(r,o);for(const[i,r]of Object.entries(n))a=c(e,`${t}.${i}`,r,a,s);return(0,i.JP)(a,o)}throw new Error(`Unsupported CompositeShaderType for ${t}`)}function l(e,t){if("string"==typeof e)return o(e,t).size;if(Array.isArray(e)){const n=e[0],i=e[1];if(Array.isArray(n))throw new Error("Nested arrays are not supported");return h(n,t)*i}let n=0;for(const r of Object.values(e)){const e=r;n=(0,i.JP)(n,u(e,t)),n+=l(e,t)}return(0,i.JP)(n,u(e,t))}function u(e,t){if("string"==typeof e)return o(e,t).alignment;if(Array.isArray(e)){const n=u(e[0],t);return f(t)?Math.max(n,4):n}let n=1;for(const i of Object.values(e)){const e=u(i,t);n=Math.max(n,e)}return function(e){return"std140"===e||"wgsl-uniform"===e}(t)?Math.max(n,4):n}function d(e,t,n,i){return{alignment:2===e?2:4,size:3===e?3:e,components:e,columns:1,rows:e,columnStride:3===e?3:e,shaderType:t,type:n}}function h(e,t){return function(e,t,n){return(0,i.JP)(e,f(n)?4:t)}(l(e,t),u(e,t),t)}function f(e){return"std140"===e||"wgsl-uniform"===e}},65219(e,t,n){function i(e){const t=s(e),n=l[t];if(!n)throw new Error(`Unsupported variable shader type: ${e}`);return n}n.d(t,{k0:()=>i,si:()=>s});function r(e){return u[e]||e}function s(e){return d[e]||e}const o=new class ShaderTypeDecoder{getVariableShaderTypeInfo(e){return i(e)}getAttributeShaderTypeInfo(e){return function(e){const t=r(e),n=c[t];if(!n)throw new Error(`Unsupported attribute shader type: ${e}`);const[i,s]=n,o="i32"===i||"u32"===i,l="u32"!==i;return{primitiveType:i,components:s,byteLength:a[i]*s,integer:o,signed:l}}(e)}makeShaderAttributeType(e,t){return function(e,t){return 1===t?e:`vec${t}<${e}>`}(e,t)}resolveAttributeShaderTypeAlias(e){return r(e)}resolveVariableShaderTypeAlias(e){return s(e)}},a={f32:4,f16:2,i32:4,u32:4},c={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},l={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<f16>":{type:"f16",components:2},"vec3<f16>":{type:"f16",components:3},"vec4<f16>":{type:"f16",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16},"mat2x2<f16>":{type:"f16",components:4},"mat2x3<f16>":{type:"f16",components:6},"mat2x4<f16>":{type:"f16",components:8},"mat3x2<f16>":{type:"f16",components:6},"mat3x3<f16>":{type:"f16",components:9},"mat3x4<f16>":{type:"f16",components:12},"mat4x2<f16>":{type:"f16",components:8},"mat4x3<f16>":{type:"f16",components:12},"mat4x4<f16>":{type:"f16",components:16},"mat2x2<i32>":{type:"i32",components:4},"mat2x3<i32>":{type:"i32",components:6},"mat2x4<i32>":{type:"i32",components:8},"mat3x2<i32>":{type:"i32",components:6},"mat3x3<i32>":{type:"i32",components:9},"mat3x4<i32>":{type:"i32",components:12},"mat4x2<i32>":{type:"i32",components:8},"mat4x3<i32>":{type:"i32",components:12},"mat4x4<i32>":{type:"i32",components:16},"mat2x2<u32>":{type:"u32",components:4},"mat2x3<u32>":{type:"u32",components:6},"mat2x4<u32>":{type:"u32",components:8},"mat3x2<u32>":{type:"u32",components:6},"mat3x3<u32>":{type:"u32",components:9},"mat3x4<u32>":{type:"u32",components:12},"mat4x2<u32>":{type:"u32",components:8},"mat4x3<u32>":{type:"u32",components:12},"mat4x4<u32>":{type:"u32",components:16}},u={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>"},d={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>",mat2x2f:"mat2x2<f32>",mat2x3f:"mat2x3<f32>",mat2x4f:"mat2x4<f32>",mat3x2f:"mat3x2<f32>",mat3x3f:"mat3x3<f32>",mat3x4f:"mat3x4<f32>",mat4x2f:"mat4x2<f32>",mat4x3f:"mat4x3<f32>",mat4x4f:"mat4x4<f32>",mat2x2i:"mat2x2<i32>",mat2x3i:"mat2x3<i32>",mat2x4i:"mat2x4<i32>",mat3x2i:"mat3x2<i32>",mat3x3i:"mat3x3<i32>",mat3x4i:"mat3x4<i32>",mat4x2i:"mat4x2<i32>",mat4x3i:"mat4x3<i32>",mat4x4i:"mat4x4<i32>",mat2x2u:"mat2x2<u32>",mat2x3u:"mat2x3<u32>",mat2x4u:"mat2x4<u32>",mat3x2u:"mat3x2<u32>",mat3x3u:"mat3x3<u32>",mat3x4u:"mat3x4<u32>",mat4x2u:"mat4x2<u32>",mat4x3u:"mat4x3<u32>",mat4x4u:"mat4x4<u32>",mat2x2h:"mat2x2<f16>",mat2x3h:"mat2x3<f16>",mat2x4h:"mat2x4<f16>",mat3x2h:"mat3x2<f16>",mat3x3h:"mat3x3<f16>",mat3x4h:"mat3x4<f16>",mat4x2h:"mat4x2<f16>",mat4x3h:"mat4x3<f16>",mat4x4h:"mat4x4<f16>"};n.d(t,["Co",0,o])},42528(e,t,n){var i=n(57285),r=n(74520);const s=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,o=["rgb","rgba","bgra"],a=["depth","stencil"],c=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"];const l=new class TextureFormatDecoder{isColor(e){return o.some(t=>e.startsWith(t))}isDepthStencil(e){return a.some(t=>e.startsWith(t))}isCompressed(e){return c.some(t=>e.startsWith(t))}getInfo(e){return u(e)}getCapabilities(e){return function(e){const t=(0,r.qG)(e),n={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},i=u(e),s=e.startsWith("depth")||e.startsWith("stencil"),o=i?.signed,a=i?.integer,c=i?.webgl,l=Boolean(i?.compressed);return n.render&&=!s&&!l,n.filter&&=!(s||o||a||c),n}(e)}getWebGPUCapabilities(e){const t=(0,r.qG)(e);return void 0!==t.webgpu?t.webgpu:this.isCompressed(e)&&!e.endsWith("-webgl")?5:0}computeMemoryLayout(e){return function({format:e,width:t,height:n,depth:i,byteAlignment:r}){const s=l.getInfo(e),{bytesPerPixel:o,bytesPerBlock:a=o,blockWidth:c=1,blockHeight:u=1,compressed:d=!1}=s,h=d?Math.ceil(t/c):t,f=d?Math.ceil(n/u):n,p=h*a,g=Math.ceil(p/r)*r;return{bytesPerPixel:o,bytesPerRow:g,rowsPerImage:f,depthOrArrayLayers:i,bytesPerImage:g*f,byteLength:g*f*i}}(e)}};function u(e){let t=function(e){const t={...(0,r.qG)(e)},n=t.bytesPerPixel||1,i=t.bitsPerChannel||[8,8,8,8];delete t.bitsPerChannel,delete t.bytesPerPixel,delete t.f,delete t.render,delete t.filter,delete t.blend,delete t.store,delete t.webgpu;const s={...t,format:e,attachment:t.attachment||"color",channels:t.channels||"r",components:t.components||t.channels?.length||1,bytesPerPixel:n,bitsPerChannel:i,dataType:t.dataType||"uint8",srgb:t.srgb??!1,packed:t.packed??!1,webgl:t.webgl??!1,integer:t.integer??!1,signed:t.signed??!1,normalized:t.normalized??!1,compressed:t.compressed??!1};return s}(e);if(l.isCompressed(e)){t.channels="rgb",t.components=3,t.bytesPerPixel=1,t.srgb=!1,t.compressed=!0,t.bytesPerBlock=function(e){if(e.startsWith("bc1")||e.startsWith("bc4")||e.startsWith("etc1")||e.startsWith("etc2-rgb8")||e.startsWith("etc2-rgb8a1")||e.startsWith("eac-r11")||"atc-rgb-unorm-webgl"===e)return 8;if(e.startsWith("bc2")||e.startsWith("bc3")||e.startsWith("bc5")||e.startsWith("bc6h")||e.startsWith("bc7")||e.startsWith("etc2-rgba8")||e.startsWith("eac-rg11")||e.startsWith("astc")||"atc-rgba-unorm-webgl"===e||"atc-rgbai-unorm-webgl"===e)return 16;if(e.startsWith("pvrtc"))return 8;return 16}(e);const n=function(e){const t=/.*-(\d+)x(\d+)-.*/.exec(e);if(t){const[,e,n]=t;return{blockWidth:Number(e),blockHeight:Number(n)}}if(e.startsWith("bc")||e.startsWith("etc1")||e.startsWith("etc2")||e.startsWith("eac")||e.startsWith("atc"))return{blockWidth:4,blockHeight:4};if(e.startsWith("pvrtc-rgb4")||e.startsWith("pvrtc-rgba4"))return{blockWidth:4,blockHeight:4};if(e.startsWith("pvrtc-rgb2")||e.startsWith("pvrtc-rgba2"))return{blockWidth:8,blockHeight:4};return null}(e);n&&(t.blockWidth=n.blockWidth,t.blockHeight=n.blockHeight)}const n=t.packed?null:s.exec(e);if(n){const[,r,s,o,a,c]=n,l=`${o}${s}`,u=i.r.getDataTypeInfo(l),d=8*u.byteLength,h=r?.length??1,f=[d,h>=2?d:0,h>=3?d:0,h>=4?d:0];t={format:e,attachment:t.attachment,dataType:u.signedType,components:h,channels:r,integer:u.integer,signed:u.signed,normalized:u.normalized,bitsPerChannel:f,bytesPerPixel:u.byteLength*h,packed:t.packed,srgb:t.srgb},"-webgl"===c&&(t.webgl=!0),"-srgb"===a&&(t.srgb=!0)}return e.endsWith("-webgl")&&(t.webgl=!0),e.endsWith("-srgb")&&(t.srgb=!0),t}n.d(t,["vz",0,l])},74520(e,t,n){n.d(t,{PU:()=>_,qG:()=>b});const i="texture-compression-bc",r="texture-compression-astc",s="texture-compression-etc2",o="texture-compression-pvrtc-webgl",a="texture-compression-atc-webgl",c="float32-renderable-webgl",l="float16-renderable-webgl",u="snorm8-renderable-webgl",d="norm16-webgl",h="norm16-renderable-webgl",f="snorm16-renderable-webgl",p="float32-filterable",g="float16-filterable-webgl",m=15,v=19,y=992;function b(e){const t=x[e];if(!t)throw new Error(`Unsupported texture format ${e}`);return t}function _(){return x}const x={...{r8unorm:{webgpu:527},rg8unorm:{webgpu:527},"rgb8unorm-webgl":{},rgba8unorm:{webgpu:31},"rgba8unorm-srgb":{webgpu:m},r8snorm:{render:u,webgpu:837},rg8snorm:{render:u,webgpu:837},"rgb8snorm-webgl":{},rgba8snorm:{render:u,webgpu:341},r8uint:{webgpu:515},rg8uint:{webgpu:515},rgba8uint:{webgpu:v},r8sint:{webgpu:515},rg8sint:{webgpu:515},rgba8sint:{webgpu:v},bgra8unorm:{webgpu:m},"bgra8unorm-srgb":{webgpu:15360},r16unorm:{f:d,render:h,webgpu:y},rg16unorm:{f:d,render:h,webgpu:y},"rgb16unorm-webgl":{f:d,render:!1},rgba16unorm:{f:d,render:h,webgpu:y},r16snorm:{f:d,render:f,webgpu:y},rg16snorm:{f:d,render:f,webgpu:y},"rgb16snorm-webgl":{f:d,render:!1},rgba16snorm:{f:d,render:f,webgpu:y},r16uint:{webgpu:515},rg16uint:{webgpu:515},rgba16uint:{webgpu:v},r16sint:{webgpu:515},rg16sint:{webgpu:515},rgba16sint:{webgpu:v},r16float:{render:l,filter:"float16-filterable-webgl",webgpu:527},rg16float:{render:l,filter:g,webgpu:527},rgba16float:{render:l,filter:g,webgpu:31},r32uint:{webgpu:v},rg32uint:{webgpu:16387},rgba32uint:{webgpu:v},r32sint:{webgpu:v},rg32sint:{webgpu:16387},rgba32sint:{webgpu:v},r32float:{render:c,filter:p,webgpu:v},rg32float:{render:!1,filter:p,webgpu:16387},"rgb32float-webgl":{render:c,filter:p},rgba32float:{render:c,filter:p,webgpu:v},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:"rgb9e5ufloat-renderable-webgl",webgpu:5},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:c,webgpu:517},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:527},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:515},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8",webgpu:3},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16",webgpu:3},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32",webgpu:3},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32",webgpu:3},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0,webgpu:3},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0,f:"depth32float-stencil8",webgpu:3}},...{"bc1-rgb-unorm-webgl":{f:i},"bc1-rgb-unorm-srgb-webgl":{f:i},"bc1-rgba-unorm":{f:i},"bc1-rgba-unorm-srgb":{f:i},"bc2-rgba-unorm":{f:i},"bc2-rgba-unorm-srgb":{f:i},"bc3-rgba-unorm":{f:i},"bc3-rgba-unorm-srgb":{f:i},"bc4-r-unorm":{f:i},"bc4-r-snorm":{f:i},"bc5-rg-unorm":{f:i},"bc5-rg-snorm":{f:i},"bc6h-rgb-ufloat":{f:i},"bc6h-rgb-float":{f:i},"bc7-rgba-unorm":{f:i},"bc7-rgba-unorm-srgb":{f:i},"etc2-rgb8unorm":{f:s},"etc2-rgb8unorm-srgb":{f:s},"etc2-rgb8a1unorm":{f:s},"etc2-rgb8a1unorm-srgb":{f:s},"etc2-rgba8unorm":{f:s},"etc2-rgba8unorm-srgb":{f:s},"eac-r11unorm":{f:s},"eac-r11snorm":{f:s},"eac-rg11unorm":{f:s},"eac-rg11snorm":{f:s},"astc-4x4-unorm":{f:r},"astc-4x4-unorm-srgb":{f:r},"astc-5x4-unorm":{f:r},"astc-5x4-unorm-srgb":{f:r},"astc-5x5-unorm":{f:r},"astc-5x5-unorm-srgb":{f:r},"astc-6x5-unorm":{f:r},"astc-6x5-unorm-srgb":{f:r},"astc-6x6-unorm":{f:r},"astc-6x6-unorm-srgb":{f:r},"astc-8x5-unorm":{f:r},"astc-8x5-unorm-srgb":{f:r},"astc-8x6-unorm":{f:r},"astc-8x6-unorm-srgb":{f:r},"astc-8x8-unorm":{f:r},"astc-8x8-unorm-srgb":{f:r},"astc-10x5-unorm":{f:r},"astc-10x5-unorm-srgb":{f:r},"astc-10x6-unorm":{f:r},"astc-10x6-unorm-srgb":{f:r},"astc-10x8-unorm":{f:r},"astc-10x8-unorm-srgb":{f:r},"astc-10x10-unorm":{f:r},"astc-10x10-unorm-srgb":{f:r},"astc-12x10-unorm":{f:r},"astc-12x10-unorm-srgb":{f:r},"astc-12x12-unorm":{f:r},"astc-12x12-unorm-srgb":{f:r},"pvrtc-rgb4unorm-webgl":{f:o},"pvrtc-rgba4unorm-webgl":{f:o},"pvrtc-rgb2unorm-webgl":{f:o},"pvrtc-rgba2unorm-webgl":{f:o},"etc1-rbg-unorm-webgl":{f:"texture-compression-etc1-webgl"},"atc-rgb-unorm-webgl":{f:a},"atc-rgba-unorm-webgl":{f:a},"atc-rgbai-unorm-webgl":{f:a}}}},61954(e,t,n){var i=n(57285);const r=new class VertexFormatDecoder{getVertexFormatInfo(e){if("unorm10-10-10-2"===e)return{type:"unorm8",components:4,byteLength:4,integer:!1,signed:!1,normalized:!0};let t,n="unorm8x4-bgra"===e?"unorm8x4":e;n.endsWith("-webgl")&&(n=n.slice(0,-6),t=!0);const r=n.split("x");if(r.length>2)throw new Error(`Unsupported vertex format: ${e}`);const[s,o]=r,a=s,c=function(e,t){if(!t)return 1;const n=Number(t);if(2===n||3===n||4===n)return n;throw new Error(`Unsupported vertex format: ${e}`)}(e,o),l=function(e,t){try{return i.r.getDataTypeInfo(t)}catch{throw new Error(`Unsupported vertex format: ${e}`)}}(e,a);let u;try{u=t?function(e,t,n){if(3!==n)throw new Error(`Unsupported vertex format: ${e}`);switch(t){case"uint8":case"sint8":case"unorm8":case"snorm8":case"uint16":case"sint16":case"unorm16":case"snorm16":return`${t}x3-webgl`;default:throw new Error(`Unsupported vertex format: ${e}`)}}(e,a,c):this.makeVertexFormat(l.signedType,c,l.normalized)}catch{throw new Error(`Unsupported vertex format: ${e}`)}if(u!==(t?e:n))throw new Error(`Unsupported vertex format: ${e}`);const d={type:a,components:c,byteLength:l.byteLength*c,integer:l.integer,signed:l.signed,normalized:l.normalized};return t&&(d.webglOnly=!0),d}makeVertexFormat(e,t,n){const r=n?i.r.getNormalizedDataType(e):e;switch(r){case"unorm8":return 1===t?"unorm8":3===t?"unorm8x3-webgl":`${r}x${t}`;case"snorm8":return 1===t?"snorm8":3===t?"snorm8x3-webgl":`${r}x${t}`;case"uint8":case"sint8":case"float16":if(3===t)throw new Error(`size: ${t}`);return 1===t?r:`${r}x${t}`;case"uint16":return 1===t?"uint16":3===t?"uint16x3-webgl":`${r}x${t}`;case"sint16":return 1===t?"sint16":3===t?"sint16x3-webgl":`${r}x${t}`;case"unorm16":return 1===t?"unorm16":3===t?"unorm16x3-webgl":`${r}x${t}`;case"snorm16":return 1===t?"snorm16":3===t?"snorm16x3-webgl":`${r}x${t}`;default:return 1===t?r:`${r}x${t}`}}getVertexFormatFromAttribute(e,t,n){if(!t||t>4)throw new Error(`size ${t}`);const r=t,s=i.r.getDataType(e);return this.makeVertexFormat(s,r,n)}getCompatibleVertexFormat(e){let t;switch(e.primitiveType){case"f32":t="float32";break;case"i32":t="sint32";break;case"u32":t="uint32";break;case"f16":return e.components<=2?"float16x2":"float16x4"}return 1===e.components?t:`${t}x${e.components}`}};n.d(t,["E",0,r])},73390(e,t,n){let i;function r(e){return(!i||i.byteLength<e)&&(i=new ArrayBuffer(e)),i}function s(e,t){return new e(r(e.BYTES_PER_ELEMENT*t),0,t)}n.d(t,{X:()=>s,o:()=>r})},80979(e,t,n){function i(e,t){if(!e){const e=new Error(t??"luma.gl assertion failed.");throw Error.captureStackTrace?.(e,i),e}}function r(e,t){return i(e,t),e}n.d(t,{i:()=>r,v:()=>i})},29651(e,t,n){const i=new(n(60776).h)({id:"luma.gl"});n.d(t,["R",0,i])},76028(e,t,n){var i=n(30568);const r=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","External Buffer Memory","External Texture Memory","Swap Chain Texture"],s=new WeakMap,o=new WeakMap;const a=new class StatsManager{stats=new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new i.A({id:e}));const t=this.stats.get(e);return"GPU Time and Memory"===e&&function(e,t){const n=e.stats;let i=!1;for(const r of t)n[r]||(e.get(r),i=!0);const r=Object.keys(n).length,a=s.get(e);if(!i&&a?.orderedStatNames===t&&a.statCount===r)return;const c={};let l=o.get(t);l||(l=new Set(t),o.set(t,l));for(const e of t)n[e]&&(c[e]=n[e]);for(const[e,t]of Object.entries(n))l.has(e)||(c[e]=t);for(const e of Object.keys(n))delete n[e];Object.assign(n,c),s.set(e,{orderedStatNames:t,statCount:r})}(t,r),t}};n.d(t,["d",0,a])},74683(e,t,n){n.d(t,{L:()=>r});const i={};function r(e="id"){i[e]=i[e]||1;return`${e}-${i[e]++}`}},55795(e,t,n){n.d(t,{p:()=>BufferTransform});var i=n(26839);function r(e){const{input:t,inputChannels:n,output:i}=e||{};if(!t)return"#version 300 es\nout vec4 transform_output;\nvoid main() {\n transform_output = vec4(0);\n}";if(!n)throw new Error("inputChannels");return`#version 300 es\nin ${function(e){switch(e){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${e}`)}}(n)} ${t};\nout vec4 ${i};\nvoid main() {\n ${i} = ${function(e,t){switch(t){case 1:return`vec4(${e}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${e}, 0.0, 1.0)`;case 3:return`vec4(${e}, 1.0)`;case 4:return e;default:throw new Error(`invalid channels: ${t}`)}}(t,n)};\n}`}var s=n(36077);class BufferTransform{device;model;transformFeedback;static defaultProps={...s.K.defaultProps,feedbackBufferMode:"separate",outputs:void 0,feedbackBuffers:void 0};static isSupported(e){return"webgl"===e?.info?.type}constructor(e,t=BufferTransform.defaultProps){if(!BufferTransform.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new s.K(this.device,{id:t.id||"buffer-transform-model",fs:t.fs||r(),topology:t.topology||"point-list",varyings:t.outputs||t.varyings,...t,bufferMode:t.bufferMode||("interleaved"===t.feedbackBufferMode?35980:35981)}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:t.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){e?.inputBuffers&&this.model.setAttributes(e.inputBuffers),e?.outputBuffers&&this.transformFeedback.setBuffers(e.outputBuffers);const t=this.device.beginRenderPass({discard:!0,...e});this.model.draw(t),t.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){const t=this.getBuffer(e);if(!t)throw new Error("BufferTransform#getBuffer");if(t instanceof i.h)return t.readAsync();const{buffer:n,byteOffset:r=0,byteLength:s=n.byteLength}=t;return n.readAsync(r,s)}}},30257(e,t,n){n.d(t,{C:()=>Computation});var i=n(26839),r=n(52009),s=n(83994),o=n(69499),a=n(69204),c=n(57285),l=n(29651),u=n(80979),d=n(33823),h=n(5959),f=n(76282),p=n(97856),g=n(16698),m=n(4500);class Computation{static defaultProps={...o.C.defaultProps,id:"unnamed",handle:void 0,userData:{},source:"",modules:[],defines:{},plugins:[],bindings:void 0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,shaderAssembler:h._P.getDefaultShaderAssembler("wgsl"),debugShaders:void 0};device;id;pipelineFactory;shaderFactory;userData={};bindings={};pipeline;source;shader;shaderInputs;_uniformStore;_pipelineNeedsUpdate="newly created";_getModuleUniforms;props;_destroyed=!1;constructor(e,t){if("webgpu"!==e.type)throw new Error("Computation is only supported in WebGPU");this.props={...Computation.defaultProps,...t},t=this.props,this.id=t.id||(0,m.L)("model"),this.device=e,Object.assign(this.userData,t.userData);const n=function(e){return{type:e.type,shaderLanguage:e.info.shadingLanguage,shaderLanguageVersion:e.info.shadingLanguageVersion,gpu:e.info.gpu,limits:e.limits,features:e.features}}(e),i=(0,d.r)(this.props.plugins,n.shaderLanguage);if(Object.keys(i.vertexInputs).length>0||Object.keys(i.varyings).length>0)throw new Error("Computation does not support ShaderPlugin vertex inputs or varyings");const o=(0,d.K)(this.props.modules,i.modules),a=Object.fromEntries(o.map(e=>[e.name,e]));this.shaderInputs=t.shaderInputs||new p.l(a),t.shaderInputs&&i.modules.length>0&&this.shaderInputs.addModules(i.modules),this.setShaderInputs(this.shaderInputs);const c=(0,g.jY)(this.props.modules,this.shaderInputs?.getModules()),l={...i.defines,...this.props.defines};this.props.shaderLayout=(0,g.Y$)(this.props.shaderLayout,c)||null,this.pipelineFactory=t.pipelineFactory||r.N.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||s.g.getDefaultShaderFactory(this.device);const f=this.props.shaderAssembler;(0,u.v)(f instanceof h.Ry);const{source:v,getUniforms:y,shaderLayout:b}=f.assembleWGSLShader({platformInfo:n,...this.props,modules:c,defines:l,scanVertexAttributes:!1,pluginInjections:i.injections});this.source=v,this._getModuleUniforms=y;const _=b??e.getShaderLayout?.(this.source,{scanVertexAttributes:!1});this.props.shaderLayout=(0,g.Y$)(this.props.shaderLayout||_||null,c)||null,this.pipeline=this._updatePipeline(),t.bindings&&this.setBindings(t.bindings)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.shader),this._uniformStore.destroy(),this._destroyed=!0)}predraw(e){this.updateShaderInputs(e)}dispatch(e,t,n,i){try{this._logDrawCallStart(),this._setPipeline(e),e.dispatch(t,n,i)}finally{this._logDrawCallEnd()}}dispatchIndirect(e,t,n=0){try{this._logDrawCallStart(),this._setPipeline(e),e.dispatchIndirect(t,n)}finally{this._logDrawCallEnd()}}_setPipeline(e){this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),e.setPipeline(this.pipeline),e.setBindings({})}setVertexCount(e){}setInstanceCount(e){}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new a.K(this.device,this.shaderInputs.modules);for(const[e,t]of Object.entries(this.shaderInputs.modules))if((0,g.fX)(t)){const t=this._uniformStore.getManagedUniformBuffer(e);this.bindings[`${e}Uniforms`]=t}}setShaderModuleProps(e){const t=this._getModuleUniforms(e),n=Object.keys(t).filter(e=>{const n=t[e];return!(0,f.H9)(n)&&"number"!=typeof n&&"boolean"!=typeof n}),i={};for(const e of n)i[e]=t[e],delete t[e]}updateShaderInputs(e){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),e)}setBindings(e){Object.assign(this.bindings,e)}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||e}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null;this.pipeline&&(l.R.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.shader),this._pipelineNeedsUpdate=!1,this.shader=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"compute",source:this.source,debugShaders:this.props.debugShaders}),this.pipeline=this.pipelineFactory.createComputePipeline({...this.props,shader:this.shader}),e&&this.shaderFactory.release(e)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){const e=l.R.level>3?0:1e4;l.R.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,l.R.group(2,`>>> DRAWING MODEL ${this.id}`,{collapsed:l.R.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=this.shaderInputs.getDebugTable();l.R.table(2,e)(),l.R.groupEnd(2)(),this._logOpen=!1}}_drawCount=0;_getBufferOrConstantValues(e,t){const n=c.r.getTypedArrayConstructor(t);return(e instanceof i.h?new n(e.debugData):e).toString()}}},99305(e,t,n){n.d(t,{Hd:()=>o,j8:()=>a,kL:()=>DynamicBuffer});var i=n(26839),r=n(4500);const s=i.h.DEBUG_DATA_MAX_LENGTH;class DynamicBuffer{device;id;ready;usage;props;isReady=!0;destroyed=!1;generation=0;updateTimestamp;debugData=new ArrayBuffer(0);_debugDataEnabled;_maxDebugDataByteLength;_ownsBuffer;_buffer;get buffer(){return this._buffer}get byteLength(){return this._buffer.byteLength}get[Symbol.toStringTag](){return"DynamicBuffer"}toString(){return`DynamicBuffer:"${this.id}":${this.byteLength}B`}toJSON(){return this.toString()}constructor(e,t){const{debugData:n=!1,buffer:o,ownsBuffer:a=!0,...c}=t;if(o&&o.device!==e)throw new Error("DynamicBuffer adopted buffers must belong to the supplied device");if(o&&(void 0!==c.byteLength||void 0!==c.data))throw new Error("DynamicBuffer cannot combine an adopted buffer with byteLength or data");const l=t.id||o?.id||(0,r.L)("dynamic-buffer"),u={...c,id:l,usage:c.usage??o?.usage,indexType:c.indexType??o?.indexType};(u.usage||0)&i.h.INDEX&&!u.indexType&&(c.data instanceof Uint32Array?u.indexType="uint32":c.data instanceof Uint16Array?u.indexType="uint16":c.data instanceof Uint8Array&&(u.indexType="uint8")),delete u.data,delete u.byteOffset,this.device=e,this.id=l,this.props=u,this.usage=u.usage||0,this._debugDataEnabled=Boolean(n),this._maxDebugDataByteLength="object"==typeof n&&void 0!==n.maxByteLength?n.maxByteLength:s,this._ownsBuffer=a,this._buffer=o??this.device.createBuffer({...c,id:l}),this.ready=Promise.resolve(this._buffer),this.updateTimestamp=this._buffer.updateTimestamp,this._resetDebugData(this._buffer.byteLength),c.data&&this._writeDebugData(c.data,c.byteOffset||0)}write(e,t=0){this._buffer.write(e,t),this._touch(),this._writeDebugData(e,t)}async mapAndWriteAsync(e,t=0,n=this.byteLength-t){let i=null;await this._buffer.mapAndWriteAsync(async(t,r)=>{await e(t,r),i=new Uint8Array(t.slice(0,n))},t,n),this._touch(),i&&this._writeDebugData(i,t)}async readAsync(e=0,t=this.byteLength-e){const n=await this._buffer.readAsync(e,t);return this._writeDebugData(n,e)&&this._touch(),n}async mapAndReadAsync(e,t=0,n=this.byteLength-t){let i=null;const r=await this._buffer.mapAndReadAsync(async(t,n)=>(i=new Uint8Array(t.slice(0)),await e(t,n)),t,n);return i&&this._writeDebugData(i,t)&&this._touch(),r}resize(e){const{byteLength:t,preserveData:n=!1}=e;if(t===this.byteLength)return!1;const i=Math.min(e.copyByteLength??Math.min(this.byteLength,t),this.byteLength,t),r=this._buffer,s=this.debugData.slice(0),{data:o,byteOffset:a,...c}=this.props,l=this.device.createBuffer({...c,byteLength:t});return n&&i>0&&this._copyBufferContents(r,l,i),this._buffer=l,this._resetDebugData(t),n&&s.byteLength>0&&this._writeDebugData(s,0),this._ownsBuffer&&r.destroy(),this._ownsBuffer=!0,this.generation++,this._touch(),!0}ensureSize(e,t){return!(e<=this.byteLength)&&this.resize({byteLength:e,preserveData:t?.preserveData})}getBinding(e){return void 0===e?.offset&&void 0===e?.size?this._buffer:{buffer:this._buffer,offset:e?.offset,size:e?.size}}destroy(){this.destroyed||(this._ownsBuffer&&this._buffer.destroy(),this.destroyed=!0,this.debugData=new ArrayBuffer(0))}_copyBufferContents(e,t,n){const i="webgpu"===this.device.type?4*Math.ceil(n/4):n,r=this.device.createCommandEncoder();r.copyBufferToBuffer({sourceBuffer:e,destinationBuffer:t,size:i}),this.device.submit(r.finish())}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_resetDebugData(e){this._debugDataEnabled?this.debugData=new ArrayBuffer(Math.min(e,this._maxDebugDataByteLength)):this.debugData=new ArrayBuffer(0)}_writeDebugData(e,t){if(!this._debugDataEnabled||0===this.debugData.byteLength||t>=this.debugData.byteLength)return!1;const n=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),i=new Uint8Array(this.debugData),r=Math.min(n.byteLength,i.byteLength-t);return i.set(n.subarray(0,r),t),r>0}}function o(e){return null!==e&&"object"==typeof e&&"buffer"in e}function a(e){return{buffer:(t=e.buffer,t instanceof DynamicBuffer?t.buffer:t),offset:e.offset,size:e.size};var t}},25337(e,t,n){n.d(t,{V:()=>Geometry,l:()=>s});var i=n(61954),r=n(4500);class Geometry{id;topology;vertexCount;indices;attributes;bufferLayout;userData={};constructor(e){const{attributes:t={},indices:n=null,vertexCount:o=null}=e;this.id=e.id||(0,r.L)("geometry"),this.topology=e.topology,n&&(this.indices=ArrayBuffer.isView(n)?{value:n,size:1}:n),this.attributes={};for(const[e,n]of Object.entries(t)){const t=ArrayBuffer.isView(n)?{value:n}:n;if(!ArrayBuffer.isView(t.value))throw new Error(`${this._print(e)}: must be typed array or object with value as typed array`);if("POSITION"!==e&&"positions"!==e||t.size||(t.size=3),"indices"===e){if(this.indices)throw new Error("Multiple indices detected");this.indices=t}else{const n=s(e),i=Object.keys(this.attributes).find(e=>s(e)===n);i&&delete this.attributes[i],this.attributes[e]=t}}this.indices&&void 0!==this.indices.isIndexed&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=o||this._calculateVertexCount(this.attributes,this.indices),this.bufferLayout=e.bufferLayout||function(e){const t=[];for(const[n,r]of Object.entries(e)){if(!r)continue;const{value:e,size:o,normalized:a}=r;if(void 0===o)throw new Error(`Attribute ${n} is missing a size`);t.push({name:s(n),format:i.E.getVertexFormatFromAttribute(e,o,a)})}return t}(this.attributes)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let n=1/0;for(const t of Object.values(e)){if(!t)continue;const{value:e,size:i,constant:r}=t;!r&&e&&void 0!==i&&i>=1&&(n=Math.min(n,e.length/i))}return n}}function s(e){switch(e){case"POSITION":return"positions";case"NORMAL":return"normals";case"TEXCOORD_0":return"texCoords";case"TEXCOORD_1":return"texCoords1";case"COLOR_0":return"colors";default:return e}}},36077(e,t,n){n.d(t,{K:()=>Model});var i=n(22512),r=n(80979),s=n(52009),o=n(83994),a=n(29651),c=n(69204),l=n(62069),u=n(75638),d=n(26839),h=n(80698),f=n(5153);class ExternalTexture extends f.F{width;height;updateTimestamp;get[Symbol.toStringTag](){return"ExternalTexture"}constructor(e,t){super(e,t,ExternalTexture.defaultProps);const n=this.props.source?e.getExternalImageSize(this.props.source):null;this.width=this.props.width||n?.width||0,this.height=this.props.height||n?.height||0,this.updateTimestamp=e.incrementTimestamp()}static defaultProps={...f.F.defaultProps,source:void 0,width:0,height:0,colorSpace:"srgb",sampler:{}}}var p=n(2021),g=n(57285),m=n(5959),v=n(33823),y=n(25337),b=n(61954);function _(e,t={}){const n=t.bufferName||"geometry";if(function(e,t){if(1!==e.bufferLayout.length)return!1;const n=e.bufferLayout[0];return n.name===t&&Boolean(n.attributes?.length)&&Boolean(e.attributes[t])}(e,n))return e;const i=t.minAttributeAlignment||4,r=function(e,t){if(t)return t.map(t=>[t,e.attributes[t]]);return Object.entries(e.attributes)}(e,t.attributes),s=[];let o=0,a=1/0;for(const[e,t]of r){if(!t)continue;if(t.constant)throw new Error(`Attribute ${e} is constant`);const{value:n,size:r,normalized:c}=t;if(!ArrayBuffer.isView(n))throw new Error(`Attribute ${e} is missing typed array data`);if(void 0===r)throw new Error(`Attribute ${e} is missing a size`);const l=b.E.getVertexFormatFromAttribute(n,r,c),u=b.E.getVertexFormatInfo(l);o=w(o,i),s.push({sourceName:e,attributeName:(0,y.l)(e),value:n,size:r,format:l,byteOffset:o,byteLength:u.byteLength}),o+=u.byteLength;const d=n.length/r;if(!Number.isInteger(d))throw new Error(`Attribute ${e} length is not divisible by size`);a=Math.min(a,d)}if(0===s.length||!Number.isFinite(a))throw new Error(`Geometry ${e.id} has no interleavable attributes`);const c=w(o,i),l=new ArrayBuffer(a*c);for(const e of s)x(l,a,c,e);return new y.V({id:e.id,topology:e.topology||"triangle-list",vertexCount:e.vertexCount,indices:e.indices,attributes:{[n]:{value:new Uint8Array(l),size:c,byteStride:c}},bufferLayout:[{name:n,stepMode:"vertex",byteStride:c,attributes:s.map(e=>({attribute:e.attributeName,format:e.format,byteOffset:e.byteOffset}))}]})}function x(e,t,n,i){const r=i.value.constructor,s=r.BYTES_PER_ELEMENT;if(i.byteOffset%s!==0||n%s!==0)throw new Error(`Attribute ${i.sourceName} is not aligned to its component type`);const o=new r(e),a=i.value,c=i.byteOffset/s,l=n/s;for(let e=0;e<t;e++){const t=e*i.size,n=e*l+c;for(let e=0;e<i.size;e++)o[n+e]=a[t+e]}}function w(e,t){return Math.ceil(e/t)*t}var P=n(4500);class GPUGeometry{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||(0,P.L)("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&d.h.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(const e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}}function C(e,t){if(t instanceof GPUGeometry)return t;const n=_(t),i=function(e,t){if(!t.indices)return;const n=t.indices.value;return e.createBuffer({usage:d.h.INDEX,data:n})}(e,n),{attributes:r,bufferLayout:s}=function(e,t){const n={};for(const[i,r]of Object.entries(t.attributes)){const s=t.bufferLayout.find(e=>e.name===i)?.name||(0,y.l)(i);r&&(n[s]=e.createBuffer({data:r.value,id:`${i}-buffer`}))}return{attributes:n,bufferLayout:t.bufferLayout,vertexCount:t.vertexCount}}(e,n);return new GPUGeometry({topology:n.topology||"triangle-list",bufferLayout:s,vertexCount:n.vertexCount,indices:i,attributes:r})}const S="__debugFramebufferState";function L(e,t,n){if("webgl"!==e.device.type)return;const i=(r=e.device,r.userData[S]||={flushing:!1,queuedFramebuffers:[]},r.userData[S]);var r;i.flushing||(!function(e){const t=e.props.framebuffer;return!t||null===t.handle}(e)?t&&"colorAttachments"in t&&null!==t.handle&&(i.queuedFramebuffers.includes(t)||i.queuedFramebuffers.push(t)):function(e,t,n){if(0===n.queuedFramebuffers.length)return;const i=e.device,{gl:r}=i,s=r.getParameter(36010),o=r.getParameter(36006),[a,c]=e.device.getDefaultCanvasContext().getDrawingBufferSize();let l=E(t.top,8);const u=E(t.left,8);n.flushing=!0;try{for(const e of n.queuedFramebuffers){const[n,i,s,o,d]=A({framebuffer:e,targetWidth:a,targetHeight:c,topPx:l,leftPx:u,minimap:t.minimap});r.bindFramebuffer(36008,e.handle),r.bindFramebuffer(36009,null),r.blitFramebuffer(0,0,e.width,e.height,n,i,s,o,16384,9728),l+=d+8}}finally{r.bindFramebuffer(36008,s),r.bindFramebuffer(36009,o),n.flushing=!1}}(e,n,i))}function A(e){const{framebuffer:t,targetWidth:n,targetHeight:i,topPx:r,leftPx:s,minimap:o}=e,a=o?Math.max(Math.floor(n/4),1):n,c=o?Math.max(Math.floor(i/4),1):i,l=Math.min(a/t.width,c/t.height),u=Math.max(Math.floor(t.width*l),1),d=Math.max(Math.floor(t.height*l),1),h=s,f=Math.max(i-r-d,0);return[h,f,h+u,f+d,d]}function E(e,t){if(!e)return t;const n=Number.parseInt(e,10);return Number.isFinite(n)?n:t}function T(e,t,n){if(e===t)return!0;if(!n||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!T(e[i],t[i],n-1))return!1;return!0}if(Array.isArray(t))return!1;if("object"==typeof e&&"object"==typeof t){const i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(const r of i){if(!t.hasOwnProperty(r))return!1;if(!T(e[r],t[r],n-1))return!1}return!0}return!1}var M=n(7244);class BufferLayoutHelper{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){return(0,M.TC)(e)}mergeBufferLayouts(e,t){const n=[...e];for(const e of t){const t=n.findIndex(t=>t.name===e.name);t<0?n.push(e):n[t]=e}return n}}var I=n(16698),B=n(97856),k=n(99305);function R(e){return null!==e&&"object"==typeof e&&"resolveTextureBinding"in e&&"function"==typeof e.resolveTextureBinding}const O="render pipeline initialization failed",z=["stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8"];class Model{static defaultProps={...i.r.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],plugins:[],geometry:null,indexBuffer:null,indexCount:void 0,firstVertex:0,firstIndex:0,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:m._P.getDefaultShaderAssembler("glsl"),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexCount;firstVertex;firstIndex;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_dynamicIndexBufferSource=null;_dynamicAttributeBufferSources={};_colorAttachmentFormats;_depthStencilAttachmentFormat;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_drawBlockedReason=!1;_destroyed=!1;_vertexCountSet=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,t){const n=Model.defaultProps.shaderAssembler,i=void 0!==t.vertexCount;this.props={...Model.defaultProps,...t,shaderAssembler:t.shaderAssembler??(D(n,e.info.shadingLanguage)?n:m._P.getDefaultShaderAssembler(e.info.shadingLanguage))},this._vertexCountSet=i,t=this.props,this.id=t.id||(0,P.L)("model"),this.device=e,Object.assign(this.userData,t.userData),this.material=t.material||null;const a=function(e){return{type:e.type,shaderLanguage:e.info.shadingLanguage,shaderLanguageVersion:e.info.shadingLanguageVersion,gpu:e.info.gpu,limits:e.limits,features:e.features}}(e),c=(0,v.r)(this.props.plugins,a.shaderLanguage),l=(0,v.K)(this.props.modules,c.modules),u=Object.fromEntries(l.map(e=>[e.name,e])),d=t.shaderInputs||new B.l(u,{disableWarnings:this.props.disableWarnings});t.shaderInputs&&c.modules.length>0&&d.addModules(c.modules),this.setShaderInputs(d);const h=(0,I.jY)(this.props.modules,d.getModules()),f={...c.defines,...this.props.defines};"webgl"===this.device.type&&(this.props._uniformBlockLayouts=(0,I._R)(h)),this.props.shaderLayout=(0,I.Y$)(this.props.shaderLayout,h)||null;if("webgpu"===this.device.type&&this.props.source){const t=this.props.shaderAssembler;(0,r.v)(D(t,"wgsl"));const{source:n,getUniforms:i,bindingTable:s,shaderLayout:o}=t.assembleWGSLShader({platformInfo:a,...this.props,modules:h,defines:f,pluginInjections:c.injections,pluginVertexInputs:c.vertexInputs,pluginVaryings:c.varyings});this.source=n,this._getModuleUniforms=i,this._bindingTable=s;const l=function(e,t){if(!e||0===Object.keys(t).length)return e;return{...e,attributes:e.attributes.map(e=>{const n=e.name.startsWith("_luma_")?e.name.slice(6):null;return n&&t[n]?{...e,name:n}:e})}}(o??e.getShaderLayout?.(this.source),c.vertexInputs),u=(0,I.He)(this.props.shaderLayout,l,Object.keys(c.vertexInputs));this.props.shaderLayout=(0,I.Y$)(u||null,h)||null}else{const e=this.props.shaderAssembler;(0,r.v)(D(e,"glsl"));const{vs:t,fs:n,getUniforms:i}=e.assembleGLSLShaderPair({platformInfo:a,...this.props,modules:h,defines:f,pluginInjections:c.injections,pluginVertexInputs:c.vertexInputs,pluginVaryings:c.varyings});this.vs=t,this.fs=n,this._getModuleUniforms=i,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.indexCount=this.props.indexCount,this.firstVertex=this.props.firstVertex,this.firstIndex=this.props.firstIndex,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,this._colorAttachmentFormats=this.props.colorAttachmentFormats,this._depthStencilAttachmentFormat=this.props.depthStencilAttachmentFormat,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||s.N.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||o.g.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");const e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}getBindingDebugTable(){return this._bindingTable}predraw(e){this._syncDynamicBuffers(),this.updateShaderInputs(e),this.material?.updateShaderInputs(e),this.pipeline=this._updatePipeline()}draw(e){if(this._drawBlockedReason&&!this._pipelineNeedsUpdate)return a.R.info(2,`>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)(),!1;const t=this._areBindingsLoading();if(t)return a.R.info(2,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;this._syncAttachmentFormats(e);try{e.pushDebugGroup(`${this}.predraw(${e})`),"webgpu"===this.device.type?(this.updateShaderInputs(),this.material?.updateShaderInputs(),this._syncDynamicBuffers(),this.pipeline=this._updatePipeline()):this.predraw(this.device.commandEncoder)}finally{e.popDebugGroup()}let n,i=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),i=this.pipeline.isErrored,i)a.R.info(2,`>>> DRAWING ABORTED ${this.id}: ${O}`)(),n=!1;else{const t=this.vertexArray.getDrawValidationError();if(t)a.R.info(2,`>>> DRAWING ABORTED ${this.id}: ${t}`)(),this._drawBlockedReason=t,n=!1;else{const t=this._getCurrentShaderLayout(),i=this._getBindings(t),r=this._getBindGroups(t,i),{indexBuffer:s}=this.vertexArray,o=s?this.indexCount??(this._vertexCountSet?this.vertexCount:s.byteLength/("uint32"===s.indexType?4:2)):void 0;e.setPipeline(this.pipeline),e.setBindings(r,{_bindGroupCacheKeys:this._getBindGroupCacheKeys()}),e.setVertexArray(this.vertexArray);n=!!(!0===this.isInstanced&&0===this.instanceCount)||e.draw({isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.isInstanced?this.instanceCount:void 0,indexCount:o,firstVertex:this.firstVertex,firstIndex:this.firstIndex,transformFeedback:this.transformFeedback||void 0,uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),n?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):i?(this._needsRedraw=O,this._drawBlockedReason=O):this._drawBlockedReason?this._needsRedraw=this._drawBlockedReason:this._needsRedraw="waiting for resource initialization",n}setGeometry(e){this._gpuGeometry?.destroy();const t=e&&C(this.device,e);if(t){this.setTopology(t.topology||"triangle-list");const e=new BufferLayoutHelper(this.bufferLayout);this.bufferLayout=e.mergeBufferLayouts(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)}this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){const t=new BufferLayoutHelper(this.bufferLayout),n=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e;T(n,this.bufferLayout,-1)||(this.bufferLayout=n,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry))}setParameters(e){T(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,void 0===this.isInstanced&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this._vertexCountSet=!0,this.setNeedsRedraw("vertexCount")}setIndexCount(e){this.indexCount=e,this.setNeedsRedraw("indexCount")}setDrawOffsets({firstVertex:e,firstIndex:t}){this.firstVertex=e,this.firstIndex=t,this.setNeedsRedraw("drawOffsets")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new c.K(this.device,this.shaderInputs.modules);for(const[e,t]of Object.entries(this.shaderInputs.modules))if((0,I.fX)(t)&&!this.material?.ownsModule(e)){const t=this._uniformStore.getManagedUniformBuffer(e);this.bindings[`${e}Uniforms`]=t}this.setNeedsRedraw("shaderInputs")}setMaterial(e){this.material=e,this.setNeedsRedraw("material")}updateShaderInputs(e){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),e),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){const t=e instanceof k.kL?e.buffer:e;this.indexBuffer=t,this._dynamicIndexBufferSource=e instanceof k.kL?{source:e,generation:e.generation}:null,this.vertexArray.setIndexBuffer(t),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){this._drawBlockedReason=!1;const n=t?.disableWarnings??this.props.disableWarnings;e.indices&&a.R.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=function(e,t){const n=(0,M.Lv)(e),i=t.slice();return i.sort((e,t)=>(0,M.Ef)((0,M.TC)(e).map(e=>n[e]))-(0,M.Ef)((0,M.TC)(t).map(e=>n[e]))),i}(this.pipeline.shaderLayout,this.bufferLayout);const i=new BufferLayoutHelper(this.bufferLayout);for(const[t,r]of Object.entries(e)){const e=r instanceof k.kL?r.buffer:r,s=i.getBufferLayout(t);if(!s){n||a.R.warn(`Model(${this.id}): Missing layout for buffer "${t}".`)();continue}const o=i.getAttributeNamesForBuffer(s);let c=!1;for(const t of o){const i=this._attributeInfos[t];if(i){const t="webgpu"===this.device.type?this.vertexArray.getBufferSlot(i.bufferName):i.location;if(null===t){n||a.R.warn(`Model(${this.id}): Missing vertex array slot for buffer "${i.bufferName}".`)();continue}this.vertexArray.setBuffer(t,e),r instanceof k.kL?this._dynamicAttributeBufferSources[t]={source:r,generation:r.generation}:delete this._dynamicAttributeBufferSources[t],c=!0}}c||n||a.R.warn(`Model(${this.id}): Ignoring buffer "${e.id}" for unknown attribute "${t}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(const[n,i]of Object.entries(e)){const e=this._attributeInfos[n];e?this.vertexArray.setConstantWebGL(e.location,i):(t?.disableWarnings??this.props.disableWarnings)||a.R.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${n}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(const e of Object.values(this.bindings))if(R(e)&&!e.isReady)return e.id;for(const e of Object.values(this.material?.bindings||{}))if(R(e)&&!e.isReady)return e.id;return!1}_getBindings(e=this._getCurrentShaderLayout()){const t={};for(const[n,i]of Object.entries(this.bindings)){const r=F(n,i,e);r&&(t[n]=r)}return t}_getBindGroups(e=this._getCurrentShaderLayout(),t=this._getBindings(e)){const n=e.bindings.length?(0,l.gO)(e,t):{0:t};if(!this.material)return n;for(const[t,i]of Object.entries(this.material.getBindingsByGroup(e))){const e=Number(t);n[e]={...n[e]||{},...i}}return n}_getBindGroupCacheKeys(){const e=this.material?.getBindGroupCacheKey(3);return e?{3:e}:{}}_getBindingsUpdateTimestamp(){let e=0;this._dynamicIndexBufferSource&&(e=Math.max(e,this._dynamicIndexBufferSource.source.updateTimestamp));for(const t of Object.values(this._dynamicAttributeBufferSources))e=Math.max(e,t.source.updateTimestamp);for(const t of Object.values(this.bindings))t instanceof u.X?e=Math.max(e,t.texture.updateTimestamp):t instanceof d.h||t instanceof h.g||t instanceof ExternalTexture||t instanceof k.kL?e=Math.max(e,t.updateTimestamp):R(t)?e=t.isReady?Math.max(e,t.updateTimestamp):1/0:(0,k.Hd)(t)&&(e=Math.max(e,(t.buffer,k.kL,t.buffer.updateTimestamp)));return Math.max(e,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(e){const t={...e.attributes};for(const[e]of Object.entries(t))this.pipeline.shaderLayout.attributes.find(t=>t.name===e)||"positions"===e||delete t[e];this.vertexCount=e.vertexCount,this._vertexCountSet=!0,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this._drawBlockedReason=!1,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(a.R.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;const n=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders});let i=null;this.source?i=n:this.fs&&(i=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,colorAttachmentFormats:this._colorAttachmentFormats,depthStencilAttachmentFormat:this._depthStencilAttachmentFormat,topology:this.topology,parameters:this.parameters,bindGroups:void 0,vs:n,fs:i}),this._attributeInfos=(0,p.P)(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&t!==e&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){const e=a.R.level>3?0:1e4;a.R.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,a.R.group(2,`>>> DRAWING MODEL ${this.id}`,{collapsed:a.R.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=function(e){const t={},n="Values";if(0===e.attributes.length&&!e.varyings?.length)return{"No attributes or varyings":{[n]:"N/A"}};for(const i of e.attributes)i&&(t[`in ${i.location} ${i.name}: ${i.type}`]={[n]:i.stepMode||"vertex"});for(const i of e.varyings||[])t[`out ${i.location} ${i.name}`]={[n]:JSON.stringify(i)};return t}(this.pipeline.shaderLayout,this.id);a.R.table(2,e)();const t=this.shaderInputs.getDebugTable();a.R.table(2,t)();const n=this._getAttributeDebugTable();a.R.table(2,this._attributeInfos)(),a.R.table(2,n)(),a.R.groupEnd(2)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){const t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;const n=e.props.framebuffer;L(e,n,{id:n?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){const e={};for(const[t,n]of Object.entries(this._attributeInfos)){const i=this.vertexArray.attributes[n.location];e[n.location]={name:t,type:n.shaderType,values:i?this._getBufferOrConstantValues(i,n.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){const{indexBuffer:t}=this.vertexArray,n="uint32"===t.indexType?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:"indices",type:t.indexType,values:n.toString()}}return e}_getBufferOrConstantValues(e,t){const n=g.r.getTypedArrayConstructor(t);return(e instanceof d.h?new n(e.debugData):e).toString()}_getNonMaterialBindings(e){if(!this.material)return e;const t={};for(const[n,i]of Object.entries(e))this.material.ownsBinding(n)||(t[n]=i);return t}_getCurrentShaderLayout(){return this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]}}_syncDynamicBuffers(){if(this._dynamicIndexBufferSource&&this._dynamicIndexBufferSource.generation!==this._dynamicIndexBufferSource.source.generation){const e=this._dynamicIndexBufferSource.source.buffer;this.indexBuffer=e,this.vertexArray.setIndexBuffer(e),this._dynamicIndexBufferSource.generation=this._dynamicIndexBufferSource.source.generation,this.setNeedsRedraw("dynamic index buffer")}for(const[e,t]of Object.entries(this._dynamicAttributeBufferSources))t.generation!==t.source.generation&&(this.vertexArray.setBuffer(Number(e),t.source.buffer),t.generation=t.source.generation,this.setNeedsRedraw("dynamic attribute buffer"))}_syncAttachmentFormats(e){if("webgpu"!==this.device.type)return;const t=e.framebuffer||e.props.framebuffer,n=e.props,i=n.colorAttachmentFormats??t?.colorAttachments?.map(e=>{return t=e?.texture?.format,t&&!N(t)?t:null;var t}),r=!1===n.depthStencilAttachmentFormat?void 0:n.depthStencilAttachmentFormat??(s=t?.depthStencilAttachment?.texture?.format,s&&N(s)?s:void 0);var s;T(this._colorAttachmentFormats,i,1)&&this._depthStencilAttachmentFormat===r||(this._colorAttachmentFormats=i,this._depthStencilAttachmentFormat=r,this._setPipelineNeedsUpdate("attachment formats"))}}function D(e,t){return(void 0===e.shaderLanguage||e.shaderLanguage===t)&&("glsl"===t?"assembleGLSLShaderPair"in e&&"function"==typeof e.assembleGLSLShaderPair:"assembleWGSLShader"in e&&"function"==typeof e.assembleWGSLShader)}function F(e,t,n){if(R(t)){const i=function(e,t,n){const i=(0,l.Jc)(e,t,{ignoreWarnings:!0});return function(e){return"texture"===e?.type||"external-texture"===e?.type}(i)?i:0===e.bindings.length&&void 0!==n?.fallbackGroup?{type:"texture",name:t,group:n.fallbackGroup,location:0}:null}(n,e,{fallbackGroup:0});return i?t.resolveTextureBinding(i):null}return t instanceof k.kL?t.buffer:(0,k.Hd)(t)?(0,k.j8)(t):t}function N(e){return z.includes(e)}},97856(e,t,n){n.d(t,{l:()=>ShaderInputs});var i=n(29651),r=n(35185),s=n(76282);function o(e,t={}){const n={bindings:{},uniforms:{}};return Object.keys(e).forEach(i=>{const r=e[i];var o;Object.prototype.hasOwnProperty.call(t,i)||(o=r,(0,s.H9)(o)||"number"==typeof o||"boolean"==typeof o)?n.uniforms[i]=r:n.bindings[i]=r}),n}class ShaderInputs{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;directBindings={};constructor(e,t){Object.assign(this.options,t);const n=(0,r.$Q)(Object.values(e).filter(h));for(const t of n)e[t.name]=t;i.R.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(const[t,n]of Object.entries(e))n&&(this._addModule(n),n.name&&t!==n.name&&!this.options.disableWarnings&&i.R.warn(`Module name: ${t} vs ${n.name}`)())}destroy(){}setProps(e){e.bindings&&Object.assign(this.directBindings,e.bindings);for(const t of Object.keys(e)){if("bindings"===t)continue;const n=t,r=e[n]||{},s=this.modules[n];if(s){const e=this.moduleUniforms[n],t=this.moduleBindings[n],i=s.getUniforms?.(r,e)||r,{uniforms:c,bindings:l}=o(i,s.uniformTypes);this.moduleUniforms[n]=a(e,c,s.uniformTypes),this.moduleBindings[n]={...t,...l}}else this.options.disableWarnings||i.R.warn(`Module ${t} not found`)()}}getModules(){return Object.values(this.modules)}addModules(e){const t=(0,r.$Q)(e);for(const e of t){const t=e.name;this.modules[t]||(this.modules[t]=e,this._addModule(e))}}getUniformValues(){return this.moduleUniforms}getBindingValues(){const e={};for(const t of Object.values(this.moduleBindings))Object.assign(e,t);return Object.assign(e,this.directBindings),e}getModuleBindingValues(e){const t=this.moduleBindings[e];return t?{...t}:{}}getDebugTable(){const e={};for(const[t,n]of Object.entries(this.moduleUniforms))for(const[i,r]of Object.entries(n))e[`${t}.${i}`]={type:this.modules[t].uniformTypes?.[i],value:String(r)};return e}_addModule(e){const t=e.name;this.moduleUniforms[t]=a({},e.defaultUniforms||{},e.uniformTypes),this.moduleBindings[t]={}}}function a(e={},t={},n={}){const i={...e};for(const[r,s]of Object.entries(t))void 0!==s&&(i[r]=c(e[r],s,n[r]));return i}function c(e,t,n){if(!n||"string"==typeof n)return l(t);if(Array.isArray(n)){if(u(t)||!Array.isArray(t))return l(t);const i=Array.isArray(e)&&!u(e)?[...e]:[],r=i.slice();for(let e=0;e<t.length;e++){const s=t[e];void 0!==s&&(r[e]=c(i[e],s,n[0]))}return r}if(!d(t))return l(t);const i=n,r=d(e)?e:{},s={...r};for(const[e,n]of Object.entries(t))void 0!==n&&(s[e]=c(r[e],n,i[e]));return s}function l(e){if(ArrayBuffer.isView(e))return Array.prototype.slice.call(e);if(Array.isArray(e)){if(u(e))return e.slice();return e.map(e=>void 0===e?void 0:l(e))}return d(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,void 0===t?void 0:l(t)])):e}function u(e){return ArrayBuffer.isView(e)||Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}function d(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)&&!ArrayBuffer.isView(e)}function h(e){return Boolean(e?.dependencies)}},16698(e,t,n){n.d(t,{He:()=>s,Y$:()=>r,_R:()=>a,fX:()=>o,jY:()=>c});var i=n(88153);function r(e,t){if(!e||!t.some(e=>e.bindingLayout?.length))return e;const n={...e,bindings:e.bindings.map(e=>({...e}))};"attributes"in(e||{})&&(n.attributes=e?.attributes||[]);for(const e of t)for(const t of e.bindingLayout||[])for(const e of l(t.name)){const i=n.bindings.find(t=>t.name===e);0===i?.group&&(i.group=t.group),i&&void 0!==t.visibility&&(i.visibility=t.visibility)}return n}function s(e,t,n=[]){return e?t?{...e,attributes:e.attributes.length?d(e.attributes,t.attributes.filter(e=>n.includes(e.name))):t.attributes,bindings:u(e.bindings,t.bindings)}:e:t}function o(e){return Boolean(e.uniformTypes&&!function(e){for(const t in e)return!1;return!0}(e.uniformTypes))}function a(e){const t=[];for(const n of e){const e=(0,i.Uj)(n),r=new Set([n.vs,n.fs].flatMap(e=>e?(0,i.V$)(e).filter(e=>e.isStd140).map(e=>e.blockName):[])),s=r.has(e)?e:1===r.size?r.values().next().value:void 0;o(n)&&s&&t.push({name:s,uniformTypes:n.uniformTypes})}return t}function c(e,t){const n=[],i=new Set;for(const r of[...e||[],...t||[]])i.has(r.name)||(i.add(r.name),n.push(r));return n}function l(e){const t=new Set([e,`${e}Uniforms`]);return e.endsWith("Uniforms")||t.add(`${e}Sampler`),[...t]}function u(e,t){const n=e.map(e=>({...e})),i=new Set(e.map(e=>e.name)),r=new Set(e.map(e=>`${e.group}:${e.location}`));for(const e of t){const t=`${e.group}:${e.location}`;i.has(e.name)||r.has(t)||n.push({...e})}return n}function d(e,t){const n=e.map(e=>({...e})),i=new Map(e.map(e=>[e.name,e])),r=new Map(e.map(e=>[e.location,e]));for(const e of t){const t=i.get(e.name);if(t){if(t.type!==e.type||t.location!==e.location)throw new Error(`Shader attribute "${e.name}" conflicts with its inferred type or location`);continue}const s=r.get(e.location);if(s)throw new Error(`Shader attributes "${s.name}" and "${e.name}" both use location ${e.location}`);n.push({...e})}return n}},4500(e,t,n){n.d(t,{L:()=>r});const i={};function r(e="id"){i[e]=i[e]||1;return`${e}-${i[e]++}`}},84226(e,t,n){n.d(t,{I:()=>GPUDataView});var i=n(61954);class GPUDataView{buffer;format;length;byteOffset;byteStride;constructor(e){const t=i.E.getVertexFormatInfo(e.format).byteLength,n=e.byteOffset??0,s=e.byteStride??t;if(r(e.length,"GPUDataView length"),r(n,"GPUDataView byteOffset"),r(s,"GPUDataView byteStride"),s<t)throw new Error(`GPUDataView byteStride ${s} is smaller than ${e.format} byte length ${t}`);const o=0===e.length?0:(e.length-1)*s+t,a=n+o;if(!Number.isSafeInteger(o)||!Number.isSafeInteger(a))throw new Error("GPUDataView byte range must use safe integers");if(a>e.buffer.byteLength)throw new Error("GPUDataView exceeds its backing buffer byte length");this.buffer=e.buffer,this.format=e.format,this.length=e.length,this.byteOffset=n,this.byteStride=s}get elementByteLength(){return i.E.getVertexFormatInfo(this.format).byteLength}get byteLength(){return 0===this.length?0:(this.length-1)*this.byteStride+this.elementByteLength}}function r(e,t){if(!Number.isSafeInteger(e)||e<0)throw new Error(`${t} must be a non-negative safe integer`)}},1990(e,t,n){n.d(t,{L:()=>h});var i=n(84226),r=n(61954),s=n(50584);function o(e){return Boolean(e&&"object"==typeof e&&"struct"===e.type)}function a(e,t){const n=Object.entries(e);if(0===n.length)throw new Error("GPUData struct format must declare at least one field");return"packed"===t?function(e){const t=[];let n=0,i=0;for(const[s,o]of e){const e=r.E.getVertexFormatInfo(o);if(e.webglOnly)throw new Error(`Packed GPUData struct field "${s}" uses WebGL-only format ${o}`);n=u(n,Math.min(4,e.byteLength)),t.push([s,Object.freeze({format:o,byteOffset:n,byteLength:e.byteLength})]),n+=e.byteLength,i+=e.components}return Object.freeze({type:"struct",layout:"packed",fields:Object.freeze(Object.fromEntries(t)),components:i,byteStride:u(n,4),rowByteLength:n})}(n):function(e){const t=Object.fromEntries(e.map(([e,t])=>[e,c(t)])),n=(0,s.Pr)(t,{layout:"wgsl-storage"}),i=[];let o=0,a=0;for(const[t,s]of e){const e=r.E.getVertexFormatInfo(s),c=4*n.fields[t].offset;i.push([t,Object.freeze({format:s,byteOffset:c,byteLength:e.byteLength})]),o=Math.max(o,c+e.byteLength),a+=e.components}return Object.freeze({type:"struct",layout:"wgsl-storage",fields:Object.freeze(Object.fromEntries(i)),components:a,byteStride:n.byteLength,rowByteLength:o})}(n)}function c(e){const t=r.E.getVertexFormatInfo(e);switch(t.type){case"float32":return l("f32",t.components);case"sint32":return l("i32",t.components);case"uint32":return l("u32",t.components);default:return l("u32",Math.ceil(t.byteLength/4))}}function l(e,t){return 1===t?e:`vec${t}<${e}>`}function u(e,t){return Math.ceil(e/t)*t}var d=n(6917);class GPUDataBufferOwner{buffer;ownsDataBuffer;constructor(e,t){this.buffer=e,this.ownsDataBuffer=t}get ownsBuffer(){return this.ownsDataBuffer}transferBufferOwnership(e){if(e.buffer!==this.buffer)throw new Error("GPUData ownership can only be transferred to the same buffer");e.ownsDataBuffer=this.ownsDataBuffer,this.ownsDataBuffer=!1}destroy(){this.ownsDataBuffer&&(this.buffer.destroy(),this.ownsDataBuffer=!1)}}const h=class GPUDataImpl extends GPUDataBufferOwner{dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;readbackMetadata;valueOffsets;nullBitmap;valueByteLength;constructor(e){const{buffer:t,format:n,length:i,valueLength:r,stride:s,byteOffset:c=0,byteStride:l,rowByteLength:u,ownsBuffer:h=!1,readbackMetadata:f,valueOffsets:p,nullBitmap:g,valueByteLength:m,dataType:v}=e;let y;super(t,h),y=n?"string"==typeof n?n:a(n,e.layout??"wgsl-storage"):void 0;const b=o(y)?y:void 0,_="string"==typeof y?(0,d.Ft)(y):void 0;if(this.dataType=v,this.format=y,this.length=i,this.valueLength=r??i,this.stride=s??_?.components??b?.components??l??u??1,this.byteOffset=c,this.rowByteLength=u??b?.rowByteLength??_?.byteLength??l??this.stride,this.byteStride=l??b?.byteStride??this.rowByteLength,b){if(this.rowByteLength<b.rowByteLength)throw new Error(`GPUData rowByteLength ${this.rowByteLength} is smaller than struct format row byte length ${b.rowByteLength}`);if(this.byteStride<Math.max(b.byteStride,this.rowByteLength))throw new Error(`GPUData byteStride ${this.byteStride} is smaller than its struct row layout`)}this.readbackMetadata=f,this.valueOffsets=p,this.nullBitmap=g,this.valueByteLength=m}getChild(e){if(!o(this.format))return null;const t=this.format.fields[e];return t?new i.I({buffer:this.buffer,format:t.format,length:this.length,byteOffset:this.byteOffset+t.byteOffset,byteStride:this.byteStride}):null}getChildAt(e){if(!o(this.format))return null;const t=Object.values(this.format.fields)[e];return t?new i.I({buffer:this.buffer,format:t.format,length:this.length,byteOffset:this.byteOffset+t.byteOffset,byteStride:this.byteStride}):null}}},6917(e,t,n){n.d(t,{Ft:()=>c,Tm:()=>o,u4:()=>a});var i=n(61954);const r=/^vertex-list<([^<>]+)>$/,s=/^value-list<([^<>]+)>$/;function o(e){return r.test(e)}function a(e){return s.test(e)}function c(e){const t=function(e){const t=r.exec(e),n=s.exec(e),o=t?.[1]??n?.[1]??e;try{i.E.getVertexFormatInfo(o)}catch{throw new Error(`Unsupported GPUVector format ${e}`)}return o}(e),n=o(e),c=a(e),u=i.E.getVertexFormatInfo(t),d=u.type,h=u.normalized,f=function(e,t){if(t)return"f32";switch(e){case"float32":return"f32";case"float16":return"f16";case"uint8":case"uint16":case"uint32":return"u32";case"sint8":case"sint16":case"sint32":return"i32";default:throw new Error(`Unsupported GPUVector component type ${e}`)}}(d,h);return{format:e,elementFormat:t,vertexList:n,valueList:c,type:d,signedDataType:l(t,d),primitiveType:f,components:u.components,byteLength:u.byteLength,integer:u.integer,signed:u.signed,normalized:h,...u.webglOnly?{webglOnly:!0}:{}}}function l(e,t){if("unorm10-10-10-2"===e)return"uint32";switch(t){case"unorm8":return"uint8";case"snorm8":return"sint8";case"unorm16":return"uint16";case"snorm16":return"sint16";default:return t}}},65181(e,t,n){n.d(t,{M:()=>GPUVector});var i=n(1990),r=n(6917);class GPUVector{name;dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;bufferLayout;data=[];device;bufferProps;isAppendable=!1;ownsDataChunks=!0;ownedVectors=[];appendableByteLength=0;constructor(e){switch(e.type){case"buffer":{const{name:t,buffer:n,format:r,length:o,valueLength:a=o,byteOffset:c=0,ownsBuffer:l=!1}=e,{stride:u,byteStride:d,rowByteLength:h}=s(e);return this.name=t,this.dataType=e.dataType,this.format=r,this.length=o,this.valueLength=a,this.stride=u,this.byteOffset=c,this.byteStride=d,this.rowByteLength=h,void this.data.push(new i.L({buffer:n,format:r,length:o,valueLength:a,stride:u,byteOffset:c,byteStride:d,rowByteLength:h,ownsBuffer:l,dataType:e.dataType}))}case"interleaved":{const{name:t,buffer:n,format:r,length:s,valueLength:o=s,byteOffset:a=0,byteStride:c,attributes:l,ownsBuffer:u=!1}=e;return this.name=t,this.dataType=e.dataType,this.format=r,this.length=s,this.valueLength=o,this.stride=c,this.byteOffset=a,this.byteStride=c,this.rowByteLength=c,this.bufferLayout={name:t,byteStride:c,attributes:l},void this.data.push(new i.L({buffer:n,format:r,length:s,valueLength:o,stride:c,byteOffset:a,byteStride:c,rowByteLength:c,ownsBuffer:u,dataType:e.dataType}))}case"data":{const t=e.format??function(e){return e[0]?.format}(e.data),n=t?(0,r.Ft)(t):void 0,{name:i,data:s,stride:o=s[0]?.stride??n?.components??1,valueLength:a=s.reduce((e,t)=>e+t.valueLength,0),byteStride:c=s[0]?.byteStride??n?.byteLength,rowByteLength:l=s[0]?.rowByteLength??n?.byteLength,bufferLayout:u,ownsData:d=!1}=e;if(void 0===c||void 0===l)throw new Error("GPUVector requires format or explicit byte layout metadata");return t&&function(e,t){const n=e.find(e=>e.format!==t);if(n)throw new Error("GPUVector data chunks must share the declared format")}(s,t),this.name=i,this.dataType=e.dataType,this.format=t,this.length=s.reduce((e,t)=>e+t.length,0),this.valueLength=a,this.stride=o,this.byteOffset=1===s.length?s[0].byteOffset:0,this.byteStride=c,this.rowByteLength=l,this.bufferLayout=u,this.ownsDataChunks=d,void this.data.push(...s)}case"appendable":{const{name:t,device:n,format:i,valueLength:r=0,bufferProps:o}=e,{stride:a,byteStride:c,rowByteLength:l}=s(e);return this.name=t,this.dataType=e.dataType,this.format=i,this.length=0,this.valueLength=r,this.stride=a,this.byteOffset=0,this.byteStride=c,this.rowByteLength=l,this.device=n,this.bufferProps=o,void(this.isAppendable=!0)}}}get ownsBuffer(){return this.ownsDataChunks&&this.data.some(e=>e.ownsBuffer)||this.ownedVectors.some(e=>e.ownsBuffer)}get capacityRows(){return this.isAppendable?this.length:void 0}get appendedByteLength(){return this.appendableByteLength}addData(e){if(this.format&&e.format!==this.format)throw new Error("GPUVector.addData() requires matching formats");if(e.byteStride!==this.byteStride)throw new Error("GPUVector.addData() requires matching byteStride");if(e.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.addData() requires matching rowByteLength");return this.data.push(e),this.length+=e.length,this.valueLength+=e.valueLength,this}appendDataChunk(e,t=this.appendableByteLength+e.buffer.byteLength){if(!this.isAppendable)throw new Error("GPUVector.appendDataChunk() requires appendable vector storage");if(this.format&&e.format!==this.format)throw new Error("GPUVector.appendDataChunk() requires matching formats");if(e.byteStride!==this.byteStride||e.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.appendDataChunk() requires matching byte layout metadata");return this.data.push(e),this.length+=e.length,this.valueLength+=e.valueLength,this.appendableByteLength=t,this}resetLastBatch(){if(!this.isAppendable)throw new Error("GPUVector.resetLastBatch() requires appendable vector storage");for(const e of this.data.splice(0))e.destroy();return this.length=0,this.valueLength=0,this.appendableByteLength=0,this}retainOwnedVectors(e){return this.ownedVectors.push(...e),this}transferBufferOwnership(e){const t=this.data[0],n=e.data[0];if(!t||!n||t.buffer!==n.buffer)throw new Error("GPUVector ownership can only be transferred to the same buffer");t.transferBufferOwnership(n)}destroy(){if(this.ownsDataChunks)for(const e of this.data)e.destroy();for(const e of this.ownedVectors.splice(0))e.destroy()}}function s(e){const t=e.format?(0,r.Ft)(e.format):void 0,n=e.rowByteLength??e.byteStride??t?.byteLength;if(void 0===n)throw new Error("GPUVector requires format or explicit rowByteLength");return{stride:e.stride??t?.components??1,byteStride:e.byteStride??n,rowByteLength:n}}},34010(e,t,n){n.d(t,{GL:()=>GPUDataEvaluator,uy:()=>u});var i=n(68597),r=n(99305),s=n(1990),o=n(84226),a=n(65181),c=n(6917),l=n(65020);class GPUDataEvaluator{static get bufferPoolSize(){return l.R.poolSize}static set bufferPoolSize(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("GPUDataEvaluator.bufferPoolSize must be a non-negative safe integer");l.R.poolSize=e,l.R.purge()}type;size;get offset(){return this._offset}get stride(){return this._stride}normalized;isConstant;length;get byteLength(){return this._byteLength}ValueType;source=null;format;_id;_destroyed=!1;_value;_offset;_stride;_byteLength;_gpuVector;_bufferOwnership="owned";_targetBuffer;static fromArray(e,{type:t,size:n=1,offset:r=0,stride:s=0,normalized:o=!1}){let a,c=t;if(Array.isArray(e)){c=c||"float32";a=new((0,i.Y0)(c))(e)}else e instanceof Float64Array?(c="uint32",n*=2,r*=2,s*=2,a=new Uint32Array(e.buffer,e.byteOffset,e.byteLength/4)):(c=c||(0,i.UE)(e),a=e);return new GPUDataEvaluator({id:`<${c} * ${n}>`,type:c,size:n,offset:r,stride:s,normalized:o,value:a})}static fromConstant(e,t="float32"){const n=(0,i.Y0)(t);let r;return Array.isArray(e)?r=`[${e.join(",")}]`:(r=String(e),e=[e]),new GPUDataEvaluator({id:r,isConstant:!0,type:t,size:e.length,value:new n(e)})}static fromGPUData(e,t={}){!function(e){if(!e.format)throw new Error("GPUDataEvaluator.fromGPUData() requires GPUData format metadata");if((0,c.Tm)(e.format)||(0,c.u4)(e.format))throw new Error("GPUDataEvaluator.fromGPUData() does not support variable-length input");const t=(0,c.Ft)(e.format),n=t.byteLength;if(e.rowByteLength!==n)throw new Error(`GPUDataEvaluator.fromGPUData() requires rowByteLength ${n} for GPUData`)}(e);const n=new o.I({buffer:e.buffer,format:e.format,length:e.length,byteOffset:e.byteOffset,byteStride:e.byteStride});return new GPUDataEvaluator({...d(n),id:t.id,gpuData:e})}static fromGPUDataView(e,t={}){return new GPUDataEvaluator({...d(e),id:t.id,buffer:e.buffer})}constructor(e){const{id:t,value:n,buffer:r,gpuData:s,format:o,source:c=null,isConstant:l=!1}=e;if(!(c||n||r||s))throw new Error("GPUDataEvaluator must have a value source");let{type:u,size:d,offset:h,stride:f,normalized:p,length:g}=e;if(c instanceof GPUDataEvaluator?(u=u??c.type,d=d??c.size,h=h??c.offset,f=f??c.stride,p=p??c.normalized,g=g??c.length):(d=d??1,h=h??0,p=p??!1,g=l?1:g),!u)throw new Error("GPUDataEvaluator: type not defined");if(this._id=t,this.type=u,this.size=d,this.ValueType=(0,i.Y0)(this.type),this._offset=h,this._stride=f||this.ValueType.BYTES_PER_ELEMENT*d,this.normalized=p,this.source=c,this.format=o,void 0===g)if(l)g=1;else{if(!n)throw new Error("GPUDataEvaluator: length not defined");g=Math.ceil(n.byteLength/this.stride)}this.isConstant=l,this.length=g;const m=this.ValueType.BYTES_PER_ELEMENT*this.size;this._byteLength=0===g?0:(g-1)*this.stride+m,this._value=n,this._bufferOwnership=c instanceof GPUDataEvaluator||r||s?"borrowed":"owned",s?this._gpuVector=new a.M({type:"data",name:this._id??"data",format:s.format,data:[s],stride:s.stride,byteStride:s.byteStride,rowByteLength:s.rowByteLength}):r&&(this._gpuVector=this.createGPUVectorView({buffer:r,name:this._id,format:this.format}))}get value(){return this._value||(this.source instanceof GPUDataEvaluator?this.source.value:void 0)}get evaluated(){return Boolean(this._gpuVector)}get id(){return this._id}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}get buffer(){return h(this.gpuVector)}setTargetBuffer({buffer:e,byteOffset:t=0,byteStride:n=this.stride}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)throw new Error(`GPUDataEvaluator ${this} already evaluated`);if(!this.source||this.source instanceof GPUDataEvaluator)throw new Error("GPUDataEvaluator target buffers require a deferred operation source");this._targetBuffer={buffer:e,byteOffset:t,byteStride:n}}async evaluate(e,t={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let n;if(this.source instanceof GPUDataEvaluator){const n=await this.source.evaluate(e);return this._gpuVector=this.createGPUVectorView({...t,buffer:h(n)}),this._gpuVector}if(n=this._getEvaluationBuffer(e),this._value)n.write(this._value);else{const t=await this.source.execute(e,n);if(!t.success)throw t.error||new Error(`${this.source} evaluation failed`);t.value&&(this._value=t.value)}return this._gpuVector=this.createGPUVectorView({...t,buffer:n}),this._gpuVector}evaluateSync(e,t={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let n;if(this.source instanceof GPUDataEvaluator){const n=this.source.evaluateSync(e);return this._gpuVector=this.createGPUVectorView({...t,buffer:h(n)}),this._gpuVector}if(n=this._getEvaluationBuffer(e),this._value)n.write(this._value);else{const t=this.source.executeSync(e,n);if(!t.success)throw t.error||new Error(`${this.source} evaluation failed`);t.value&&(this._value=t.value)}return this._gpuVector=this.createGPUVectorView({...t,buffer:n}),this._gpuVector}createGPUVectorView(e){const t=e.name??this._id??"vector",n=e.format??this.format??g(this.type,this.size,this.normalized);if(e.interleaved){const n="object"==typeof e.interleaved&&e.interleaved.attributes?e.interleaved.attributes:function(e){const t=[];return f(e,t,{byteOffset:0}),t}(this);return new a.M({type:"interleaved",name:t,buffer:e.buffer,format:e.format??this.format,length:this.length,byteOffset:this.offset,byteStride:this.stride,attributes:n,ownsBuffer:!1})}return new a.M({type:"buffer",name:t,buffer:e.buffer,format:n,length:this.length,stride:this.size,byteOffset:this.offset,byteStride:this.stride,rowByteLength:this.ValueType.BYTES_PER_ELEMENT*this.size,ownsBuffer:!1})}_getEvaluationBuffer(e){const t=this._targetBuffer;if(!t)return l.R.createOrReuse(e,this.byteLength);if(t.buffer.device!==e)throw new Error("GPUDataEvaluator target buffer belongs to a different device");const n=this.ValueType.BYTES_PER_ELEMENT*this.size,i=0===this.length?0:(this.length-1)*t.byteStride+n;if(t.byteOffset+i>t.buffer.byteLength)throw new Error("GPUDataEvaluator target buffer is too small for the output layout");return this._offset=t.byteOffset,this._stride=t.byteStride,this._byteLength=i,this._bufferOwnership="borrowed",this._targetBuffer=void 0,t.buffer}async readValue(e=0,t){const{ValueType:n}=this,{size:i,offset:r,stride:s,length:o}=this,a=n.BYTES_PER_ELEMENT*i;if(t=t??o,e=Math.max(0,Math.min(o,e)),t=Math.max(e,Math.min(o,t)),this._value)return function(e,t,n,i){const{ValueType:r,size:s,offset:o,stride:a}=e,c=a/r.BYTES_PER_ELEMENT,l=o/r.BYTES_PER_ELEMENT,u=i-n;if(c===s){const e=l+n*c;return t.subarray(e,e+u*s)}const d=new r(u*s);for(let e=0;e<u;e++){const i=l+(n+e)*c;d.set(t.subarray(i,i+s),e*s)}return d}(this,this._value,e,t);const c=t-e;if(0===c)return new n(0);const l=r+e*s,u=s===a?c*a:(c-1)*s+a,d=await this.buffer.readAsync(l,u),h=new n(d.buffer,d.byteOffset,d.byteLength/n.BYTES_PER_ELEMENT);if(s===a)return h;const f=new Uint8Array(a*c);for(let e=0;e<c;e++){const t=e*s;f.set(d.subarray(t,t+a),e*a)}return new n(f.buffer)}async ensureCPUValue(){const e=this.value;if(e)return e;const t=await this.buffer.readAsync(0,this.offset+this.byteLength);if(t.byteLength%this.ValueType.BYTES_PER_ELEMENT!==0)throw new Error(`${this} backing buffer byte length is not aligned to its scalar type`);const n=t.slice();return this._value=new this.ValueType(n.buffer,n.byteOffset,n.byteLength/this.ValueType.BYTES_PER_ELEMENT),this._value}ensureCPUValueSync(){const e=this.value;if(e)return e;throw new Error(`${this} CPU value is not available for synchronous evaluation`)}toString(){return this._id??this.source?.toString()??this.constructor.name}destroy(){this._gpuVector&&("owned"===this._bufferOwnership&&l.R.recycle(h(this._gpuVector)),this._gpuVector=void 0),this._targetBuffer=void 0,this._destroyed=!0}}function u(e){if(e instanceof GPUDataEvaluator)return e;if("number"==typeof e||Array.isArray(e))return GPUDataEvaluator.fromConstant(e);if(e instanceof s.L)return GPUDataEvaluator.fromGPUData(e);if(e instanceof o.I)return GPUDataEvaluator.fromGPUDataView(e);throw new Error("getGPUDataEvaluator() requires GPUDataEvaluator, GPUData, GPUDataView, number, or number[]")}function d(e){const t=(0,c.Ft)(e.format),n=(0,i.Y0)(t.signedDataType),r=n.BYTES_PER_ELEMENT*t.components;if(t.byteLength!==r)throw new Error(`GPUDataEvaluator does not support packed vertex format ${e.format}: ${t.byteLength} physical bytes cannot expose ${t.components} ${t.signedDataType} components`);if(e.byteOffset%n.BYTES_PER_ELEMENT!==0||e.byteStride%n.BYTES_PER_ELEMENT!==0)throw new Error(`GPUDataEvaluator requires ${e.format} offset and stride aligned to ${n.BYTES_PER_ELEMENT} bytes`);return{type:t.signedDataType,size:t.components,offset:e.byteOffset,stride:e.byteStride,normalized:t.normalized,length:e.length,format:e.format}}function h(e){const t=function(e){const[t,...n]=e.data;if(!t||n.length>0)throw new Error(`GPUDataEvaluator requires exactly one GPUData chunk for "${e.name}"`);return t}(e).buffer;return t instanceof r.kL?t.buffer:t}function f(e,t,n){const i=e.source;if(!i||i instanceof GPUDataEvaluator||"interleave"!==i.name)t.push({attribute:e.id??e.toString(),format:p(e.type,e.size,e.normalized),byteOffset:n.byteOffset}),n.byteOffset+=e.ValueType.BYTES_PER_ELEMENT*e.size;else for(const e of Object.values(i.inputs))e instanceof GPUDataEvaluator&&f(e,t,n)}function p(e,t,n=!1){if(t<1||t>4)throw new Error(`Cannot synthesize a GPUVector vertex format with ${t} components`);let i=e;if(n)switch(e){case"uint8":i="unorm8";break;case"sint8":i="snorm8";break;case"uint16":i="unorm16";break;case"sint16":i="snorm16";break;case"float32":i="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${e}`)}return"uint8"!==i&&"sint8"!==i&&"uint16"!==i&&"sint16"!==i&&"unorm8"!==i&&"snorm8"!==i&&"unorm16"!==i&&"snorm16"!==i||3!==t?`${i}${1===t?"":`x${t}`}`:`${i}x3-webgl`}function g(e,t,n=!1){return t>=1&&t<=4?p(e,t,n):void 0}},78705(e,t,n){n.d(t,["E",0,{add:{arity:2,symbol:"arithmetic_add"},subtract:{arity:2,symbol:"arithmetic_subtract"},multiply:{arity:2,symbol:"arithmetic_multiply"},divide:{arity:2,symbol:"arithmetic_divide"},pow:{arity:2,symbol:"pow"},sqrt:{arity:1,symbol:"sqrt"},abs:{arity:1,symbol:"abs"},sin:{arity:1,symbol:"sin"},cos:{arity:1,symbol:"cos"},tan:{arity:1,symbol:"arithmetic_tan"},exp:{arity:1,symbol:"exp"},log:{arity:1,symbol:"log"}}])},70049(e,t,n){n.d(t,{B:()=>r,BB:()=>i,vL:()=>s});function i(e,t){const n=function(e){if(Number.isFinite(e)&&e>0)return Math.floor(e);return 65535}(t),i=Math.max(1,Math.ceil(e)),r=Math.min(i,n),s=Math.min(Math.ceil(i/r),n),o=Math.ceil(i/r/s);if(o>n)throw new Error(`WebGPU dispatch requires ${i} workgroups, exceeding the 3D dispatch limit of ${n} per dimension`);return{x:r,y:s,z:o}}function r(e,t="workgroupId"){return`((${t}.z * ${e.y}u + ${t}.y) * ${e.x}u + ${t}.x)`}function s(e,t,n="workgroupId",i="localId"){return`(${r(e,n)} * ${t}u + ${i}.x)`}},27611(e,t,n){function i(e,t){switch(e){case"u32":return`${t}u`;case"f32":return Number.isInteger(t)?`${t}.0`:`${t}`;default:return`${t}`}}function r(e,t){switch(e){case"uint32":return i("u32",Math.trunc(t));case"sint32":return`${Math.trunc(t)}`;case"float32":return i("f32",t);default:throw new Error(`WebGPU operations only support 32-bit output types, got ${e}`)}}function s(e){switch(e){case"uint32":return"0u";case"sint32":return"0";case"float32":return"0.0";default:throw new Error(`WebGPU operations only support 32-bit output types, got ${e}`)}}function o(e){switch(e){case"uint32":return"u32";case"sint32":return"i32";case"float32":return"f32";default:throw new Error(`WebGPU operations only support 32-bit storage types, got ${e}`)}}n.d(t,{C1:()=>r,Lm:()=>i,_1:()=>s,iP:()=>o})},26266(e,t,n){n.d(t,{P:()=>c});var i=n(30257),r=n(5959),s=n(70049),o=n(27611);const a=new r.Ry;function c({module:e,elementWise:t=!1,expression:n,inputs:r,output:c,operationType:l=c.type,outputBuffer:u}){if(!e.source)throw new Error(`WebGPU computation ${e.name} requires WGSL source`);const d=function(e){return Array.isArray(e)?e.map((e,t)=>[`x${t}`,e]):Object.entries(e)}(r),h=d.map(([e,t])=>({name:e,input:t})),f=h.filter(({input:e})=>!e.isConstant).map((e,t)=>({...e,index:t})),p=(0,o.iP)(l),g=(0,o.iP)(c.type),m={TYPE:p,RESULT_LEN:c.size.toString()},v=(0,s.BB)(Math.ceil(c.length/64),u.device.limits.maxComputeWorkgroupsPerDimension);for(const[e,t]of d)m[`${e.toUpperCase()}_LEN`]=t.size.toString();const y=`\n${function(e,t){for(const n in t)e=e.replaceAll(`{${n}}`,t[n]);return e}(e.source,m)}\n${f.map(({name:e,input:t,index:n})=>function(e,t,n){if(t.isConstant)return"";const i=(0,o.iP)(t.type);return`@group(0) @binding(${n}) var<storage, read> ${e}: array<${i}>;`}(e,t,n)).join("\n")}\n${h.map(({name:e,input:t})=>function(e,t,n){const i=(0,o.iP)(n),r=t.type===n?"":i,s=t.stride/t.ValueType.BYTES_PER_ELEMENT,a=t.offset/t.ValueType.BYTES_PER_ELEMENT;if(t.isConstant)return`fn read_${e}(_rowIndex: u32) -> array<${i}, ${t.size}> {\n return array<${i}, ${t.size}>(${function(e,t){const n=e.value;if(!n)throw new Error(`Constant input ${e} is missing CPU values`);return Array.from({length:e.size},(e,i)=>(0,o.Lm)(t,n[i]??0)).join(", ")}(t,r)});\n}`;return`fn read_${e}(rowIndex: u32) -> array<${i}, ${t.size}> {\n var value: array<${i}, ${t.size}>;\n let rowOffset = ${a}u + rowIndex * ${s}u;\n${Array.from({length:t.size},(t,n)=>r?` value[${n}] = ${r}(${e}[rowOffset + ${n}u]);`:` value[${n}] = ${e}[rowOffset + ${n}u];`).join("\n")}\n return value;\n}`}(e,t,l)).join("\n")}\n${function(e,t){const n=(0,o.iP)(e.type);return`@group(0) @binding(${t}) var<storage, read_write> result: array<${n}>;`}(c,f.length)}\n${function(e){const t=e.stride/e.ValueType.BYTES_PER_ELEMENT,n=e.offset/e.ValueType.BYTES_PER_ELEMENT,i=(0,o.iP)(e.type);return`fn write_result(rowIndex: u32, value: array<${i}, ${e.size}>) {\n let rowOffset = ${n}u + rowIndex * ${t}u;\n${Array.from({length:e.size},(e,t)=>` result[rowOffset + ${t}u] = value[${t}];`).join("\n")}\n}`}(c)}\n\n@compute @workgroup_size(64) fn main(\n @builtin(workgroup_id) workgroupId: vec3<u32>,\n @builtin(local_invocation_id) localId: vec3<u32>\n) {\n let rowIndex = ${(0,s.vL)(v,64)};\n if (rowIndex >= ${c.length}u) {\n return;\n }\n\n${h.map(({name:e})=>` let ${e} = read_${e}(rowIndex);`).join("\n")}\n var result: array<${g}, ${c.size}>;\n${function(e,t,n,i,r){let s="";if(r)for(let e=0;e<n.size;e++)s+=` result[${e}] = ${r(e)};\n`;else if(i){const i=(0,o._1)(n.type),r=(0,o.iP)(n.type);for(let a=0;a<n.size;a++){const n=t.map(([e,t])=>{if(a<t.size){return(0,o.iP)(t.type)===r?`${e}[${a}]`:`${r}(${e}[${a}])`}return i});s+=` result[${a}] = ${e}(${n.join(", ")});\n`}}else s+=`result = ${e}(${t.map(([e])=>e).join(", ")});`;return s.trimEnd()}(e.name,d,c,t,n)}\n write_result(rowIndex, result);\n}\n`,b=new i.C(u.device,{source:y,modules:e.dependencies,shaderAssembler:a,shaderLayout:{bindings:[...f.map(({name:e},t)=>({name:e,type:"storage",group:0,location:t})),{name:"result",type:"storage",group:0,location:f.length}]}}),_=Object.fromEntries(f.map(({name:e,input:t})=>[e,t.buffer]));_.result=u,b.setBindings(_);const x=u.device.beginComputePass({});u.device.statsManager.getStats("GPGPU Operation Counts").get("Computation Runs").incrementCount(),b.dispatch(x,v.x,v.y,v.z),x.end(),u.device.submit(),b.destroy()}},10924(e,t,n){var i=n(26266);n.d(t,["C",0,({inputs:e,output:t,target:n})=>{const r=e.map((e,t)=>[`x${t}`,e]);!function(e,t){const n=t.filter(([,e])=>!e.isConstant).length,i=n+1;if(i>e.maxStorageBuffersPerShaderStage)throw new Error(`interleave() requires ${i} storage buffers, exceeding device limit ${e.maxStorageBuffersPerShaderStage}`);if(i>e.maxBindingsPerBindGroup)throw new Error(`interleave() requires ${i} bindings, exceeding bind group limit ${e.maxBindingsPerBindGroup}`)}(n.device.limits,r);const s=r.map(([e,t])=>`${e}: array<{TYPE}, ${t.size}>`).join(", ");let o=0;const a=`fn interleave(${s}) -> array<{TYPE}, {RESULT_LEN}> {\n var out: array<{TYPE}, {RESULT_LEN}>;\n${r.map(([e,t])=>{const n=Array.from({length:t.size},(t,n)=>` out[${o+n}] = ${e}[${n}];`).join("\n");return o+=t.size,n}).join("\n")}\n return out;\n}\n`;return(0,i.P)({module:{name:"interleave",source:a},inputs:e,output:t,outputBuffer:n}),{success:!0}}])},65020(e,t,n){var i=n(26839);const r=new class BufferPool{poolSize=20;bufferPools;constructor(){this.bufferPools=new Map}createOrReuse(e,t){if(t>e.limits.maxBufferSize)throw new Error(`Buffer pool cannot allocate ${t} bytes: device.limits.maxBufferSize is ${e.limits.maxBufferSize}`);const n=this.bufferPools.get(e),r=n?n.findIndex(e=>e.byteLength>=t):-1;if(r<0)return e.createBuffer({usage:i.h.VERTEX|i.h.STORAGE|i.h.COPY_DST|i.h.COPY_SRC,byteLength:t});const[s]=n.splice(r,1);return s}recycle(e){const t=e.device;this.bufferPools.has(t)||this.bufferPools.set(t,[]);const n=this.bufferPools.get(t),i=n.findIndex(t=>t.byteLength>e.byteLength);i<0?n.push(e):n.splice(i,0,e),this.purge()}purge(){for(const[e,t]of this.bufferPools){const n=e.isLost?0:this.poolSize;for(;t.length>n;)t.shift().destroy();0===t.length&&this.bufferPools.delete(e)}}};n.d(t,["R",0,r])},55611(e,t,n){function i(e,t=!0){return e??t}function r(e=[0,0,0],t=!0){return t?e.map(e=>e/255):[...e]}function s(e,t=!0){const n=r(e.slice(0,3),t),i=Number.isFinite(e[3]),s=i?e[3]:1;return[n[0],n[1],n[2],t&&i?s/255:s]}n.d(t,{eS:()=>i,jI:()=>s,sC:()=>r})},5959(e,t,n){n.d(t,{U0:()=>GLSLShaderAssembler,_P:()=>ShaderAssembler,Ry:()=>WGSLShaderAssembler});var i=n(16094),r=n(35185);var s=n(48377);const o=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,"#version 300 es\n"],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],a=[...o,[u("attribute"),"in $1"],[u("varying"),"out $1"]],c=[...o,[u("varying"),"in $1"]];function l(e,t){for(const[n,i]of t)e=e.replace(n,i);return e}function u(e){return new RegExp(`\\b${e}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}var d=n(88153);function h(e,t,n="glsl"){let i="";for(const r in e){const s=e[r];if(i+=`${"wgsl"===n?"fn":"void"} ${s.signature} {\n`,s.header&&(i+=` ${s.header}`),t[r]){const e=t[r];e.sort((e,t)=>e.order-t.order);for(const t of e)i+=` ${t.injection}\n`}s.footer&&(i+=` ${s.footer}`),i+="}\n"}return i}function f(e){const t={vertex:{},fragment:{}};for(const n of e){let e,i;"string"!=typeof n?(e=n,i=e.hook):(e={},i=n),i=i.trim();const r=i.indexOf(":"),s=i.slice(0,r),o=i.slice(r+1),a=i.replace(/\(.+/,""),c=Object.assign(e,{signature:o});switch(s){case"vs":t.vertex[a]=c;break;case"fs":t.fragment[a]=c;break;default:throw new Error(s)}}return t}var p=n(68074);function g(e,t="unnamed"){const n=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(e);return n?n[1]:t}function m(e){let t=100;const n=e.match(/[^\s]+/g);if(n&&n.length>=2&&"#version"===n[0]){const e=parseInt(n[1],10);Number.isFinite(e)&&(t=e)}if(100!==t&&300!==t)throw new Error(`Invalid GLSL version ${t}`);return t}const v="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)",y="\\s*",b=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${y}@group\\(\\s*(\\d+)\\s*\\)${y}${v}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${y}@binding\\(\\s*(auto|\\d+)\\s*\\)${y}${v}`,"g")],_=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${y}@group\\(\\s*(\\d+)\\s*\\)${y}${v}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${y}@binding\\(\\s*(auto|\\d+)\\s*\\)${y}${v}`,"g")],x=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${y}@group\\(\\s*(\\d+)\\s*\\)${y}${v}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${y}@binding\\(\\s*(\\d+)\\s*\\)${y}${v}`,"g")],w=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${v}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${v}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${v}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${v}`,"g")];function P(e){const t=e.split("");let n=0,i=0,r=!1,s=!1,o=!1;for(;n<e.length;){const a=e[n],c=e[n+1];if(s)o?o=!1:"\\"===a?o=!0:'"'===a&&(s=!1),n++;else if(r)"\n"===a||"\r"===a?r=!1:t[n]=" ",n++;else if(i>0){if("/"===a&&"*"===c){t[n]=" ",t[n+1]=" ",i++,n+=2;continue}if("*"===a&&"/"===c){t[n]=" ",t[n+1]=" ",i--,n+=2;continue}"\n"!==a&&"\r"!==a&&(t[n]=" "),n++}else'"'!==a?"/"!==a||"/"!==c?"/"!==a||"*"!==c?n++:(t[n]=" ",t[n+1]=" ",i=1,n+=2):(t[n]=" ",t[n+1]=" ",r=!0,n+=2):(s=!0,n++)}return t.join("")}function C(e,t){const n=P(e),i=[];for(const r of t){let s;for(r.lastIndex=0,s=r.exec(n);s;){const o=r===t[0],a=s.index,c=s[0].length;i.push({match:e.slice(a,a+c),index:a,length:c,bindingToken:s[o?1:2],groupToken:s[o?2:1],accessDeclaration:s[3]?.trim(),name:s[4]}),s=r.exec(n)}}return i.sort((e,t)=>e.index-t.index)}function S(e,t,n){const i=C(e,t);if(!i.length)return e;let r="",s=0;for(const t of i)r+=e.slice(s,t.index),r+=n(t),s=t.index+t.length;return r+=e.slice(s),r}function L(e){return/@binding\(\s*auto\s*\)/.test(P(e))}const A=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${v}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${v}\\s*:\\s*([^;]+);`,"g")];function E(e,t=[]){const n=P(e),i=new Map;for(const e of t)i.set(M(e.name,e.group,e.location),e.moduleName);const r=[];for(const e of A){let t;for(e.lastIndex=0,t=e.exec(n);t;){const s=e===A[0],o=Number(t[s?1:2]),a=Number(t[s?2:1]),c=t[3]?.trim(),l=t[4],u=t[5].trim(),d=i.get(M(l,a,o));r.push(T({name:l,group:a,binding:o,owner:d?"module":"application",moduleName:d,accessDeclaration:c,resourceType:u})),t=e.exec(n)}}return r.sort((e,t)=>e.group!==t.group?e.group-t.group:e.binding!==t.binding?e.binding-t.binding:e.name.localeCompare(t.name))}function T(e){const t={name:e.name,group:e.group,binding:e.binding,owner:e.owner,kind:"unknown",moduleName:e.moduleName,resourceType:e.resourceType};if(e.accessDeclaration){const n=e.accessDeclaration.split(",").map(e=>e.trim());if("uniform"===n[0])return{...t,kind:"uniform",access:"uniform"};if("storage"===n[0]){const e=n[1]||"read_write";return{...t,kind:"read"===e?"read-only-storage":"storage",access:e}}}return"sampler"===e.resourceType||"sampler_comparison"===e.resourceType?{...t,kind:"sampler",samplerKind:"sampler_comparison"===e.resourceType?"comparison":"filtering"}:e.resourceType.startsWith("texture_storage_")?{...t,kind:"storage-texture",access:k(e.resourceType),viewDimension:I(e.resourceType)}:e.resourceType.startsWith("texture_")?{...t,kind:"texture",viewDimension:I(e.resourceType),sampleType:B(e.resourceType),multisampled:e.resourceType.startsWith("texture_multisampled_")}:t}function M(e,t,n){return`${t}:${n}:${e}`}function I(e){return e.includes("cube_array")?"cube-array":e.includes("2d_array")?"2d-array":e.includes("cube")?"cube":e.includes("3d")?"3d":e.includes("2d")?"2d":e.includes("1d")?"1d":void 0}function B(e){return e.startsWith("texture_depth_")?"depth":e.includes("<i32>")?"sint":e.includes("<u32>")?"uint":e.includes("<f32>")?"float":void 0}function k(e){const t=/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(e);return t?.[1]}function R(e,t={}){const n=O(e),i=function(e){const t=[];let n=0;for(const i of e){if("}"===i.value&&0===n)return null;t.push(n),"{"===i.value?n++:"}"===i.value&&n--}return 0===n?t:null}(n);if(!i)return null;const r=function(e,t){const n=new Map;for(let i=0;i<e.length;i++){if(0!==t[i]||"alias"!==e[i].value)continue;const r=e[i+1]?.value;if(!Z(r)||"="!==e[i+2]?.value||n.has(r))return null;const s=W(e,t,i+3,";");if(s<0||s===i+3)return null;n.set(r,q(e.slice(i+3,s))),i=s}return n}(n,i);if(!r)return null;const s=function(e,t,n){const i=[],r=new Set,s=new Set;for(let o=0;o<e.length;o++){if(0!==t[o]||"var"!==e[o].value)continue;const a=H(e,t,o),c=e.slice(a,o),l=$(c,"group"),u=$(c,"binding");if(null===l||null===u||void 0===l!=(void 0===u))return null;if(void 0===l||void 0===u)continue;let d=o+1,h=[];if("<"===e[d]?.value){const t=G(e,d,"<",">");if(t<0)return null;const n=j(e.slice(d+1,t),",");if(!n)return null;h=n.map(q),d=t+1}const f=e[d]?.value;if(!Z(f)||":"!==e[d+1]?.value)return null;const p=W(e,t,d+2,";");if(p<0||p===d+2)return null;const g=F(q(e.slice(d+2,p)),n);if(!g)return null;const m=z({name:f,group:l,location:u,addressSpace:h,resourceType:g}),v=`${l}:${u}`;if(!m||r.has(v)||s.has(f))return null;i.push(m),r.add(v),s.add(f),o=p}return function(e){for(const t of e){if("sampler"!==t.type||t.samplerType||!t.name.endsWith("Sampler"))continue;const n=t.name.slice(0,-7),i=e.find(e=>"texture"===e.type&&e.name===n&&e.group===t.group);"depth"===i?.sampleType&&(t.samplerType="non-filtering")}}(i),i.sort((e,t)=>e.group-t.group||e.location-t.location||e.name.localeCompare(t.name))}(n,i,r);if(!s)return null;if(!1===t.scanVertexAttributes)return{attributes:[],bindings:s};const o=function(e,t){const n=new Map;for(let i=0;i<e.length;i++){if(0!==t[i]||"struct"!==e[i].value)continue;const r=e[i+1]?.value,s=i+2;if(!Z(r)||n.has(r)||"{"!==e[s]?.value)return null;const o=G(e,s,"{","}");if(o<0)return null;n.set(r,e.slice(s+1,o)),i=o}return n}(n,i);if(!o)return null;const a=function(e,t,n,i,r){const s=function(e,t){const n=[],i=new Set;for(let r=0;r<e.length;r++){if(0!==t[r]||"fn"!==e[r].value)continue;const s=e[r+1]?.value,o=r+2;if(!Z(s)||i.has(s)||"("!==e[o]?.value)return null;const a=G(e,o,"(",")");if(a<0)return null;const c=H(e,t,r);n.push({name:s,vertex:U(e.slice(c,r),"vertex"),parameters:e.slice(o+1,a)}),i.add(s),r=a}return n}(e,t);if(!s)return null;const o=s.filter(e=>e.vertex),a=r?o.find(e=>e.name===r):1===o.length?o[0]:void 0;if(!a)return 0!==o.length||r?null:[];const c=j(a.parameters,",");if(!c)return null;const l=[],u=new Set,d=new Set,h=new Set;for(const e of c)if(e.length>0&&!D({declaration:e,aliases:n,structures:i,attributes:l,attributeLocations:u,attributeNames:d,visitedStructures:h}))return null;return l.sort((e,t)=>e.location-t.location||e.name.localeCompare(t.name))}(n,i,r,o,t.vertexEntryPoint);return a?{attributes:a,bindings:s}:null}function O(e){const t=P(e),n=/[A-Za-z_][A-Za-z0-9_]*|(?:0[xX][0-9A-Fa-f]+|\d+)|[@(){}<>\[\]:,;=]/g,i=[];let r=n.exec(t);for(;r;)i.push({value:r[0],index:r.index}),r=n.exec(t);return i}function z(e){const{name:t,group:n,location:i,addressSpace:r,resourceType:s}=e,o={name:t,group:n,location:i};if("uniform"===r[0]&&1===r.length)return{...o,type:"uniform"};if("storage"===r[0]&&r.length<=2){const e=r[1]||"read";return"read"===e?{...o,type:"read-only-storage"}:"read_write"===e?{...o,type:"storage"}:null}return r.length>0?null:"sampler"===s||"sampler_comparison"===s?{...o,type:"sampler",..."sampler_comparison"===s?{samplerType:"comparison"}:{}}:"texture_external"===s?{...o,type:"external-texture"}:function(e,t){const n=/^texture_storage_(1d|2d|2d_array|3d)<([A-Za-z0-9_]+),(read|write|read_write)>$/.exec(t);if(!n)return null;const i={read:"read-only",write:"write-only",read_write:"read-write"}[n[3]];return{...e,type:"storage",format:n[2],access:i,viewDimension:V(n[1])}}(o,s)||function(e,t){const n=/^texture_(multisampled_)?(1d|2d|2d_array|cube|cube_array|3d)<(f32|i32|u32)>$/.exec(t);if(n){if(n[1]&&"2d"!==n[2])return null;const t={f32:"float",i32:"sint",u32:"uint"}[n[3]];return{...e,type:"texture",viewDimension:V(n[2]),sampleType:t,multisampled:Boolean(n[1])}}const i=/^texture_depth_(multisampled_)?(2d|2d_array|cube|cube_array)$/.exec(t);if(!i||i[1]&&"2d"!==i[2])return null;return{...e,type:"texture",viewDimension:V(i[2]),sampleType:"depth",multisampled:Boolean(i[1])}}(o,s)}function D(e){const{declaration:t,aliases:n,structures:i,attributes:r,attributeLocations:s,attributeNames:o,visitedStructures:a}=e,c=function(e,t){const n=j(e,t);return n&&2===n.length?n[0].length:-1}(t,":");if(c<1||c===t.length-1)return!1;const l=function(e){for(let t=e.length-1;t>=0;t--)if(Z(e[t].value))return e[t].value;return null}(t.slice(0,c)),u=$(t.slice(0,c),"location"),d=U(t.slice(0,c),"builtin"),h=F(q(t.slice(c+1)),n);if(!l||null===u||!h||void 0!==u&&d)return!1;if(void 0!==u){const e=/^(?:i32|u32|f32|f16|vec[234]<(?:i32|u32|f32|f16)>)$/.test(f=h)?f:null;return!(!e||s.has(u)||o.has(l))&&(r.push({name:l,location:u,type:e}),s.add(u),o.add(l),!0)}var f;if(d)return!0;const p=i.get(h);if(!p||a.has(h))return!1;const g=j(p,",");if(!g)return!1;a.add(h);for(const t of g)if(t.length>0&&!D({...e,declaration:t}))return!1;return a.delete(h),!0}function F(e,t,n=new Set){const i=O(e);let r="";for(const e of i){const i=t.get(e.value);if(!i){r+=N(e.value);continue}if(n.has(e.value))return null;const s=new Set(n);s.add(e.value);const o=F(i,t,s);if(!o)return null;r+=o}return r}function N(e){const t=/^(vec[234]|mat[234]x[234])([fiuh])$/.exec(e);if(!t)return e;const n={f:"f32",i:"i32",u:"u32",h:"f16"}[t[2]];return`${t[1]}<${n}>`}function $(e,t){let n;for(let i=0;i<e.length;i++)if("@"===e[i].value&&e[i+1]?.value===t){if(void 0!==n||"("!==e[i+2]?.value||!/^\d+$/.test(e[i+3]?.value||"")||")"!==e[i+4]?.value)return null;n=Number(e[i+3].value)}return n}function U(e,t){return e.some((n,i)=>"@"===n.value&&e[i+1]?.value===t)}function V(e){return e.replace("_","-")}function G(e,t,n,i){let r=0;for(let s=t;s<e.length;s++)if(e[s].value===n)r++;else if(e[s].value===i&&0===--r)return s;return-1}function j(e,t){const n=[];let i=0;const r={"(":0,"<":0,"[":0,"{":0},s=Object.keys(r),o={")":"(",">":"<","]":"[","}":"{"};for(let a=0;a<e.length;a++){const c=e[a].value;if(c===t&&s.every(e=>0===r[e]))n.push(e.slice(i,a)),i=a+1;else if(c in r)r[c]++;else if(c in o){const e=o[c];if(r[e]--,r[e]<0)return null}}return s.every(e=>0===r[e])?(n.push(e.slice(i)),n):null}function W(e,t,n,i){for(let r=n;r<e.length;r++)if(0===t[r]&&e[r].value===i)return r;return-1}function H(e,t,n){for(let i=n-1;i>=0;i--)if(";"===e[i].value&&0===t[i]||"}"===e[i].value&&1===t[i])return i+1;return 0}function q(e){return e.map(e=>e.value).join("")}function Z(e){return Boolean(e&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(e))}const Y="([a-zA-Z_][a-zA-Z0-9_]*)",K=/^\s*\#\s*if\s+(.+?)\s*(?:\/\/.*)?$/,Q=new RegExp(`^\\s*\\#\\s*ifdef\\s*${Y}\\s*$`),X=new RegExp(`^\\s*\\#\\s*ifndef\\s*${Y}\\s*(?:\\/\\/.*)?$`),J=/^\s*\#\s*else\s*(?:\/\/.*)?$/,ee=/^\s*\#\s*endif\s*$/,te=new RegExp(`^\\s*\\#\\s*ifdef\\s*${Y}\\s*(?:\\/\\/.*)?$`),ne=/^\s*\#\s*endif\s*(?:\/\/.*)?$/;function ie(e,t){const n=e.split("\n"),i=[],r=[];let s=!0;for(const e of n){const n=e.match(K),o=e.match(te)||e.match(Q),a=e.match(X),c=e.match(J),l=e.match(ne)||e.match(ee);if(n){const e=re(n[1],t?.defines||{}),i=s&&e;r.push({parentActive:s,branchTaken:e,active:i}),s=i}else if(o||a){const e=(o||a)?.[1],n=Boolean(t?.defines?.[e]),i=o?n:!n,c=s&&i;r.push({parentActive:s,branchTaken:i,active:c}),s=c}else if(c){const e=r[r.length-1];if(!e)throw new Error("Encountered #else without matching #if, #ifdef or #ifndef");e.active=e.parentActive&&!e.branchTaken,e.branchTaken=!0,s=e.active}else l?(r.pop(),s=!r.length||r[r.length-1].active):s&&i.push(e)}if(r.length>0)throw new Error("Unterminated conditional block in shader source");return i.join("\n")}function re(e,t){const n=e.trim();if(/^[+-]?\d+(?:\.\d+)?$/.test(n))return 0!==Number(n);if("true"===n)return!0;if("false"===n)return!1;const i=n.match(new RegExp(`^!\\s*${Y}$`));if(i)return!Boolean(t[i[1]]);const r=n.match(new RegExp(`^${Y}$`));if(r)return Boolean(t[r[1]]);const s=n.match(new RegExp(`^defined\\s*\\(\\s*${Y}\\s*\\)$`));if(s)return void 0!==t[s[1]];const o=n.match(new RegExp(`^!\\s*defined\\s*\\(\\s*${Y}\\s*\\)$`));if(o)return void 0===t[o[1]];throw new Error(`Unsupported #if expression "${e}"`)}var se=n(65219);function oe(e,t,n){const i=Object.entries(n);if(0===i.length)return{source:e,declarations:"",initialization:""};const r=function(e,t){const n=new RegExp(`\\bfn\\s+${me(t)}\\s*\\(`,"g").exec(e);if(!n)throw new Error(`ShaderPlugin vertex inputs require WGSL vertex entry point "${t}"`);const i=e.indexOf("(",n.index),r=pe(e,i,"(",")");if(r<0)throw new Error(`Unable to parse WGSL vertex entry point "${t}" parameters`);return{openParenthesis:i,closeParenthesis:r}}(e,t),s=e.slice(r.openParenthesis+1,r.closeParenthesis),o=function(e,t){const n=le(t),i=new Set(ue(t)),r=function(e){const t=[],n=/:\s*([A-Za-z_][\w]*)\b/g;let i=n.exec(e);for(;i;)t.push(i[1]),i=n.exec(e);return t}(t);for(const t of r){const r=de(e,t);if(null!==r){n.push(...le(r));for(const e of ue(r))i.add(e)}}return{locations:n,names:i}}(e,s),a=new Set(o.locations),c=[],l=[],u=[];for(const[t,n]of i){if(o.names.has(t)||he(e,t))throw new Error(`ShaderPlugin vertex input "${t}" conflicts with an existing WGSL shader input or variable`);const i=fe(a);a.add(i);const r=`_luma_${t}`;c.push(`@location(${i}) ${r}: ${n}`),l.push(`var<private> ${t}: ${n};`),u.push(`${t} = ${r};`)}const d=s.trim()?",\n ":"\n ",h=s.trim()?"":"\n",f=`${s}${d}${c.join(",\n ")}${h}`;return{source:e.slice(0,r.openParenthesis+1)+f+e.slice(r.closeParenthesis),declarations:l.join("\n"),initialization:u.join("\n")}}function ae(e){const{primitiveType:t,components:n}=se.Co.getAttributeShaderTypeInfo(e),i="i32"===t?"int":"u32"===t?"uint":"float";if(1===n)return i;return`${"int"===i?"i":"uint"===i?"u":""}vec${n}`}function ce(e,t){const n=me(t);if(new RegExp(`\\b(?:in|attribute)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${n}\\s*(?:\\[|;)`).test(e))throw new Error(`ShaderPlugin vertex input "${t}" conflicts with an existing GLSL input`)}function le(e){const t=[],n=/@location\s*\(\s*(\d+)\s*\)/g;let i=n.exec(e);for(;i;)t.push(Number(i[1])),i=n.exec(e);return t}function ue(e){const t=[],n=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm;let i=n.exec(e);for(;i;)t.push(i[1]),i=n.exec(e);return t}function de(e,t){const n=new RegExp(`\\bstruct\\s+${me(t)}\\s*\\{`,"g").exec(e);if(!n)return null;const i=e.indexOf("{",n.index),r=pe(e,i,"{","}");return r<0?null:e.slice(i+1,r)}function he(e,t){const n=me(t),i=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${n}\\b`,"g");let r=i.exec(e);for(;r;){if(0===ge(e,r.index))return!0;r=i.exec(e)}return!1}function fe(e){let t=0;for(;e.has(t);)t++;return t}function pe(e,t,n,i){let r=0,s=0,o=!1;for(let a=t;a<e.length;a++){const t=e[a],c=e[a+1];if(o)"\n"===t&&(o=!1);else if(s>0)"/"===t&&"*"===c?(s++,a++):"*"===t&&"/"===c&&(s--,a++);else if("/"!==t||"/"!==c)if("/"!==t||"*"!==c){if(t===n&&r++,t===i&&0===--r)return a}else s=1,a++;else o=!0,a++}return-1}function ge(e,t){let n=0,i=0,r=!1;for(let s=0;s<t;s++){const t=e[s],o=e[s+1];r?"\n"===t&&(r=!1):i>0?"/"===t&&"*"===o?(i++,s++):"*"===t&&"/"===o&&(i--,s++):"/"===t&&"/"===o?(r=!0,s++):"/"===t&&"*"===o?(i=1,s++):"{"===t?n++:"}"===t&&n--}return n}function me(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ve(e,t,n,i){const r=Object.entries(i);if(0===r.length)return{source:e,declarations:"",vertexInitialization:"",fragmentInitialization:""};let s=e,o=ye(s,t,"vertex");const a=function(e,t){const n=e.slice(t.closeParenthesis+1,t.openBrace),i=/->\s*([A-Za-z_][\w]*)\s*$/.exec(n.trim());if(!i||null===_e(e,i[1]))throw new Error("ShaderPlugin varyings require the WGSL vertex entry point to return a named struct");return i[1]}(s,o);let c=ye(s,n,"fragment");const l=function(e,t){const n=[];for(const i of function(e,t){const n=[];let i=0,r=0,s=0;for(let o=0;o<e.length;o++){const a=e[o];"("===a&&r++,")"===a&&r--,"<"===a&&s++,">"===a&&s--,a===t&&0===r&&0===s&&(n.push(e.slice(i,o)),i=o+1)}return n.push(e.slice(i)),n}(t.parameters,",")){const t=/(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:\s*([A-Za-z_][\w]*)\s*$/.exec(i.trim());t&&_e(e,t[2])&&n.push({name:t[1],type:t[2]})}if(1!==n.length)throw new Error(`ShaderPlugin varyings require exactly one named WGSL fragment input struct; found ${n.length}`);return n[0]}(s,c),u=be(s,a),d=be(s,l.type),h=new Set([...Ce(o.parameters),...Ce(u.body),...Ce(c.parameters),...Ce(d.body)]),f=new Set([...Pe(u.body),...Pe(d.body)]),p=[],g=[],m=[],v=[];for(const[e,t]of r){if(h.has(e)||Se(s,e))throw new Error(`ShaderPlugin varying "${e}" conflicts with existing WGSL stage I/O or a module variable`);const n=Le(f);f.add(n);const i="flat"===t.interpolation?" @interpolate(flat)":"";p.push(` @location(${n})${i} ${e}: ${t.type},`),g.push(`var<private> ${e}: ${t.type};`),m.push(`${e} = ${Ee(t.type)};`),v.push(`${e} = ${l.name}.${e};`)}!function(e,t,n,i){const r=new RegExp(`\\b${Be(t)}\\s*\\(`,"g");let s=r.exec(e);for(;s;){if(s.index<n||s.index>i)throw new Error(`ShaderPlugin varying output struct "${t}" is constructed outside the selected vertex entry point`);s=r.exec(e)}}(s,a,o.openBrace,o.closeBrace),s=function(e,t,n,i){const r=new RegExp(`\\b${Be(t)}\\s*\\(`,"g"),s=[];let o=r.exec(e);for(;o;){if(o.index>n.openBrace&&o.index<n.closeBrace){const i=e.indexOf("(",o.index),r=Me(e,i,"(",")");if(r<0||r>n.closeBrace)throw new Error(`Unable to parse WGSL output constructor "${t}"`);s.push({openParenthesis:i,closeParenthesis:r})}o=r.exec(e)}for(const t of s.sort((e,t)=>t.closeParenthesis-e.closeParenthesis)){const n=e.slice(t.openParenthesis+1,t.closeParenthesis).trim()?", ":"";e=e.slice(0,t.closeParenthesis)+n+i.join(", ")+e.slice(t.closeParenthesis)}return e}(s,a,o,r.map(([e])=>e)),o=ye(s,t,"vertex"),s=function(e,t,n){const i=function(e,t,n){const i=[];let r=t;for(;r<n;)if(r=we(e,r,n),"return"!==e.slice(r,r+6)||/[A-Za-z0-9_]/.test(e[r+6]||""))r++;else{const t=r+6,s=xe(e,t,n);if(s<0)throw new Error("Unable to parse WGSL return statement in selected vertex entry point");i.push({start:r,expressionStart:t,semicolon:s}),r=s+1}return i}(e,t.openBrace+1,t.closeBrace);for(let t=i.length-1;t>=0;t--){const r=i[t],s=e.slice(r.expressionStart,r.semicolon).trim();if(!s)throw new Error("ShaderPlugin varying vertex entry point cannot use an empty return");const o=`_luma_vertexOutput${t}`,a=n.map(e=>`${o}.${e} = ${e};`).join("\n"),c=`{\nvar ${o} = ${s};\n${a}\nreturn ${o};\n}`;e=e.slice(0,r.start)+c+e.slice(r.semicolon+1)}return e}(s,o,r.map(([e])=>e));const y=(a===l.type?[a]:[a,l.type]).map(e=>be(s,e).closeBrace).sort((e,t)=>t-e);for(const e of y)s=s.slice(0,e)+`${p.join("\n")}\n`+s.slice(e);c=ye(s,n,"fragment");if(!new RegExp(`\\b${Be(l.name)}\\s*:`).test(c.parameters))throw new Error(`Unable to preserve WGSL fragment input "${l.name}"`);return{source:s,declarations:g.join("\n"),vertexInitialization:m.join("\n"),fragmentInitialization:v.join("\n")}}function ye(e,t,n){const i=new RegExp(`\\bfn\\s+${Be(t)}\\s*\\(`,"g").exec(e);if(!i)throw new Error(`ShaderPlugin varyings require WGSL ${n} entry point "${t}"`);const r=e.indexOf("(",i.index),s=Me(e,r,"(",")"),o=e.indexOf("{",s),a=Me(e,o,"{","}");if(s<0||o<0||a<0)throw new Error(`Unable to parse WGSL ${n} entry point "${t}"`);return{openParenthesis:r,closeParenthesis:s,openBrace:o,closeBrace:a,parameters:e.slice(r+1,s)}}function be(e,t){const n=_e(e,t);if(!n)throw new Error(`Unable to find WGSL stage I/O struct "${t}"`);return n}function _e(e,t){const n=new RegExp(`\\bstruct\\s+${Be(t)}\\s*\\{`,"g").exec(e);if(!n)return null;const i=e.indexOf("{",n.index),r=Me(e,i,"{","}");return r<0?null:{openBrace:i,closeBrace:r,body:e.slice(i+1,r)}}function xe(e,t,n){let i=0,r=0;for(let s=t;s<n;s++){const t=we(e,s,n);if(t!==s){s=t-1;continue}const o=e[s];if("("===o&&i++,")"===o&&i--,"["===o&&r++,"]"===o&&r--,";"===o&&0===i&&0===r)return s}return-1}function we(e,t,n){let i=t;if("/"===e[i]&&"/"===e[i+1]){const t=e.indexOf("\n",i+2);return t<0||t>n?n:t+1}if("/"===e[i]&&"*"===e[i+1]){let t=1;for(i+=2;i<n&&t>0;)"/"===e[i]&&"*"===e[i+1]?(t++,i+=2):"*"===e[i]&&"/"===e[i+1]?(t--,i+=2):i++}return i}function Pe(e){const t=[],n=/@location\s*\(\s*(\d+)\s*\)/g;let i=n.exec(e);for(;i;)t.push(Number(i[1])),i=n.exec(e);return t}function Ce(e){const t=[],n=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm;let i=n.exec(e);for(;i;)t.push(i[1]),i=n.exec(e);return t}function Se(e,t){const n=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${Be(t)}\\b`,"g");let i=n.exec(e);for(;i;){if(0===Ie(e,i.index))return!0;i=n.exec(e)}return!1}function Le(e){let t=0;for(;e.has(t);)t++;return t}function Ae(e){const{primitiveType:t,components:n}=se.Co.getAttributeShaderTypeInfo(e),i="u32"===t?"0u":"i32"===t?"0":"0.0";return 1===n?i:`${ae(e)}(${i})`}function Ee(e){const{primitiveType:t,components:n}=se.Co.getAttributeShaderTypeInfo(e),i=`${t}(0)`;return 1===n?i:`${e}(${i})`}function Te(e,t){if(new RegExp(`\\b(?:flat\\s+|smooth\\s+)?(?:in|out|varying)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${Be(t)}\\s*(?:\\[|;)`).test(e))throw new Error(`ShaderPlugin varying "${t}" conflicts with existing GLSL stage I/O`)}function Me(e,t,n,i){let r=0,s=0,o=!1;for(let a=t;a<e.length;a++){const t=e[a],c=e[a+1];if(o)"\n"===t&&(o=!1);else if(s>0)"/"===t&&"*"===c?(s++,a++):"*"===t&&"/"===c&&(s--,a++);else if("/"!==t||"/"!==c)if("/"!==t||"*"!==c){if(t===n&&r++,t===i&&0===--r)return a}else s=1,a++;else o=!0,a++}return-1}function Ie(e,t){let n=0;for(let i=0;i<t;i++){const r=we(e,i,t);r===i?("{"===e[i]&&n++,"}"===e[i]&&n--):i=r-1}return n}function Be(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const ke=`\n\n${s.O_}\n`,Re=100;function Oe(e){const t=(0,r.$Q)(e.modules||[]),{source:n,bindingAssignments:o}=function(e,t){const{source:n,stage:r,modules:o,defines:a={},hookFunctions:c=[],inject:l={},pluginInjections:u={},pluginVertexInputs:d={},pluginVaryings:g={},vertexEntryPoint:m="vertexMain",fragmentEntryPoint:v="fragmentMain",log:y}=t;(0,p.v)("string"==typeof n,"shader source must be a string");const P=ie(n,{defines:a}),A=oe(P,m,d),E=ve(A.source,m,v,g),T=E.source;let M="";const I=f(c),B={},k={},R={};Fe(u,B,k,R);for(const e in l){const t="string"==typeof l[e]?{injection:l[e],order:0}:l[e],n=/^(v|f)s:(#)?([\w-]+)$/.exec(e);if(n){const i=n[2],r=n[3];i?"decl"===r?k[e]=[t]:R[e]=[t]:B[e]=[t]}else R[e]=[t]}(function(e,t,n,i){e&&(n["vs:#decl"]=n["vs:#decl"]||[],n["vs:#decl"].push({injection:e,order:Number.MIN_SAFE_INTEGER}));t&&(i["vs:#main-start"]=i["vs:#main-start"]||[],i["vs:#main-start"].push({injection:t,order:Number.MIN_SAFE_INTEGER}))})(A.declarations,A.initialization,k,R),function(e,t,n){e.declarations&&(t["vs:#decl"]=t["vs:#decl"]||[],t["vs:#decl"].push({injection:e.declarations,order:Number.MIN_SAFE_INTEGER}));e.vertexInitialization&&(n["vs:#main-start"]=n["vs:#main-start"]||[],n["vs:#main-start"].push({injection:e.vertexInitialization,order:Number.MIN_SAFE_INTEGER}));e.fragmentInitialization&&(n["fs:#main-start"]=n["fs:#main-start"]||[],n["fs:#main-start"].push({injection:e.fragmentInitialization,order:Number.MIN_SAFE_INTEGER}))}(E,k,R);const O=o,z=function(e){const t=C(e,_),n=new Map;for(const e of t){if("auto"===e.bindingToken)continue;const t=Number(e.bindingToken),i=Number(e.groupToken);Ge(i,t,e.name),We(n,i,t,`application binding "${e.name}"`)}const i={sawSupportedBindingDeclaration:t.length>0},r=S(e,_,e=>function(e,t,n){const{match:i,bindingToken:r,groupToken:s,name:o}=e,a=Number(s);if("auto"===r){const e=function(e,t){const n=t.get(e)||new Set;let i=0;for(;n.has(i);)i++;return i}(a,t);return Ge(a,e,o),We(t,a,e,`application binding "${o}"`),i.replace(/@binding\(\s*auto\s*\)/,`@binding(${e})`)}return n.sawSupportedBindingDeclaration=!0,i}(e,n,i));if(L(e)&&!i.sawSupportedBindingDeclaration)throw new Error('Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.');return{source:r}}(T),D=function(e){const t=new Map;for(const n of C(e,x)){const e=Number(n.bindingToken),i=Number(n.groupToken);Ge(i,e,n.name),We(t,i,e,`application binding "${n.name}"`)}return t}(z.source),F=function(e,t,n,i){const r=new Map;if(!t)return r;for(const s of e)for(const e of Ve(s,i)){const i=He(e.group,s.name,e.name),o=t.get(i);if(void 0!==o){const t=r.get(e.group)||new Map,s=t.get(o);if(s&&s!==i)throw new Error(`Duplicate WGSL binding reservation for modules "${s}" and "${i}": group ${e.group}, binding ${o}.`);We(n,e.group,o,`registered module binding "${i}"`),t.set(o,i),r.set(e.group,t)}}return r}(O,t._bindingRegistry,D,a),N=[];for(const e of O){y&&(0,i.ZG)(e,T,y);const n=Ue(ie($e(e,"wgsl",y),{defines:a}),e,{usedBindingsByGroup:D,bindingRegistry:t._bindingRegistry,reservedBindingKeysByGroup:F});N.push(...n.bindingAssignments);M+=n.source;const r=Ne(e);for(const e in r){const t=/^(v|f)s:#([\w-]+)$/.exec(e);if(t){const n="decl"===t[2]?k:R;n[e]=n[e]||[],n[e].push(r[e])}else B[e]=B[e]||[],B[e].push(r[e])}}return M+=ke,M=(0,s.bv)(M,r,function(e){const t=[...e["vs:#decl"]||[],...e["fs:#decl"]||[]];return t.length?{"vs:#decl":t}:{}}(k),!1,"wgsl",{vertex:m,fragment:v}),M+=function(e,t){return h(e.vertex,t,"wgsl")+h(e.fragment,t,"wgsl")}(I,B),M+=function(e){if(0===e.length)return"";let t="// ----- MODULE WGSL BINDING ASSIGNMENTS ---------------\n";for(const n of e)t+=`// ${n.moduleName}.${n.name} -> @group(${n.group}) @binding(${n.location})\n`;return t+="\n",t}(N),M+=z.source,M=(0,s.bv)(M,r,R,!1,"wgsl",{vertex:m,fragment:v}),function(e){const t=function(e,t){return C(e,t===b||t===_?w:t).find(e=>"auto"===e.bindingToken)}(e,b);if(!t)return;const n=function(e,t){const n=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm;let i,r;r=n.exec(e);for(;r&&r.index<=t;)i=r[1],r=n.exec(e);return i}(e,t.index);if(n)throw new Error(`Unresolved @binding(auto) for module "${n}" binding "${t.name}" remained in assembled WGSL source.`);if(function(e,t){const n=e.indexOf(ke);return!(n>=0)||t>n}(e,t.index))throw new Error(`Unresolved @binding(auto) for application binding "${t.name}" remained in assembled WGSL source.`);throw new Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${function(e){return e.replace(/\s+/g," ").trim()}(t.match)}".`)}(M),{source:M,bindingAssignments:N}}(e.platformInfo,{...e,source:e.source,stage:"vertex",modules:t});return{source:n,getUniforms:De(t),bindingAssignments:o,bindingTable:E(n,o),shaderLayout:R(n,{vertexEntryPoint:e.vertexEntryPoint,scanVertexAttributes:e.scanVertexAttributes})}}function ze(e,t){const{source:n,stage:r,language:o="glsl",modules:u,defines:v={},hookFunctions:y=[],inject:b={},pluginInjections:_={},pluginVertexInputs:x={},pluginVaryings:w={},prologue:P=!0,log:C}=t;(0,p.v)("string"==typeof n,"shader source must be a string");const S="glsl"===o?function(e,t){return{name:g(e,t),language:"glsl",version:m(e)}}(n).version:-1,L=e.shaderLanguageVersion,A=100===S?"#version 100":"#version 300 es",E=n.split("\n").slice(1).join("\n"),T={};u.forEach(e=>{Object.assign(T,e.defines)}),Object.assign(T,v);let M="";switch(o){case"wgsl":break;case"glsl":M=P?`${A}\n\n// ----- PROLOGUE -------------------------\n#define SHADER_TYPE_${r.toUpperCase()}\n\n${function(e){switch(e?.gpu.toLowerCase()){case"apple":return"#define APPLE_GPU\n// Apple optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"nvidia":return"#define NVIDIA_GPU\n// Nvidia optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n";case"intel":return"#define INTEL_GPU\n// Intel optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n// Intel's built-in 'tan' function doesn't have acceptable precision\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"amd":return"#define AMD_GPU\n";default:return"#define DEFAULT_GPU\n// Prevent driver from optimizing away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n// Headless Chrome's software shader 'tan' function doesn't have acceptable precision\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// If the GPU doesn't have full 32 bits precision, will causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n"}}(e)}\n${"fragment"===r?"precision highp float;\n":""}\n\n// ----- APPLICATION DEFINES -------------------------\n\n${function(e={}){let t="";for(const n in e){const i=e[n];(i||Number.isFinite(i))&&(t+=`#define ${n.toUpperCase()} ${e[n]}\n`)}return t}(T)}\n\n`:`${A}\n`}const I=f(y),B={},k={},R={};Fe(_,B,k,R);for(const e in b){const t="string"==typeof b[e]?{injection:b[e],order:0}:b[e],n=/^(v|f)s:(#)?([\w-]+)$/.exec(e);if(n){const i=n[2],r=n[3];i?"decl"===r?k[e]=[t]:R[e]=[t]:B[e]=[t]}else R[e]=[t]}if("vertex"===r){const e=function(e,t){const n=[];for(const[i,r]of Object.entries(t))ce(e,i),n.push(`in ${ae(r)} ${i};`);return n.join("\n")}(E,x);e&&(k["vs:#decl"]=k["vs:#decl"]||[],k["vs:#decl"].push({injection:e,order:Number.MIN_SAFE_INTEGER}))}const O=function(e,t,n){const i=[],r=[];for(const[s,o]of Object.entries(n)){Te(e,s);const n="flat"===o.interpolation?"flat ":"",a="vertex"===t?"out":"in";i.push(`${n}${a} ${ae(o.type)} ${s};`),"vertex"===t&&r.push(`${s} = ${Ae(o.type)};`)}return{declarations:i.join("\n"),initialization:r.join("\n")}}(E,r,w);if(O.declarations){const e="vertex"===r?"vs:#decl":"fs:#decl";k[e]=k[e]||[],k[e].push({injection:O.declarations,order:Number.MIN_SAFE_INTEGER})}O.initialization&&(R["vs:#main-start"]=R["vs:#main-start"]||[],R["vs:#main-start"].push({injection:O.initialization,order:Number.MIN_SAFE_INTEGER}));for(const e of u){C&&(0,i.ZG)(e,E,C);M+=$e(e,r,C);const t=e.instance?.normalizedInjections[r]||{};for(const e in t){const n=/^(v|f)s:#([\w-]+)$/.exec(e);if(n){const i="decl"===n[2]?k:R;i[e]=i[e]||[],i[e].push(t[e])}else B[e]=B[e]||[],B[e].push(t[e])}}return M+="// ----- MAIN SHADER SOURCE -------------------------",M+=ke,M=(0,s.bv)(M,r,k),M+=h(I[r],B),M+=E,M=(0,s.bv)(M,r,R),"glsl"===o&&S!==L&&(M=function(e,t){if(300!==Number(e.match(/^#version[ \t]+(\d+)/m)?.[1]||100))throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(t){case"vertex":return l(e,a);case"fragment":return l(e,c);default:throw new Error(t)}}(M,r)),"glsl"===o&&(0,d.N1)(M,r,C),M.trim()}function De(e){return function(t){const n={};for(const i of e){const e=i.getUniforms?.(t,n);Object.assign(n,e)}return n}}function Fe(e,t,n,i){for(const r in e){const s=/^(v|f)s:(#)?([\w-]+)$/.exec(r);if(s){const o=s[2],a=s[3],c=o?"decl"===a?n:i:t;c[r]=c[r]||[],c[r].push(...e[r])}else i[r]=i[r]||[],i[r].push(...e[r])}}function Ne(e){return{...e.instance?.normalizedInjections.vertex||{},...e.instance?.normalizedInjections.fragment||{}}}function $e(e,t,n){let i;switch(t){case"vertex":i=e.vs||"";break;case"fragment":i=e.fs||"";break;case"wgsl":i=e.source||"";break;default:(0,p.v)(!1)}if(!e.name)throw new Error("Shader module must have a name");(0,d.mY)(e,t,{log:n});const r=e.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");let s=`// ----- MODULE ${e.name} ---------------\n\n`;return"wgsl"!==t&&(s+=`#define MODULE_${r}\n`),s+=`${i}\n`,s}function Ue(e,t,n){const i=[],r={sawSupportedBindingDeclaration:C(e,b).length>0,nextHintedBindingLocation:"number"==typeof t.firstBindingSlot?t.firstBindingSlot:null},s=S(e,b,e=>function(e,t){const{module:n,context:i,bindingAssignments:r,relocationState:s}=t,{match:o,bindingToken:a,groupToken:c,name:l}=e,u=Number(c);if("auto"===a){const e=He(u,n.name,l),t=i.bindingRegistry?.get(e),a=void 0!==t?t:function(e,t,n,i,r){const s=t.get(e)||new Set,o=new Set,a=`${e}:`,c=`${a}${n}:`;for(const[e,t]of r||[])e.startsWith(c)&&o.add(t);let l=i??(0===e?Re:s.size>0?Math.max(...s)+1:0);for(;s.has(l)||o.has(l);)l++;for(const[e,t]of r||[])t===l&&e.startsWith(a)&&r?.delete(e);return l}(u,i.usedBindingsByGroup,n.name,s.nextHintedBindingLocation??void 0,i.bindingRegistry);return je(n.name,u,a,l),void 0!==t&&function(e,t,n,i){const r=e.get(t);if(!r)return!1;const s=r.get(n);if(!s)return!1;if(s!==i)throw new Error(`Registered module binding "${i}" collided with "${s}": group ${t}, binding ${n}.`);return!0}(i.reservedBindingKeysByGroup,u,a,e)?(r.push({moduleName:n.name,name:l,group:u,location:a}),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${a})`)):(We(i.usedBindingsByGroup,u,a,`module "${n.name}" binding "${l}"`),i.bindingRegistry?.set(e,a),r.push({moduleName:n.name,name:l,group:u,location:a}),null!==s.nextHintedBindingLocation&&void 0===t&&(s.nextHintedBindingLocation=a+1),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${a})`))}const d=Number(a);return je(n.name,u,d,l),We(i.usedBindingsByGroup,u,d,`module "${n.name}" binding "${l}"`),r.push({moduleName:n.name,name:l,group:u,location:d}),o}(e,{module:t,context:n,bindingAssignments:i,relocationState:r}));if(L(e)&&!r.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${t.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:s,bindingAssignments:i}}function Ve(e,t){const n=[],i=ie(e.source||"",{defines:t});for(const e of C(i,b))n.push({name:e.name,group:Number(e.groupToken)});return n}function Ge(e,t,n){if(0===e&&t>=Re)throw new Error(`Application binding "${n}" in group 0 uses reserved binding ${t}. Application-owned explicit group-0 bindings must stay below 100.`)}function je(e,t,n,i){if(0===t&&n<Re)throw new Error(`Module "${e}" binding "${i}" in group 0 uses reserved application binding ${n}. Module-owned explicit group-0 bindings must be 100 or higher.`)}function We(e,t,n,i){const r=e.get(t)||new Set;if(r.has(n))throw new Error(`Duplicate WGSL binding assignment for ${i}: group ${t}, binding ${n}.`);r.add(n),e.set(t,r)}function He(e,t,n){return`${e}:${t}:${n}`}class ShaderAssembler{static defaultShaderAssemblers={};_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(e){return(0,p.v)("glsl"===e||"wgsl"===e),"wgsl"===e?(ShaderAssembler.defaultShaderAssemblers.wgsl=ShaderAssembler.defaultShaderAssemblers.wgsl||new WGSLShaderAssembler,ShaderAssembler.defaultShaderAssemblers.wgsl):(ShaderAssembler.defaultShaderAssemblers.glsl=ShaderAssembler.defaultShaderAssemblers.glsl||new GLSLShaderAssembler,ShaderAssembler.defaultShaderAssemblers.glsl)}addDefaultModule(e){this._defaultModules.find(t=>t.name===("string"==typeof e?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){const t="string"==typeof e?e:e.name;this._defaultModules=this._defaultModules.filter(e=>e.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}_getModuleList(e=[]){const t=new Array(this._defaultModules.length+e.length),n={};let r=0;for(let e=0,i=this._defaultModules.length;e<i;++e){const i=this._defaultModules[e],s=i.name;t[r++]=i,n[s]=!0}for(let i=0,s=e.length;i<s;++i){const s=e[i],o=s.name;n[o]||(t[r++]=s,n[o]=!0)}return t.length=r,(0,i.$g)(t),t}}class GLSLShaderAssembler extends ShaderAssembler{shaderLanguage="glsl";assembleGLSLShaderPair(e){const t=this._getModuleList(e.modules),n=this._hookFunctions,i=function(e){const{vs:t,fs:n}=e,i=(0,r.$Q)(e.modules||[]);return{vs:ze(e.platformInfo,{...e,source:t,stage:"vertex",modules:i}),fs:ze(e.platformInfo,{...e,source:n,stage:"fragment",modules:i}),getUniforms:De(i)}}({...e,vs:e.vs,fs:e.fs,modules:t,hookFunctions:n});return{...i,modules:t}}}class WGSLShaderAssembler extends ShaderAssembler{shaderLanguage="wgsl";_wgslBindingRegistry=new Map;assembleWGSLShader(e){const t=this._getModuleList(e.modules),n=this._hookFunctions,i=WGSLShaderAssembler.getShaderPreprocessorDefines(e,t),r="wgsl"===e.platformInfo.shaderLanguage&&e.source?ie(e.source,{defines:i}):e.source,{source:s,getUniforms:o,bindingAssignments:a}=Oe({...e,source:r,defines:i,_bindingRegistry:this._wgslBindingRegistry,modules:t,hookFunctions:n}),c="wgsl"===e.platformInfo.shaderLanguage?ie(s,{defines:i}):s;return{source:c,getUniforms:o,modules:t,bindingAssignments:a,bindingTable:E(c,a),shaderLayout:R(c,{vertexEntryPoint:e.vertexEntryPoint,scanVertexAttributes:e.scanVertexAttributes})}}static getShaderPreprocessorDefines(e,t){return{...WGSLShaderAssembler.getPlatformPreprocessorDefines(e.platformInfo),...t.reduce((e,t)=>(Object.assign(e,t.defines),e),{}),...e.defines}}static getPlatformPreprocessorDefines(e){const t=e.limits||{};return{LUMA_SUPPORTS_VERTEX_STORAGE_BUFFERS:"webgpu"===e.type&&(t.maxStorageBuffersInVertexStage||0)>0,LUMA_FP32_TAN_PRECISION_WORKAROUND:"webgpu"===e.type&&"nvidia"!==e.gpu.toLowerCase()&&"amd"!==e.gpu.toLowerCase(),LUMA_FP64_INTEGER_ARITHMETIC:"webgpu"===e.type&&"apple"===e.gpu.toLowerCase()}}}},48377(e,t,n){n.d(t,{O_:()=>a,bv:()=>u,Uu:()=>c});const i={vertex:"#ifdef MODULE_LOGDEPTH\n logdepth_adjustPosition(gl_Position);\n#endif\n",fragment:"#ifdef MODULE_MATERIAL\n fragColor = material_filterColor(fragColor);\n#endif\n\n#ifdef MODULE_LIGHTING\n fragColor = lighting_filterColor(fragColor);\n#endif\n\n#ifdef MODULE_FOG\n fragColor = fog_filterColor(fragColor);\n#endif\n\n#ifdef MODULE_PICKING\n fragColor = picking_filterHighlightColor(fragColor);\n fragColor = picking_filterPickingColor(fragColor);\n#endif\n\n#ifdef MODULE_LOGDEPTH\n logdepth_setFragDepth();\n#endif\n"},r=/void\s+main\s*\([^)]*\)\s*\{\n?/,s=/}\n?[^{}]*$/,o=[],a="__LUMA_INJECT_DECLARATIONS__";function c(e){const t={vertex:{},fragment:{}};for(const n in e){let i=e[n];"string"==typeof i&&(i={order:0,injection:i}),t[l(n)][n]=i}return t}function l(e){const t=e.slice(0,2);switch(t){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(t)}}function u(e,t,n,c=!1,l="glsl",u={}){const h="vertex"===t;for(const t in n){const i=n[t];i.sort((e,t)=>e.order-t.order),o.length=i.length;for(let e=0,t=i.length;e<t;++e)o[e]=i[e].injection;const c=`${o.join("\n")}\n`;switch(t){case"vs:#decl":("wgsl"===l||h)&&(e=e.replace(a,c));break;case"vs:#main-start":("wgsl"===l||h)&&(e="wgsl"===l?d(e,"vertex",c,"start",u.vertex):e.replace(r,e=>e+c));break;case"vs:#main-end":("wgsl"===l||h)&&(e="wgsl"===l?d(e,"vertex",c,"end",u.vertex):e.replace(s,e=>c+e));break;case"fs:#decl":"wgsl"!==l&&h||(e=e.replace(a,c));break;case"fs:#main-start":"wgsl"!==l&&h||(e="wgsl"===l?d(e,"fragment",c,"start",u.fragment):e.replace(r,e=>e+c));break;case"fs:#main-end":"wgsl"!==l&&h||(e="wgsl"===l?d(e,"fragment",c,"end",u.fragment):e.replace(s,e=>c+e));break;default:e=e.replace(t,e=>e+c)}}return e=e.replace(a,""),c&&(e=e.replace(/\}\s*$/,e=>e+i[t])),e}function d(e,t,n,i,r){const s=function(e,t,n){const i="vertex"===t?"@vertex":"@fragment",r=e.indexOf(i);if(r<0)return null;const s=n?e.search(new RegExp(`\\bfn\\s+${o=n,o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`)):e.indexOf("fn",r);var o;if(s<0)return null;const a=e.indexOf("{",s);if(a<0)return null;let c=0;for(let t=a;t<e.length;t++){const n=e[t];if("{"===n)c++;else if("}"===n&&(c--,0===c))return{openBraceIndex:a,closeBraceIndex:t}}return null}(e,t,r);if(!s)return e;if("start"===i){const t=s.openBraceIndex+1;return`${e.slice(0,t)}\n${n}${e.slice(t)}`}return`${e.slice(0,s.closeBraceIndex)}${n}${e.slice(s.closeBraceIndex)}`}},35185(e,t,n){n.d(t,{$Q:()=>r});var i=n(16094);function r(e){(0,i.$g)(e);const t={},n={};s({modules:e,level:0,moduleMap:t,moduleDepth:n});const r=Object.keys(n).sort((e,t)=>n[t]-n[e]).map(e=>t[e]);return(0,i.$g)(r),r}function s(e){const{modules:t,level:n,moduleMap:i,moduleDepth:r}=e;if(n>=5)throw new Error("Possible loop in shader dependency graph");for(const e of t)i[e.name]=e,(void 0===r[e.name]||r[e.name]<n)&&(r[e.name]=n);for(const e of t)e.dependencies&&s({modules:e.dependencies,level:n+1,moduleMap:i,moduleDepth:r})}},88153(e,t,n){n.d(t,{N1:()=>u,Uj:()=>o,V$:()=>l,mY:()=>c});var i=n(68074);const r=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,s=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g;function o(e){return`${e.name}Uniforms`}function a(e,t){const n="wgsl"===t?e.source:"vertex"===t?e.vs:e.fs;if(!n)return null;return function(e,t,n){const i="wgsl"===t?function(e,t){const n=new RegExp(`\\bstruct\\s+${t}\\b`,"m").exec(e);if(!n)return null;const i=e.indexOf("{",n.index);if(i<0)return null;let r=0;for(let t=i;t<e.length;t++){const n=e[t];if("{"!==n){if("}"===n&&(r--,0===r))return e.slice(i+1,t)}else r++}return null}(e,n):function(e,t){const n=l(e).find(e=>e.blockName===t);return n?.body||null}(e,n);if(!i)return null;const s=[];for(const e of i.split("\n")){const n=e.replace(/\/\/.*$/,"").trim();if(!n||n.startsWith("#"))continue;const i="wgsl"===t?n.match(/^([A-Za-z0-9_]+)\s*:/):n.match(r);i&&s.push(i[1])}return s}(n,"wgsl"===t?"wgsl":"glsl",o(e))}function c(e,t,n={}){const r=function(e,t){const n=Object.keys(e.uniformTypes||{});if(!n.length)return null;const i=a(e,t);return i?{moduleName:e.name,uniformBlockName:o(e),stage:t,expectedUniformNames:n,actualUniformNames:i,matches:d(n,i)}:null}(e,t);if(!r||r.matches)return r;const s=function(e){const{expectedUniformNames:t,actualUniformNames:n}=e,i=t.filter(e=>!n.includes(e)),r=n.filter(e=>!t.includes(e)),s=[`Expected ${t.length} fields, found ${n.length}.`],o=function(e,t){const n=Math.min(e.length,t.length);for(let i=0;i<n;i++)if(e[i]!==t[i])return`First mismatch at field ${i+1}: expected ${e[i]}, found ${t[i]}.`;if(e.length>t.length)return`Shader block ends after field ${t.length}; expected next field ${e[t.length]}.`;if(t.length>e.length)return`Shader block has extra field ${t.length}: ${t[e.length]}.`;return null}(t,n);o&&s.push(o);i.length&&s.push(`Missing from shader block (${i.length}): ${f(i)}.`);r.length&&s.push(`Unexpected in shader block (${r.length}): ${f(r)}.`);t.length<=12&&n.length<=12&&(i.length||r.length)&&(s.push(`Expected: ${t.join(", ")}.`),s.push(`Actual: ${n.join(", ")}.`));return`${e.moduleName}: ${e.stage} shader uniform block ${e.uniformBlockName} does not match module.uniformTypes. ${s.join(" ")}`}(r);return n.log?.error?.(s,r)(),!1!==n.throwOnError&&(0,i.v)(!1,s),r}function l(e){const t=[],n=function(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}(e);for(const e of n.matchAll(s)){const n=e[1]?.trim()||null;t.push({blockName:e[2],body:e[3],instanceName:e[4]||null,layoutQualifier:n,hasLayoutQualifier:Boolean(n),isStd140:Boolean(n&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(n))})}return t}function u(e,t,n,i){const r=l(e).filter(e=>!e.isStd140),s=new Set;for(const e of r){if(s.has(e.blockName))continue;s.add(e.blockName);const r=i?.label?`${i.label} `:"",o=e.hasLayoutQualifier?`declares ${h(e.layoutQualifier)} instead of layout(std140)`:"does not declare layout(std140)",a=`${r}${t} shader uniform block ${e.blockName} ${o}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;n?.warn?.(a,e)()}return r}function d(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function h(e){return e.replace(/\s+/g," ").trim()}function f(e,t=8){if(e.length<=t)return e.join(", ");const n=e.length-t;return`${e.slice(0,t).join(", ")}, ... (${n} more)`}},16094(e,t,n){n.d(t,{ZG:()=>l,$g:()=>a});const i={number:{type:"number",validate:(e,t)=>Number.isFinite(e)&&"object"==typeof t&&(void 0===t.max||e<=t.max)&&(void 0===t.min||e>=t.min)},array:{type:"array",validate:(e,t)=>Array.isArray(e)||ArrayBuffer.isView(e)}};function r(e){let t=s(e);if("object"!==t)return{value:e,...i[t],type:t};if("object"==typeof e)return e?void 0!==e.type?{...e,...i[e.type],type:e.type}:void 0===e.value?{type:"object",value:e}:(t=s(e.value),{...e,...i[t],type:t}):{type:"object",value:null};throw new Error("props")}function s(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}var o=n(48377);function a(e){e.map(e=>c(e))}function c(e){if(e.instance)return;a(e.dependencies||[]);const{propTypes:t={},deprecations:n=[],inject:i={}}=e,s={normalizedInjections:(0,o.Uu)(i),parsedDeprecations:u(n)};t&&(s.propValidators=function(e){const t={};for(const[n,i]of Object.entries(e))t[n]=r(i);return t}(t)),e.instance=s;let c={};t&&(c=Object.entries(t).reduce((e,[t,n])=>{const i=n?.value;return i&&(e[t]=i),e},{})),e.defaultUniforms={...e.defaultUniforms,...c}}function l(e,t,n){e.deprecations?.forEach(e=>{e.regex?.test(t)&&(e.deprecated?n.deprecated(e.old,e.new)():n.removed(e.old,e.new)())})}function u(e){return e.forEach(e=>{if("function"===e.type)e.regex=new RegExp(`\\b${e.old}\\(`);else e.regex=new RegExp(`${e.type} ${e.old};`)}),e}},33823(e,t,n){n.d(t,{K:()=>o,r:()=>s});var i=n(65219);const r=/^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][\w-]*)$/;function s(e=[],t){const n=[],i={},r={},s={},o={};for(const c of e)a({modules:n,defines:i,injections:r,vertexInputs:s,varyings:o},c),a({modules:n,defines:i,injections:r,vertexInputs:s,varyings:o},c[t]);for(const e of Object.keys(o))if(s[e])throw new Error(`ShaderPlugin name "${e}" cannot be both a vertex input and a varying`);return{modules:n,defines:i,injections:r,vertexInputs:s,varyings:o}}function o(e=[],t=[]){const n=[...e],i=new Set(n.map(e=>e.name));for(const e of t)i.has(e.name)||(n.push(e),i.add(e.name));return n}function a(e,t){if(t){t.modules?.length&&e.modules.push(...t.modules),t.defines&&Object.assign(e.defines,t.defines);for(const[n,i]of Object.entries(t.vertexInputs||{})){c(n,"vertex input");const t=e.vertexInputs[n];if(t&&t!==i)throw new Error(`ShaderPlugin vertex input "${n}" has conflicting types "${t}" and "${i}"`);e.vertexInputs[n]=i}for(const[n,i]of Object.entries(t.varyings||{})){c(n,"varying");const t=l(n,i),r=e.varyings[n];if(r&&(r.type!==t.type||r.interpolation!==t.interpolation))throw new Error(`ShaderPlugin varying "${n}" has conflicting declarations "${r.type}/${r.interpolation}" and "${t.type}/${t.interpolation}"`);e.varyings[n]=t}for(const n of t.injections||[]){u(n.target),e.injections[n.target]||(e.injections[n.target]=[]);e.injections[n.target].push({injection:n.injection,order:n.order??0})}}}function c(e,t){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)||e.startsWith("_luma_"))throw new Error(`ShaderPlugin ${t} "${e}" must be a valid non-reserved identifier`)}function l(e,t){const{primitiveType:n}=i.Co.getAttributeShaderTypeInfo(t.type),r="i32"===n||"u32"===n,s=t.interpolation||(r?"flat":"smooth");if(r&&"smooth"===s)throw new Error(`ShaderPlugin integer varying "${e}" must use flat interpolation`);return{type:t.type,interpolation:s}}function u(e){if(!r.test(e))throw new Error(`ShaderPlugin injection target "${e}" must be a named shader anchor or hook`)}},68074(e,t,n){function i(e,t){if(!e){const e=new Error(t||"shadertools: assertion failed.");throw Error.captureStackTrace?.(e,i),e}}n.d(t,{v:()=>i})},8719(e,t,n){n.d(t,{WebGLDevice:()=>WebGLDevice});var i=n(77296),r=n(29651);const s={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},o=(e,t,n)=>t?e.enable(n):e.disable(n),a=(e,t,n)=>e.hint(n,t),c=(e,t,n)=>e.pixelStorei(n,t),l=(e,t,n)=>{const i=36006===n?36009:36008;return e.bindFramebuffer(i,t)},u=(e,t,n)=>{const i={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[n];e.bindBuffer(i,t)};function d(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}const h={3042:o,32773:(e,t)=>e.blendColor(...t),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(e,t)=>e.clearColor(...t),3107:(e,t)=>e.colorMask(...t),2884:o,2885:(e,t)=>e.cullFace(t),2929:o,2931:(e,t)=>e.clearDepth(t),2932:(e,t)=>e.depthFunc(t),2928:(e,t)=>e.depthRange(...t),2930:(e,t)=>e.depthMask(t),3024:o,35723:a,35725:(e,t)=>e.useProgram(t),36007:(e,t)=>e.bindRenderbuffer(36161,t),36389:(e,t)=>e.bindTransformFeedback?.(36386,t),34229:(e,t)=>e.bindVertexArray(t),36006:l,36010:l,34964:u,36662:u,36663:u,35053:u,35055:u,2886:(e,t)=>e.frontFace(t),33170:a,2849:(e,t)=>e.lineWidth(t),32823:o,32824:"polygonOffset",10752:"polygonOffset",35977:o,32926:o,32928:o,32938:"sampleCoverage",32939:"sampleCoverage",3089:o,3088:(e,t)=>e.scissor(...t),2960:o,2961:(e,t)=>e.clearStencil(t),2968:(e,t)=>e.stencilMaskSeparate(1028,t),36005:(e,t)=>e.stencilMaskSeparate(1029,t),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(e,t)=>e.viewport(...t),34383:o,10754:o,12288:o,12289:o,12290:o,12291:o,12292:o,12293:o,12294:o,12295:o,3333:c,3317:c,37440:c,37441:c,37443:c,3330:c,3332:c,3331:c,3314:c,32878:c,3316:c,3315:c,32877:c,framebuffer:(e,t)=>{const n=t&&"handle"in t?t.handle:t;return e.bindFramebuffer(36160,n)},blend:(e,t)=>t?e.enable(3042):e.disable(3042),blendColor:(e,t)=>e.blendColor(...t),blendEquation:(e,t)=>{const n="number"==typeof t?[t,t]:t;e.blendEquationSeparate(...n)},blendFunc:(e,t)=>{const n=2===t?.length?[...t,...t]:t;e.blendFuncSeparate(...n)},clearColor:(e,t)=>e.clearColor(...t),clearDepth:(e,t)=>e.clearDepth(t),clearStencil:(e,t)=>e.clearStencil(t),colorMask:(e,t)=>e.colorMask(...t),cull:(e,t)=>t?e.enable(2884):e.disable(2884),cullFace:(e,t)=>e.cullFace(t),depthTest:(e,t)=>t?e.enable(2929):e.disable(2929),depthFunc:(e,t)=>e.depthFunc(t),depthMask:(e,t)=>e.depthMask(t),depthRange:(e,t)=>e.depthRange(...t),dither:(e,t)=>t?e.enable(3024):e.disable(3024),derivativeHint:(e,t)=>{e.hint(35723,t)},frontFace:(e,t)=>e.frontFace(t),mipmapHint:(e,t)=>e.hint(33170,t),lineWidth:(e,t)=>e.lineWidth(t),polygonOffsetFill:(e,t)=>t?e.enable(32823):e.disable(32823),polygonOffset:(e,t)=>e.polygonOffset(...t),sampleCoverage:(e,t)=>e.sampleCoverage(t[0],t[1]||!1),scissorTest:(e,t)=>t?e.enable(3089):e.disable(3089),scissor:(e,t)=>e.scissor(...t),stencilTest:(e,t)=>t?e.enable(2960):e.disable(2960),stencilMask:(e,t)=>{t=d(t)?t:[t,t];const[n,i]=t;e.stencilMaskSeparate(1028,n),e.stencilMaskSeparate(1029,i)},stencilFunc:(e,t)=>{t=d(t)&&3===t.length?[...t,...t]:t;const[n,i,r,s,o,a]=t;e.stencilFuncSeparate(1028,n,i,r),e.stencilFuncSeparate(1029,s,o,a)},stencilOp:(e,t)=>{t=d(t)&&3===t.length?[...t,...t]:t;const[n,i,r,s,o,a]=t;e.stencilOpSeparate(1028,n,i,r),e.stencilOpSeparate(1029,s,o,a)},viewport:(e,t)=>e.viewport(...t)};function f(e,t,n){return void 0!==t[e]?t[e]:n[e]}const p={blendEquation:(e,t,n)=>e.blendEquationSeparate(f(32777,t,n),f(34877,t,n)),blendFunc:(e,t,n)=>e.blendFuncSeparate(f(32969,t,n),f(32968,t,n),f(32971,t,n),f(32970,t,n)),polygonOffset:(e,t,n)=>e.polygonOffset(f(32824,t,n),f(10752,t,n)),sampleCoverage:(e,t,n)=>e.sampleCoverage(f(32938,t,n),f(32939,t,n)),stencilFuncFront:(e,t,n)=>e.stencilFuncSeparate(1028,f(2962,t,n),f(2967,t,n),f(2963,t,n)),stencilFuncBack:(e,t,n)=>e.stencilFuncSeparate(1029,f(34816,t,n),f(36003,t,n),f(36004,t,n)),stencilOpFront:(e,t,n)=>e.stencilOpSeparate(1028,f(2964,t,n),f(2965,t,n),f(2966,t,n)),stencilOpBack:(e,t,n)=>e.stencilOpSeparate(1029,f(34817,t,n),f(34818,t,n),f(34819,t,n))},g={enable:(e,t)=>e({[t]:!0}),disable:(e,t)=>e({[t]:!1}),pixelStorei:(e,t,n)=>e({[t]:n}),hint:(e,t,n)=>e({[t]:n}),useProgram:(e,t)=>e({35725:t}),bindRenderbuffer:(e,t,n)=>e({36007:n}),bindTransformFeedback:(e,t,n)=>e({36389:n}),bindVertexArray:(e,t)=>e({34229:t}),bindFramebuffer:(e,t,n)=>{switch(t){case 36160:return e({36006:n,36010:n});case 36009:return e({36006:n});case 36008:return e({36010:n});default:return null}},bindBuffer:(e,t,n)=>{const i={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[t];return i?e({[i]:n}):{valueChanged:!0}},blendColor:(e,t,n,i,r)=>e({32773:new Float32Array([t,n,i,r])}),blendEquation:(e,t)=>e({32777:t,34877:t}),blendEquationSeparate:(e,t,n)=>e({32777:t,34877:n}),blendFunc:(e,t,n)=>e({32969:t,32968:n,32971:t,32970:n}),blendFuncSeparate:(e,t,n,i,r)=>e({32969:t,32968:n,32971:i,32970:r}),clearColor:(e,t,n,i,r)=>e({3106:new Float32Array([t,n,i,r])}),clearDepth:(e,t)=>e({2931:t}),clearStencil:(e,t)=>e({2961:t}),colorMask:(e,t,n,i,r)=>e({3107:[t,n,i,r]}),cullFace:(e,t)=>e({2885:t}),depthFunc:(e,t)=>e({2932:t}),depthRange:(e,t,n)=>e({2928:new Float32Array([t,n])}),depthMask:(e,t)=>e({2930:t}),frontFace:(e,t)=>e({2886:t}),lineWidth:(e,t)=>e({2849:t}),polygonOffset:(e,t,n)=>e({32824:t,10752:n}),sampleCoverage:(e,t,n)=>e({32938:t,32939:n}),scissor:(e,t,n,i,r)=>e({3088:new Int32Array([t,n,i,r])}),stencilMask:(e,t)=>e({2968:t,36005:t}),stencilMaskSeparate:(e,t,n)=>e({[1028===t?2968:36005]:n}),stencilFunc:(e,t,n,i)=>e({2962:t,2967:n,2963:i,34816:t,36003:n,36004:i}),stencilFuncSeparate:(e,t,n,i,r)=>e({[1028===t?2962:34816]:n,[1028===t?2967:36003]:i,[1028===t?2963:36004]:r}),stencilOp:(e,t,n,i)=>e({2964:t,2965:n,2966:i,34817:t,34818:n,34819:i}),stencilOpSeparate:(e,t,n,i,r)=>e({[1028===t?2964:34817]:n,[1028===t?2965:34818]:i,[1028===t?2966:34819]:r}),viewport:(e,t,n,i,r)=>e({2978:[t,n,i,r]})},m=(e,t)=>e.isEnabled(t),v={3042:m,2884:m,2929:m,3024:m,32823:m,32926:m,32928:m,3089:m,2960:m,35977:m},y=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function b(e,t){if(function(e){for(const t in e)return!1;return!0}(t))return;const n={};for(const i in t){const r=Number(i),s=h[i];s&&("string"==typeof s?n[s]=!0:s(e,t[i],r))}const i=e.lumaState?.cache;if(i)for(const r in n){(0,p[r])(e,t,i)}}function _(e,t=s){if("number"==typeof t){const n=t,i=v[n];return i?i(e,n):e.getParameter(n)}const n=Array.isArray(t)?t:Object.keys(t),i={};for(const t of n){const n=v[t];i[t]=n?n(e,Number(t)):e.getParameter(Number(t))}return i}function x(e,t){if(e===t)return!0;if(w(e)&&w(t)&&e.length===t.length){for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}return!1}function w(e){return Array.isArray(e)||ArrayBuffer.isView(e)}class WebGLStateTracker{static get(e){return e.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(e,t){this.gl=e,this.log=t?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){const e=this.stateStack[this.stateStack.length-1];b(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t?.copyState?_(e):Object.assign({},s),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,function(e){const t=e.useProgram.bind(e);e.useProgram=function(n){const i=WebGLStateTracker.get(e);i.program!==n&&(t(n),i.program=n)}}(e);for(const t in g){C(e,t,g[t])}P(e,"getParameter"),P(e,"isEnabled")}_updateCache(e){let t,n=!1;const i=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(const r in e){const s=e[r],o=this.cache[r];x(s,o)||(n=!0,t=o,i&&!(r in i)&&(i[r]=o),this.cache[r]=s)}return{valueChanged:n,oldValue:t}}}function P(e,t){const n=e[t].bind(e);e[t]=function(t){if(void 0===t||y.has(t))return n(t);const i=WebGLStateTracker.get(e);return t in i.cache||(i.cache[t]=n(t)),i.enable?i.cache[t]:n(t)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function C(e,t,n){if(!e[t])return;const i=e[t].bind(e);e[t]=function(...t){const r=WebGLStateTracker.get(e),{valueChanged:s,oldValue:o}=n(r._updateCache,...t);return s&&i(...t),o},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}function S(e){const t=e.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return t._polyfilled??=!1,t.extensions||={},e.luma=t,t}function L(e,t,n){return void 0===n[t]&&(n[t]=e.getExtension(t)||null),n[t]}function A(e,t){const n=e.getParameter(7936),i=e.getParameter(7937);L(e,"WEBGL_debug_renderer_info",t);const r=t.WEBGL_debug_renderer_info,s=e.getParameter(r?r.UNMASKED_VENDOR_WEBGL:7936)||n,o=e.getParameter(r?r.UNMASKED_RENDERER_WEBGL:7937)||i,a=e.getParameter(7938),c=E(s,o),l=function(e,t){if(/Metal/i.exec(e)||/Metal/i.exec(t))return"metal";if(/ANGLE/i.exec(e)||/ANGLE/i.exec(t))return"opengl";return"unknown"}(s,o),u=function(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return"cpu";switch(E(e,t)){case"apple":return function(e,t){return/Apple (M\d|A\d|GPU)/i.test(`${e} ${t}`)}(e,t)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}(s,o);return{type:"webgl",gpu:c,gpuType:u,gpuBackend:l,vendor:s,renderer:o,version:a,shadingLanguage:"glsl",shadingLanguageVersion:300}}function E(e,t){return/NVIDIA/i.exec(e)||/NVIDIA/i.exec(t)?"nvidia":/INTEL/i.exec(e)||/INTEL/i.exec(t)?"intel":/Apple/i.exec(e)||/Apple/i.exec(t)?"apple":/AMD/i.exec(e)||/AMD/i.exec(t)||/ATI/i.exec(e)||/ATI/i.exec(t)?"amd":/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t)?"software":"unknown"}var T=n(42528);function M(e){switch(e){case"uint8":case"unorm8":return 5121;case"sint8":case"snorm8":return 5120;case"uint16":case"unorm16":return 5123;case"sint16":case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(e))}const I="WEBGL_compressed_texture_s3tc",B="WEBGL_compressed_texture_s3tc_srgb",k="EXT_texture_compression_rgtc",R="EXT_texture_compression_bptc",O="EXT_render_snorm",z="EXT_color_buffer_float",D="snorm8-renderable-webgl",F="norm16-renderable-webgl",N="snorm16-renderable-webgl",$="float16-renderable-webgl",U="float32-renderable-webgl",V={"float32-renderable-webgl":{extensions:[z]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[O]},"norm16-webgl":{extensions:["EXT_texture_norm16"]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[O]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[I,B,k,R]},"texture-compression-bc5-webgl":{extensions:[k]},"texture-compression-bc7-webgl":{extensions:[R]},"texture-compression-etc2":{extensions:["WEBGL_compressed_texture_etc"]},"texture-compression-astc":{extensions:["WEBGL_compressed_texture_astc"]},"texture-compression-etc1-webgl":{extensions:["WEBGL_compressed_texture_etc1"]},"texture-compression-pvrtc-webgl":{extensions:["WEBGL_compressed_texture_pvrtc"]},"texture-compression-atc-webgl":{extensions:["WEBGL_compressed_texture_atc"]}};function G(e,t,n){return j(e,t,n,new Set)}function j(e,t,n,i){const r=V[t];if(!r)return!1;if(i.has(t))return!1;i.add(t);const s=(r.features||[]).every(t=>j(e,t,n,i));return i.delete(t),!!s&&(r.extensions||[]).every(t=>Boolean(L(e,t,n)))}const W={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:D},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:D},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:$},r16unorm:{gl:33322,rb:!0,r:F},r16snorm:{gl:36760,r:N},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:D},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:$},rg16unorm:{gl:33324,r:F},rg16snorm:{gl:36761,r:N},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:U},rgb9e5ufloat:{gl:35901,r:"rgb9e5ufloat-renderable-webgl"},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:U},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:$},rgba16unorm:{gl:32859,rb:!0,r:F},rgba16snorm:{gl:36763,r:N},"rgb32float-webgl":{gl:34837,x:z,r:U,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:U},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:I},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:B},"bc1-rgba-unorm":{gl:33777,x:I},"bc1-rgba-unorm-srgb":{gl:35916,x:B},"bc2-rgba-unorm":{gl:33778,x:I},"bc2-rgba-unorm-srgb":{gl:35918,x:B},"bc3-rgba-unorm":{gl:33779,x:I},"bc3-rgba-unorm-srgb":{gl:35919,x:B},"bc4-r-unorm":{gl:36283,x:k},"bc4-r-snorm":{gl:36284,x:k},"bc5-rg-unorm":{gl:36285,x:k},"bc5-rg-snorm":{gl:36286,x:k},"bc6h-rgb-ufloat":{gl:36495,x:R},"bc6h-rgb-float":{gl:36494,x:R},"bc7-rgba-unorm":{gl:36492,x:R},"bc7-rgba-unorm-srgb":{gl:36493,x:R},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}};function H(e,t,n){let i=t.create;const r=W[t.format];void 0===r?.gl&&(i=!1),r?.x&&(i=i&&Boolean(L(e,r.x,n))),"stencil8"===t.format&&(i=!1);const s=!1!==r?.r&&(void 0===r?.r||G(e,r.r,n)),o=i&&t.render&&s&&function(e,t,n){const i=W[t],r=i?.gl;if(void 0===r)return!1;if(i?.x&&!L(e,i.x,n))return!1;const s=e.getParameter(32873),o=e.getParameter(36006),a=e.createTexture(),c=e.createFramebuffer();if(!a||!c)return!1;const l=Number(0);let u=Number(e.getError());for(;u!==l;)u=e.getError();let d=!1;try{if(e.bindTexture(3553,a),e.texStorage2D(3553,1,r,1,1),Number(e.getError())!==l)return!1;e.bindFramebuffer(36160,c),e.framebufferTexture2D(36160,36064,3553,a,0),d=Number(e.checkFramebufferStatus(36160))===Number(36053)&&Number(e.getError())===l}finally{e.bindFramebuffer(36160,o),e.deleteFramebuffer(c),e.bindTexture(3553,s),e.deleteTexture(a)}return d}(e,t.format,n);return{format:t.format,create:i&&t.create,render:o,filter:i&&t.filter,blend:i&&t.blend,store:i&&t.store}}function q(e){const t=W[e],n=function(e){const t=W[e],n=t?.gl;if(void 0===n)throw new Error(`Unsupported texture format ${e}`);return n}(e),i=T.vz.getInfo(e);return i.compressed&&(t.dataFormat=n),{internalFormat:n,format:t?.dataFormat||Z(i.channels,i.integer,i.normalized,n),type:i.dataType?M(i.dataType):t?.types?.[0]||5121,compressed:i.compressed||!1}}function Z(e,t,n,i){if(6408===i||6407===i)return i;switch(e){case"r":return t&&!n?36244:6403;case"rg":return t&&!n?33320:33319;case"rgb":return t&&!n?36248:6407;case"rgba":return t&&!n?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}const Y={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","html-in-canvas":e=>(0,i.zc)()&&"function"==typeof e.texElementImage2D,"polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"};class WebGLDeviceFeatures extends i.I7{gl;extensions;testedFeatures=new Set;constructor(e,t,n){super([],n),this.gl=e,this.extensions=t,L(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){const e=this.getFeatures();for(const t of e)this.has(t)&&(yield t);return[]}has(e){return!this.disabledFeatures?.[e]&&(this.testedFeatures.has(e)||(this.testedFeatures.add(e),function(e){return e in V}(e)&&G(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){const e=this.getFeatures().filter(e=>"polygon-mode-webgl"!==e);for(const t of e)this.has(t)}getFeatures(){return[...Object.keys(Y),...Object.keys(V)]}getWebGLFeature(e){const t=Y[e];return"string"==typeof t?Boolean(L(this.gl,t,this.extensions)):"function"==typeof t?t(this.gl):Boolean(t)}}class WebGLDeviceLimits extends i.PI{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxBindGroupsPlusVertexBuffers(){return 0}get maxBindingsPerBindGroup(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageBuffersInVertexStage(){return 0}get maxStorageBuffersInFragmentStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxStorageTexturesInVertexStage(){return 0}get maxStorageTexturesInFragmentStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get maxBufferSize(){return Number.MAX_SAFE_INTEGER}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxColorAttachments(){return this.getParameter(36063)}get maxColorAttachmentBytesPerSample(){return 0}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return void 0===this.limits[e]&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}var K=n(16769);class CanvasObserver{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(e){this.props=e}start(){if(this._started||!this.props.canvas)return;this._started=!0,this._intersectionObserver||=new IntersectionObserver(e=>this.props.onIntersection(e)),this._resizeObserver||=new ResizeObserver(e=>this.props.onResize(e)),this._intersectionObserver.observe(this.props.canvas);const e=this.props.resizeObserverBox;try{this._resizeObserver.observe(this.props.canvas,{box:e})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(e=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},e))}}var Q=n(74683);var X=n(80979);class CanvasSurface{static isHTMLCanvas(e){return"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas}static defaultProps={id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,pixelSizeSource:"exact",autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",colorFormat:void 0,toneMapping:"standard",trackPosition:!1};id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=function(){let e,t;return{promise:new Promise((n,i)=>{e=n,t=i}),resolve:e,reject:t}}();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;_configuredDrawingBufferSize=[0,0];toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){this.props={...CanvasSurface.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,(0,K.B)()?e.canvas?"string"==typeof e.canvas?this.canvas=function(e){const t=document.getElementById(e);if(!CanvasSurface.isHTMLCanvas(t))throw new Error("Object is not a canvas element");return t}(e.canvas):this.canvas=e.canvas:this.canvas=function(e){const{width:t,height:n}=e,i=document.createElement("canvas");i.id=(0,Q.L)("lumagl-auto-created-canvas"),i.width=t||1,i.height=n||1,i.style.width=Number.isFinite(t)?`${t}px`:"100%",i.style.height=Number.isFinite(n)?`${n}px`:"100%",e?.visible||(i.style.visibility="hidden");const r=function(e){if("string"==typeof e){const t=document.getElementById(e);if(!t)throw new Error(`${e} is not an HTML element`);return t}if(e)return e;return document.body}(e?.container||null);return r.insertBefore(i,r.firstChild),i}(e):this.canvas={width:e.width||1,height:e.height||1},CanvasSurface.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):CanvasSurface.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this._configuredDrawingBufferSize=[this.canvas.width,this.canvas.height],this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new CanvasObserver({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,resizeObserverBox:"css-dpr"===this.props.pixelSizeSource?"content-box":"device-pixel-content-box",onResize:e=>this._handleResize(e),onIntersection:e=>this._handleIntersection(e),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){const e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){e=Math.floor(e),t=Math.floor(t),this.drawingBufferWidth===e&&this.drawingBufferHeight===t||(this.drawingBufferWidth=e,this.drawingBufferHeight=t,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return"undefined"!=typeof window&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){const n=this.cssToDeviceRatio(),[i,r]=this.getDrawingBufferSize();return function(e,t,n,i,r){const s=e,o=J(s[0],t,n);let a=ee(s[1],t,i,r),c=J(s[0]+1,t,n);const l=c===n-1?c:c-1;let u;c=ee(s[1]+1,t,i,r),r?(c=0===c?c:c+1,u=a,a=c):u=c===i-1?c:c-1;return{x:o,y:a,width:Math.max(l-o+1,1),height:Math.max(u-a+1,1)}}(e,n,i,r,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){const[e,t]=this.getDrawingBufferSize();return e>0&&t>0?e/t:1}cssToDeviceRatio(){try{const[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){"lumagl-auto-created-canvas"===this.htmlCanvas?.id&&(this.htmlCanvas.id=e)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(e){if(this.destroyed)return;const t=e.find(e=>e.target===this.canvas);if(!t)return;const n=t.isIntersecting;this.isVisible!==n&&(this.isVisible=n,this.device.props.onVisibilityChange(this))}_handleResize(e){if(this.destroyed)return;const t=e.find(e=>e.target===this.canvas);if(!t)return;const n=(0,X.i)(t.contentBoxSize?.[0]);this.cssWidth=n.inlineSize,this.cssHeight=n.blockSize;const i=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromResizeEntry(t)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:i})}_updateDrawingBufferSize(){if(this.props.autoResize)if("number"==typeof this.props.useDevicePixels){const e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_getDevicePixelSizeFromResizeEntry(e){const t=(0,X.i)(e.contentBoxSize?.[0]);return"css-dpr"===this.props.pixelSizeSource?this._getDevicePixelSizeFromCSSSize(t.inlineSize,t.blockSize):{devicePixelWidth:e.devicePixelContentBoxSize?.[0]?.inlineSize||t.inlineSize*devicePixelRatio,devicePixelHeight:e.devicePixelContentBoxSize?.[0]?.blockSize||t.blockSize*devicePixelRatio}}_getDevicePixelSizeFromCSSSize(e,t){const n=this.getDevicePixelRatio();return{devicePixelWidth:Math.floor(e*n),devicePixelHeight:Math.floor(t*n)}}_setDevicePixelSize({devicePixelWidth:e,devicePixelHeight:t}){const[n,i]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(e,n)),this.devicePixelHeight=Math.max(1,Math.min(t,i))}_resizeDrawingBufferIfNeeded(){if(this._needsDrawingBufferResize){this._needsDrawingBufferResize=!1;(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight);const[e,t]=this._configuredDrawingBufferSize;(this.drawingBufferWidth!==e||this.drawingBufferHeight!==t)&&(this._configureDevice(),this._configuredDrawingBufferSize=[this.drawingBufferWidth,this.drawingBufferHeight])}}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;const e=this.devicePixelRatio;if(this.devicePixelRatio=window.devicePixelRatio,"css-dpr"===this.props.pixelSizeSource){const e=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromCSSSize(this.cssWidth,this.cssHeight)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:e})}this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:e})}updatePosition(){if(this.destroyed)return;const e=this.htmlCanvas?.getBoundingClientRect();if(e){const t=[e.left,e.top];this._position??=t;if(t[0]!==this._position[0]||t[1]!==this._position[1]){const e=this._position;this._position=t,this.device.props.onPositionChange?.(this,{oldPosition:e})}}}}function J(e,t,n){return Math.min(Math.round(e*t),n-1)}function ee(e,t,n,i){return i?Math.max(0,n-1-Math.round(e*t)):Math.min(Math.round(e*t),n-1)}class CanvasContext extends CanvasSurface{static defaultProps=CanvasSurface.defaultProps}var te=n(5153),ne=n(80698);class Framebuffer extends te.F{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,t={}){super(e,t,Framebuffer.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){const t=this.colorAttachments.map(t=>t.texture.clone(e)),n=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,...e,colorAttachments:t,depthStencilAttachment:n})}resize(e){let t=!e;if(e){const[n,i]=Array.isArray(e)?e:[e.width,e.height];t=t||i!==this.height||n!==this.width,this.width=n,this.height=i}t&&(r.R.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(0===this.props.colorAttachments.length&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((e,t)=>{if("string"==typeof e){const n=this.createColorTexture(e,t);return this.attachResource(n),n.view}return e instanceof ne.g?e.view:e});const e=this.props.depthStencilAttachment;if(e)if("string"==typeof e){const t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else e instanceof ne.g?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:ne.g.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:ne.g.RENDER_ATTACHMENT|ne.g.SAMPLE,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){if(this.colorAttachments.forEach((n,i)=>{const r=n.texture.clone({width:e,height:t});this.destroyAttachedResource(n),this.colorAttachments[i]=r.view,this.attachResource(r.view)}),this.depthStencilAttachment){const n=this.depthStencilAttachment.texture.clone({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=n.view,this.attachResource(n)}this.updateAttachments()}static defaultProps={...te.F.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null}}class WEBGLFramebuffer extends Framebuffer{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t);const n=t.handle,i=null===n;this.device=e,this.gl=e.gl,this.handle=n||i?n:this.gl.createFramebuffer(),i||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),t.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),this.destroyed||null===this.handle||this.props.handle||this.gl.deleteFramebuffer(this.handle)}updateAttachments(){const e=this.gl.bindFramebuffer(36160,this.handle);for(let e=0;e<this.colorAttachments.length;++e){const t=this.colorAttachments[e];if(t){const n=36064+e;this._attachTextureView(n,t)}}if(this.depthStencilAttachment){const e=function(e){switch(T.vz.getInfo(e).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${e}`)}}(this.depthStencilAttachment.props.format);this._attachTextureView(e,this.depthStencilAttachment)}if(this.device.props.debug){const e=this.gl.checkFramebufferStatus(36160);if(36053!==e)throw new Error(`Framebuffer ${function(e){switch(e){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${e}`}}(e)}`)}this.gl.bindFramebuffer(36160,e)}_attachTextureView(e,t){const{gl:n}=this.device,{texture:i}=t,r=t.props.baseMipLevel,s=t.props.baseArrayLayer;switch(n.bindTexture(i.glTarget,i.handle),i.glTarget){case 35866:case 32879:n.framebufferTextureLayer(36160,e,i.handle,r,s);break;case 34067:const t=function(e){return e<34069?e+34069:e}(s);n.framebufferTexture2D(36160,e,t,i.handle,r);break;case 3553:n.framebufferTexture2D(36160,e,3553,i.handle,r);break;default:throw new Error("Illegal texture type")}n.bindTexture(i.glTarget,null)}resizeAttachments(e,t){if(null===this.handle)return this.width=e,void(this.height=t);super.resizeAttachments(e,t)}}class WebGLCanvasContext extends CanvasContext{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(e,t){super(t),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new WEBGLFramebuffer(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}class PresentationContext extends CanvasSurface{}class WebGLPresentationContext extends PresentationContext{device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(e,t={}){super(t),this.device=e;const n=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${n}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);const i=this.canvas.getContext("2d");if(!i)throw new Error(`${n}: Failed to create 2d presentation context`);this.context2d=i,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();const e=this.device.getDefaultCanvasContext(),[t,n]=e.getDrawingBufferSize();if(0!==this.drawingBufferWidth&&0!==this.drawingBufferHeight&&0!==t&&0!==n&&0!==e.canvas.width&&0!==e.canvas.height){if(t!==this.drawingBufferWidth||n!==this.drawingBufferHeight||e.canvas.width!==this.drawingBufferWidth||e.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${t}x${n} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(e.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(e){const t=this.device.getDefaultCanvasContext();return t.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),t.getCurrentFramebuffer(e)}}var ie=n(89689);const re={};function se(e="id"){re[e]=re[e]||1;return`${e}-${re[e]++}`}var oe=n(26839);class WEBGLBuffer extends oe.h{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(e,t={}){super(e,t),this.device=e,this.gl=this.device.gl;const n="object"==typeof t?t.handle:void 0;this.handle=n||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=function(e){if(e&oe.h.INDEX)return 34963;if(e&oe.h.VERTEX)return 34962;if(e&oe.h.UNIFORM)return 35345;return 34962}(this.props.usage),this.glUsage=function(e){if(e&oe.h.INDEX)return 35044;if(e&oe.h.VERTEX)return 35044;if(e&oe.h.UNIFORM)return 35048;return 35044}(this.props.usage),this.glIndexType="uint32"===this.props.indexType?5125:5123,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(e,t=0,n=e.byteLength+t){const i=this.glTarget;this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,n,this.glUsage),this.gl.bufferSubData(i,t,e),this.gl.bindBuffer(i,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(e,t,n),this.props.handle?this.trackReferencedMemory(n,"Buffer"):this.trackAllocatedMemory(n)}_initWithByteLength(e){let t=e;0===e&&(t=new Float32Array(0));const n=this.glTarget;return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,t,this.glUsage),this.gl.bindBuffer(n,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.props.handle?this.trackReferencedMemory(e,"Buffer"):this.trackAllocatedMemory(e),this}write(e,t=0){const n=ArrayBuffer.isView(e)?e:new Uint8Array(e),i=36663;this.gl.bindBuffer(i,this.handle),this.gl.bufferSubData(i,t,n),this.gl.bindBuffer(i,null),this._setDebugData(e,t,e.byteLength)}async mapAndWriteAsync(e,t=0,n=this.byteLength-t){const i=new ArrayBuffer(n);await e(i,"copied"),this.write(i,t)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}async mapAndReadAsync(e,t=0,n){const i=await this.readAsync(t,n);return await e(i.buffer,"copied")}readSyncWebGL(e=0,t){t=t??this.byteLength-e;const n=new Uint8Array(t);return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,n,0,t),this.gl.bindBuffer(36662,null),this._setDebugData(n,e,t),n}}var ae=n(40720);function ce(e){const t=e.toLowerCase();return["warning","error","info"].includes(t)?t:"info"}class WEBGLShader extends ae.M{device;handle;_compilationInfoLog="";constructor(e,t){super(e,t),this.device=e;const n=this.props.handle;switch(this.props.stage){case"vertex":this.handle=n||this.device.gl.createShader(35633);break;case"fragment":this.handle=n||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props});const i=this._compile(this.source);i&&"function"==typeof i.catch&&i.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){const e=this._getCompilationInfoLog();return e?function(e){const t=e.split(/\r?\n/),n=[];for(const e of t){if(e.length<=1)continue;const t=e.trim(),i=e.split(":"),r=i[0]?.trim();if(2===i.length){const[e,s]=i;if(!e||!s){n.push({message:t,type:ce(r||"info"),lineNum:0,linePos:0});continue}n.push({message:s.trim(),type:ce(e),lineNum:0,linePos:0});continue}const[s,o,a,...c]=i;if(!s||!o||!a){n.push({message:i.slice(1).join(":").trim()||t,type:ce(r||"info"),lineNum:0,linePos:0});continue}let l=parseInt(a,10);Number.isNaN(l)&&(l=0);let u=parseInt(o,10);Number.isNaN(u)&&(u=0),n.push({message:c.join(":").trim(),type:ce(s),lineNum:l,linePos:u})}return n}(e):[]}getTranslatedSource(){const e=this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders;return e?.getTranslatedShaderSource(this.handle)||null}_compile(e){e=e.startsWith("#version ")?e:`#version 300 es\n${e}`;const{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(this.handle),this.device.props.debug){if(this.device.features.has("compilation-status-async-webgl"))return r.R.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{r.R.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()});if(this._getCompilationStatus(),this.debugShader(),"error"===this.compilationStatus)throw new Error(this._getCompilationErrorMessage(e))}else this.compilationStatus="pending"}async _waitForCompilationComplete(){const e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has("compilation-status-async-webgl"))return void await e(10);const{gl:t}=this.device;for(;;){if(t.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error","error"===this.compilationStatus&&this._getCompilationInfoLog()}_getCompilationErrorMessage(e){const t=`${this.props.stage} shader ${this.props.id}`,n=(i=this._getCompilationInfoLog(),i.split(/\r?\n/).find(e=>e.trim())?.trim());var i;const r=this.getCompilationInfoSync(),s=r.find(e=>"error"===e.type&&e.message.trim())||r.find(e=>e.message.trim())||r.find(e=>"error"===e.type)||r[0];if(!s)return n?`GLSL compilation errors in ${t}: ${n}`:`GLSL compilation errors in ${t}: WebGL did not provide a shader compiler log`;const o=s.lineNum?e.split(/\r?\n/)[s.lineNum-1]?.trim():void 0,a=o?`\nSource: ${o}`:"";return`GLSL compilation errors in ${t}:${s.lineNum?` line ${s.lineNum}`:""}: ${s.message.trim()||n||"WebGL did not provide a shader compiler log"}${a}`}_getCompilationInfoLog(){const e=this.device.gl.getShaderInfoLog(this.handle)?.trim();return e&&(this._compilationInfoLog=e),this._compilationInfoLog}}var le=n(89277);function ue(e,t){const n=e,{gl:i}=n;if(t.cullMode)switch(t.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029)}if(t.frontFace&&i.frontFace(ge("frontFace",t.frontFace,{ccw:2305,cw:2304})),t.unclippedDepth&&e.features.has("depth-clip-control")&&i.enable(34383),void 0!==t.depthBias&&(i.enable(32823),i.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0)),t.provokingVertex&&e.features.has("provoking-vertex-webgl")){const e=n.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,i=ge("provokingVertex",t.provokingVertex,{first:36429,last:36430});e?.provokingVertexWEBGL(i)}if((t.polygonMode||t.polygonOffsetLine)&&e.features.has("polygon-mode-webgl")){if(t.polygonMode){const e=n.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,i=ge("polygonMode",t.polygonMode,{fill:6914,line:6913});e?.polygonModeWEBGL(1028,i),e?.polygonModeWEBGL(1029,i)}t.polygonOffsetLine&&i.enable(10754)}if(e.features.has("shader-clip-cull-distance-webgl")&&(t.clipDistance0&&i.enable(12288),t.clipDistance1&&i.enable(12289),t.clipDistance2&&i.enable(12290),t.clipDistance3&&i.enable(12291),t.clipDistance4&&i.enable(12292),t.clipDistance5&&i.enable(12293),t.clipDistance6&&i.enable(12294),t.clipDistance7&&i.enable(12295)),void 0!==t.depthWriteEnabled&&i.depthMask(t.depthWriteEnabled),t.depthCompare&&("always"!==t.depthCompare?i.enable(2929):i.disable(2929),i.depthFunc(de("depthCompare",t.depthCompare))),void 0!==t.clearDepth&&i.clearDepth(t.clearDepth),t.stencilWriteMask){const e=t.stencilWriteMask;i.stencilMaskSeparate(1028,e),i.stencilMaskSeparate(1029,e)}if(t.stencilReadMask&&r.R.warn("stencilReadMask not supported under WebGL"),t.stencilCompare){const e=t.stencilReadMask||4294967295,n=de("depthCompare",t.stencilCompare);"always"!==t.stencilCompare?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,n,0,e),i.stencilFuncSeparate(1029,n,0,e)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){const e=he("stencilPassOperation",t.stencilPassOperation),n=he("stencilFailOperation",t.stencilFailOperation),r=he("stencilDepthFailOperation",t.stencilDepthFailOperation);i.stencilOpSeparate(1028,n,r,e),i.stencilOpSeparate(1029,n,r,e)}switch(t.blend){case!0:i.enable(3042);break;case!1:i.disable(3042)}if(t.blendColorOperation||t.blendAlphaOperation){const e=fe("blendColorOperation",t.blendColorOperation||"add"),n=fe("blendAlphaOperation",t.blendAlphaOperation||"add");i.blendEquationSeparate(e,n);const r=pe("blendColorSrcFactor",t.blendColorSrcFactor||"one"),s=pe("blendColorDstFactor",t.blendColorDstFactor||"zero"),o=pe("blendAlphaSrcFactor",t.blendAlphaSrcFactor||"one"),a=pe("blendAlphaDstFactor",t.blendAlphaDstFactor||"zero");i.blendFuncSeparate(r,s,o,a)}}function de(e,t){return ge(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function he(e,t){return ge(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function fe(e,t){return ge(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function pe(e,t,n="color"){return ge(e,t,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:"color"===n?32769:32771,"one-minus-constant":"color"===n?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function ge(e,t,n){if(!(t in n))throw new Error(function(e,t){return`Illegal parameter ${t} for ${e}`}(e,t));return n[t]}function me(e){let t=!0;for(const n in e){t=!1;break}return t}function ve(e){const t={};return e.addressModeU&&(t[10242]=ye(e.addressModeU)),e.addressModeV&&(t[10243]=ye(e.addressModeV)),e.addressModeW&&(t[32882]=ye(e.addressModeW)),e.magFilter&&(t[10240]=be(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=function(e,t="none"){if(!t)return be(e);switch(t){case"none":return be(e);case"nearest":switch(e){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(e){case"nearest":return 9986;case"linear":return 9987}}}(e.minFilter||"linear",e.mipmapFilter)),void 0!==e.lodMinClamp&&(t[33082]=e.lodMinClamp),void 0!==e.lodMaxClamp&&(t[33083]=e.lodMaxClamp),"comparison-sampler"===e.type&&(t[34892]=34894),e.compare&&(t[34893]=de("compare",e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function ye(e){switch(e){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function be(e){switch(e){case"nearest":return 9728;case"linear":return 9729}}class WEBGLSampler extends le.L{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=ve(t),this.handle=t.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(const[t,n]of Object.entries(e)){const e=Number(t);switch(e){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,e,n);break;default:this.device.gl.samplerParameteri(this.handle,e,n)}}}}var _e=n(68597);function xe(e,t,n){if(function(e){for(const t in e)return!1;return!0}(t))return n(e);const{nocatch:i=!0}=t,r=WebGLStateTracker.get(e);let s;if(r.push(),b(e,t),i)s=n(e),r.pop();else try{s=n(e)}finally{r.pop()}return s}var we=n(75638);class WEBGLTextureView extends we.X{device;gl;handle;texture;constructor(e,t){super(e,{...ne.g.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}function Pe(e){return Ce[e]}const Ce={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"};class WEBGLTexture extends ne.g{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(e,t){super(e,t,{byteAlignment:1}),this.device=e,this.gl=this.device.gl;const n=q(this.props.format);if(this.glTarget=function(e){switch(e){case"1d":case"cube-array":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866}throw new Error(e)}(this.props.dimension),this.glInternalFormat=n.internalFormat,this.glFormat=n.format,this.glType=n.type,this.compressed=n.compressed,this.isHandleBorrowed&&void 0===this.props.handle)throw new Error("Borrowed WebGL textures require a texture handle");if(this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),!this.isHandleBorrowed){this.gl.bindTexture(this.glTarget,this.handle);const{dimension:e,width:n,height:i,depth:r,mipLevels:s,glTarget:o,glInternalFormat:a}=this;if(!this.compressed)switch(e){case"2d":case"cube":this.gl.texStorage2D(o,s,a,n,i);break;case"2d-array":case"3d":this.gl.texStorage3D(o,s,a,n,i,r);break;default:throw new Error(e)}this.gl.bindTexture(this.glTarget,null),this._initializeData(t.data)}this.ownsHandle?this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"):this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"),this.isHandleBorrowed||this.setSampler(this.props.sampler),this.view=new WEBGLTextureView(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.ownsHandle?(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")):this.trackDeallocatedReferencedMemory("Texture"),this.destroyed=!0)}createView(e){return new WEBGLTextureView(this.device,{...e,texture:this})}clone(e){if(this.isHandleBorrowed&&e&&(e.width!==this.width||e.height!==this.height))throw new Error(`Cannot resize borrowed read-only ${this}`);return super.clone(e)}setSampler(e={}){this._assertWritable("set sampler parameters on"),super.setSampler(e);const t=ve(this.sampler.props);this._setSamplerParameters(t)}copyExternalImage(e){this._assertWritable("copy external image data into");const t=this._normalizeCopyExternalImageOptions(e);if(t.sourceX||t.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");const{glFormat:n,glType:i}=this,{image:r,depth:s,mipLevel:o,x:a,y:c,z:l,width:u,height:d}=t,h=Se(this.glTarget,this.dimension,l),f=t.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),xe(this.gl,f,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(h,o,a,c,u,d,n,i,r);break;case"2d-array":case"3d":this.gl.texSubImage3D(h,o,a,c,l,u,d,s,n,i,r)}}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyElementImage(e){this._assertWritable("copy element image data into");const t=this._normalizeCopyElementImageOptions(e),{glFormat:n}=this,{element:i,depth:r,mipLevel:s,sourceX:o,sourceY:a,sourceWidth:c,sourceHeight:l,x:u,y:d,z:h,width:f,height:p}=t,g=Se(this.glTarget,this.dimension,h),m=t.flipY?{37440:!0}:{},v=this.gl;if(1!==r||"2d"!==this.dimension&&"cube"!==this.dimension)throw new Error(`${this} copyElementImage only supports 2d and cube textures on WebGL`);if(0!==s||0!==u||0!==d)throw new Error(`${this} copyElementImage only supports full base-level uploads on WebGL`);if("function"!=typeof v.texElementImage2D)throw new Error(`${this} copyElementImage is not supported by this WebGL implementation`);return this.gl.bindTexture(this.glTarget,this.handle),xe(this.gl,m,()=>{v.texElementImage2D?.(g,n,i,{sx:o,sy:a,swidth:c??f,sheight:l??p,width:f,height:p})}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyImageData(e){super.copyImageData(e)}readBuffer(e={},t){if(!t)throw new Error(`${this} readBuffer requires a destination buffer`);const n=this._getSupportedColorReadOptions(e),i=e.byteOffset??0,r=this.computeMemoryLayout(n);if(t.byteLength<i+r.byteLength)throw new Error(`${this} readBuffer target is too small (${t.byteLength} < ${i+r.byteLength})`);const s=t;this.gl.bindBuffer(35051,s.handle);try{this._readColorTextureLayers(n,r,e=>{this.gl.readPixels(n.x,n.y,n.width,n.height,this.glFormat,this.glType,i+e)})}finally{this.gl.bindBuffer(35051,null)}return t}async readDataAsync(e={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(e,t={}){this._assertWritable("write buffer data into");const n=this._normalizeTextureWriteOptions(t),{width:i,height:r,depthOrArrayLayers:s,mipLevel:o,byteOffset:a,x:c,y:l,z:u}=n,{glFormat:d,glType:h,compressed:f}=this,p=Se(this.glTarget,this.dimension,u);if(f)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");const{bytesPerPixel:g}=this.device.getTextureFormatInfo(this.format),m=g?n.bytesPerRow/g:void 0,v={3317:this.byteAlignment,...void 0!==m?{3314:m}:{},32878:n.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),xe(this.gl,v,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(p,o,c,l,i,r,d,h,a);break;case"2d-array":case"3d":this.gl.texSubImage3D(p,o,c,l,u,i,r,s,d,h,a)}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,t={}){this._assertWritable("write data into");const n=this._normalizeTextureWriteOptions(t),i=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:r,height:s,depthOrArrayLayers:o,mipLevel:a,x:c,y:l,z:u,byteOffset:d}=n,{glFormat:h,glType:f,compressed:p}=this,g=Se(this.glTarget,this.dimension,u);let m;if(!p){const{bytesPerPixel:e}=this.device.getTextureFormatInfo(this.format);e&&(m=n.bytesPerRow/e)}const v=this.compressed?{}:{3317:this.byteAlignment,...void 0!==m?{3314:m}:{},32878:n.rowsPerImage},y=function(e,t){if(t%e.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${t} must align to typed array element size ${e.BYTES_PER_ELEMENT}`);return t/e.BYTES_PER_ELEMENT}(i,d),b=p?function(e,t=0){if(!t)return e;return new e.constructor(e.buffer,e.byteOffset+t,(e.byteLength-t)/e.BYTES_PER_ELEMENT)}(i,d):i,_=this._getMipLevelSize(a),x=0===c&&0===l&&0===u&&r===_.width&&s===_.height&&o===_.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),xe(this.gl,v,()=>{switch(this.dimension){case"2d":case"cube":p?x?this.gl.compressedTexImage2D(g,a,h,r,s,0,b):this.gl.compressedTexSubImage2D(g,a,c,l,r,s,h,b):this.gl.texSubImage2D(g,a,c,l,r,s,h,f,i,y);break;case"2d-array":case"3d":p?x?this.gl.compressedTexImage3D(g,a,h,r,s,o,0,b):this.gl.compressedTexSubImage3D(g,a,c,l,u,r,s,o,h,b):this.gl.texSubImage3D(g,a,c,l,u,r,s,o,h,f,i,y)}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(e,t){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(e={}){const t=this._getSupportedColorReadOptions(e),n=this.computeMemoryLayout(t),i=Pe(this.glType),r=(0,_e.Ak)(i),s=new r(n.byteLength/r.BYTES_PER_ELEMENT);return this._readColorTextureLayers(t,n,e=>{const i=new r(s.buffer,s.byteOffset+e,n.bytesPerImage/r.BYTES_PER_ELEMENT);this.gl.readPixels(t.x,t.y,t.width,t.height,this.glFormat,this.glType,i)}),s.buffer}_readColorTextureLayers(e,t,n){const i=this._getFramebuffer(),r=t.bytesPerRow/t.bytesPerPixel,s={3333:this.byteAlignment,...r!==e.width?{3330:r}:{}},o=this.gl.getParameter(3074),a=this.gl.bindFramebuffer(36160,i.handle);try{this.gl.readBuffer(36064),xe(this.gl,s,()=>{for(let r=0;r<e.depthOrArrayLayers;r++)this._attachReadSubresource(i,e.mipLevel,e.z+r),n(r*t.bytesPerImage)})}finally{this.gl.bindFramebuffer(36160,a||null),this.gl.readBuffer(o)}}_attachReadSubresource(e,t,n){const i=`${t}:${n}`;if(this._framebufferAttachmentKey!==i){switch(this.dimension){case"2d":this.gl.framebufferTexture2D(36160,36064,3553,this.handle,t);break;case"cube":this.gl.framebufferTexture2D(36160,36064,Se(this.glTarget,this.dimension,n),this.handle,t);break;case"2d-array":case"3d":this.gl.framebufferTextureLayer(36160,36064,this.handle,t,n);break;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}if(this.device.props.debug){const t=Number(this.gl.checkFramebufferStatus(36160));if(t!==Number(36053))throw new Error(`${e} incomplete for ${this} readback (${t})`)}this._framebufferAttachmentKey=i}}generateMipmapsWebGL(e){this._assertWritable("generate mipmaps for");if(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format)||(r.R.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)(),e?.force))try{this.gl.bindTexture(this.glTarget,this.handle),this.gl.generateMipmap(this.glTarget)}catch(e){r.R.warn(`Error generating mipmap for ${this}: ${e.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(e){r.R.level>=2&&r.R.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(const[t,n]of Object.entries(e)){const e=Number(t),i=n;switch(e){case 33082:case 33083:this.gl.texParameterf(this.glTarget,e,i);break;case 10240:case 10241:case 10242:case 10243:case 32882:case 34892:case 34893:this.gl.texParameteri(this.glTarget,e,i);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,e,i)}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){const{gl:t}=this;return void 0!==e&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,this.handle),e}_unbind(e){const{gl:t}=this;return void 0!==e&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,null),e}_assertWritable(e){if(this.isHandleBorrowed)throw new Error(`Cannot ${e} borrowed read-only ${this}`)}}function Se(e,t,n){return"cube"===t?34069+n:e}var Le=n(22512),Ae=n(62069);function Ee(e,t,n,i){const r=e;let s=i;!0===s&&(s=1),!1===s&&(s=0);const o="number"==typeof s?[s]:s;switch(n){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if("number"!=typeof i)throw new Error("samplers must be set to integers");return e.uniform1i(t,i);case 5126:return e.uniform1fv(t,o);case 35664:return e.uniform2fv(t,o);case 35665:return e.uniform3fv(t,o);case 35666:return e.uniform4fv(t,o);case 5124:case 35670:return e.uniform1iv(t,o);case 35667:case 35671:return e.uniform2iv(t,o);case 35668:case 35672:return e.uniform3iv(t,o);case 35669:case 35673:return e.uniform4iv(t,o);case 5125:return r.uniform1uiv(t,o,1);case 36294:return r.uniform2uiv(t,o,2);case 36295:return r.uniform3uiv(t,o,3);case 36296:return r.uniform4uiv(t,o,4);case 35674:return e.uniformMatrix2fv(t,!1,o);case 35675:return e.uniformMatrix3fv(t,!1,o);case 35676:return e.uniformMatrix4fv(t,!1,o);case 35685:return r.uniformMatrix2x3fv(t,!1,o);case 35686:return r.uniformMatrix2x4fv(t,!1,o);case 35687:return r.uniformMatrix3x2fv(t,!1,o);case 35688:return r.uniformMatrix3x4fv(t,!1,o);case 35689:return r.uniformMatrix4x2fv(t,!1,o);case 35690:return r.uniformMatrix4x3fv(t,!1,o)}throw new Error("Illegal uniform")}var Te=n(65219),Me=n(50584);function Ie(e){return Re[e]}function Be(e){return Boolean(Oe[e])}function ke(e){return Oe[e]}const Re={5126:"f32",35664:"vec2<f32>",35665:"vec3<f32>",35666:"vec4<f32>",5124:"i32",35667:"vec2<i32>",35668:"vec3<i32>",35669:"vec4<i32>",5125:"u32",36294:"vec2<u32>",36295:"vec3<u32>",36296:"vec4<u32>",35670:"f32",35671:"vec2<f32>",35672:"vec3<f32>",35673:"vec4<f32>",35674:"mat2x2<f32>",35685:"mat2x3<f32>",35686:"mat2x4<f32>",35687:"mat3x2<f32>",35675:"mat3x3<f32>",35688:"mat3x4<f32>",35689:"mat4x2<f32>",35690:"mat4x3<f32>",35676:"mat4x4<f32>"},Oe={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},ze={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126};function De(e,t,n={}){const i={attributes:[],bindings:[]};i.attributes=function(e,t){const n=[],i=e.getProgramParameter(t,35721);for(let r=0;r<i;r++){const i=e.getActiveAttrib(t,r);if(!i)throw new Error("activeInfo");const{name:s,type:o}=i,a=e.getAttribLocation(t,s);if(a>=0){const e=Ie(o),t=/instance/i.test(s)?"instance":"vertex";n.push({name:s,location:a,stepMode:t,type:e})}}return n.sort((e,t)=>e.location-t.location),n}(e,t);const s=function(e,t,n){const i=[],s=function(e,t,n){const i=new Map;for(const e of n.uniformBlockLayouts||[])i.set(e.name,je(e));for(const e of n.shaderLayout?.bindings||[])We(e)&&i.set(e.name,e);const r=new Map;for(const n of i.values()){const i=Ne(e,t,n.name);if(!i)continue;const{blockIndex:s,blockName:o}=i;if(r.has(s))throw new Error(`Multiple supplied uniform block layouts resolve to active WebGL block "${o}"`);r.set(s,{name:o,location:s,byteLength:n.minBindingSize,vertex:Boolean(n.visibility&&1&n.visibility),fragment:Boolean(n.visibility&&2&n.visibility),uniformCount:n.uniforms.length,uniforms:n.uniforms.map(e=>({...e}))})}return r}(e,t,n);for(const[n,o]of s){i.push(o);try{Fe($e(e,t,n,o.name),o)}catch(e){const t=e instanceof Error?e.message:String(e);r.R.once(0,`WebGL uniform block reflection failed for "${o.name}"; using supplied std140 metadata. ${t}`)()}}const o=e.getProgramParameter(t,35382);if(!Number.isInteger(o)||o<0)throw new Error(`Failed to reflect WebGL uniform blocks: ACTIVE_UNIFORM_BLOCKS returned ${String(o)}`);for(let n=0;n<o;n++)s.has(n)||i.push($e(e,t,n));return i.sort((e,t)=>e.location-t.location),i}(e,t,n);for(const e of s){const t=e.uniforms.map(e=>({name:e.name,format:e.format,byteOffset:e.byteOffset,byteStride:e.byteStride,arrayLength:e.arrayLength}));i.bindings.push({type:"uniform",name:e.name,group:0,location:e.location,visibility:(e.vertex?1:0)|(e.fragment?2:0),minBindingSize:e.byteLength,uniforms:t})}const o=function(e,t){const n=[],i=e.getProgramParameter(t,35718);for(let r=0;r<i;r++){const i=e.getActiveUniform(t,r);if(!i)throw new Error("activeInfo");const{name:s,size:o,type:a}=i,{name:c,isArray:l}=He(s);let u=e.getUniformLocation(t,c);const d={location:u,name:c,size:o,type:a,isArray:l};if(n.push(d),d.size>1)for(let i=0;i<d.size;i++){const r=`${c}[${i}]`;u=e.getUniformLocation(t,r);const s={...d,name:r,location:u};n.push(s)}}return n}(e,t);let a=0;for(const e of o)if(Be(e.type)){const{viewDimension:t,sampleType:n}=ke(e.type);i.bindings.push({type:"texture",name:e.name,group:0,location:a,viewDimension:t,sampleType:n}),e.textureUnit=a,a+=1}o.length&&(i.uniforms=o);const c=function(e,t){const n=[],i=e.getProgramParameter(t,35971);for(let r=0;r<i;r++){const i=e.getTransformFeedbackVarying(t,r);if(!i)throw new Error("activeInfo");const{name:s,type:o,size:a}=i,c=Ie(o),{type:l,components:u}=(0,Te.k0)(c);n.push({location:r,name:s,type:l,size:a*u})}return n.sort((e,t)=>e.location-t.location),n}(e,t);return c?.length&&(i.varyings=c),i}function Fe(e,t){for(const n of e.uniforms){const e=t.uniforms.find(e=>n.name===e.name||n.name.endsWith(`.${e.name}`));if(!e)throw new Error(`Failed to validate WebGL uniform block "${t.name}": reflected unexpected member "${n.name}"`);if(n.format!==e.format||n.arrayLength!==e.arrayLength||n.byteOffset!==e.byteOffset||n.byteStride!==e.byteStride)throw new Error(`Failed to validate WebGL uniform block "${t.name}": reflected layout for "${n.name}" does not match supplied std140 metadata`)}}function Ne(e,t,n){const i=n.endsWith("Uniforms")?[n,n.slice(0,-8)]:[n,`${n}Uniforms`];for(const n of i){const i=e.getUniformBlockIndex(t,n);if(4294967295!==i){if(!Number.isInteger(i)||i<0)throw new Error(`Failed to resolve WebGL uniform block "${n}": getUniformBlockIndex returned ${String(i)}`);return{blockIndex:i,blockName:n}}}return null}function $e(e,t,n,i){const s=i||e.getActiveUniformBlockName(t,n);if(!s)throw new Error(`Failed to reflect WebGL uniform block at index ${n}: missing block name`);const o=(i,r)=>{const o=e.getActiveUniformBlockParameter(t,n,i);if(null==o)throw new Error(`Failed to reflect WebGL uniform block "${s}": ${r} returned null`);return o},a=Ge(o(35391,"UNIFORM_BLOCK_BINDING"),s,"UNIFORM_BLOCK_BINDING",0),c=Ge(o(35392,"UNIFORM_BLOCK_DATA_SIZE"),s,"UNIFORM_BLOCK_DATA_SIZE",0),l=Ge(o(35394,"UNIFORM_BLOCK_ACTIVE_UNIFORMS"),s,"UNIFORM_BLOCK_ACTIVE_UNIFORMS",0),u=Ve(o(35395,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"),s,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",l),d=Ue(e,t,u,35383,"UNIFORM_TYPE",s,l),h=Ue(e,t,u,35384,"UNIFORM_SIZE",s,l),f=Ue(e,t,u,35386,"UNIFORM_BLOCK_INDEX",s,l),p=Ue(e,t,u,35387,"UNIFORM_OFFSET",s,l),g=Ue(e,t,u,35388,"UNIFORM_ARRAY_STRIDE",s,l),m=[];for(let i=0;i<l;i++){if(f[i]!==n)throw new Error(`Failed to reflect WebGL uniform block "${s}": active uniform index ${u[i]} belongs to block ${f[i]}, expected ${n}`);const r=u[i],o=e.getActiveUniform(t,r);if(!o)throw new Error(`Failed to reflect WebGL uniform block "${s}": getActiveUniform(${r}) returned null`);const a=Ge(d[i],s,`UNIFORM_TYPE[${i}]`,1),c=Ge(h[i],s,`UNIFORM_SIZE[${i}]`,1),l=Ge(p[i],s,`UNIFORM_OFFSET[${i}]`,0),v=Ge(g[i],s,`UNIFORM_ARRAY_STRIDE[${i}]`,0);if(o.type!==a||o.size!==c)throw new Error(`Failed to reflect WebGL uniform block "${s}": getActiveUniform(${r}) disagrees with getActiveUniforms`);m.push({name:o.name,format:Ie(a),arrayLength:c,byteOffset:l,byteStride:v})}const v={name:s,location:a,byteLength:c,vertex:Boolean(o(35396,"UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER")),fragment:Boolean(o(35398,"UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER")),uniformCount:l,uniforms:m},y=new Set(v.uniforms.map(e=>e.name.split(".")[0]).filter(e=>Boolean(e))),b=v.name.replace(/Uniforms$/,"");if(1===y.size&&!y.has(v.name)&&!y.has(b)){const[e]=y;r.R.warn(`Uniform block "${v.name}" uses GLSL instance "${e}". luma.gl binds uniform buffers by block name ("${v.name}") and alias ("${b}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}return v}function Ue(e,t,n,i,r,s,o){const a=e.getActiveUniforms(t,n,i);if(null===a)throw new Error(`Failed to reflect WebGL uniform block "${s}": ${r} returned null`);return Ve(a,s,r,o)}function Ve(e,t,n,i){if(!Array.isArray(e)&&!ArrayBuffer.isView(e))throw new Error(`Failed to reflect WebGL uniform block "${t}": ${n} returned a non-array value`);const r=Array.from(e);if(r.length!==i||r.some(e=>!Number.isInteger(e)))throw new Error(`Failed to reflect WebGL uniform block "${t}": ${n} returned ${r.length} invalid values, expected ${i}`);return r}function Ge(e,t,n,i){if(!Number.isInteger(e)||e<i)throw new Error(`Failed to reflect WebGL uniform block "${t}": ${n} returned ${String(e)}`);return e}function je(e){const t=(0,Me.Pr)(e.uniformTypes,{layout:"std140"}),n=function(e,t){const n=[],i=(e,s)=>{if("string"==typeof s){const i=t[e];if(!i)throw new Error(`Missing std140 layout field ${e}`);return void n.push({name:e,format:i.shaderType,arrayLength:1,byteOffset:4*i.offset,byteStride:0})}if(Array.isArray(s))r(e,s[0],s[1]);else for(const[t,n]of Object.entries(s))i(`${e}.${t}`,n)},r=(e,i,r)=>{if("string"==typeof i){const i=t[`${e}[0]`],s=r>1?t[`${e}[1]`]:void 0;if(!i)throw new Error(`Missing std140 array layout field ${e}[0]`);return void n.push({name:`${e}[0]`,format:i.shaderType,arrayLength:r,byteOffset:4*i.offset,byteStride:s?4*(s.offset-i.offset):0})}if(Array.isArray(i))throw new Error(`Nested uniform arrays are not supported for ${e}`);for(const[s,o]of Object.entries(i)){if("string"!=typeof o)throw new Error(`Composite uniform array members are not supported for ${e}`);const i=`${e}[0].${s}`,a=`${e}[1].${s}`,c=t[i],l=r>1?t[a]:void 0;if(!c)throw new Error(`Missing std140 array layout field ${i}`);n.push({name:i,format:c.shaderType,arrayLength:r,byteOffset:4*c.offset,byteStride:l?4*(l.offset-c.offset):0})}};for(const[t,n]of Object.entries(e))i(t,n);return n}(e.uniformTypes,t.fields);return{type:"uniform",name:e.name,group:0,location:0,minBindingSize:t.byteLength,uniforms:n}}function We(e){return"uniform"===e.type&&Number.isInteger(e.minBindingSize)&&e.minBindingSize>=0&&Array.isArray(e.uniforms)&&e.uniforms.every(e=>"string"==typeof e.name&&"string"==typeof e.format&&Number.isInteger(e.arrayLength)&&e.arrayLength>0&&Number.isInteger(e.byteOffset)&&e.byteOffset>=0&&Number.isInteger(e.byteStride)&&e.byteStride>=0)}function He(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};const t=/([^[]*)(\[[0-9]+\])?/.exec(e);return{name:(0,X.i)(t?.[1],`Failed to parse GLSL uniform name ${e}`),length:t?.[2]?1:0,isArray:Boolean(t?.[2])}}class WEBGLRenderPipeline extends Le.r{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(e,t){super(e,t),this.device=e;const n=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(t);this.sharedRenderPipeline=n,this.handle=n.handle,this.vs=n.vs,this.fs=n.fs,this.linkStatus=n.linkStatus,this.introspectedLayout=De(this.device.gl,this.handle,{uniformBlockLayouts:t._uniformBlockLayouts,shaderLayout:t.shaderLayout}),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=t.shaderLayout?function(e,t){const n={...e,attributes:e.attributes.map(e=>({...e})),bindings:e.bindings.map(e=>({...e}))};for(const e of t?.attributes||[]){const t=n.attributes.find(t=>t.name===e.name);t?(t.type=e.type||t.type,t.stepMode=e.stepMode||t.stepMode):r.R.warn(`shader layout attribute ${e.name} not present in shader`)}for(const e of t?.bindings||[]){const t=qe(n,e.name);t?Object.assign(t,e):r.R.warn(`shader layout binding ${e.name} not present in shader`)}return n}(this.introspectedLayout,t.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(e,t){const n=(0,Ae.h0)((0,Ae.gO)(this.shaderLayout,e));for(const[e,i]of Object.entries(n)){const n=qe(this.shaderLayout,e);if(n){switch(i||r.R.warn(`Unsetting binding "${e}" in render pipeline "${this.id}"`)(),n.type){case"uniform":if(!(i instanceof WEBGLBuffer||i.buffer instanceof WEBGLBuffer))throw new Error("buffer value");break;case"texture":if(!(i instanceof WEBGLTextureView||i instanceof WEBGLTexture||i instanceof WEBGLFramebuffer))throw new Error(`${this} Bad texture binding for ${e}`);break;case"sampler":r.R.warn(`Ignoring sampler ${e}`)();break;default:throw new Error(n.type)}this.bindings[e]=i}else{const n=this.shaderLayout.bindings.map(e=>`"${e.name}"`).join(", ");t?.disableWarnings||r.R.warn(`No binding "${e}" in render pipeline "${this.id}", expected one of ${n}`,i)()}}}draw(e){const t=e.renderPass,n=e.bindGroups?(0,Ae.h0)(e.bindGroups):e.bindings||this.bindings;return t.setPipeline(this),t.setBindings(n),t.setVertexArray(e.vertexArray),t.draw({parameters:e.parameters,topology:e.topology,isInstanced:e.isInstanced,vertexCount:e.vertexCount,indexCount:e.indexCount,instanceCount:e.instanceCount,firstVertex:e.firstVertex,firstIndex:e.firstIndex,firstInstance:e.firstInstance,baseVertex:e.baseVertex,transformFeedback:e.transformFeedback,uniforms:e.uniforms})}_areTexturesRenderable(e){let t=!0;for(const n of this.shaderLayout.bindings)Ze(e,n.name)||(r.R.warn(`Binding ${n.name} not found in ${this.id}`)(),t=!1);return t}_applyBindings(e,t){if(this._syncLinkStatus(),"success"!==this.linkStatus)return;const{gl:n}=this.device;n.useProgram(this.handle);let i=0,s=0;for(const t of this.shaderLayout.bindings){const o=Ze(e,t.name);if(!o)throw new Error(`No value for binding ${t.name} in ${this.id}`);switch(t.type){case"uniform":const{name:e}=t,a=n.getUniformBlockIndex(this.handle,e);if(4294967295===a)throw new Error(`Invalid uniform block name ${e}`);if(n.uniformBlockBinding(this.handle,a,s),o instanceof WEBGLBuffer)n.bindBufferBase(35345,s,o.handle);else{const e=o;n.bindBufferRange(35345,s,e.buffer.handle,e.offset||0,e.size||e.buffer.byteLength-(e.offset||0))}s+=1;break;case"texture":if(!(o instanceof WEBGLTextureView||o instanceof WEBGLTexture||o instanceof WEBGLFramebuffer))throw new Error("texture");let c;if(o instanceof WEBGLTextureView)c=o.texture;else if(o instanceof WEBGLTexture)c=o;else{if(!(o instanceof WEBGLFramebuffer&&o.colorAttachments[0]instanceof WEBGLTextureView))throw new Error("No texture");r.R.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),c=o.colorAttachments[0].texture}n.activeTexture(33984+i),n.bindTexture(c.glTarget,c.handle),i+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${t.type}' not supported in WebGL`)}}}_applyUniforms(e){for(const t of this.shaderLayout.uniforms||[]){const{name:n,location:i,type:r,textureUnit:s}=t,o=e[n]??s;void 0!==o&&Ee(this.device.gl,i,r,o)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}function qe(e,t){return e.bindings.find(e=>e.name===t||e.name===`${t}Uniforms`||`${e.name}Uniforms`===t)}function Ze(e,t){return e[t]||e[`${t}Uniforms`]||e[t.replace(/Uniforms$/,"")]}class SharedRenderPipeline extends te.F{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(e,t){super(e,t,{...te.F.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}class WEBGLSharedRenderPipeline extends SharedRenderPipeline{device;handle;vs;fs;linkStatus="pending";constructor(e,t){super(e,t),this.device=e,this.handle=t.handle||this.device.gl.createProgram(),this.vs=t.vs,this.fs=t.fs,t.varyings&&t.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,t.varyings,t.bufferMode||35981),this._linkShaders()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){const{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),r.R.time(4,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),r.R.timeEnd(4,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){const e=this._getLinkStatus();return void this._reportLinkStatus(e)}r.R.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),r.R.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();const t=this._getLinkStatus();this._reportLinkStatus(t)}async _reportLinkStatus(e){if("success"!==e){const t="link-error"===e?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${t} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader()}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${t} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader()}const n=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${t} during ${e}: ${n}`),this)(),this.device.debug()}}_getLinkStatus(){const{gl:e}=this.device;if(!e.getProgramParameter(this.handle,35714))return this.linkStatus="error","link-error";this._initializeSamplerUniforms(),e.validateProgram(this.handle);return e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")}_initializeSamplerUniforms(){const{gl:e}=this.device;e.useProgram(this.handle);let t=0;const n=e.getProgramParameter(this.handle,35718);for(let i=0;i<n;i++){const n=e.getActiveUniform(this.handle,i);if(n&&Be(n.type)){const i=n.name.endsWith("[0]"),r=i?n.name.slice(0,-3):n.name,s=e.getUniformLocation(this.handle,r);null!==s&&(t=this._assignSamplerUniform(s,n,i,t))}}}_assignSamplerUniform(e,t,n,i){const{gl:r}=this.device;if(n&&t.size>1){const n=Int32Array.from({length:t.size},(e,t)=>i+t);return r.uniform1iv(e,n),i+t.size}return r.uniform1i(e,i),i+1}async _waitForLinkComplete(){const e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has("compilation-status-async-webgl"))return void await e(10);const{gl:t}=this.device;for(;;){if(t.getProgramParameter(this.handle,37297))return;await e(10)}}}class CommandEncoder extends te.F{get[Symbol.toStringTag](){return"CommandEncoder"}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(e,t){super(e,t,CommandEncoder.defaultProps),this._timeProfilingQuerySet=t.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;const e=Math.floor(this._timeProfilingSlotCount/2);if(e<=0)return;const t=2*e,n=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:t});let i=0n;for(let e=0;e<t;e+=2)i+=n[e+1]-n[e];this._gpuTimeMs=Number(i)/1e6}getTimeProfilingSlotCount(){return this._timeProfilingSlotCount}getTimeProfilingQuerySet(){return this._timeProfilingQuerySet}_applyTimeProfilingToPassProps(e){const t=e||{};if(!this._supportsTimestampQueries()||!this._timeProfilingQuerySet)return t;if(void 0!==t.timestampQuerySet||void 0!==t.beginTimestampIndex||void 0!==t.endTimestampIndex)return t;const n=this._timeProfilingSlotCount;return n+1>=this._timeProfilingQuerySet.props.count?t:(this._timeProfilingSlotCount+=2,{...t,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:n,endTimestampIndex:n+1})}_supportsTimestampQueries(){return this.device.features.has("timestamp-query")}static defaultProps={...te.F.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0}}class CommandBuffer extends te.F{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,CommandBuffer.defaultProps)}static defaultProps={...te.F.defaultProps}}class WEBGLCommandBuffer extends CommandBuffer{device;handle=null;commands=[];constructor(e,t={}){super(e,t),this.device=e}_executeCommands(e=this.commands){for(const t of e)switch(t.name){case"copy-buffer-to-buffer":Ye(this.device,t.options);break;case"copy-buffer-to-texture":Ke(this.device,t.options);break;case"copy-texture-to-buffer":Qe(this.device,t.options);break;case"copy-texture-to-texture":Xe(this.device,t.options);break;default:throw new Error(t.name)}}}function Ye(e,t){const n=t.sourceBuffer,i=t.destinationBuffer;e.gl.bindBuffer(36662,n.handle),e.gl.bindBuffer(36663,i.handle),e.gl.copyBufferSubData(36662,36663,t.sourceOffset??0,t.destinationOffset??0,t.size),e.gl.bindBuffer(36662,null),e.gl.bindBuffer(36663,null)}function Ke(e,t){const{sourceBuffer:n,byteOffset:i=0,destinationTexture:r,mipLevel:s=0,origin:o=[0,0,0],aspect:a="all",bytesPerRow:c,rowsPerImage:l,size:u}=t;if("all"!==a)throw new Error("copyBufferToTexture aspect is not supported in WebGL");r.writeBuffer(n,{byteOffset:i,bytesPerRow:c,rowsPerImage:l,mipLevel:s,x:o[0]??0,y:o[1]??0,z:o[2]??0,width:u[0],height:u[1],depthOrArrayLayers:u[2]})}function Qe(e,t){const{sourceTexture:n,mipLevel:i=0,aspect:r="all",width:s=t.sourceTexture.width,height:o=t.sourceTexture.height,depthOrArrayLayers:a,origin:c=[0,0,0],destinationBuffer:l,byteOffset:u=0,bytesPerRow:d,rowsPerImage:h}=t;if(n instanceof ne.g)return void n.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:s,height:o,depthOrArrayLayers:a,mipLevel:i,aspect:r,byteOffset:u},l);if("all"!==r)throw new Error("aspect not supported in WebGL");if(0!==i||void 0!==a||d||h)throw new Error("not implemented");const{framebuffer:f,destroyFramebuffer:p}=Je(n);let g;try{const t=l,n=s||f.width,i=o||f.height,r=q((0,X.i)(f.colorAttachments[0]).texture.props.format),a=r.format,d=r.type;e.gl.bindBuffer(35051,t.handle),g=e.gl.bindFramebuffer(36160,f.handle),e.gl.readPixels(c[0],c[1],n,i,a,d,u)}finally{e.gl.bindBuffer(35051,null),void 0!==g&&e.gl.bindFramebuffer(36160,g),p&&f.destroy()}}function Xe(e,t){const{sourceTexture:n,destinationMipLevel:i=0,origin:r=[0,0],destinationOrigin:s=[0,0,0],destinationTexture:o}=t;let{width:a=t.destinationTexture.width,height:c=t.destinationTexture.height}=t;const{framebuffer:l,destroyFramebuffer:u}=Je(n),[d=0,h=0]=r,[f,p,g]=s,m=e.gl.bindFramebuffer(36160,l.handle);let v,y;if(!(o instanceof WEBGLTexture))throw new Error("invalid destination");switch(v=o,a=Number.isFinite(a)?a:v.width,c=Number.isFinite(c)?c:v.height,v._bind(0),y=v.glTarget,y){case 3553:case 34067:e.gl.copyTexSubImage2D(y,i,f,p,d,h,a,c);break;case 35866:case 32879:e.gl.copyTexSubImage3D(y,i,f,p,g,d,h,a,c)}v&&v._unbind(),e.gl.bindFramebuffer(36160,m),u&&l.destroy()}function Je(e){if(e instanceof ne.g){const{width:t,height:n,id:i}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${i}`,width:t,height:n,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}class RenderPass extends te.F{static defaultClearColor=[0,0,0,1];static defaultClearDepth=1;static defaultClearStencil=0;get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t,n=RenderPass.defaultProps){super(e,t=RenderPass.normalizeProps(e,t),n)}static normalizeProps(e,t){return t}static defaultProps={...te.F.defaultProps,framebuffer:null,resolveTargets:void 0,parameters:void 0,clearColor:RenderPass.defaultClearColor,clearColors:void 0,clearDepth:RenderPass.defaultClearDepth,clearStencil:RenderPass.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0}}const et=[1,2,4,8];class WEBGLRenderPass extends RenderPass{device;handle=null;glParameters={};pipeline=null;bindings={};bindingsPipeline=null;vertexArray=null;constructor(e,t){super(e,t),this.device=e;const n=this.props.framebuffer,i=!n||null===n.handle;let r;if(i&&e.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded(),!t?.parameters?.viewport)if(!i&&n){const{width:e,height:t}=n;r=[0,0,e,t]}else{const[t,n]=e.getDefaultCanvasContext().getDrawingBufferSize();r=[0,0,t,n]}if(this.device.pushState(),this.setParameters({viewport:r,...this.props.parameters}),!i&&n?.colorAttachments.length){const e=n.colorAttachments.map((e,t)=>36064+t);this.device.gl.drawBuffers(e)}else i&&this.device.gl.drawBuffers([1029]);if(this.clear(),this.props.timestampQuerySet&&void 0!==this.props.beginTimestampIndex){this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}}end(){if(!this.destroyed){if(this.props.timestampQuerySet&&void 0!==this.props.endTimestampIndex){this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex)}this.device.popState(),this.destroy()}}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}executeBundles(e){throw new Error("Render bundles are only supported in WebGPU")}setParameters(e={}){const t={...this.glParameters};t.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=this.props.stencilReadOnly?0:1,t[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),e.scissorRect&&(t.scissorTest=!0,t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),void 0!==e.stencilReference&&(t[2967]=e.stencilReference,t[36003]=e.stencilReference),"colorMask"in e&&(t.colorMask=et.map(t=>Boolean(t&e.colorMask))),this.glParameters=t,b(this.device.gl,t)}setPipeline(e){this.pipeline=e}setBindings(e,t){if(!this.pipeline)throw new Error("RenderPass.setPipeline() must be called before setBindings()");this.bindings=(0,Ae.h0)((0,Ae.gO)(this.pipeline.shaderLayout,e)),this.bindingsPipeline=this.pipeline}setVertexArray(e){this.vertexArray=e}draw(e){const t=this.pipeline,n=this.vertexArray;if(!t)throw new Error("RenderPass.setPipeline() must be called before draw()");if(!n)throw new Error("RenderPass.setVertexArray() must be called before draw()");if(t.shaderLayout.bindings.length>0&&this.bindingsPipeline!==t)throw new Error("RenderPass.setBindings() must be called after setPipeline() before draw()");t._syncLinkStatus();const{parameters:i=t.props.parameters,topology:s=t.props.topology,vertexCount:o,indexCount:a,instanceCount:c,isInstanced:l=!1,firstVertex:u=0,transformFeedback:d,uniforms:h=t.uniforms}=e,f=function(e){switch(e){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(e)}}(s),p=Boolean(n.indexBuffer),g=n.indexBuffer?.glIndexType,m=a??o??0;if("success"!==t.linkStatus)return r.R.info(2,`RenderPipeline:${t.id}.draw() aborted - waiting for shader linking`)(),!1;if(!t._areTexturesRenderable(this.bindings))return r.R.info(2,`RenderPipeline:${t.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(t.handle),n.bindBeforeRender(this);const v=d;return v&&v.begin(t.props.topology),t._applyBindings(this.bindings,{disableWarnings:t.props.disableWarnings}),t._applyUniforms(h),function(e,t,n,i){if(me(t))return i(e);const r=e;r.pushState();try{return ue(e,t),b(r.gl,n),i(e)}finally{r.popState()}}(this.device,i,this.glParameters,()=>{p&&l?this.device.gl.drawElementsInstanced(f,m,g,u,c||0):p?this.device.gl.drawElements(f,m,g,u):l?this.device.gl.drawArraysInstanced(f,u,o||0,c||0):this.device.gl.drawArrays(f,u,o||0),v&&v.end()}),n.unbindAfterRender(this),!0}drawIndirect(e,t=0){throw new Error("Indirect drawing is only supported in WebGPU")}drawIndexedIndirect(e,t=0){throw new Error("Indirect drawing is only supported in WebGPU")}beginOcclusionQuery(e){const t=this.props.occlusionQuerySet;t?.beginOcclusionQuery()}endOcclusionQuery(){const e=this.props.occlusionQuerySet;e?.endOcclusionQuery()}clear(){const e={...this.glParameters};let t=0;this.props.clearColors&&this.props.clearColors.forEach((e,t)=>{e&&this.clearColorBuffer(t,e)}),!1!==this.props.clearColor&&void 0===this.props.clearColors&&(t|=16384,e.clearColor=this.props.clearColor),!1!==this.props.clearDepth&&(t|=256,e.clearDepth=this.props.clearDepth),!1!==this.props.clearStencil&&(t|=1024,e.clearStencil=this.props.clearStencil),0!==t&&xe(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){xe(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,t);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,t);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,t);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}class WEBGLCommandEncoder extends CommandEncoder{device;handle=null;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new WEBGLCommandBuffer(e,{id:this.id,userData:this.userData})}destroy(){this.destroyResource()}finish(){return this.destroy(),this.commandBuffer}beginRenderPass(e={}){return new WEBGLRenderPass(this.device,this._applyTimeProfilingToPassProps(e))}beginComputePass(e={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,t,n){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(e,t){e.writeTimestamp(t)}}class VertexArray extends te.F{static defaultProps={...te.F.defaultProps,shaderLayout:void 0,bufferLayout:[]};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;indexBuffer=null;attributes;constructor(e,t){super(e,t,VertexArray.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null)}getBufferSlot(e){return null}getDrawValidationError(){return null}setConstantWebGL(e,t){this.device.reportError(new Error("constant attributes not supported"),this)()}}var tt=n(2021),nt=n(73390),it=n(15399),rt=n(35526);class WEBGLVertexArray extends VertexArray{get[Symbol.toStringTag](){return"VertexArray"}device;handle;attributeInfosByLocation;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return"Chrome"==(t||(0,K.B)()?(0,it.b)(t)?"Electron":(t||rt.gM.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown":"Node");var t}constructor(e,t){super(e,t),this.device=e,this.handle=this.device.gl.createVertexArray(),this.attributeInfosByLocation=new Array(this.maxVertexAttributes).fill(null);for(const e of Object.values((0,tt.P)(t.shaderLayout,t.bufferLayout)))this.attributeInfosByLocation[e.location]=e}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){const t=e;if(t&&34963!==t.glTarget)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,t?t.handle:null),this.indexBuffer=t,this.device.gl.bindVertexArray(null)}setBuffer(e,t){const n=t;if(34963===n.glTarget)throw new Error("Use .setIndexBuffer()");const{size:i,type:r,stride:s,offset:o,normalized:a,integer:c,divisor:l}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,n.handle),c?this.device.gl.vertexAttribIPointer(e,i,r,s,o):this.device.gl.vertexAttribPointer(e,i,r,a,s,o),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,l||0),this.attributes[e]=n,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,t){this._enable(e,!1),this.attributes[e]=t}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e<this.maxVertexAttributes;++e){const t=this.attributes[e];ArrayBuffer.isView(t)&&this.device.setConstantAttributeWebGL(e,t)}}_getAccessor(e){const t=this.attributeInfosByLocation[e];if(!t)throw new Error(`Unknown attribute location ${e}`);const n=M(t.bufferDataType);return{size:t.bufferComponents,type:n,stride:t.byteStride,offset:t.byteOffset,normalized:t.normalized,integer:t.integer,divisor:"instance"===t.stepMode?1:0}}_enable(e,t=!0){const n=WEBGLVertexArray.isConstantAttributeZeroSupported(this.device);(t||(n||0!==e))&&(e=Number(e),this.device.gl.bindVertexArray(this.handle),t?this.device.gl.enableVertexAttribArray(e):this.device.gl.disableVertexAttribArray(e),this.device.gl.bindVertexArray(null))}getConstantBuffer(e,t){const n=function(e){if(Array.isArray(e))return new Float32Array(e);return e}(t),i=n.byteLength*e,r=n.length*e;if(this.buffer&&i!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${i} !== ${this.buffer.byteLength}.`);let s=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:i}),s||=!function(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}(n,this.bufferValue),s){const e=(0,nt.X)(t.constructor,r);!function(e){const{target:t,source:n,start:i=0,count:r=1}=e,s=n.length,o=r*s;let a=0;for(let e=i;a<s;a++)t[e++]=n[a]??0;for(;a<o;)a<o-a?(t.copyWithin(i+a,i,i+a),a*=2):(t.copyWithin(i+a,i,i+o-a),a=o);e.target}({target:e,source:n,start:0,count:r}),this.buffer.write(e),this.bufferValue=t}return this.buffer}}class TransformFeedback extends te.F{static defaultProps={...te.F.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,TransformFeedback.defaultProps)}}class WEBGLTransformFeedback extends TransformFeedback{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,t){super(e,t),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,t.buffers&&this.setBuffers(t.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(function(e){switch(e){case"point-list":return 0;case"line-list":case"line-strip":return 1;case"triangle-list":case"triangle-strip":return 4;default:throw new Error(e)}}(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(const[t,n]of Object.entries(e))this.setBuffer(t,n)})}setBuffer(e,t){const n=this._getVaryingIndex(e),{buffer:i,byteLength:s,byteOffset:o}=this._getBufferRange(t);if(n<0)return this.unusedBuffers[e]=i,void r.R.warn(`${this.id} unusedBuffers varying buffer ${e}`)();this.buffers[n]={buffer:i,byteLength:s,byteOffset:o},this.bindOnUse||this._bindBuffer(n,i,o,s)}getBuffer(e){if(st(e))return this.buffers[e]||null;const t=this._getVaryingIndex(e);return this.buffers[t]??null}bind(e=this.handle){if("function"!=typeof e)return this.gl.bindTransformFeedback(36386,e),this;let t;return this._bound?t=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),t}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof WEBGLBuffer)return{buffer:e,byteOffset:0,byteLength:e.byteLength};const{buffer:t,byteOffset:n=0,byteLength:i=e.buffer.byteLength}=e;return{buffer:t,byteOffset:n,byteLength:i}}_getVaryingIndex(e){if(st(e))return Number(e);for(const t of this.layout.varyings||[])if(e===t.name)return t.location;return-1}_bindBuffers(){for(const[e,t]of Object.entries(this.buffers)){const{buffer:n,byteLength:i,byteOffset:r}=this._getBufferRange(t);this._bindBuffer(Number(e),n,r,i)}}_unbindBuffers(){for(const e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,n=0,i){const r=t&&t.handle;r&&void 0!==i?this.gl.bindBufferRange(35982,e,r,n,i):this.gl.bindBufferBase(35982,e,r)}}function st(e){return"number"==typeof e?Number.isInteger(e):/^\d+$/.test(e)}class QuerySet extends te.F{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,QuerySet.defaultProps)}static defaultProps={...te.F.defaultProps,type:void 0,count:void 0}}class WEBGLQuerySet extends QuerySet{device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){if(super(e,t),this.device=e,"timestamp"===t.type){if(t.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(t.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(t.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");const e=this.device.gl.createQuery();if(!e)throw new Error("WebGL query not supported");this.handle=e}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(const e of this._timestampPairs){e.activeQuery&&(this._cancelPendingQuery(e.activeQuery),this.device.gl.deleteQuery(e.activeQuery.handle));for(const t of e.completedQueries)this._cancelPendingQuery(t),this.device.gl.deleteQuery(t.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(const e of Array.from(this._pendingReads))this._cancelPendingQuery(e);this.destroyResource()}}isResultAvailable(e){return"timestamp"===this.props.type?void 0===e?this._timestampPairs.some((e,t)=>this._isTimestampPairAvailable(t)):this._isTimestampPairAvailable(this._getTimestampPairIndex(e)):!!this._occlusionQuery&&this._pollQueryAvailability(this._occlusionQuery)}async readResults(e){const t=e?.firstQuery||0,n=e?.queryCount||this.props.count-t;if(this._validateRange(t,n),"timestamp"===this.props.type){const e=new Array(n).fill(0n),i=Math.floor(t/2),r=Math.floor((t+n-1)/2);for(let s=i;s<=r;s++){const i=await this._consumeTimestampPairResult(s),r=2*s,o=r+1;r>=t&&r<t+n&&(e[r-t]=0n),o>=t&&o<t+n&&(e[o-t]=i)}return e}if(!this._occlusionQuery)throw new Error("Occlusion query has not been started");return[await this._consumeQueryResult(this._occlusionQuery)]}async readTimestampDuration(e,t){if("timestamp"!==this.props.type)throw new Error("Timestamp durations require a timestamp QuerySet");if(e<0||t>=this.props.count||t<=e)throw new Error("Timestamp duration range is out of bounds");if(e%2!=0||t!==e+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");const n=await this._consumeTimestampPairResult(this._getTimestampPairIndex(e));return Number(n)/1e6}beginOcclusionQuery(){if("occlusion"!==this.props.type)throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(e){if("timestamp"!==this.props.type)throw new Error("Timestamp writes require a timestamp QuerySet");const t=this._getTimestampPairIndex(e),n=this._timestampPairs[t];if(e%2==0){if(n.activeQuery)throw new Error("Timestamp query pair is already active");const e=this.device.gl.createQuery();if(!e)throw new Error("WebGL query not supported");const t={handle:e,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};return this.device.gl.beginQuery(35007,e),void(n.activeQuery=t)}if(!n.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),n.completedQueries.push(n.activeQuery),n.activeQuery=null}_validateRange(e,t){if(e<0||t<0||e+t>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(e){if(e<0||e>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(e/2)}_isTimestampPairAvailable(e){const t=this._timestampPairs[e];return!(!t||0===t.completedQueries.length)&&this._pollQueryAvailability(t.completedQueries[0])}_pollQueryAvailability(e){if(e.cancelled||this.destroyed)return e.result=0n,!0;if(null!==e.result||e.disjoint)return!0;if(!this.device.gl.getQueryParameter(e.handle,34919))return!1;const t=Boolean(this.device.gl.getParameter(36795));return e.disjoint=t,e.result=t?0n:BigInt(this.device.gl.getQueryParameter(e.handle,34918)),!0}async _consumeTimestampPairResult(e){const t=this._timestampPairs[e];if(!t||0===t.completedQueries.length)throw new Error("Timestamp query pair has no completed result");const n=t.completedQueries.shift();try{return await this._consumeQueryResult(n)}finally{this.device.gl.deleteQuery(n.handle)}}_consumeQueryResult(e){return e.promise||(this._pendingReads.add(e),e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n;const i=()=>{if(e.pollRequestId=null,e.cancelled||this.destroyed)return this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,void t(0n);this._pollQueryAvailability(e)?(this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,e.disjoint?n(new Error("GPU timestamp query was invalidated by a disjoint event")):t(e.result||0n)):e.pollRequestId=this._requestAnimationFrame(i)};i()})),e.promise}_cancelPendingQuery(e){if(this._pendingReads.delete(e),e.cancelled=!0,null!==e.pollRequestId&&(this._cancelAnimationFrame(e.pollRequestId),e.pollRequestId=null),e.resolve){const t=e.resolve;e.promise=null,e.resolve=null,e.reject=null,t(0n)}}_requestAnimationFrame(e){return requestAnimationFrame(e)}_cancelAnimationFrame(e){cancelAnimationFrame(e)}}class Fence extends te.F{static defaultProps={...te.F.defaultProps};get[Symbol.toStringTag](){return"Fence"}constructor(e,t={}){super(e,t,Fence.defaultProps)}}class WEBGLFence extends Fence{device;gl;handle;signaled;_signaled=!1;constructor(e,t={}){super(e,{}),this.device=e,this.gl=e.gl;const n=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!n)throw new Error("Failed to create WebGL fence");this.handle=n,this.signaled=new Promise(e=>{const t=()=>{const n=this.gl.clientWaitSync(this.handle,0,0);n===this.gl.ALREADY_SIGNALED||n===this.gl.CONDITION_SATISFIED?(this._signaled=!0,e()):setTimeout(t,1)};t()})}isSignaled(){if(this._signaled)return!0;const e=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=e===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}var ot=n(57285);function at(e){switch(e){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function ct(e,t){const{sourceX:n=0,sourceY:i=0,sourceAttachment:r=0}=t||{};let{target:s=null,sourceWidth:o,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:u}=t||{};const{framebuffer:d,deleteFramebuffer:h}=lt(e),{gl:f,handle:p}=d;o||=d.width,a||=d.height;const g=d.colorAttachments[r]?.texture;if(!g)throw new Error(`Invalid framebuffer attachment ${r}`);c=g?.depth||1,l||=g?.glFormat||6408,u||=g?.glType||5121,s=function(e,t,n,i,r){if(e)return e;t||=5121;const s=Pe(t),o=ot.r.getTypedArrayConstructor(s),a=at(n);return new o(i*r*a)}(s,u,l,o,a);const m=ot.r.getDataType(s);u=u||ze[m];const v=f.bindFramebuffer(36160,p);return f.readBuffer(36064+r),f.readPixels(n,i,o,a,l,u,s),f.readBuffer(36064),f.bindFramebuffer(36160,v||null),h&&d.destroy(),s}function lt(e){return e instanceof Framebuffer?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:ut(e),deleteFramebuffer:!0}}function ut(e,t){const{device:n,width:i,height:r,id:s}=e;return n.createFramebuffer({...t,id:`framebuffer-for-${s}`,width:i,height:r,colorAttachments:[e]})}class WebGLDevice extends i.pF{static getDeviceFromContext(e){return e?e.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;_isLost=!1;gl;_glKeyByValue=null;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){return"unorm8x4-bgra"!==e}constructor(e){super({...e,id:e.id||se("webgl-device")});const t=i.pF._getCanvasContextProps(e);if(!t)throw new Error("WebGLDevice requires props.createCanvasContext to be set");const n=t.canvas?.gl??null;let s=WebGLDevice.getDeviceFromContext(n);if(s)throw new Error(`WebGL context already attached to device ${s.id}`);this.canvasContext=new WebGLCanvasContext(this,t),this.lost=new Promise(e=>{this._resolveContextLost=e});const o={...e.webgl};"premultiplied"===t.alphaMode&&(o.premultipliedAlpha=!0),void 0!==e.powerPreference&&(o.powerPreference=e.powerPreference),void 0!==e.failIfMajorPerformanceCaveat&&(o.failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat);const a=this.props._handle||function(e,t,n){let i="";const r=e=>{const t=e.statusMessage;t&&(i||=t)};e.addEventListener("webglcontextcreationerror",r,!1);const s=!0!==n.failIfMajorPerformanceCaveat,o={preserveDrawingBuffer:!0,...n,failIfMajorPerformanceCaveat:!0};let a=null;try{a||=e.getContext("webgl2",o),!a&&o.failIfMajorPerformanceCaveat&&(i||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let n=!1;if(!a&&s&&(o.failIfMajorPerformanceCaveat=!1,a=e.getContext("webgl2",o),n=!0),a||(a=e.getContext("webgl",{}),a&&(a=null,i||="Your browser only supports WebGL1")),!a)throw i||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${i}`);S(a).softwareRenderer=n;const{onContextLost:r,onContextRestored:c}=t;return e.addEventListener("webglcontextlost",e=>r(e),!1),e.addEventListener("webglcontextrestored",e=>c(e),!1),a}finally{e.removeEventListener("webglcontextcreationerror",r,!1)}}(this.canvasContext.canvas,{onContextLost:e=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:e=>{console.log("WebGL context restored")}},o);if(!a)throw new Error("WebGL context creation failed");if(s=WebGLDevice.getDeviceFromContext(a),s){if(e._reuseDevices)return r.R.log(1,`Not creating a new Device, instead returning a reference to Device ${s.id} already attached to WebGL context`,s)(),this.canvasContext.destroy(),s._reused=!0,s;throw new Error(`WebGL context already attached to device ${s.id}`)}this.handle=a,this.gl=a,this.spectorJS=(0,ie.c0)({...this.props,gl:this.handle});const c=S(this.handle);c.device=this,c.extensions||(c.extensions={}),this.extensions=c.extensions,this.info=A(this.gl,this.extensions),this.limits=new WebGLDeviceLimits(this.gl),this.features=new WebGLDeviceFeatures(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures();new WebGLStateTracker(this.gl,{log:(...e)=>r.R.log(1,...e)()}).trackState(this.gl,{copyState:!1}),(e.debug||e.debugWebGL)&&(this.gl=(0,ie.Pz)(this.gl,{debugWebGL:!0,traceWebGL:e.debugWebGL}),r.R.warn("WebGL debug mode activated. Performance reduced.")()),e.debugWebGL&&(r.R.level=Math.max(r.R.level,1)),this.commandEncoder=new WEBGLCommandEncoder(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(!this.props._reuseDevices&&!this._reused){this._isLost=!0,this.commandEncoder?.destroy();S(this.handle).device=null}}get isLost(){return this._isLost||this.gl.isContextLost()}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createPresentationContext(e){return new WebGLPresentationContext(this,e||{})}createBuffer(e){const t=this._normalizeBufferProps(e);return new WEBGLBuffer(this,t)}createTexture(e){return new WEBGLTexture(this,e)}createExternalTexture(e){throw new Error("ExternalTexture is not available on WebGL")}createSampler(e){return new WEBGLSampler(this,e)}createShader(e){return new WEBGLShader(this,e)}createFramebuffer(e){return new WEBGLFramebuffer(this,e)}createVertexArray(e){return new WEBGLVertexArray(this,e)}createTransformFeedback(e){return new WEBGLTransformFeedback(this,e)}createQuerySet(e){return new WEBGLQuerySet(this,e)}createFence(){return new WEBGLFence(this)}createRenderPipeline(e){return new WEBGLRenderPipeline(this,e)}_createSharedRenderPipelineWebGL(e){return new WEBGLSharedRenderPipeline(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}createRenderBundleEncoder(e){throw new Error("Render bundles are only supported in WebGPU")}createCommandEncoder(e={}){return new WEBGLCommandEncoder(this,e)}submit(e){let t=null;e||({submittedCommandEncoder:t,commandBuffer:e}=this._finalizeDefaultCommandEncoderForSubmit());try{e._executeCommands(),t&&t.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=t._gpuTimeMs}).catch(()=>{})}finally{e.destroy()}}writeBufferViaCommandEncoder(e,t,n,i=0){t.write(n,i)}_finalizeDefaultCommandEncoderForSubmit(){const e=this.commandEncoder,t=e.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:e.props.id,timeProfilingQuerySet:e.getTimeProfilingQuerySet()}),{submittedCommandEncoder:e,commandBuffer:t}}readPixelsToArrayWebGL(e,t){return ct(e,t)}readPixelsToBufferWebGL(e,t){return function(e,t){const{target:n,sourceX:i=0,sourceY:r=0,sourceFormat:s=6408,targetByteOffset:o=0}=t||{};let{sourceWidth:a,sourceHeight:c,sourceType:l}=t||{};const{framebuffer:u,deleteFramebuffer:d}=lt(e);a=a||u.width,c=c||u.height;const h=u;l=l||5121;let f=n;if(!f){const e=o+a*c*at(s)*function(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}(l);f=h.device.createBuffer({byteLength:e})}const p=e.device.createCommandEncoder();return p.copyTextureToBuffer({sourceTexture:e,width:a,height:c,origin:[i,r],destinationBuffer:f,byteOffset:o}),p.destroy(),d&&u.destroy(),f}(e,t)}setParametersWebGL(e){b(this.gl,e)}getParametersWebGL(e){return _(this.gl,e)}withParametersWebGL(e,t){return xe(this.gl,e,t)}resetWebGL(){r.R.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),b(this.gl,s)}_getDeviceSpecificTextureFormatCapabilities(e){return H(this.gl,e,this.extensions)}loseDevice(){let e=!1;const t=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return t&&(e=!0,t.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){WebGLStateTracker.get(this.gl).push()}popState(){WebGLStateTracker.get(this.gl).pop()}getGLKey(e,t){const n=this._getGLKeyByValue().get(Number(e));return n||(t?.emptyIfUnknown?"":String(e))}getGLKeys(e){const t={emptyIfUnknown:!0};return Object.entries(e).reduce((e,[n,i])=>(e[`${n}:${this.getGLKey(n,t)}`]=`${i}:${this.getGLKey(i,t)}`,e),{})}_getGLKeyByValue(){return this._glKeyByValue??=function(e){const t=new Map;for(const n in e){const i=e[n];if(n<"a"){const e=t.get(i);t.set(i,e?`${e}, GL.${n}`:`GL.${n}`)}}return t}(this.gl),this._glKeyByValue}setConstantAttributeWebGL(e,t){const n=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(n).fill(null);const i=this._constants[e];switch(i&&function(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}(i,t)&&r.R.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=t,t.constructor){case Float32Array:!function(e,t,n){switch(n.length){case 1:e.gl.vertexAttrib1fv(t,n);break;case 2:e.gl.vertexAttrib2fv(t,n);break;case 3:e.gl.vertexAttrib3fv(t,n);break;case 4:e.gl.vertexAttrib4fv(t,n)}}(this,e,t);break;case Int32Array:!function(e,t,n){e.gl.vertexAttribI4iv(t,n)}(this,e,t);break;case Uint32Array:!function(e,t,n){e.gl.vertexAttribI4uiv(t,n)}(this,e,t);break;default:throw new Error("constant")}}getExtension(e){return L(this.gl,e,this.extensions),this.extensions}_setWebGLDebugMetadata(e,t,n){e.luma=t;const i={props:n.spector,id:n.spector.id};e.__SPECTOR_Metadata=i}}},89689(e,t,n){n.d(t,{Oy:()=>l,Pz:()=>c,c0:()=>u,z2:()=>a});var i=n(29651);let r=null,s=null,o=!1;async function a(){r?await r.load():d()}function c(e,t){return r?r.makeDebugContext(e,t):(d(),e)}async function l(e){s?await s.load(e):d()}function u(e){return s?.initialize(e)||null}function d(){o||(o=!0,i.R.warn("Import @luma.gl/webgl/debug before enabling WebGL debugging.")())}},18584(e,t,n){function i(e,t,n,i,r=[]){let s,o;if(8&n)s=(i[3]-e[1])/(t[1]-e[1]),o=3;else if(4&n)s=(i[1]-e[1])/(t[1]-e[1]),o=1;else if(2&n)s=(i[2]-e[0])/(t[0]-e[0]),o=2;else{if(!(1&n))return null;s=(i[0]-e[0])/(t[0]-e[0]),o=0}for(let n=0;n<e.length;n++)r[n]=(1&o)===n?i[o]:s*(t[n]-e[n])+e[n];return r}function r(e,t){let n=0;return e[0]<t[0]?n|=1:e[0]>t[2]&&(n|=2),e[1]<t[1]?n|=4:e[1]>t[3]&&(n|=8),n}n.d(t,{w:()=>a,M:()=>o});var s=n(76520);function o(e,t){const{size:n=2,broken:o=!1,gridResolution:a=10,gridOffset:c=[0,0],startIndex:d=0,endIndex:h=e.length}=t||{},f=(h-d)/n;let p=[];const g=[p],m=(0,s.ah)(e,0,n,d);let v,y;const b=l(m,a,c,[]),_=[];(0,s.VC)(p,m);for(let t=1;t<f;t++){for(v=(0,s.ah)(e,t,n,d,v),y=r(v,b);y;){i(m,v,y,b,_);const e=r(_,b);e&&(i(m,_,e,b,_),y=e),(0,s.VC)(p,_),(0,s.C)(m,_),u(b,a,y),o&&p.length>n&&(p=[],g.push(p),(0,s.VC)(p,m)),y=r(v,b)}(0,s.VC)(p,v),(0,s.C)(m,v)}return o?g:g[0]}function a(e,t=null,n){if(!e.length)return[];const{size:i=2,gridResolution:s=10,gridOffset:o=[0,0],edgeTypes:a=!1}=n||{},u=[],f=[{pos:e,types:a?new Array(e.length/i).fill(1):null,holes:t||[]}],p=[[],[]];let g=[];for(;f.length;){const{pos:e,types:t,holes:n}=f.shift();d(e,i,n[0]||e.length,p),g=l(p[0],s,o,g);const m=r(p[1],g);if(m){let r=c(e,t,i,0,n[0]||e.length,g,m);const s={pos:r[0].pos,types:r[0].types,holes:[]},o={pos:r[1].pos,types:r[1].types,holes:[]};f.push(s,o);for(let l=0;l<n.length;l++)r=c(e,t,i,n[l],n[l+1]||e.length,g,m),r[0]&&(s.holes.push(s.pos.length),s.pos=h(s.pos,r[0].pos),a&&(s.types=h(s.types,r[0].types))),r[1]&&(o.holes.push(o.pos.length),o.pos=h(o.pos,r[1].pos),a&&(o.types=h(o.types,r[1].types)))}else{const i={positions:e};a&&(i.edgeTypes=t),n.length&&(i.holeIndices=n),u.push(i)}}return u}function c(e,t,n,r,o,a,c){const l=(o-r)/n,u=[],d=[],h=[],f=[],p=[];let g,m,v;const y=(0,s.ah)(e,l-1,n,r);let b=Math.sign(8&c?y[1]-a[3]:y[0]-a[2]),_=t&&t[l-1],x=0,w=0;for(let o=0;o<l;o++)g=(0,s.ah)(e,o,n,r,g),m=Math.sign(8&c?g[1]-a[3]:g[0]-a[2]),v=t&&t[r/n+o],m&&b&&b!==m&&(i(y,g,c,a,p),(0,s.VC)(u,p)&&h.push(_),(0,s.VC)(d,p)&&f.push(_)),m<=0?((0,s.VC)(u,g)&&h.push(v),x-=m):h.length&&(h[h.length-1]=0),m>=0?((0,s.VC)(d,g)&&f.push(v),w+=m):f.length&&(f[f.length-1]=0),(0,s.C)(y,g),b=m,_=v;return[x?{pos:u,types:t&&h}:null,w?{pos:d,types:t&&f}:null]}function l(e,t,n,i){const r=Math.floor((e[0]-n[0])/t)*t+n[0],s=Math.floor((e[1]-n[1])/t)*t+n[1];return i[0]=r,i[1]=s,i[2]=r+t,i[3]=s+t,i}function u(e,t,n){8&n?(e[1]+=t,e[3]+=t):4&n?(e[1]-=t,e[3]-=t):2&n?(e[0]+=t,e[2]+=t):1&n&&(e[0]-=t,e[2]-=t)}function d(e,t,n,i){let r=1/0,s=-1/0,o=1/0,a=-1/0;for(let i=0;i<n;i+=t){const t=e[i],n=e[i+1];r=t<r?t:r,s=t>s?t:s,o=n<o?n:o,a=n>a?n:a}return i[0][0]=r,i[0][1]=o,i[1][0]=s,i[1][1]=a,i}function h(e,t){for(let n=0;n<t.length;n++)e.push(t[n]);return e}},6423(e,t,n){n.d(t,{E:()=>o,I:()=>s});var i=n(18584),r=n(76520);function s(e,t){const{size:n=2,startIndex:r=0,endIndex:s=e.length,normalize:o=!0}=t||{},a=e.slice(r,s);l(a,n,0,s-r);const c=(0,i.M)(a,{size:n,broken:!0,gridResolution:360,gridOffset:[-180,-180]});if(o)for(const e of c)u(e,n);return c}function o(e,t=null,n){const{size:r=2,normalize:s=!0,edgeTypes:o=!1}=n||{};t=t||[];const d=[],h=[];let f=0,p=0;for(let i=0;i<=t.length;i++){const s=t[i]||e.length,o=p,u=a(e,r,f,s);for(let t=u;t<s;t++)d[p++]=e[t];for(let t=f;t<u;t++)d[p++]=e[t];l(d,r,o,p),c(d,r,o,p,n?.maxLatitude),f=s,h[i]=p}h.pop();const g=(0,i.w)(d,h,{size:r,gridResolution:360,gridOffset:[-180,-180],edgeTypes:o});if(s)for(const e of g)u(e.positions,r);return g}function a(e,t,n,i){let r=-1,s=-1;for(let o=n+1;o<i;o+=t){const t=Math.abs(e[o]);t>r&&(r=t,s=o-1)}return s}function c(e,t,n,i,s=85.051129){const o=e[n],a=e[i-t];if(Math.abs(o-a)>180){const i=(0,r.ah)(e,0,t,n);i[0]+=360*Math.round((a-o)/360),(0,r.VC)(e,i),i[1]=Math.sign(i[1])*s,(0,r.VC)(e,i),i[0]=o,(0,r.VC)(e,i)}}function l(e,t,n,i){let r,s=e[0];for(let o=n;o<i;o+=t){r=e[o];const t=r-s;(t>180||t<-180)&&(r-=360*Math.round(t/360)),e[o]=s=r}}function u(e,t){let n;const i=e.length/t;for(let r=0;r<i&&(n=e[r*t],(n+180)%360==0);r++);const r=360*-Math.round(n/360);if(0!==r)for(let n=0;n<i;n++)e[n*t]+=r}},76520(e,t,n){function i(e,t){const n=t.length,i=e.length;if(i>0){let r=!0;for(let s=0;s<n;s++)if(e[i-n+s]!==t[s]){r=!1;break}if(r)return!1}for(let r=0;r<n;r++)e[i+r]=t[r];return!0}function r(e,t){const n=t.length;for(let i=0;i<n;i++)e[i]=t[i]}function s(e,t,n,i,r=[]){const s=i+t*n;for(let t=0;t<n;t++)r[t]=e[s+t];return r}n.d(t,{C:()=>r,VC:()=>i,ah:()=>s})},76282(e,t,n){function i(e){return function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}(e)||function(e){return!!Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}(e)}n.d(t,{H9:()=>i})},30568(e,t,n){function i(){let e;if("undefined"!=typeof window&&window.performance)e=window.performance.now();else if("undefined"!=typeof process&&process.hrtime){const t=process.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}n.d(t,{A:()=>Stats});class Stat{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=i(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(i()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}class Stats{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e of Object.values(this.stats))e.reset();return this}forEach(e){for(const t of Object.values(this.stats))e(t)}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(e=>this._getOrCreate(e))}_getOrCreate(e){const{name:t,type:n}=e;let i=this.stats[t];return i||(i=e instanceof Stat?e:new Stat(t,n),this.stats[t]=i),i}}}}]);
|