@prostgles/app 2.3.6-dev.1793125925 → 2.3.6-dev.1795951452
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 +14 -32
- 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 -44
- package/dist/server/src/Alerts/getAlertTableOptions.js.map +1 -1
- package/dist/server/src/Alerts/getAlertTables.d.ts +187 -154
- package/dist/server/src/Alerts/getAlertTables.d.ts.map +1 -1
- package/dist/server/src/Alerts/getAlertTables.js +57 -50
- 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 +60 -36
- 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 +0 -2
- 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 +4 -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/Alerts/syncConfiguredAlerts.d.ts +0 -5
- package/dist/server/src/Alerts/syncConfiguredAlerts.d.ts.map +0 -1
- package/dist/server/src/Alerts/syncConfiguredAlerts.js +0 -52
- package/dist/server/src/Alerts/syncConfiguredAlerts.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
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([[489],{81456(e,t){var n,i,r;i=[],void 0===(r="function"==typeof(n=function(){"use strict";function e(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function t(e){return!0===(e&&e.__isLong__)}e.prototype.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),e.isLong=t;var n={},i={};function r(e,t){var r,s,a;return t?(a=0<=(e>>>=0)&&e<256)&&(s=i[e])?s:(r=o(e,(0|e)<0?-1:0,!0),a&&(i[e]=r),r):(a=-128<=(e|=0)&&e<128)&&(s=n[e])?s:(r=o(e,e<0?-1:0,!1),a&&(n[e]=r),r)}function s(e,t){if(isNaN(e)||!isFinite(e))return t?g:p;if(t){if(e<0)return g;if(e>=h)return y}else{if(e<=-d)return w;if(e+1>=d)return v}return e<0?s(-e,t).neg():o(e%u|0,e/u|0,t)}function o(t,n,i){return new e(t,n,i)}e.fromInt=r,e.fromNumber=s,e.fromBits=o;var a=Math.pow;function l(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return p;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||36<n)throw RangeError("radix");var i;if((i=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===i)return l(e.substring(1),t,n).neg();for(var r=s(a(n,8)),o=p,c=0;c<e.length;c+=8){var A=Math.min(8,e.length-c),u=parseInt(e.substring(c,c+A),n);if(A<8){var h=s(a(n,A));o=o.mul(h).add(s(u))}else o=(o=o.mul(r)).add(s(u))}return o.unsigned=t,o}function c(t){return t instanceof e?t:"number"==typeof t?s(t):"string"==typeof t?l(t):o(t.low,t.high,t.unsigned)}e.fromString=l,e.fromValue=c;var A=65536,u=A*A,h=u*u,d=h/2,f=r(1<<24),p=r(0);e.ZERO=p;var g=r(0,!0);e.UZERO=g;var m=r(1);e.ONE=m;var b=r(1,!0);e.UONE=b;var _=r(-1);e.NEG_ONE=_;var v=o(-1,2147483647,!1);e.MAX_VALUE=v;var y=o(-1,-1,!0);e.MAX_UNSIGNED_VALUE=y;var w=o(0,-2147483648,!1);e.MIN_VALUE=w;var x=e.prototype;return x.toInt=function(){return this.unsigned?this.low>>>0:this.low},x.toNumber=function(){return this.unsigned?(this.high>>>0)*u+(this.low>>>0):this.high*u+(this.low>>>0)},x.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(w)){var t=s(e),n=this.div(t),i=n.mul(t).sub(this);return n.toString(e)+i.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var r=s(a(e,6),this.unsigned),o=this,l="";;){var c=o.div(r),A=(o.sub(c.mul(r)).toInt()>>>0).toString(e);if((o=c).isZero())return A+l;for(;A.length<6;)A="0"+A;l=""+A+l}},x.getHighBits=function(){return this.high},x.getHighBitsUnsigned=function(){return this.high>>>0},x.getLowBits=function(){return this.low},x.getLowBitsUnsigned=function(){return this.low>>>0},x.getNumBitsAbs=function(){if(this.isNegative())return this.eq(w)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<<t);t--);return 0!=this.high?t+33:t+1},x.isZero=function(){return 0===this.high&&0===this.low},x.isNegative=function(){return!this.unsigned&&this.high<0},x.isPositive=function(){return this.unsigned||this.high>=0},x.isOdd=function(){return!(1&~this.low)},x.isEven=function(){return!(1&this.low)},x.equals=function(e){return t(e)||(e=c(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},x.eq=x.equals,x.notEquals=function(e){return!this.eq(e)},x.neq=x.notEquals,x.lessThan=function(e){return this.comp(e)<0},x.lt=x.lessThan,x.lessThanOrEqual=function(e){return this.comp(e)<=0},x.lte=x.lessThanOrEqual,x.greaterThan=function(e){return this.comp(e)>0},x.gt=x.greaterThan,x.greaterThanOrEqual=function(e){return this.comp(e)>=0},x.gte=x.greaterThanOrEqual,x.compare=function(e){if(t(e)||(e=c(e)),this.eq(e))return 0;var n=this.isNegative(),i=e.isNegative();return n&&!i?-1:!n&&i?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},x.comp=x.compare,x.negate=function(){return!this.unsigned&&this.eq(w)?w:this.not().add(m)},x.neg=x.negate,x.add=function(e){t(e)||(e=c(e));var n=this.high>>>16,i=65535&this.high,r=this.low>>>16,s=65535&this.low,a=e.high>>>16,l=65535&e.high,A=e.low>>>16,u=0,h=0,d=0,f=0;return d+=(f+=s+(65535&e.low))>>>16,h+=(d+=r+A)>>>16,u+=(h+=i+l)>>>16,u+=n+a,o((d&=65535)<<16|(f&=65535),(u&=65535)<<16|(h&=65535),this.unsigned)},x.subtract=function(e){return t(e)||(e=c(e)),this.add(e.neg())},x.sub=x.subtract,x.multiply=function(e){if(this.isZero())return p;if(t(e)||(e=c(e)),e.isZero())return p;if(this.eq(w))return e.isOdd()?w:p;if(e.eq(w))return this.isOdd()?w:p;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(f)&&e.lt(f))return s(this.toNumber()*e.toNumber(),this.unsigned);var n=this.high>>>16,i=65535&this.high,r=this.low>>>16,a=65535&this.low,l=e.high>>>16,A=65535&e.high,u=e.low>>>16,h=65535&e.low,d=0,g=0,m=0,b=0;return m+=(b+=a*h)>>>16,g+=(m+=r*h)>>>16,m&=65535,g+=(m+=a*u)>>>16,d+=(g+=i*h)>>>16,g&=65535,d+=(g+=r*u)>>>16,g&=65535,d+=(g+=a*A)>>>16,d+=n*h+i*u+r*A+a*l,o((m&=65535)<<16|(b&=65535),(d&=65535)<<16|(g&=65535),this.unsigned)},x.mul=x.multiply,x.divide=function(e){if(t(e)||(e=c(e)),e.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?g:p;var n,i,r;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return g;if(e.gt(this.shru(1)))return b;r=g}else{if(this.eq(w))return e.eq(m)||e.eq(_)?w:e.eq(w)?m:(n=this.shr(1).div(e).shl(1)).eq(p)?e.isNegative()?m:_:(i=this.sub(e.mul(n)),r=n.add(i.div(e)));if(e.eq(w))return this.unsigned?g:p;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();r=p}for(i=this;i.gte(e);){n=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(n)/Math.LN2),l=o<=48?1:a(2,o-48),A=s(n),u=A.mul(e);u.isNegative()||u.gt(i);)u=(A=s(n-=l,this.unsigned)).mul(e);A.isZero()&&(A=m),r=r.add(A),i=i.sub(u)}return r},x.div=x.divide,x.modulo=function(e){return t(e)||(e=c(e)),this.sub(this.div(e).mul(e))},x.mod=x.modulo,x.not=function(){return o(~this.low,~this.high,this.unsigned)},x.and=function(e){return t(e)||(e=c(e)),o(this.low&e.low,this.high&e.high,this.unsigned)},x.or=function(e){return t(e)||(e=c(e)),o(this.low|e.low,this.high|e.high,this.unsigned)},x.xor=function(e){return t(e)||(e=c(e)),o(this.low^e.low,this.high^e.high,this.unsigned)},x.shiftLeft=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?o(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):o(0,this.low<<e-32,this.unsigned)},x.shl=x.shiftLeft,x.shiftRight=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?o(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):o(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},x.shr=x.shiftRight,x.shiftRightUnsigned=function(e){if(t(e)&&(e=e.toInt()),0==(e&=63))return this;var n=this.high;return e<32?o(this.low>>>e|n<<32-e,n>>>e,this.unsigned):o(32===e?n:n>>>e-32,0,this.unsigned)},x.shru=x.shiftRightUnsigned,x.toSigned=function(){return this.unsigned?o(this.low,this.high,!1):this},x.toUnsigned=function(){return this.unsigned?this:o(this.low,this.high,!0)},x.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},x.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255]},x.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t]},e})?n.apply(t,i):n)||(e.exports=r)},83909(e,t,n){"use strict";n.d(t,{I7:()=>DeviceFeatures,PI:()=>DeviceLimits,pF:()=>Device});var i=n(76028),r=n(29651),s=n(74683),o=n(26839),a=n(61954),l=n(42528),c=n(90153),A=n(74520);class DeviceLimits{}function u(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(u);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)}}class Device{static defaultProps={id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{const[n,i]=e.getDevicePixelSize();r.R.log(1,`${e} resized => ${n}x${i}px`)()},onPositionChange:(e,t)=>{const[n,i]=e.getPosition();r.R.log(1,`${e} repositioned => ${n},${i}`)()},onVisibilityChange:e=>r.R.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>r.R.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:h(),debugGPUTime:!1,debugShaders:r.R.get("debug-shaders")||void 0,debugFramebuffers:Boolean(r.R.get("debug-framebuffers")),debugFactories:Boolean(r.R.get("debug-factories")),debugWebGL:Boolean(r.R.get("debug-webgl")),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0};get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}id;props;userData={};statsManager=i.d;_factories={};timestamp=0;_reused=!1;_moduleData={};_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 l.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(0,c.x)(e)}getExternalImageSize(e){return(0,c.c)(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 l.vz.isCompressed(e)}getSupportedCompressedTextureFormats(){const e=[];for(const t of Object.keys((0,A.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[u(e),...t.map(u).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)}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=l.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}}function h(){return e=r.R.get("debug"),t=function(){const e=globalThis.process;if(e?.env)return e.env.NODE_ENV}(),null!=e?Boolean(e):void 0!==t&&"production"!==t;var e,t}},76028(e,t,n){"use strict";var i=n(30568);const r=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","Referenced Buffer Memory","Referenced 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 l={};let c=o.get(t);c||(c=new Set(t),o.set(t,c));for(const e of t)n[e]&&(l[e]=n[e]);for(const[e,t]of Object.entries(n))c.has(e)||(l[e]=t);for(const e of Object.keys(n))delete n[e];Object.assign(n,l),s.set(e,{orderedStatNames:t,statCount:r})}(t,r),t}};n.d(t,["d",0,a])},62738(e,t,n){"use strict";n.d(t,{WebGLDevice:()=>WebGLDevice});var i=n(83909),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),l=(e,t,n)=>e.pixelStorei(n,t),c=(e,t,n)=>{const i=36006===n?36009:36008;return e.bindFramebuffer(i,t)},A=(e,t,n)=>{const i={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[n];e.bindBuffer(i,t)};function u(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:c,36010:c,34964:A,36662:A,36663:A,35053:A,35055:A,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:l,3317:l,37440:l,37441:l,37443:l,3330:l,3332:l,3331:l,3314:l,32878:l,3316:l,3315:l,32877:l,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=u(t)?t:[t,t];const[n,i]=t;e.stencilMaskSeparate(1028,n),e.stencilMaskSeparate(1029,i)},stencilFunc:(e,t)=>{t=u(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=u(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 d(e,t,n){return void 0!==t[e]?t[e]:n[e]}const f={blendEquation:(e,t,n)=>e.blendEquationSeparate(d(32777,t,n),d(34877,t,n)),blendFunc:(e,t,n)=>e.blendFuncSeparate(d(32969,t,n),d(32968,t,n),d(32971,t,n),d(32970,t,n)),polygonOffset:(e,t,n)=>e.polygonOffset(d(32824,t,n),d(10752,t,n)),sampleCoverage:(e,t,n)=>e.sampleCoverage(d(32938,t,n),d(32939,t,n)),stencilFuncFront:(e,t,n)=>e.stencilFuncSeparate(1028,d(2962,t,n),d(2967,t,n),d(2963,t,n)),stencilFuncBack:(e,t,n)=>e.stencilFuncSeparate(1029,d(34816,t,n),d(36003,t,n),d(36004,t,n)),stencilOpFront:(e,t,n)=>e.stencilOpSeparate(1028,d(2964,t,n),d(2965,t,n),d(2966,t,n)),stencilOpBack:(e,t,n)=>e.stencilOpSeparate(1029,d(34817,t,n),d(34818,t,n),d(34819,t,n))},p={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]})},g=(e,t)=>e.isEnabled(t),m={3042:g,2884:g,2929:g,3024:g,32823:g,32926:g,32928:g,3089:g,2960:g,35977:g},b=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 _(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,f[r])(e,t,i)}}function v(e,t=s){if("number"==typeof t){const n=t,i=m[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=m[t];i[t]=n?n(e,Number(t)):e.getParameter(Number(t))}return i}function y(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];_(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t?.copyState?v(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 p){T(e,t,p[t])}x(e,"getParameter"),x(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];y(s,o)||(n=!0,t=o,i&&!(r in i)&&(i[r]=o),this.cache[r]=s)}return{valueChanged:n,oldValue:t}}}function x(e,t){const n=e[t].bind(e);e[t]=function(t){if(void 0===t||b.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 T(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})}var E=n(28891);function S(e,t,n){return void 0===n[t]&&(n[t]=e.getExtension(t)||null),n[t]}function C(e,t){const n=e.getParameter(7936),i=e.getParameter(7937);S(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),l=P(s,o),c=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),A=function(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return"cpu";switch(P(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:l,gpuType:A,gpuBackend:c,vendor:s,renderer:o,version:a,shadingLanguage:"glsl",shadingLanguageVersion:300}}function P(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 R=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 L="WEBGL_compressed_texture_s3tc",I="WEBGL_compressed_texture_s3tc_srgb",O="EXT_texture_compression_rgtc",B="EXT_texture_compression_bptc",N="EXT_render_snorm",k="EXT_color_buffer_float",F="snorm8-renderable-webgl",D="norm16-renderable-webgl",U="snorm16-renderable-webgl",V="float16-renderable-webgl",z="float32-renderable-webgl",G={"float32-renderable-webgl":{extensions:[k]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[N]},"norm16-webgl":{extensions:["EXT_texture_norm16"]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[N]},"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:[L,I,O,B]},"texture-compression-bc5-webgl":{extensions:[O]},"texture-compression-bc7-webgl":{extensions:[B]},"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 j(e,t,n){return H(e,t,n,new Set)}function H(e,t,n,i){const r=G[t];if(!r)return!1;if(i.has(t))return!1;i.add(t);const s=(r.features||[]).every(t=>H(e,t,n,i));return i.delete(t),!!s&&(r.extensions||[]).every(t=>Boolean(S(e,t,n)))}const W={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:F},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:F},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:V},r16unorm:{gl:33322,rb:!0,r:D},r16snorm:{gl:36760,r:U},"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:F},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:V},rg16unorm:{gl:33324,r:D},rg16snorm:{gl:36761,r:U},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:z},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:z},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:V},rgba16unorm:{gl:32859,rb:!0,r:D},rgba16snorm:{gl:36763,r:U},"rgb32float-webgl":{gl:34837,x:k,r:z,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:z},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:L},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:I},"bc1-rgba-unorm":{gl:33777,x:L},"bc1-rgba-unorm-srgb":{gl:35916,x:I},"bc2-rgba-unorm":{gl:33778,x:L},"bc2-rgba-unorm-srgb":{gl:35918,x:I},"bc3-rgba-unorm":{gl:33779,x:L},"bc3-rgba-unorm-srgb":{gl:35919,x:I},"bc4-r-unorm":{gl:36283,x:O},"bc4-r-snorm":{gl:36284,x:O},"bc5-rg-unorm":{gl:36285,x:O},"bc5-rg-snorm":{gl:36286,x:O},"bc6h-rgb-ufloat":{gl:36495,x:B},"bc6h-rgb-float":{gl:36494,x:B},"bc7-rgba-unorm":{gl:36492,x:B},"bc7-rgba-unorm-srgb":{gl:36493,x:B},"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 q(e,t,n){let i=t.create;const r=W[t.format];void 0===r?.gl&&(i=!1),r?.x&&(i=i&&Boolean(S(e,r.x,n))),"stencil8"===t.format&&(i=!1);const s=!1!==r?.r&&(void 0===r?.r||j(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&&!S(e,i.x,n))return!1;const s=e.getParameter(32873),o=e.getParameter(36006),a=e.createTexture(),l=e.createFramebuffer();if(!a||!l)return!1;const c=Number(0);let A=Number(e.getError());for(;A!==c;)A=e.getError();let u=!1;try{if(e.bindTexture(3553,a),e.texStorage2D(3553,1,r,1,1),Number(e.getError())!==c)return!1;e.bindFramebuffer(36160,l),e.framebufferTexture2D(36160,36064,3553,a,0),u=Number(e.checkFramebufferStatus(36160))===Number(36053)&&Number(e.getError())===c}finally{e.bindFramebuffer(36160,o),e.deleteFramebuffer(l),e.bindTexture(3553,s),e.deleteTexture(a)}return u}(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 K(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=R.vz.getInfo(e);return i.compressed&&(t.dataFormat=n),{internalFormat:n,format:t?.dataFormat||Q(i.channels,i.integer,i.normalized,n),type:i.dataType?M(i.dataType):t?.types?.[0]||5121,compressed:i.compressed||!1}}function Q(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 X={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","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,S(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 G}(e)&&j(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(X),...Object.keys(G)]}getWebGLFeature(e){const t=X[e];return"string"==typeof t?Boolean(S(this.gl,t,this.extensions)):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 maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}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 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 $=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 Z=n(74683);function Y(e,t){if(!e){const e=new Error(t??"luma.gl assertion failed.");throw Error.captureStackTrace?.(e,Y),e}}function J(e,t){return Y(e,t),e}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",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;toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){this.props={...CanvasSurface.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,(0,$.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,Z.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.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=ee(s[0],t,n);let a=te(s[1],t,i,r),l=ee(s[0]+1,t,n);const c=l===n-1?l:l-1;let A;l=te(s[1]+1,t,i,r),r?(l=0===l?l:l+1,A=a,a=l):A=l===i-1?l:l-1;return{x:o,y:a,width:Math.max(c-o+1,1),height:Math.max(A-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=J(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=J(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,this._configureDevice())}}_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 ee(e,t,n){return Math.min(Math.round(e*t),n-1)}function te(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 ne=n(5153),ie=n(80698);class Framebuffer extends ne.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 ie.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 ie.g?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:ie.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:ie.g.RENDER_ATTACHMENT,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={...ne.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=null===t.handle;this.device=e,this.gl=e.gl,this.handle=this.props.handle||n?this.props.handle:this.gl.createFramebuffer(),n||(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(R.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 re=n(25299),se=n(89869);const oe={};function ae(e="id"){oe[e]=oe[e]||1;return`${e}-${oe[e]++}`}var le=n(26839);class WEBGLBuffer extends le.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&le.h.INDEX)return 34963;if(e&le.h.VERTEX)return 34962;if(e&le.h.UNIFORM)return 35345;return 34962}(this.props.usage),this.glUsage=function(e){if(e&le.h.INDEX)return 35044;if(e&le.h.VERTEX)return 35044;if(e&le.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 ce=n(40720);function Ae(e){const t=e.toLowerCase();return["warning","error","info"].includes(t)?t:"info"}class WEBGLShader extends ce.M{device;handle;constructor(e,t){switch(super(e,t),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props});const n=this._compile(this.source);n&&"function"==typeof n.catch&&n.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.device.gl.getShaderInfoLog(this.handle);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:Ae(r||"info"),lineNum:0,linePos:0});continue}n.push({message:s.trim(),type:Ae(e),lineNum:0,linePos:0});continue}const[s,o,a,...l]=i;if(!s||!o||!a){n.push({message:i.slice(1).join(":").trim()||t,type:Ae(r||"info"),lineNum:0,linePos:0});continue}let c=parseInt(a,10);Number.isNaN(c)&&(c=0);let A=parseInt(o,10);Number.isNaN(A)&&(A=0),n.push({message:l.join(":").trim(),type:Ae(s),lineNum:c,linePos:A})}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(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`)}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"}}var ue=n(89277);function he(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(me("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=me("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=me("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=fe("stencilPassOperation",t.stencilPassOperation),n=fe("stencilFailOperation",t.stencilFailOperation),r=fe("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=pe("blendColorOperation",t.blendColorOperation||"add"),n=pe("blendAlphaOperation",t.blendAlphaOperation||"add");i.blendEquationSeparate(e,n);const r=ge("blendColorSrcFactor",t.blendColorSrcFactor||"one"),s=ge("blendColorDstFactor",t.blendColorDstFactor||"zero"),o=ge("blendAlphaSrcFactor",t.blendAlphaSrcFactor||"one"),a=ge("blendAlphaDstFactor",t.blendAlphaDstFactor||"zero");i.blendFuncSeparate(r,s,o,a)}}function de(e,t){return me(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function fe(e,t){return me(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function pe(e,t){return me(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function ge(e,t,n="color"){return me(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 me(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 be(e){let t=!0;for(const n in e){t=!1;break}return t}function _e(e){const t={};return e.addressModeU&&(t[10242]=ve(e.addressModeU)),e.addressModeV&&(t[10243]=ve(e.addressModeV)),e.addressModeW&&(t[32882]=ve(e.addressModeW)),e.magFilter&&(t[10240]=ye(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=function(e,t="none"){if(!t)return ye(e);switch(t){case"none":return ye(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 ve(e){switch(e){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function ye(e){switch(e){case"nearest":return 9728;case"linear":return 9729}}class WEBGLSampler extends ue.L{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=_e(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 we=n(72246);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(),_(e,t),i)s=n(e),r.pop();else try{s=n(e)}finally{r.pop()}return s}var Te=n(75638);class WEBGLTextureView extends Te.X{device;gl;handle;texture;constructor(e,t){super(e,{...ie.g.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}function Ee(e){return Se[e]}const Se={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 ie.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=K(this.props.format);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.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.gl.bindTexture(this.glTarget,this.handle);const{dimension:i,width:r,height:s,depth:o,mipLevels:a,glTarget:l,glInternalFormat:c}=this;if(!this.compressed)switch(i){case"2d":case"cube":this.gl.texStorage2D(l,a,c,r,s);break;case"2d-array":case"3d":this.gl.texStorage3D(l,a,c,r,s,o);break;default:throw new Error(i)}this.gl.bindTexture(this.glTarget,null),this._initializeData(t.data),this.props.handle?this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"):this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"),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.props.handle?this.trackDeallocatedReferencedMemory("Texture"):(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")),this.destroyed=!0)}createView(e){return new WEBGLTextureView(this.device,{...e,texture:this})}setSampler(e={}){super.setSampler(e);const t=_e(this.sampler.props);this._setSamplerParameters(t)}copyExternalImage(e){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:l,z:c,width:A,height:u}=t,h=Ce(this.glTarget,this.dimension,c),d=t.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),xe(this.gl,d,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(h,o,a,l,A,u,n,i,r);break;case"2d-array":case"3d":this.gl.texSubImage3D(h,o,a,l,c,A,u,s,n,i,r)}}),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={}){const n=this._normalizeTextureWriteOptions(t),{width:i,height:r,depthOrArrayLayers:s,mipLevel:o,byteOffset:a,x:l,y:c,z:A}=n,{glFormat:u,glType:h,compressed:d}=this,f=Ce(this.glTarget,this.dimension,A);if(d)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");const{bytesPerPixel:p}=this.device.getTextureFormatInfo(this.format),g=p?n.bytesPerRow/p:void 0,m={3317:this.byteAlignment,...void 0!==g?{3314:g}:{},32878:n.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),xe(this.gl,m,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(f,o,l,c,i,r,u,h,a);break;case"2d-array":case"3d":this.gl.texSubImage3D(f,o,l,c,A,i,r,s,u,h,a)}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,t={}){const n=this._normalizeTextureWriteOptions(t),i=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:r,height:s,depthOrArrayLayers:o,mipLevel:a,x:l,y:c,z:A,byteOffset:u}=n,{glFormat:h,glType:d,compressed:f}=this,p=Ce(this.glTarget,this.dimension,A);let g;if(!f){const{bytesPerPixel:e}=this.device.getTextureFormatInfo(this.format);e&&(g=n.bytesPerRow/e)}const m=this.compressed?{}:{3317:this.byteAlignment,...void 0!==g?{3314:g}:{},32878:n.rowsPerImage},b=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,u),_=f?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,u):i,v=this._getMipLevelSize(a),y=0===l&&0===c&&0===A&&r===v.width&&s===v.height&&o===v.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),xe(this.gl,m,()=>{switch(this.dimension){case"2d":case"cube":f?y?this.gl.compressedTexImage2D(p,a,h,r,s,0,_):this.gl.compressedTexSubImage2D(p,a,l,c,r,s,h,_):this.gl.texSubImage2D(p,a,l,c,r,s,h,d,i,b);break;case"2d-array":case"3d":f?y?this.gl.compressedTexImage3D(p,a,h,r,s,o,0,_):this.gl.compressedTexSubImage3D(p,a,l,c,A,r,s,o,h,_):this.gl.texSubImage3D(p,a,l,c,A,r,s,o,h,d,i,b)}}),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=Ee(this.glType),r=(0,we.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,Ce(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){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.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}}function Ce(e,t,n){return"cube"===t?34069+n:e}var Pe=n(22512),Re=n(62069);function Me(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")}class WEBGLRenderPipeline extends Pe.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=n.introspectedLayout,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=Le(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,Re.h0)((0,Re.gO)(this.shaderLayout,e));for(const[e,i]of Object.entries(n)){const n=Le(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){this._syncLinkStatus();const t=e.bindGroups?(0,Re.h0)(e.bindGroups):e.bindings||this.bindings,{renderPass:n,parameters:i=this.props.parameters,topology:s=this.props.topology,vertexArray:o,vertexCount:a,instanceCount:l,isInstanced:c=!1,firstVertex:A=0,transformFeedback:u,uniforms:h=this.uniforms}=e,d=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),f=Boolean(o.indexBuffer),p=o.indexBuffer?.glIndexType;if("success"!==this.linkStatus)return r.R.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable(t))return r.R.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),o.bindBeforeRender(n),u&&u.begin(this.props.topology),this._applyBindings(t,{disableWarnings:this.props.disableWarnings}),this._applyUniforms(h);const g=n;return function(e,t,n,i){if(be(t))return i(e);const r=e;r.pushState();try{return he(e,t),_(r.gl,n),i(e)}finally{r.popState()}}(this.device,i,g.glParameters,()=>{f&&c?this.device.gl.drawElementsInstanced(d,a||0,p,A,l||0):f?this.device.gl.drawElements(d,a||0,p,A):c?this.device.gl.drawArraysInstanced(d,A,a||0,l||0):this.device.gl.drawArrays(d,A,a||0),u&&u.end()}),o.unbindAfterRender(n),!0}_areTexturesRenderable(e){let t=!0;for(const n of this.shaderLayout.bindings)Ie(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=Ie(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 l;if(o instanceof WEBGLTextureView)l=o.texture;else if(o instanceof WEBGLTexture)l=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")(),l=o.colorAttachments[0].texture}n.activeTexture(33984+i),n.bindTexture(l.glTarget,l.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&&Me(this.device.gl,i,r,o)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}function Le(e,t){return e.bindings.find(e=>e.name===t||e.name===`${t}Uniforms`||`${e.name}Uniforms`===t)}function Ie(e,t){return e[t]||e[`${t}Uniforms`]||e[t.replace(/Uniforms$/,"")]}class SharedRenderPipeline extends ne.F{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(e,t){super(e,t,{...ne.F.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}var Oe=n(65219);function Be(e){return Fe[e]}function Ne(e){return Boolean(De[e])}function ke(e){return De[e]}const Fe={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>"},De={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"}},Ue={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 Ve(e,t){const n={attributes:[],bindings:[]};n.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=Be(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 i=function(e,t){const n=(n,i)=>e.getActiveUniformBlockParameter(t,n,i),i=[],s=e.getProgramParameter(t,35382);for(let o=0;o<s;o++){const s={name:e.getActiveUniformBlockName(t,o)||"",location:n(o,35391),byteLength:n(o,35392),vertex:n(o,35396),fragment:n(o,35398),uniformCount:n(o,35394),uniforms:[]},a=n(o,35395)||[],l=e.getActiveUniforms(t,a,35383),c=e.getActiveUniforms(t,a,35384),A=e.getActiveUniforms(t,a,35387),u=e.getActiveUniforms(t,a,35388);for(let n=0;n<s.uniformCount;++n){const i=a[n];if(void 0!==i){const r=e.getActiveUniform(t,i);if(!r)throw new Error("activeInfo");const o=Be(l[n]);s.uniforms.push({name:r.name,format:o,type:l[n],arrayLength:c[n],byteOffset:A[n],byteStride:u[n]})}}const h=new Set(s.uniforms.map(e=>e.name.split(".")[0]).filter(e=>Boolean(e))),d=s.name.replace(/Uniforms$/,"");if(1===h.size&&!h.has(s.name)&&!h.has(d)){const[e]=h;r.R.warn(`Uniform block "${s.name}" uses GLSL instance "${e}". luma.gl binds uniform buffers by block name ("${s.name}") and alias ("${d}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}i.push(s)}return i.sort((e,t)=>e.location-t.location),i}(e,t);for(const e of i){const t=e.uniforms.map(e=>({name:e.name,format:e.format,byteOffset:e.byteOffset,byteStride:e.byteStride,arrayLength:e.arrayLength}));n.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 s=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:l,isArray:c}=ze(s);let A=e.getUniformLocation(t,l);const u={location:A,name:l,size:o,type:a,isArray:c};if(n.push(u),u.size>1)for(let i=0;i<u.size;i++){const r=`${l}[${i}]`;A=e.getUniformLocation(t,r);const s={...u,name:r,location:A};n.push(s)}}return n}(e,t);let o=0;for(const e of s)if(Ne(e.type)){const{viewDimension:t,sampleType:i}=ke(e.type);n.bindings.push({type:"texture",name:e.name,group:0,location:o,viewDimension:t,sampleType:i}),e.textureUnit=o,o+=1}s.length&&(n.uniforms=s);const a=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,l=Be(o),{type:c,components:A}=(0,Oe.k0)(l);n.push({location:r,name:s,type:c,size:a*A})}return n.sort((e,t)=>e.location-t.location),n}(e,t);return a?.length&&(n.varyings=a),n}function ze(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};const t=/([^[]*)(\[[0-9]+\])?/.exec(e);return{name:J(t?.[1],`Failed to parse GLSL uniform name ${e}`),length:t?.[2]?1:0,isArray:Boolean(t?.[2])}}class WEBGLSharedRenderPipeline extends SharedRenderPipeline{device;handle;vs;fs;introspectedLayout={attributes:[],bindings:[],uniforms:[]};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(),r.R.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=Ve(this.device.gl,this.handle),r.R.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)()}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&&Ne(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 ne.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={...ne.F.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0}}class CommandBuffer extends ne.F{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,CommandBuffer.defaultProps)}static defaultProps={...ne.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":Ge(this.device,t.options);break;case"copy-buffer-to-texture":je(this.device,t.options);break;case"copy-texture-to-buffer":He(this.device,t.options);break;case"copy-texture-to-texture":We(this.device,t.options);break;default:throw new Error(t.name)}}}function Ge(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 je(e,t){throw new Error("copyBufferToTexture is not supported in WebGL")}function He(e,t){const{sourceTexture:n,mipLevel:i=0,aspect:r="all",width:s=t.sourceTexture.width,height:o=t.sourceTexture.height,depthOrArrayLayers:a,origin:l=[0,0,0],destinationBuffer:c,byteOffset:A=0,bytesPerRow:u,rowsPerImage:h}=t;if(n instanceof ie.g)return void n.readBuffer({x:l[0]??0,y:l[1]??0,z:l[2]??0,width:s,height:o,depthOrArrayLayers:a,mipLevel:i,aspect:r,byteOffset:A},c);if("all"!==r)throw new Error("aspect not supported in WebGL");if(0!==i||void 0!==a||u||h)throw new Error("not implemented");const{framebuffer:d,destroyFramebuffer:f}=qe(n);let p;try{const t=c,n=s||d.width,i=o||d.height,r=K(J(d.colorAttachments[0]).texture.props.format),a=r.format,u=r.type;e.gl.bindBuffer(35051,t.handle),p=e.gl.bindFramebuffer(36160,d.handle),e.gl.readPixels(l[0],l[1],n,i,a,u,A)}finally{e.gl.bindBuffer(35051,null),void 0!==p&&e.gl.bindFramebuffer(36160,p),f&&d.destroy()}}function We(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:l=t.destinationTexture.height}=t;const{framebuffer:c,destroyFramebuffer:A}=qe(n),[u=0,h=0]=r,[d,f,p]=s,g=e.gl.bindFramebuffer(36160,c.handle);let m,b;if(!(o instanceof WEBGLTexture))throw new Error("invalid destination");switch(m=o,a=Number.isFinite(a)?a:m.width,l=Number.isFinite(l)?l:m.height,m._bind(0),b=m.glTarget,b){case 3553:case 34067:e.gl.copyTexSubImage2D(b,i,d,f,u,h,a,l);break;case 35866:case 32879:e.gl.copyTexSubImage3D(b,i,d,f,p,u,h,a,l)}m&&m._unbind(),e.gl.bindFramebuffer(36160,g),A&&c.destroy()}function qe(e){if(e instanceof ie.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 ne.F{static defaultClearColor=[0,0,0,1];static defaultClearDepth=1;static defaultClearStencil=0;get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t){super(e,t=RenderPass.normalizeProps(e,t),RenderPass.defaultProps)}static normalizeProps(e,t){return t}static defaultProps={...ne.F.defaultProps,framebuffer:null,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 Ke=[1,2,4,8];class WEBGLRenderPass extends RenderPass{device;handle=null;glParameters={};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){}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=Ke.map(t=>Boolean(t&e.colorMask))),this.glParameters=t,_(this.device.gl,t)}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.props.id}-command-buffer`})}destroy(){this.destroyResource()}finish(e){return e?.id&&this.commandBuffer.id!==e.id&&(this.commandBuffer.id=e.id,this.commandBuffer.props.id=e.id),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)}}var Qe=n(2021);class VertexArray extends ne.F{static defaultProps={...ne.F.defaultProps,shaderLayout:void 0,bufferLayout:[]};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,t){super(e,t,VertexArray.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=(0,Qe.M)(t.shaderLayout,t.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,t){this.device.reportError(new Error("constant attributes not supported"),this)()}}var Xe=n(73390),$e=n(15399),Ze=n(35526);class WEBGLVertexArray extends VertexArray{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return"Chrome"==(t||(0,$.B)()?(0,$e.b)(t)?"Electron":(t||Ze.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()}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:l,divisor:c}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,n.handle),l?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,c||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.attributeInfos[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,Xe.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 ne.F{static defaultProps={...ne.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(Ye(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(Ye(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 Ye(e){return"number"==typeof e?Number.isInteger(e):/^\d+$/.test(e)}class QuerySet extends ne.F{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,QuerySet.defaultProps)}static defaultProps={...ne.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 ne.F{static defaultProps={...ne.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 Je=n(57285);function et(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 tt(e,t){const{sourceX:n=0,sourceY:i=0,sourceAttachment:r=0}=t||{};let{target:s=null,sourceWidth:o,sourceHeight:a,sourceDepth:l,sourceFormat:c,sourceType:A}=t||{};const{framebuffer:u,deleteFramebuffer:h}=nt(e),{gl:d,handle:f}=u;o||=u.width,a||=u.height;const p=u.colorAttachments[r]?.texture;if(!p)throw new Error(`Invalid framebuffer attachment ${r}`);l=p?.depth||1,c||=p?.glFormat||6408,A||=p?.glType||5121,s=function(e,t,n,i,r){if(e)return e;t||=5121;const s=Ee(t),o=Je.r.getTypedArrayConstructor(s),a=et(n);return new o(i*r*a)}(s,A,c,o,a);const g=Je.r.getDataType(s);A=A||Ue[g];const m=d.bindFramebuffer(36160,f);return d.readBuffer(36064+r),d.readPixels(n,i,o,a,c,A,s),d.readBuffer(36064),d.bindFramebuffer(36160,m||null),h&&u.destroy(),s}function nt(e){return e instanceof Framebuffer?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:it(e),deleteFramebuffer:!0}}function it(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;gl;_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||ae("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}`);(0,E.V)(a).softwareRenderer=n;const{onContextLost:r,onContextRestored:l}=t;return e.addEventListener("webglcontextlost",e=>r(e),!1),e.addEventListener("webglcontextrestored",e=>l(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,re.k2)({...this.props,gl:this.handle});const l=(0,E.V)(this.handle);l.device=this,l.extensions||(l.extensions={}),this.extensions=l.extensions,this.info=C(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,se.l)(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.commandEncoder?.destroy(),!this.props._reuseDevices&&!this._reused){(0,E.V)(this.handle).device=null}}get isLost(){return 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("createExternalTexture() not implemented")}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")}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()}}_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 tt(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:l,sourceType:c}=t||{};const{framebuffer:A,deleteFramebuffer:u}=nt(e);a=a||A.width,l=l||A.height;const h=A;c=c||5121;let d=n;if(!d){const e=o+a*l*et(s)*function(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}(c);d=h.device.createBuffer({byteLength:e})}const f=e.device.createCommandEncoder();return f.copyTextureToBuffer({sourceTexture:e,width:a,height:l,origin:[i,r],destinationBuffer:d,byteOffset:o}),f.destroy(),u&&A.destroy(),d}(e,t)}setParametersWebGL(e){_(this.gl,e)}getParametersWebGL(e){return v(this.gl,e)}withParametersWebGL(e,t){return xe(this.gl,e,t)}resetWebGL(){r.R.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),_(this.gl,s)}_getDeviceSpecificTextureFormatCapabilities(e){return q(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=Number(e);for(const e in this.gl)if(this.gl[e]===n)return`GL.${e}`;return 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),{})}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 S(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}}},25299(e,t,n){"use strict";n.d(t,{_G:()=>c,k2:()=>A});var i=n(29651),r=n(32077),s=n(28891);let o=null,a=!1;const l={debugSpectorJS:i.R.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0};async function c(e){if(!globalThis.SPECTOR)try{await(0,r.k)(e.debugSpectorJSUrl||l.debugSpectorJSUrl)}catch(e){i.R.warn(String(e))}}function A(e){if(!(e={...l,...e}).debugSpectorJS)return null;if(!o&&globalThis.SPECTOR&&!globalThis.luma?.spector){i.R.probe(1,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();const{Spector:e}=globalThis.SPECTOR;o=new e,globalThis.luma&&(globalThis.luma.spector=o)}if(!o)return null;if(a||(a=!0,o.spyCanvases(),o?.onCaptureStarted.add(e=>i.R.info("Spector capture started:",e)()),o?.onCapture.add(e=>{i.R.info("Spector capture complete:",e)(),o?.getResultUI(),o?.resultView.display(),o?.resultView.addCapture(e)})),e.gl){const t=e.gl,n=(0,s.V)(t),r=n.device;o?.startCapture(e.gl,500),n.device=r,new Promise(e=>setTimeout(e,2e3)).then(e=>{i.R.info("Spector capture stopped after 2 seconds")(),o?.stopCapture()})}return o}n.d(t,["ic",0,l])},89869(e,t,n){"use strict";n.d(t,{$:()=>l,l:()=>c});var i,r=n(29651);!function(e){e[e.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",e[e.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",e[e.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",e[e.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",e[e.BLEND_EQUATION=32777]="BLEND_EQUATION",e[e.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",e[e.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",e[e.BLEND_DST_RGB=32968]="BLEND_DST_RGB",e[e.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",e[e.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",e[e.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",e[e.BLEND_COLOR=32773]="BLEND_COLOR",e[e.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",e[e.LINE_WIDTH=2849]="LINE_WIDTH",e[e.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",e[e.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",e[e.CULL_FACE_MODE=2885]="CULL_FACE_MODE",e[e.FRONT_FACE=2886]="FRONT_FACE",e[e.DEPTH_RANGE=2928]="DEPTH_RANGE",e[e.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",e[e.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",e[e.DEPTH_FUNC=2932]="DEPTH_FUNC",e[e.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",e[e.STENCIL_FUNC=2962]="STENCIL_FUNC",e[e.STENCIL_FAIL=2964]="STENCIL_FAIL",e[e.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",e[e.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",e[e.STENCIL_REF=2967]="STENCIL_REF",e[e.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",e[e.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",e[e.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",e[e.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",e[e.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",e[e.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",e[e.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",e[e.VIEWPORT=2978]="VIEWPORT",e[e.SCISSOR_BOX=3088]="SCISSOR_BOX",e[e.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",e[e.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",e[e.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",e[e.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",e[e.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",e[e.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",e[e.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",e[e.RED_BITS=3410]="RED_BITS",e[e.GREEN_BITS=3411]="GREEN_BITS",e[e.BLUE_BITS=3412]="BLUE_BITS",e[e.ALPHA_BITS=3413]="ALPHA_BITS",e[e.DEPTH_BITS=3414]="DEPTH_BITS",e[e.STENCIL_BITS=3415]="STENCIL_BITS",e[e.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",e[e.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",e[e.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",e[e.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",e[e.SAMPLES=32937]="SAMPLES",e[e.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",e[e.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",e[e.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",e[e.VENDOR=7936]="VENDOR",e[e.RENDERER=7937]="RENDERER",e[e.VERSION=7938]="VERSION",e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",e[e.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",e[e.STATIC_DRAW=35044]="STATIC_DRAW",e[e.STREAM_DRAW=35040]="STREAM_DRAW",e[e.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.BUFFER_SIZE=34660]="BUFFER_SIZE",e[e.BUFFER_USAGE=34661]="BUFFER_USAGE",e[e.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",e[e.CULL_FACE=2884]="CULL_FACE",e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK",e[e.BLEND=3042]="BLEND",e[e.DEPTH_TEST=2929]="DEPTH_TEST",e[e.DITHER=3024]="DITHER",e[e.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",e[e.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",e[e.SCISSOR_TEST=3089]="SCISSOR_TEST",e[e.STENCIL_TEST=2960]="STENCIL_TEST",e[e.NO_ERROR=0]="NO_ERROR",e[e.INVALID_ENUM=1280]="INVALID_ENUM",e[e.INVALID_VALUE=1281]="INVALID_VALUE",e[e.INVALID_OPERATION=1282]="INVALID_OPERATION",e[e.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",e[e.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",e[e.CW=2304]="CW",e[e.CCW=2305]="CCW",e[e.DONT_CARE=4352]="DONT_CARE",e[e.FASTEST=4353]="FASTEST",e[e.NICEST=4354]="NICEST",e[e.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.DOUBLE=5130]="DOUBLE",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",e[e.VERTEX_SHADER=35633]="VERTEX_SHADER",e[e.COMPILE_STATUS=35713]="COMPILE_STATUS",e[e.DELETE_STATUS=35712]="DELETE_STATUS",e[e.LINK_STATUS=35714]="LINK_STATUS",e[e.VALIDATE_STATUS=35715]="VALIDATE_STATUS",e[e.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",e[e.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",e[e.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",e[e.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",e[e.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",e[e.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",e[e.SHADER_TYPE=35663]="SHADER_TYPE",e[e.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",e[e.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",e[e.NEVER=512]="NEVER",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.GEQUAL=518]="GEQUAL",e[e.ALWAYS=519]="ALWAYS",e[e.KEEP=7680]="KEEP",e[e.REPLACE=7681]="REPLACE",e[e.INCR=7682]="INCR",e[e.DECR=7683]="DECR",e[e.INVERT=5386]="INVERT",e[e.INCR_WRAP=34055]="INCR_WRAP",e[e.DECR_WRAP=34056]="DECR_WRAP",e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE=5890]="TEXTURE",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",e[e.TEXTURE0=33984]="TEXTURE0",e[e.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",e[e.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D",e[e.SAMPLER_CUBE=35680]="SAMPLER_CUBE",e[e.LOW_FLOAT=36336]="LOW_FLOAT",e[e.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",e[e.HIGH_FLOAT=36338]="HIGH_FLOAT",e[e.LOW_INT=36339]="LOW_INT",e[e.MEDIUM_INT=36340]="MEDIUM_INT",e[e.HIGH_INT=36341]="HIGH_INT",e[e.FRAMEBUFFER=36160]="FRAMEBUFFER",e[e.RENDERBUFFER=36161]="RENDERBUFFER",e[e.RGBA4=32854]="RGBA4",e[e.RGB5_A1=32855]="RGB5_A1",e[e.RGB565=36194]="RGB565",e[e.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",e[e.STENCIL_INDEX=6401]="STENCIL_INDEX",e[e.STENCIL_INDEX8=36168]="STENCIL_INDEX8",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e[e.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",e[e.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",e[e.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",e[e.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",e[e.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",e[e.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",e[e.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",e[e.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",e[e.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",e[e.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",e[e.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",e[e.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",e[e.NONE=0]="NONE",e[e.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",e[e.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",e[e.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",e[e.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",e[e.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",e[e.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",e[e.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",e[e.READ_BUFFER=3074]="READ_BUFFER",e[e.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",e[e.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",e[e.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",e[e.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",e[e.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",e[e.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",e[e.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",e[e.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",e[e.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",e[e.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",e[e.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",e[e.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",e[e.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",e[e.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",e[e.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",e[e.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",e[e.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",e[e.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",e[e.RED=6403]="RED",e[e.RGB8=32849]="RGB8",e[e.RGBA8=32856]="RGBA8",e[e.RGB10_A2=32857]="RGB10_A2",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",e[e.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",e[e.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",e[e.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",e[e.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",e[e.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",e[e.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",e[e.SRGB=35904]="SRGB",e[e.SRGB8=35905]="SRGB8",e[e.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",e[e.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",e[e.RGBA32F=34836]="RGBA32F",e[e.RGB32F=34837]="RGB32F",e[e.RGBA16F=34842]="RGBA16F",e[e.RGB16F=34843]="RGB16F",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",e[e.R11F_G11F_B10F=35898]="R11F_G11F_B10F",e[e.RGB9_E5=35901]="RGB9_E5",e[e.RGBA32UI=36208]="RGBA32UI",e[e.RGB32UI=36209]="RGB32UI",e[e.RGBA16UI=36214]="RGBA16UI",e[e.RGB16UI=36215]="RGB16UI",e[e.RGBA8UI=36220]="RGBA8UI",e[e.RGB8UI=36221]="RGB8UI",e[e.RGBA32I=36226]="RGBA32I",e[e.RGB32I=36227]="RGB32I",e[e.RGBA16I=36232]="RGBA16I",e[e.RGB16I=36233]="RGB16I",e[e.RGBA8I=36238]="RGBA8I",e[e.RGB8I=36239]="RGB8I",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.R8=33321]="R8",e[e.RG8=33323]="RG8",e[e.R16F=33325]="R16F",e[e.R32F=33326]="R32F",e[e.RG16F=33327]="RG16F",e[e.RG32F=33328]="RG32F",e[e.R8I=33329]="R8I",e[e.R8UI=33330]="R8UI",e[e.R16I=33331]="R16I",e[e.R16UI=33332]="R16UI",e[e.R32I=33333]="R32I",e[e.R32UI=33334]="R32UI",e[e.RG8I=33335]="RG8I",e[e.RG8UI=33336]="RG8UI",e[e.RG16I=33337]="RG16I",e[e.RG16UI=33338]="RG16UI",e[e.RG32I=33339]="RG32I",e[e.RG32UI=33340]="RG32UI",e[e.R8_SNORM=36756]="R8_SNORM",e[e.RG8_SNORM=36757]="RG8_SNORM",e[e.RGB8_SNORM=36758]="RGB8_SNORM",e[e.RGBA8_SNORM=36759]="RGBA8_SNORM",e[e.RGB10_A2UI=36975]="RGB10_A2UI",e[e.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",e[e.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.HALF_FLOAT=5131]="HALF_FLOAT",e[e.RG=33319]="RG",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",e[e.CURRENT_QUERY=34917]="CURRENT_QUERY",e[e.QUERY_RESULT=34918]="QUERY_RESULT",e[e.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",e[e.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",e[e.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",e[e.DRAW_BUFFER0=34853]="DRAW_BUFFER0",e[e.DRAW_BUFFER1=34854]="DRAW_BUFFER1",e[e.DRAW_BUFFER2=34855]="DRAW_BUFFER2",e[e.DRAW_BUFFER3=34856]="DRAW_BUFFER3",e[e.DRAW_BUFFER4=34857]="DRAW_BUFFER4",e[e.DRAW_BUFFER5=34858]="DRAW_BUFFER5",e[e.DRAW_BUFFER6=34859]="DRAW_BUFFER6",e[e.DRAW_BUFFER7=34860]="DRAW_BUFFER7",e[e.DRAW_BUFFER8=34861]="DRAW_BUFFER8",e[e.DRAW_BUFFER9=34862]="DRAW_BUFFER9",e[e.DRAW_BUFFER10=34863]="DRAW_BUFFER10",e[e.DRAW_BUFFER11=34864]="DRAW_BUFFER11",e[e.DRAW_BUFFER12=34865]="DRAW_BUFFER12",e[e.DRAW_BUFFER13=34866]="DRAW_BUFFER13",e[e.DRAW_BUFFER14=34867]="DRAW_BUFFER14",e[e.DRAW_BUFFER15=34868]="DRAW_BUFFER15",e[e.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",e[e.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",e[e.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",e[e.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",e[e.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",e[e.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",e[e.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",e[e.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",e[e.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",e[e.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",e[e.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",e[e.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",e[e.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",e[e.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",e[e.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",e[e.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",e[e.SAMPLER_3D=35679]="SAMPLER_3D",e[e.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",e[e.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",e[e.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",e[e.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",e[e.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",e[e.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",e[e.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",e[e.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",e[e.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",e[e.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",e[e.MAX_SAMPLES=36183]="MAX_SAMPLES",e[e.SAMPLER_BINDING=35097]="SAMPLER_BINDING",e[e.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",e[e.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",e[e.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",e[e.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",e[e.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",e[e.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",e[e.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",e[e.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",e[e.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",e[e.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",e[e.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",e[e.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",e[e.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",e[e.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",e[e.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",e[e.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",e[e.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",e[e.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",e[e.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",e[e.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",e[e.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",e[e.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",e[e.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",e[e.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",e[e.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",e[e.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",e[e.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",e[e.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e[e.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",e[e.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",e[e.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",e[e.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",e[e.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",e[e.UNIFORM_TYPE=35383]="UNIFORM_TYPE",e[e.UNIFORM_SIZE=35384]="UNIFORM_SIZE",e[e.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",e[e.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",e[e.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",e[e.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",e[e.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",e[e.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",e[e.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",e[e.OBJECT_TYPE=37138]="OBJECT_TYPE",e[e.SYNC_CONDITION=37139]="SYNC_CONDITION",e[e.SYNC_STATUS=37140]="SYNC_STATUS",e[e.SYNC_FLAGS=37141]="SYNC_FLAGS",e[e.SYNC_FENCE=37142]="SYNC_FENCE",e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",e[e.UNSIGNALED=37144]="UNSIGNALED",e[e.SIGNALED=37145]="SIGNALED",e[e.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",e[e.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",e[e.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",e[e.WAIT_FAILED=37149]="WAIT_FAILED",e[e.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",e[e.COLOR=6144]="COLOR",e[e.DEPTH=6145]="DEPTH",e[e.STENCIL=6146]="STENCIL",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX",e[e.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",e[e.STREAM_READ=35041]="STREAM_READ",e[e.STREAM_COPY=35042]="STREAM_COPY",e[e.STATIC_READ=35045]="STATIC_READ",e[e.STATIC_COPY=35046]="STATIC_COPY",e[e.DYNAMIC_READ=35049]="DYNAMIC_READ",e[e.DYNAMIC_COPY=35050]="DYNAMIC_COPY",e[e.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",e[e.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",e[e.INVALID_INDEX=4294967295]="INVALID_INDEX",e[e.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",e[e.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",e[e.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",e[e.R16_EXT=33322]="R16_EXT",e[e.RG16_EXT=33324]="RG16_EXT",e[e.RGB16_EXT=32852]="RGB16_EXT",e[e.RGBA16_EXT=32859]="RGBA16_EXT",e[e.R16_SNORM_EXT=36760]="R16_SNORM_EXT",e[e.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",e[e.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",e[e.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",e[e.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",e[e.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",e[e.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",e[e.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",e[e.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",e[e.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",e[e.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",e[e.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",e[e.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",e[e.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",e[e.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",e[e.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",e[e.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",e[e.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",e[e.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",e[e.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",e[e.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",e[e.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",e[e.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",e[e.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",e[e.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",e[e.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",e[e.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",e[e.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",e[e.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",e[e.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",e[e.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",e[e.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",e[e.LINE_WEBGL=6913]="LINE_WEBGL",e[e.FILL_WEBGL=6914]="FILL_WEBGL",e[e.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",e[e.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",e[e.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",e[e.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",e[e.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",e[e.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",e[e.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",e[e.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",e[e.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",e[e.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",e[e.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",e[e.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",e[e.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",e[e.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",e[e.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",e[e.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",e[e.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",e[e.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",e[e.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",e[e.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",e[e.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",e[e.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",e[e.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",e[e.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"}(i||(i={}));var s=n(16769),o=n(32077);function a(e){return e.luma=e.luma||{},e.luma}async function l(){(0,s.B)()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await(0,o.k)("https://unpkg.com/webgl-debug@2.0.1/index.js"))}function c(e,t={}){return t.debugWebGL||t.traceWebGL?function(e,t){if(!globalThis.WebGLDebugUtils)return r.R.warn("webgl-debug not loaded")(),e;const n=a(e);if(n.debugContext)return n.debugContext;globalThis.WebGLDebugUtils.init({...i,...e});const s=globalThis.WebGLDebugUtils.makeDebugContext(e,u.bind(null,t),h.bind(null,t));for(const e in i)e in s||"number"!=typeof i[e]||(s[e]=i[e]);class WebGLDebugContext{}Object.setPrototypeOf(s,Object.getPrototypeOf(e)),Object.setPrototypeOf(WebGLDebugContext,s);const o=Object.create(WebGLDebugContext);return n.realContext=e,n.debugContext=o,o.luma=n,o.debug=!0,o}(e,t):function(e){const t=a(e);return t.realContext?t.realContext:e}(e)}function A(e,t){t=Array.from(t).map(e=>void 0===e?"undefined":e);let n=globalThis.WebGLDebugUtils.glFunctionArgsToString(e,t);return n=`${n.slice(0,100)}${n.length>100?"...":""}`,`gl.${e}(${n})`}function u(e,t,n,i){i=Array.from(i).map(e=>void 0===e?"undefined":e);const s=`${globalThis.WebGLDebugUtils.glEnumToString(t)} in gl.${n}(${globalThis.WebGLDebugUtils.glFunctionArgsToString(n,i)})`;throw r.R.error("%cWebGL","color: white; background: red; padding: 2px 6px; border-radius: 3px;",s)(),new Error(s)}function h(e,t,n){let i="";e.traceWebGL&&r.R.level>=1&&(i=A(t,n),r.R.info(1,"%cWebGL","color: white; background: blue; padding: 2px 6px; border-radius: 3px;",i)());for(const e of n)void 0===e&&(i=i||A(t,n))}},28891(e,t,n){"use strict";function i(e){const t=e.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return t._polyfilled??=!1,t.extensions||={},e.luma=t,t}n.d(t,{V:()=>i})},32077(e,t,n){"use strict";async function i(e,t){const n=document.getElementsByTagName("head")[0];if(!n)throw new Error("loadScript");const i=document.createElement("script");return i.setAttribute("type","text/javascript"),i.setAttribute("src",e),t&&(i.id=t),new Promise((t,r)=>{i.onload=t,i.onerror=t=>r(new Error(`Unable to load script '${e}': ${t}`)),n.appendChild(i)})}n.d(t,{k:()=>i})},30568(e,t,n){"use strict";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}}},52346(e,t,n){"use strict";n.r(t),n.d(t,{A5Layer:()=>Sm,AmbientLight:()=>AmbientLight,ArcLayer:()=>Mo,Attribute:()=>Attribute,AttributeManager:()=>AttributeManager,BitmapLayer:()=>Fo,COORDINATE_SYSTEM:()=>Mn.rf,CPUAggregator:()=>CPUAggregator,ColumnLayer:()=>Sa,CompassWidget:()=>CompassWidget,CompositeLayer:()=>Ss,ContextMenuWidget:()=>ContextMenuWidget,ContourLayer:()=>KA,Controller:()=>Controller,Deck:()=>lr,DeckGL:()=>GO,DeckRenderer:()=>DeckRenderer,DirectionalLight:()=>DirectionalLight,FirstPersonController:()=>FirstPersonController,FirstPersonView:()=>Ms,FirstPersonViewport:()=>Ps,FlyToInterpolator:()=>FlyToInterpolator,FullscreenWidget:()=>FullscreenWidget,GeoJsonLayer:()=>lc,GeohashLayer:()=>MO,GimbalWidget:()=>GimbalWidget,GreatCircleLayer:()=>Cm,GridCellLayer:()=>Ca,GridLayer:()=>YA,H3ClusterLayer:()=>jm,H3HexagonLayer:()=>Gm,HeatmapLayer:()=>gu,HexagonLayer:()=>Xc,IconLayer:()=>$o,IconWidget:()=>IconWidget,InfoWidget:()=>InfoWidget,Layer:()=>Ts,LayerExtension:()=>Eo.A,LayerManager:()=>LayerManager,LightingEffect:()=>LightingEffect,LineLayer:()=>ea,LinearInterpolator:()=>LinearInterpolator,LoadingWidget:()=>LoadingWidget,MVTLayer:()=>wO,MapController:()=>MapController,MapView:()=>ni,OPERATION:()=>Mn.qR,OrbitController:()=>OrbitController,OrbitView:()=>Bs,OrbitViewport:()=>Os,OrthographicController:()=>OrthographicController,OrthographicView:()=>Fs,OrthographicViewport:()=>Ns.A,PathLayer:()=>Za,PointCloudLayer:()=>oa,PointLight:()=>PointLight,PolygonLayer:()=>yl,PopupWidget:()=>PopupWidget,PostProcessEffect:()=>PostProcessEffect,QuadkeyLayer:()=>Vm,ResetViewWidget:()=>ResetViewWidget,S2Layer:()=>Dm,ScatterplotLayer:()=>ua,ScenegraphLayer:()=>dE,ScreenGridLayer:()=>Lc,ScreenshotWidget:()=>ScreenshotWidget,ScrollbarWidget:()=>ScrollbarWidget,SelectorWidget:()=>SelectorWidget,SimpleMeshLayer:()=>NE,SolidPolygonLayer:()=>ml,TRANSITION_EVENTS:()=>En,TerrainController:()=>TerrainController,TerrainLayer:()=>iO,Tesselator:()=>Tesselator,TextLayer:()=>Xl,ThemeWidget:()=>ThemeWidget,Tile3DLayer:()=>ZI,TileLayer:()=>U_,ToggleWidget:()=>ToggleWidget,TransitionInterpolator:()=>TransitionInterpolator,TripsLayer:()=>G_,UNIT:()=>Mn.p5,VERSION:()=>Fe,View:()=>View,Viewport:()=>hn.A,WebGLAggregator:()=>WebGLAggregator,WebMercatorViewport:()=>wn.A,Widget:()=>Widget,ZoomWidget:()=>ZoomWidget,_GeocoderWidget:()=>GeocoderWidget,_GlobeController:()=>GlobeController,_GlobeView:()=>js,_GlobeViewport:()=>Un,_ScaleWidget:()=>ScaleWidget,_SplitterWidget:()=>SplitterWidget,_StatsWidget:()=>StatsWidget,_Tileset2D:()=>Tileset2D,_TimelineWidget:()=>TimelineWidget,assert:()=>Pn,color:()=>Hs,createIterable:()=>br,default:()=>GO,fp64LowPart:()=>Jn.qk,getShaderAssembler:()=>He,gouraudMaterial:()=>co,log:()=>Ie.A,phongMaterial:()=>Ao,picking:()=>Qs,project:()=>hi.A,project32:()=>Xs,shadow:()=>wi});var i=n.cw(function(e,t){function n(e,t,n){n=n||2;var r,o,a,l,c,h,d,p=t&&t.length,g=p?t[0]*n:e.length,m=i(e,0,g,n,!0),b=[];if(!m||m.next===m.prev)return b;if(p&&(m=function(e,t,n,r){var s,o,a,l=[];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),l.push(f(a));for(l.sort(A),s=0;s<l.length;s++)n=u(l[s],n);return n}(e,t,m,n)),e.length>80*n){r=a=e[0],o=l=e[1];for(var _=n;_<g;_+=n)(c=e[_])<r&&(r=c),(h=e[_+1])<o&&(o=h),c>a&&(a=c),h>l&&(l=h);d=0!==(d=Math.max(a-r,l-o))?32767/d:0}return s(m,b,n,r,o,d,0),b}function i(e,t,n,i,r){var s,o;if(r===C(e,t,n,i)>0)for(s=t;s<n;s+=i)o=T(s,e[s],e[s+1],o);else for(s=n-i;s>=t;s-=i)o=T(s,e[s],e[s+1],o);return o&&b(o,o.next)&&(E(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||!b(i,i.next)&&0!==m(i.prev,i,i.next))i=i.next;else{if(E(i),(i=t=i.prev)===i.next)break;n=!0}}while(n||i!==t);return t}function s(e,t,n,i,A,u,h){if(e){!h&&u&&function(e,t,n,i){var r=e;do{0===r.z&&(r.z=d(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,l,c=1;do{for(n=e,e=null,s=null,o=0;n;){for(o++,i=n,a=0,t=0;t<c&&(a++,i=i.nextZ);t++);for(l=c;a>0||l>0&&i;)0!==a&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,a--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:e=r,r.prevZ=s,s=r;n=i}s.nextZ=null,c*=2}while(o>1)}(r)}(e,i,A,u);for(var f,p,g=e;e.prev!==e.next;)if(f=e.prev,p=e.next,u?a(e,i,A,u):o(e))t.push(f.i/n|0),t.push(e.i/n|0),t.push(p.i/n|0),E(e),e=p.next,g=p.next;else if((e=p)===g){h?1===h?s(e=l(r(e),t,n),t,n,i,A,u,2):2===h&&c(e,t,n,i,A,u):s(r(e),t,n,i,A,u,1);break}}}function o(e){var t=e.prev,n=e,i=e.next;if(m(t,n,i)>=0)return!1;for(var r=t.x,s=n.x,o=i.x,a=t.y,l=n.y,c=i.y,A=r<s?r<o?r:o:s<o?s:o,u=a<l?a<c?a:c:l<c?l:c,h=r>s?r>o?r:o:s>o?s:o,d=a>l?a>c?a:c:l>c?l:c,f=i.next;f!==t;){if(f.x>=A&&f.x<=h&&f.y>=u&&f.y<=d&&p(r,a,s,l,o,c,f.x,f.y)&&m(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function a(e,t,n,i){var r=e.prev,s=e,o=e.next;if(m(r,s,o)>=0)return!1;for(var a=r.x,l=s.x,c=o.x,A=r.y,u=s.y,h=o.y,f=a<l?a<c?a:c:l<c?l:c,g=A<u?A<h?A:h:u<h?u:h,b=a>l?a>c?a:c:l>c?l:c,_=A>u?A>h?A:h:u>h?u:h,v=d(f,g,t,n,i),y=d(b,_,t,n,i),w=e.prevZ,x=e.nextZ;w&&w.z>=v&&x&&x.z<=y;){if(w.x>=f&&w.x<=b&&w.y>=g&&w.y<=_&&w!==r&&w!==o&&p(a,A,l,u,c,h,w.x,w.y)&&m(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,x.x>=f&&x.x<=b&&x.y>=g&&x.y<=_&&x!==r&&x!==o&&p(a,A,l,u,c,h,x.x,x.y)&&m(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;w&&w.z>=v;){if(w.x>=f&&w.x<=b&&w.y>=g&&w.y<=_&&w!==r&&w!==o&&p(a,A,l,u,c,h,w.x,w.y)&&m(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;x&&x.z<=y;){if(x.x>=f&&x.x<=b&&x.y>=g&&x.y<=_&&x!==r&&x!==o&&p(a,A,l,u,c,h,x.x,x.y)&&m(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function l(e,t,n){var i=e;do{var s=i.prev,o=i.next.next;!b(s,o)&&_(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),E(i),E(i.next),i=e=o),i=i.next}while(i!==e);return r(i)}function c(e,t,n,i,o,a){var l=e;do{for(var c=l.next.next;c!==l.prev;){if(l.i!==c.i&&g(l,c)){var A=x(l,c);return l=r(l,l.next),A=r(A,A.next),s(l,t,n,i,o,a,0),void s(A,t,n,i,o,a,0)}c=c.next}l=l.next}while(l!==e)}function A(e,t){return e.x-t.x}function u(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 l,c=n,A=n.x,u=n.y,d=1/0;i=n;do{r>=i.x&&i.x>=A&&r!==i.x&&p(s<u?r:o,s,A,u,s<u?o:r,s,i.x,i.y)&&(l=Math.abs(s-i.y)/(r-i.x),w(i,e)&&(l<d||l===d&&(i.x>n.x||i.x===n.x&&h(n,i)))&&(n=i,d=l)),i=i.next}while(i!==c);return n}(e,t);if(!n)return t;var i=x(n,e);return r(i,i.next),r(n,n.next)}function h(e,t){return m(e.prev,e,t.prev)<0&&m(t.next,e,e.next)<0}function d(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 f(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 p(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 g(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&&_(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)&&(m(e.prev,e,t.prev)||m(e,t.prev,t))||b(e,t)&&m(e.prev,e,e.next)>0&&m(t.prev,t,t.next)>0)}function m(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function b(e,t){return e.x===t.x&&e.y===t.y}function _(e,t,n,i){var r=y(m(e,t,n)),s=y(m(e,t,i)),o=y(m(n,i,e)),a=y(m(n,i,t));return r!==s&&o!==a||(!(0!==r||!v(e,n,t))||(!(0!==s||!v(e,i,t))||(!(0!==o||!v(n,e,i))||!(0!==a||!v(n,t,i)))))}function v(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 y(e){return e>0?1:e<0?-1:0}function w(e,t){return m(e.prev,e,e.next)<0?m(e,t,e.next)>=0&&m(e,e.prev,t)>=0:m(e,t,e.prev)<0||m(e,e.next,t)<0}function x(e,t){var n=new S(e.i,e.x,e.y),i=new S(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 T(e,t,n,i){var r=new S(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 E(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 S(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 C(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(C(e,0,s,n));if(r)for(var a=0,l=t.length;a<l;a++){var c=t[a]*n,A=a<l-1?t[a+1]*n:e.length;o-=Math.abs(C(e,c,A,n))}var u=0;for(a=0;a<i.length;a+=3){var h=i[a]*n,d=i[a+1]*n,f=i[a+2]*n;u+=Math.abs((e[h]-e[f])*(e[d+1]-e[h+1])-(e[h]-e[d])*(e[f+1]-e[h+1]))}return 0===o&&0===u?0:Math.abs((u-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.r(r),n.d(r,{createExtMeshFeatures:()=>Zw,decode:()=>Qw,encode:()=>Xw,name:()=>Kw});var s={};n.r(s),n.d(s,{createExtStructuralMetadata:()=>ux,decode:()=>tx,encode:()=>nx,name:()=>ex});var o={};n.r(o),n.d(o,{decode:()=>_x,name:()=>bx});var a={};n.r(a),n.d(a,{decode:()=>yx,name:()=>vx});var l={};n.r(l),n.d(l,{name:()=>Sx,preprocess:()=>Cx});var c={};n.r(c),n.d(c,{name:()=>Rx,preprocess:()=>Mx});var A={};n.r(A),n.d(A,{decode:()=>Zx,encode:()=>Yx,name:()=>Xx,preprocess:()=>$x});var u={};n.r(u),n.d(u,{decode:()=>aT,name:()=>iT});var h={};n.r(h),n.d(h,{decode:()=>dT,encode:()=>fT,name:()=>hT});var d={};n.r(d),n.d(d,{decode:()=>mT,encode:()=>bT,name:()=>gT});var f={};n.r(f),n.d(f,{decode:()=>yT,encode:()=>wT,name:()=>vT});var p={};n.r(p),n.d(p,{decode:()=>ST,name:()=>ET});var g={};n.r(g),n.d(g,{createExtMeshFeatures:()=>DR,decode:()=>NR,encode:()=>kR,name:()=>BR});var m={};n.r(m),n.d(m,{createExtStructuralMetadata:()=>YR,decode:()=>GR,encode:()=>jR,name:()=>zR});var b={};n.r(b),n.d(b,{decode:()=>sM,name:()=>rM});var _={};n.r(_),n.d(_,{decode:()=>aM,name:()=>oM});var v={};n.r(v),n.d(v,{name:()=>mM,preprocess:()=>bM});var y={};n.r(y),n.d(y,{name:()=>vM,preprocess:()=>yM});var w={};n.r(w),n.d(w,{name:()=>xM,preprocess:()=>TM});var x={};n.r(x),n.d(x,{decode:()=>RM,encode:()=>MM,name:()=>CM,preprocess:()=>PM});var T={};n.r(T),n.d(T,{decode:()=>UM,name:()=>NM});var E={};n.r(E),n.d(E,{decode:()=>QM,encode:()=>XM,name:()=>KM});var S={};n.r(S),n.d(S,{decode:()=>YM,encode:()=>JM,name:()=>ZM});var C={};n.r(C),n.d(C,{decode:()=>nL,encode:()=>iL,name:()=>tL});var P={};function R(e,t){if(!e)throw new Error(t||"loader assertion failed.")}function M(e){if(!e)return!1;Array.isArray(e)&&(e=e[0]);return Array.isArray(e?.extensions)}function L(e){let t;return R(e,"null loader"),R(M(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}n.r(P),n.d(P,{decode:()=>aL,name:()=>oL});const I=e=>"boolean"==typeof e,O=e=>"function"==typeof e,B=e=>null!==e&&"object"==typeof e,N=e=>B(e)&&e.constructor==={}.constructor,k=e=>"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer,F=e=>B(e)&&"number"==typeof e.byteLength&&"function"==typeof e.slice,D=e=>"undefined"!=typeof Response&&e instanceof Response||B(e)&&O(e.arrayBuffer)&&O(e.text)&&O(e.json),U=e=>"undefined"!=typeof Blob&&e instanceof Blob,V=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||B(e)&&O(e.tee)&&O(e.cancel)&&O(e.getReader))(e)||(e=>B(e)&&O(e.read)&&O(e.pipe)&&I(e.readable))(e);function z(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):e}function G(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}var j=n(16587);const H=new j.h({id:"loaders.gl"});class NullLog{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}"undefined"!=typeof self&&self,"undefined"!=typeof window&&window,"undefined"!=typeof globalThis&&globalThis,"undefined"!=typeof document&&document;const W=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),q="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version),K=(q&&parseFloat(q[1]),{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:W,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}}),Q={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"},X=/\?.*/;function $(e){return e.replace(X,"")}const Z=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function Y(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state||(e._state={}),e._state}function J(){const e=Y();return e.globalOptions=e.globalOptions||{...K,core:{...K.core}},te(e.globalOptions)}function ee(e,t,n,i){return n=n||[],function(e,t){ne(e,null,K,Q,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]||{};ne(i,n.id,r,s,t)}}(e,n=Array.isArray(n)?n:[n]),te(re(t,e,i))}function te(e){const t=function(e){const t={...e};e.core&&(t.core={...e.core});return t}(e);oe(t);for(const e of Z)t.core&&void 0!==t.core[e]&&delete t[e];return t.core&&void 0!==t.core._workerType&&delete t._worker,t}function ne(e,t,n,i,r){const s=t||"Top level",o=t?`${t}.`:"";for(const a in e){const l=!t&&B(e[a]);if(!(a in n)&&!("baseUri"===a&&!t)&&!("workerUrl"===a&&t))if(a in i)H.level>0&&H.warn(`${s} loader option '${o}${a}' no longer supported, use '${i[a]}'`)();else if(!l&&H.level>0){const e=ie(a,r);H.warn(`${s} loader option '${o}${a}' not recognized. ${e}`)()}}}function ie(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 re(e,t,n){const i=e.options||{},r={...i};i.core&&(r.core={...i.core}),oe(r),null===r.core?.log&&(r.core={...r.core,log:new NullLog}),se(r,te(J()));return se(r,te(t)),function(e,t){if(!t)return;const n=void 0!==e.core?.baseUrl;n||(e.core||={},e.core.baseUrl=G($(t)))}(r,n),function(e){const t=e.core;if(!t)return;for(const n of Z)void 0!==t[n]&&(e[n]=t[n])}(r),r}function se(e,t){for(const n in t)if(n in t){const i=t[n];N(i)&&N(e[n])?e[n]={...e[n],...t[n]}:e[n]=t[n]}}function oe(e){void 0!==e.baseUri&&(e.core||={},void 0===e.core.baseUrl&&(e.core.baseUrl=e.baseUri));for(const t of Z)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))}const ae=()=>{const e=Y();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry};function le(e,t){if(!e)throw new Error(t||"loader assertion failed.")}"undefined"!=typeof self&&self,"undefined"!=typeof window&&window,"undefined"!=typeof globalThis&&globalThis,"undefined"!=typeof document&&document;const ce=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),Ae="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version),ue=(Ae&&parseFloat(Ae[1]),globalThis.loaders?.parseImageNode),he="undefined"!=typeof Image,de="undefined"!=typeof ImageBitmap,fe=Boolean(ue),pe=!!ce||fe;function ge(e){const t=be(e);if(!t)throw new Error("Not an image");return t}function me(e){switch(ge(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 be(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 _e=/^data:image\/svg\+xml/,ve=/\.svg((\?|#).*)?$/;function ye(e){return e&&(_e.test(e)||ve.test(e))}function we(e,t){if(ye(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function xe(e,t,n){const i=function(e,t){if(ye(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 we(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 Ee(e,t,n){let i;if(ye(n)){i=await xe(e,t,n)}else i=we(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 Se(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 Ce=!1,Pe=!0;function Re(e){const t=Me(e);return function(e){const t=Me(e),n=t.byteLength>=24&&2303741511===t.getUint32(0,Ce);if(!n)return null;return{mimeType:"image/png",width:t.getUint32(16,Ce),height:t.getUint32(20,Ce)}}(t)||function(e){const t=Me(e),n=t.byteLength>=3&&65496===t.getUint16(0,Ce)&&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,Ce);if(r.has(e))return{mimeType:"image/jpeg",height:t.getUint16(s+5,Ce),width:t.getUint16(s+7,Ce)};if(!i.has(e))return null;s+=2,s+=t.getUint16(s,Ce)}return null}(t)||function(e){const t=Me(e),n=t.byteLength>=10&&1195984440===t.getUint32(0,Ce);if(!n)return null;return{mimeType:"image/gif",width:t.getUint16(6,Pe),height:t.getUint16(8,Pe)}}(t)||function(e){const t=Me(e),n=t.byteLength>=14&&16973===t.getUint16(0,Ce)&&t.getUint32(2,Pe)===t.byteLength;if(!n)return null;return{mimeType:"image/bmp",width:t.getUint32(18,Pe),height:t.getUint32(22,Pe)}}(t)||function(e){const t=new Uint8Array(e instanceof DataView?e.buffer:e),n=Se(t);if(!n)return null;return{mimeType:n.mimeType,width:0,height:0}}(t)}function Me(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 Le={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:"4.5.1",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(de)return"imagebitmap";if(he)return"image";if(pe)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return de||he||pe;case"imagebitmap":return de;case"image":return he;case"data":return pe;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}(e),e}}(i)){case"imagebitmap":s=await Ee(e,t,r);break;case"image":s=await xe(e,t,r);break;case"data":s=await async function(e){const{mimeType:t}=Re(e)||{},n=globalThis.loaders?.parseImageNode;return le(n),await n(e,t)}(e);break;default:le(!1)}return"data"===i&&(s=me(s)),s},tests:[e=>Boolean(Re(new DataView(e)))],options:{image:{type:"auto",decode:!0}}};var Ie=n(3459);let Oe={};function Be(e){Oe=e}function Ne(e,t,n,i){Ie.A.level>0&&Oe[e]&&Oe[e].call(null,t,n,i)}const ke={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.3.7",t=globalThis.deck&&globalThis.deck.VERSION;if(t&&t!==e)throw new Error(`deck.gl - multiple versions detected: ${t} vs ${e}`);return t||(Ie.A.log(1,`deck.gl ${e}`)(),globalThis.deck={...globalThis.deck,VERSION:e,version:e,log:Ie.A,_registerLoggers:Be},function(e){const t=ae();e=Array.isArray(e)?e:[e];for(const n of e){const e=L(n);t.find(t=>e===t)||t.unshift(e)}}([ke,[Le,{imagebitmap:{premultiplyAlpha:"none"}}]])),e}();let De=1,Ue=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:i=1,repeat:r=1}=e,s=De++,o={time:0,delay:t,duration:n,rate:i,repeat:r};return this._setChannelTime(o,this.time),this.channels.set(s,o),s}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=Ue++;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 Ve=n(63234);const ze=[n(3065).A],Ge=["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)"],je=[];function He(e){const t=Ve._.getDefaultShaderAssembler();for(const e of ze)t.addDefaultModule(e);t._hookFunctions.length=0;const n="glsl"===e?Ge:je;for(const e of n)t.addShaderHook(e);return t}const We="layout(std140) uniform layerUniforms {\n uniform float opacity;\n} layer;\n",qe={name:"layer",source:"struct LayerUniforms {\n opacity: f32,\n};\n\n@group(0) @binding(auto)\nvar<uniform> layer: LayerUniforms;\n",vs:We,fs:We,getUniforms:e=>({opacity:Math.pow(e.opacity,1/2.2)}),uniformTypes:{opacity:"f32"}},Ke="Awaiting state",Qe="Matched. State transferred from previous layer",Xe="Initialized",$e="Discarded. Awaiting garbage collection",Ze="No longer matched. Awaiting garbage collection",Ye="Finalized! Awaiting garbage collection",Je=Symbol.for("component"),et=Symbol.for("propTypes"),tt=Symbol.for("deprecatedProps"),nt=Symbol.for("asyncPropDefaults"),it=Symbol.for("asyncPropOriginal"),rt=Symbol.for("asyncPropResolved");function st(e,t=()=>!0){return Array.isArray(e)?ot(e,t,[]):t(e)?[e]:[]}function ot(e,t,n){let i=-1;for(;++i<e.length;){const r=e[i];Array.isArray(r)?ot(r,t,n):t(r)&&n.push(r)}return n}function at({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}var lt=n(30568);let ct="";const At={};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 ut=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,ht=/^([-\w.]+\/[-\w.+]+)/;function dt(e,t){return e.toLowerCase()===t.toLowerCase()}function ft(e){const t=ut.exec(e);return t?t[1]:""}function pt(e){if(D(e))return e.url;if(U(e)){return("name"in e?e.name:"")||""}return"string"==typeof e?e:""}function gt(e){if(D(e)){const t=e.headers.get("content-type")||"",n=$(e.url);return function(e){const t=ht.exec(e);return t?t[1]:e}(t)||ft(n)}return U(e)?e.type||"":"string"==typeof e?ft(e):""}async function mt(e){if(D(e))return e;const t={},n=function(e){if(D(e))return e.headers["content-length"]||-1;if(U(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 i=pt(e),r=gt(e);r&&(t["content-type"]=r);const s=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);s&&(t["x-first-bytes"]=s),"string"==typeof e&&(e=(new TextEncoder).encode(e));const o=new Response(e,{headers:t});return Object.defineProperty(o,"url",{value:i}),o}async function bt(e){if(!e.ok){const t=await async function(e){const t=function(e){if(e.length<50)return e;const t=e.slice(e.length-15);return`${e.substr(0,32)}...${t}`}(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 _t(e,t){if("string"==typeof e){const n=function(e){for(const t in At)if(e.startsWith(t)){const n=At[t];e=e.replace(t,n)}return e.startsWith("http://")||e.startsWith("https://")||(e=`${ct}${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 mt(e)}function vt(e,t){const n=J(),i=e||n,r=i.fetch??i.core?.fetch;return"function"==typeof r?r:B(r)?e=>_t(e,r):t?.fetch?t?.fetch:_t}function yt(e,t){return wt(e||{},t)}function wt(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]=wt(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 xt="object"!=typeof process||"[object process]"!==String(process)||process.browser,Tt="undefined"!=typeof window&&void 0!==window.orientation,Et="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);Et&&parseFloat(Et[1]);class NodeWorker{terminate(){}}function St(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}const Ct=new Map;function Pt(e){St(e.source&&!e.url||!e.source&&e.url);let t=Ct.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return Rt((t=e,`try {\n importScripts('${t}');\n} catch (error) {\n console.error(error);\n throw error;\n}`));var t}(e.url),Ct.set(e.url,t)),e.source&&(t=Rt(e.source),Ct.set(e.source,t))),St(t),t}function Rt(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function Mt(e,t=!0,n){const i=n||new Set;if(e){if(Lt(e))i.add(e);else if(Lt(e.buffer))i.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const n in e)Mt(e[n],t,i)}else;return void 0===n?Array.from(i):[]}function Lt(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 It=()=>{};class WorkerThread{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return"undefined"!=typeof Worker&&xt||void 0!==NodeWorker&&!xt}constructor(e){const{name:t,source:n,url:i}=e;St(n||i),this.name=t,this.source=n,this.url=i,this.onMessage=It,this.onError=e=>console.log(e),this.worker=xt?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=It,this.onError=It,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||Mt(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=Pt({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){St(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){St(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){!xt||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 Tt?this.maxMobileConcurrency:this.maxConcurrency}}const Ot={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={...Ot},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 Bt(e,t,n,i,r){const s=e.id,o=function(e,t={}){const n=t[e.id]||{},i=xt?`${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=xt?`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 St(r),r}(e,n),a=WorkerFarm.getWorkerFarm(n?.core).getWorkerPool({name:s,url:o});n=JSON.parse(JSON.stringify(n)),i=JSON.parse(JSON.stringify(i||{}));const l=await a.startJob("process-on-worker",Nt.bind(null,r));l.postMessage("process",{input:t,options:n,context:i});const c=await l.result;return await c.result}async function Nt(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.4.5"),globalThis._loadersgl_.version;function kt(e){return e&&"object"==typeof e&&e.isBuffer}function Ft(e){if(kt(e))return e;if(e instanceof ArrayBuffer)return e;if(k(e))return Ut(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 Dt(e){if(e instanceof ArrayBuffer)return e;if(k(e))return Ut(e);const{buffer:t,byteOffset:n,byteLength:i}=e;return t instanceof ArrayBuffer&&0===n&&i===t.byteLength?t:Ut(t,n,i)}function Ut(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 Vt(...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 zt(e){if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e)){const{buffer:t,byteOffset:n,byteLength:i}=e;return Gt(t,n,i)}return Gt(e)}function Gt(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 jt=262144;function Ht(e,t){return W?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 Ft(s)}}catch(e){n.releaseLock()}}(e,t):async function*(e){for await(const t of e)yield Ft(t)}(e)}function Wt(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 Dt(r.encode(s))}}(e,t);if(e instanceof ArrayBuffer)return function*(e,t={}){const{chunkSize:n=jt}=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(U(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(V(e))return Ht(e,t);if(D(e)){const n=e.body;if(!n)throw new Error("Readable stream not available on Response");return Ht(n,t)}throw new Error("makeIterator")}const qt="Cannot convert supplied data type";function Kt(e,t,n){if(t.text&&"string"==typeof e)return e;if(kt(e)&&(e=e.buffer),F(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 Ft(n)}throw new Error(qt)}async function Qt(e,t,n){if("string"==typeof e||F(e))return Kt(e,t);if(U(e)&&(e=await mt(e)),D(e))return await bt(e),t.binary?await e.arrayBuffer():await e.text();if(V(e)&&(e=Wt(e,n)),i=e,Boolean(i)&&O(i[Symbol.iterator])||(e=>Boolean(e)&&O(e[Symbol.asyncIterator]))(e))return async function(e){const t=[];for await(const n of e)t.push(zt(n));return Vt(...t)}(e);var i;throw new Error(qt)}function Xt(e,t,n){if(n)return n;const i={fetch:vt(t,e),...e};if(i.url){const e=$(i.url);i.baseUrl=e,i.queryString=function(e){const t=e.match(X);return t&&t[0]}(i.url),i.filename=z(e),i.baseUrl=G(e)}return Array.isArray(i.loaders)||(i.loaders=null),i}const $t="4.4.5",Zt=$t[0]>="0"&&$t[0]<="9"?`v${$t}`:"";const Yt=function(){const e=new j.h({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=e,globalThis.loaders.version=Zt,globalThis.probe||={},globalThis.probe.loaders=e,e}(),Jt=/\.([^.]+)$/;function en(e){const t=gt(e);return Boolean(t&&(t.startsWith("text/")||"application/json"===t||t.endsWith("+json")))}function tn(e,t=[],n,i){if(!nn(e))return null;const r=te(n||{});if(r.core||={},t&&!Array.isArray(t))return L(t);let s=[];t&&(s=s.concat(t)),r.core.ignoreRegisteredLoaders||s.push(...ae()),function(e){for(const t of e)L(t)}(s);const o=function(e,t,n,i){const r=pt(e),s=gt(e),o=$(r)||i?.url;let a=null,l="";n?.core?.mimeType&&(a=sn(t,n?.core?.mimeType),l=`match forced by supplied MIME type ${n?.core?.mimeType}`);a=a||function(e,t){const n=t&&Jt.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),l=l||(a?`matched url ${o}`:""),a=a||sn(t,s),l=l||(a?`matched MIME type ${s}`:""),a=a||function(e,t){if(!t)return null;for(const n of e)if("string"==typeof t){if(on(t,n))return n}else if(ArrayBuffer.isView(t)){if(an(t.buffer,t.byteOffset,n))return n}else if(t instanceof ArrayBuffer){if(an(t,0,n))return n}return null}(t,e),l=l||(a?`matched initial data ${ln(e)}`:""),n?.core?.fallbackMimeType&&(a=a||sn(t,n?.core?.fallbackMimeType),l=l||(a?`matched fallback MIME type ${s}`:""));l&&Yt.log(1,`selectLoader selected ${a?.name}: ${l}.`);return a}(e,s,r,i);if(!o&&!r.core.nothrow)throw new Error(rn(e));return o}function nn(e){return!(e instanceof Response&&204===e.status)}function rn(e){const t=pt(e),n=gt(e);let i="No valid loader found (";i+=t?`${z(t)}, `:"no url provided, ",i+=`MIME type: ${n?`"${n}"`:"not provided"}, `;const r=e?ln(e):"";return i+=r?` first bytes: "${r}"`:"first bytes: not available",i+=")",i}function sn(e,t){for(const n of e){if(n.mimeTypes?.some(e=>dt(t,e)))return n;if(dt(t,`application/x.${n.id}`))return n}return null}function on(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function an(e,t,n){return(Array.isArray(n.tests)?n.tests:[n.tests]).some(n=>function(e,t,n,i){if(F(i))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}(i,e,i.byteLength);switch(typeof i){case"function":return i(Dt(e));case"string":return i===cn(e,t,i.length);default:return!1}}(e,t,0,n))}function ln(e,t=5){if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return cn(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){return cn(e,0,t)}return""}function cn(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 An(e,t,n,i){!t||Array.isArray(t)||M(t)||(i=void 0,n=t,t=void 0),n=n||{};const r=pt(e=await e),s=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,i),o=await async function(e,t=[],n,i){if(!nn(e))return null;const r=te(n||{});if(r.core||={},e instanceof Response&&en(e)){const n=tn(await e.clone().text(),t,{...r,core:{...r.core,nothrow:!0}},i);if(n)return n}let s=tn(e,t,{...r,core:{...r.core,nothrow:!0}},i);if(s)return s;U(e)&&(s=tn(e=await e.slice(0,10).arrayBuffer(),t,r,i)),!s&&e instanceof Response&&en(e)&&(s=tn(await e.clone().text(),t,r,i));if(!s&&!r.core.nothrow)throw new Error(rn(e));return s}(e,s,n);if(!o)return null;const a=ee(n,o,s,r);return i=Xt({url:r,_parse:An,loaders:s},a,i||null),await async function(e,t,n,i){if(function(e){St(e,"no worker provided");const t=e.version}(e),n=yt(e.options,n),D(t)){const{ok:e,redirected:n,status:r,statusText:s,type:o,url:a}=t,l=Object.fromEntries(t.headers.entries());i.response={headers:l,ok:e,redirected:n,status:r,statusText:s,type:o,url:a}}t=await Qt(t,e,n);const r=e;if(r.parseTextSync&&"string"==typeof t)return r.parseTextSync(t,n,i);if(function(e,t){if(!WorkerFarm.isSupported())return!1;if(!xt&&!(t?._nodeWorkers??t?.core?._nodeWorkers))return!1;const n=t?.worker??t?.core?.worker;return Boolean(e.worker&&n)}(e,n))return await Bt(e,t,n,i,An);if(r.parseText&&"string"==typeof t)return await r.parseText(t,n,i);if(r.parse)return await r.parse(t,n,i);throw St(!r.parseSync),new Error(`${e.id} loader - no parser found and worker is disabled`)}(o,e,a,i)}async function un(e,t,n,i){let r,s;Array.isArray(t)||M(t)?(r=t,s=n):(r=[],s=t);const o=vt(s);let a=e;if("string"==typeof e&&(a=await o(e)),U(e)&&(a=await o(e)),"string"==typeof e){const t=te(s||{});t.core?.baseUrl||(s={...s,core:{...s?.core,baseUrl:e}})}return Array.isArray(r),await An(a,r,s)}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=un(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 hn=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=>{Ne("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:He(e?.info?.shadingLanguage||"glsl"),defaultShaderModules:[qe],renderPass:void 0,stats:i||new lt.A({id:"deck.gl"}),viewport:r||new hn.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){Ne("layerManager.setLayers",this,t,e),this._lastRenderedLayers=e;const n=st(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]?Ie.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&&Ie.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=Xe}catch(t){this._handleError("initialization",t,e)}}_transferLayerState(e,t){t._transferState(e),t.lifecycle=Qe,t!==e&&(e.lifecycle=$e)}_updateLayer(e){try{e._update()}catch(t){this._handleError("update",t,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=Ze;try{e._finalize(),e.lifecycle=Ye}catch(t){this._handleError("finalization",t,e)}}}var dn=n(7914);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._eventCallbacks={onViewStateChange:e.onViewStateChange,onInteractionStateChange:e.onInteractionStateChange},this._pickPosition=e.pickPosition,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=>t.containsPixel(e)):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]}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),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,t){e===this.width&&t===this.height||(this.width=e,this.height=t,this.setNeedsUpdate("Size changed"))}_setViews(e){e=st(e,Boolean);this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){if(e){!(0,dn.b)(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e}else Ie.A.warn("missing `viewState` or `initialViewState`")()}_createController(e,t){return new(0,t.type)({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:t=>this.getView(e.id)?.makeViewport({viewState:t,width:this.width,height:this.height}),pickPosition:this._pickPosition})}_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,t=this.controllers;this._viewports=[],this.controllers={};let n=!1;for(let i=e.length;i--;){const r=e[i],s=this.getViewState(r),o=r.makeViewport({viewState:s,width:this.width,height:this.height});let a=t[r.id];const l=Boolean(r.controller);l&&!a&&(n=!0),!n&&l||!a||(a.finalize(),a=null),this.controllers[r.id]=this._updateController(r,s,o,a),o&&this._viewports.unshift(o)}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]))}}const fn=/^(?:\d+\.?\d*|\.\d+)$/;function pn(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 i=e[n];if(/\s/.test(i))n++;else{if("+"!==i&&"-"!==i&&"("!==i&&")"!==i&&"%"!==i){if(bn(i)||"."===i){const r=n;let s="."===i;for(n++;n<e.length;){const t=e[n];if(bn(t))n++;else{if("."!==t||s)break;s=!0,n++}}const o=e.slice(r,n);if(!fn.test(o))throw new Error("Invalid number token");t.push({type:"number",value:parseFloat(o)});continue}if(_n(i)){const i=n;for(;n<e.length&&_n(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:i}),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 gn(e,t){switch(e.type){case"literal":return e.value;case"percentage":return Math.round(e.value*t);case"binary":const n=gn(e.left,t),i=gn(e.right,t);return"+"===e.operator?n+i:n-i;default:throw new Error("Unknown layout expression type")}}function mn(e,t){return gn(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(;vn(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 bn(e){return e>="0"&&e<="9"}function _n(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}function vn(e){return Boolean(e&&"symbol"===e.type&&("+"===e.value||"-"===e.value))}function yn(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:i=0,width:r="100%",height:s="100%",padding:o=null}=e;this.id=t||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=pn(n),this._y=pn(i),this._width=pn(r),this._height=pn(s),this._padding=o&&{left:pn(o.left||0),right:pn(o.right||0),top:pn(o.top||0),bottom:pn(o.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e||this.constructor===e.constructor&&(0,dn.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]=yn(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:mn(this._x,e),y:mn(this._y,t),width:mn(this._width,e),height:mn(this._height,t)};return this._padding&&(n.padding={left:mn(this._padding.left,e),top:mn(this._padding.top,t),right:mn(this._padding.right,e),bottom:mn(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}}var wn=n(69502),xn=n(54901);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(){}}const Tn=()=>{},En={BREAK:1,SNAP_TO_END:2,IGNORE:3},Sn=e=>e,Cn=En.BREAK;class TransitionManager{constructor(e){this._onTransitionUpdate=e=>{const{time:t,settings:{interpolator:n,startProps:i,endProps:r,duration:s,easing:o}}=e,a=o(t/s),l=n.interpolateProps(i,r,a);this.propsInTransition=this.getControllerState({...this.props,...l}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new Transition(e.timeline),this.onViewStateChange=e.onViewStateChange||Tn,this.onStateChange=e.onStateChange||Tn}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===En.SNAP_TO_END?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===En.IGNORE||this._isUpdateDueToCurrentTransition(t)}return!this._isTransitionEnabled(t)||t.transitionInterpolator.arePropsEqual(e,t)}_triggerTransition(e,t){const n=this.getControllerState(e),i=this.getControllerState(t).shortestPathFrom(n),r=t.transitionInterpolator,s=r.getDuration?r.getDuration(e,t):t.transitionDuration;if(0===s)return;const o=r.initializeProps(e,i);this.propsInTransition={};const a={duration:s,easing:t.transitionEasing||Sn,interpolator:r,interruption:t.transitionInterruption||Cn,startProps:o.start,endProps:o.end,onStart:t.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(t.onTransitionInterrupt),onEnd:this._onTransitionEnd(t.onTransitionEnd)};this.transition.start(a),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)}}}function Pn(e,t){if(!e)throw new Error(t||"deck.gl: assertion failed.")}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,xn.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];Pn(Number.isFinite(n)||Array.isArray(n),`${t} is required for transition`)})}}var Rn=n(31886),Mn=n(9350),Ln=n(45249),In=n(82859),On=n(39426);const Bn=Math.PI/180,Nn=180/Math.PI,kn=6370972,Fn=256;function Dn(){const e=4018225162502676e-20,t=Math.PI/180*Fn;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 hn.A{constructor(e={}){const{longitude:t=0,zoom:n=0,nearZMultiplier:i=.5,farZMultiplier:r=1,resolution:s=10}=e;let{latitude:o=0,height:a,altitude:l=1.5,fovy:c}=e;o=Math.max(Math.min(o,Ln.aH),-Ln.aH),a=a||1,c?l=(0,Ln.wZ)(c):c=(0,Ln.Os)(l);const A=Math.pow(2,n-Vn(o)),u=e.nearZ??i,h=e.farZ??(l+512*A/a)*r,d=(new Rn.k).lookAt({eye:[0,-l,0],up:[0,0,1]});d.rotateX(o*Bn),d.rotateZ(-t*Bn),d.scale(A/a),super({...e,height:a,viewMatrix:d,longitude:t,latitude:o,zoom:n,distanceScales:Dn(),fovy:c,focalDistance:l,near:u,far:h}),this.scale=A,this.latitude=o,this.longitude=t,this.fovy=c,this.resolution=s}get projectionMode(){return Mn.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])]}unproject(e,{topLeft:t=!0,targetZ:n}={}){const[i,r,s]=e,o=t?r:this.height-r,{pixelUnprojectionMatrix:a}=this;let l;if(Number.isFinite(s))l=zn(a,[i,o,s,1]);else{const e=zn(a,[i,o,-1,1]),t=zn(a,[i,o,1,1]),r=((n||0)/kn+1)*Fn,s=In.uE(In.jb([],e,t)),c=In.uE(e),A=In.uE(t),u=4*((4*c*A-(s-c-A)**2)/16)/s,h=(Math.sqrt(c-u)-Math.sqrt(Math.max(0,r*r-u)))/Math.sqrt(s);l=In.Cc([],e,t,h)}const[c,A,u]=this.unprojectPosition(l);return Number.isFinite(s)?[c,A,u]:Number.isFinite(n)?[c,A,n]:[c,A]}projectPosition(e){const[t,n,i=0]=e,r=t*Bn,s=n*Bn,o=Math.cos(s),a=(i/kn+1)*Fn;return[Math.sin(r)*o*a,-Math.cos(r)*o*a,Math.sin(s)*a]}unprojectPosition(e){const[t,n,i]=e,r=In.Il(e),s=Math.asin(i/r);return[Math.atan2(t,-n)*Nn,s*Nn,(r/Fn-1)*kn]}projectFlat(e){return e}unprojectFlat(e){return e}panByPosition([e,t,n],i,r){const s=.25/Math.pow(2,this.zoom-Vn(this.latitude)),o=e+s*(r[0]-i[0]);let a=t-s*(r[1]-i[1]);a=Math.max(Math.min(a,Ln.aH),-Ln.aH);const l={longitude:o,latitude:a,zoom:n-Vn(t)};return l.zoom+=Vn(l.latitude),l}}GlobeViewport.displayName="GlobeViewport";const Un=GlobeViewport;function Vn(e){const t=Math.PI*Math.cos(e*Math.PI/180);return Math.log2(t)}function zn(e,t){const n=On.Z0([],t,e);return On.hs(n,n,1/n[3]),n}const Gn=["longitude","latitude","zoom","bearing","pitch"],jn=["longitude","latitude","zoom"];class LinearInterpolator extends TransitionInterpolator{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:Gn,required:jn},super(n.transitionProps),this.opts=n}initializeProps(e,t){const n=super.initializeProps(e,t),{makeViewport:i,around:r}=this.opts;if(i&&r){if(i(e)instanceof Un)Ie.A.warn("around not supported in GlobeView")();else{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 r of this._propsToExtract)i[r]=(0,xn.Cc)(e[r]||0,t[r]||0,n);if(t.aroundPosition&&this.opts.makeViewport){const r=this.opts.makeViewport({...t,...i});Object.assign(i,r.panByPosition(t.aroundPosition,(0,xn.Cc)(e.around,t.around,n)))}return i}}const Hn={transitionDuration:0},Wn=e=>1-(1-e)*(1-e),qn=["wheel"],Kn=["panstart","panmove","panend"],Qn=["pinchstart","pinchmove","pinchend"],Xn=["multipanstart","multipanmove","multipanend"],$n=["dblclick"],Zn=["keydown"],Yn={};class Controller{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new TransitionManager({...e,getControllerState:e=>new this.ControllerState(e),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._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return 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"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]}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){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,touchZoom:a=!0,touchRotate:l=!1,keyboard:c=!0}=e,A=Boolean(this.onViewStateChange);this.toggleEvents(qn,A&&i),this.toggleEvents(Kn,A),this.toggleEvents(Qn,A&&(a||l)),this.toggleEvents(Xn,A&&l),this.toggleEvents($n,A&&o),this.toggleEvents(Zn,A&&c),this.scrollZoom=i,this.dragPan=r,this.dragRotate=s,this.doubleClickZoom=o,this.touchZoom=a,this.touchRotate=l,this.keyboard=c;if((!t||t.height!==e.height||t.width!==e.width||t.maxBounds!==e.maxBounds)&&e.maxBounds){const t=new this.ControllerState({...e,makeViewport:this.makeViewport}),n=t.getViewportProps();Object.keys(n).some(t=>!(0,dn.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)}_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=this.controllerState[n?"panStart":"rotateStart"]({pos:t});return this._panMove=n,this.updateViewport(i,Hn,{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});return this.updateViewport(n,Hn,{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:Wn},{isDragging:!1,isPanning:!0})}else{const e=this.controllerState.panEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;const t=this.getCenter(e),n=this.controllerState.rotate({pos:t});return this.updateViewport(n,Hn,{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:Wn},{isDragging:!1,isRotating:!0})}else{const e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)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=i?{...this._getTransitionProps({around:t}),transitionDuration:250}:Hn,a=this.controllerState.zoom({pos:t,scale:s});return this.updateViewport(a,o,{isZooming:!0,isPanning:!0}),i||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const n=this.controllerState.rotateStart({pos:t});return this.updateViewport(n,Hn,{isDragging:!0}),!0}_onMultiPan(e){if(!this.touchRotate)return!1;if(!this.isDragging())return!1;const t=this.getCenter(e);t[0]-=e.deltaX;const n=this.controllerState.rotate({pos:t});return this.updateViewport(n,Hn,{isDragging:!0,isRotating:!0}),!0}_onMultiPanEnd(e){if(!this.isDragging())return!1;const{inertia:t}=this;if(this.touchRotate&&t&&e.velocityY){const n=this.getCenter(e),i=[n[0],n[1]+=e.velocityY*t/2],r=this.controllerState.rotate({pos:i});this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:Wn},{isDragging:!1,isRotating:!0}),this.blockEvents(t)}else{const e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const n=this.controllerState.zoomStart({pos:t}).rotateStart({pos:t});return Yn._startPinchRotation=e.rotation,Yn._lastPinchEvent=e,this.updateViewport(n,Hn,{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:i,scale:n})}if(this.touchRotate){const{rotation:n}=e;t=t.rotate({deltaAngleX:Yn._startPinchRotation-n})}return this.updateViewport(t,Hn,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),Yn._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;const{inertia:t}=this,{_lastPinchEvent:n}=Yn;if(this.touchZoom&&t&&n&&e.scale!==n.scale){const i=this.getCenter(e);let r=this.controllerState.rotateEnd();const s=Math.log2(e.scale),o=(s-Math.log2(n.scale))/(e.deltaTime-n.deltaTime),a=Math.pow(2,s+o*t/2);r=r.zoom({pos:i,scale:a}).zoomEnd(),this.updateViewport(r,{...this._getTransitionProps({around:i}),transitionDuration:t,transitionEasing:Wn},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(t)}else{const e=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return Yn._startPinchRotation=null,Yn._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom)return!1;const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const n=this.isFunctionKeyPressed(e),i=this.controllerState.zoom({pos:t,scale:n?.5:2});return this.updateViewport(i,this._getTransitionProps({around:t}),{isZooming:!0,isPanning:!0}),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 l={};switch(e.srcEvent.code){case"Minus":a=t?o.zoomOut(n).zoomOut(n):o.zoomOut(n),l.isZooming=!0;break;case"Equal":a=t?o.zoomIn(n).zoomIn(n):o.zoomIn(n),l.isZooming=!0;break;case"ArrowLeft":t?(a=o.rotateLeft(r),l.isRotating=!0):(a=o.moveLeft(i),l.isPanning=!0);break;case"ArrowRight":t?(a=o.rotateRight(r),l.isRotating=!0):(a=o.moveRight(i),l.isPanning=!0);break;case"ArrowUp":t?(a=o.rotateUp(s),l.isRotating=!0):(a=o.moveUp(i),l.isPanning=!0);break;case"ArrowDown":t?(a=o.rotateDown(s),l.isRotating=!0):(a=o.moveDown(i),l.isPanning=!0);break;default:return!1}return this.updateViewport(a,this._getTransitionProps(),l),!0}_getTransitionProps(e){const{transition:t}=this;return t&&t.transitionInterpolator?e?{...t,transitionInterpolator:new LinearInterpolator({...e,...t.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:t:Hn}}class ViewState{constructor(e,t,n){this.makeViewport=n,this._viewportProps=this.applyConstraints(e),this._state=t}getViewportProps(){return this._viewportProps}getState(){return this._state}}var Jn=n(25667);const ei=[[-1/0,-90],[1/0,90]];function ti([e,t]){if(Math.abs(t)>90&&(t=90*Math.sign(t)),Number.isFinite(e)){const[n,i]=(0,Ln.Gw)([e,t]);return[n,(0,xn.qE)(i,0,512)]}const[,n]=(0,Ln.Gw)([0,t]);return[e,(0,xn.qE)(n,0,512)]}class MapState extends ViewState{constructor(e){const{width:t,height:n,latitude:i,longitude:r,zoom:s,bearing:o=0,pitch:a=0,altitude:l=1.5,position:c=[0,0,0],maxZoom:A=20,minZoom:u=0,maxPitch:h=60,minPitch:d=0,startPanLngLat:f,startZoomLngLat:p,startRotatePos:g,startRotateLngLat:m,startBearing:b,startPitch:_,startZoom:v,normalize:y=!0}=e;Pn(Number.isFinite(r)),Pn(Number.isFinite(i)),Pn(Number.isFinite(s));super({width:t,height:n,latitude:i,longitude:r,zoom:s,bearing:o,pitch:a,altitude:l,maxZoom:A,minZoom:u,maxPitch:h,minPitch:d,normalize:y,position:c,maxBounds:e.maxBounds||(y?ei:null)},{startPanLngLat:f,startZoomLngLat:p,startRotatePos:g,startRotateLngLat:m,startBearing:b,startPitch:_,startZoom:v},e.makeViewport),this.getAltitude=e.getAltitude}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:t}){const n=this.getState().startPanLngLat||this._unproject(t);if(!n)return this;const i=this.makeViewport(this.getViewportProps()).panByPosition(n,e);return this._getUpdatedState(i)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}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}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:t,scale:n}){let{startZoom:i,startZoomLngLat:r}=this.getState();if(r||(i=this.getViewportProps().zoom,r=this._unproject(t)||this._unproject(e)),!r)return this;const s=this._constrainZoom(i+Math.log2(n)),o=this.makeViewport({...this.getViewportProps(),zoom:s});return this._getUpdatedState({zoom:s,...o.panByPosition(r,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}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){const{maxPitch:t,minPitch:n,pitch:i,longitude:r,bearing:s,normalize:o,maxBounds:a}=e;if(o&&((r<-180||r>180)&&(e.longitude=(0,Jn.zi)(r+180,360)-180),(s<-180||s>180)&&(e.bearing=(0,Jn.zi)(s+180,360)-180)),e.pitch=(0,xn.qE)(i,n,t),e.zoom=this._constrainZoom(e.zoom,e),a){const t=ti(a[0]),n=ti(a[1]),i=2**e.zoom,r=e.width/2/i,s=e.height/2/i,[o,l]=(0,Ln.iV)([t[0]+r,t[1]+s]),[c,A]=(0,Ln.iV)([n[0]-r,n[1]-s]);e.longitude=(0,xn.qE)(e.longitude,o,c),e.latitude=(0,xn.qE)(e.latitude,l,A)}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:s}=t;if(r){const e=ti(i[0]),r=ti(i[1]),o=r[0]-e[0],a=r[1]-e[1];Number.isFinite(o)&&o>0&&(s=Math.max(s,Math.log2(t.width/o))),Number.isFinite(a)&&a>0&&(s=Math.max(s,Math.log2(t.height/a))),s>n&&(s=n)}return(0,xn.qE)(e,s,n)}_zoomFromCenter(e){const{width:t,height:n}=this.getViewportProps();return this.zoom({pos:[t/2,n/2],scale:e})}_panFromCenter(e){const{width:t,height:n}=this.getViewportProps();return this.pan({startPos:[t/2,n/2],pos:[t/2+e[0],n/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_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],s=e[1]-t[1],o=e[1],a=t[1],{width:l,height:c}=this.getViewportProps(),A=r/l;let u=0;s>0?Math.abs(c-a)>5&&(u=s/(a-c)*1.2):s<0&&a>5&&(u=1-o/a),u=(0,xn.qE)(u,-1,1);const{minPitch:h,maxPitch:d}=this.getViewportProps();let f=n;return u>0?f=n+u*(d-n):u<0&&(f=n-u*(h-n)),{pitch:f,bearing:i+180*A}}}class MapController extends Controller{constructor(){super(...arguments),this.ControllerState=MapState,this.transition={transitionDuration:300,transitionInterpolator:new LinearInterpolator({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:ei),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 View{constructor(e={}){super(e)}getViewportType(){return wn.A}get ControllerType(){return MapController}}MapView.displayName="MapView";const ni=MapView,ii=[255,255,255],ri=1;let si=0;class AmbientLight{constructor(e={}){this.type="ambient";const{color:t=ii}=e,{intensity:n=ri}=e;this.id=e.id||"ambient-"+si++,this.color=t,this.intensity=n}}var oi=n(87597);const ai=[255,255,255],li=1,ci=[0,0,-1];let Ai=0;class DirectionalLight{constructor(e={}){this.type="directional";const{color:t=ai}=e,{intensity:n=li}=e,{direction:i=ci}=e,{_shadow:r=!1}=e;this.id=e.id||"directional-"+Ai++,this.color=t,this.intensity=n,this.type="directional",this.direction=new oi.P(i).normalize().toArray(),this.shadow=r}getProjectedLight(e){return this}}var ui=n(25285);class ShadowPass extends ui.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"}}shouldDrawLayer(e){return!1!==e.props.shadowEnabled}getShaderModuleProps(e,t,n){return{shadow:{project:n.project,drawToShadowMap:!0}}}}var hi=n(62029),di=n(82417),fi=n(74334);const pi="\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",gi=`\n${pi}\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`,mi=`\n${pi}\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`,bi=(0,di.A)(function({viewport:e,center:t}){return new Rn.k(e.viewProjectionMatrix).invert().transform(t)}),_i=(0,di.A)(function({viewport:e,shadowMatrices:t}){const n=[],i=e.pixelUnprojectionMatrix,r=e.isGeospatial?void 0:1,s=[[0,0,r],[e.width,0,r],[0,e.height,r],[e.width,e.height,r],[0,0,-1],[e.width,0,-1],[0,e.height,-1],[e.width,e.height,-1]].map(e=>function(e,t){const[n,i,r]=e,s=(0,Ln.xJ)([n,i,r],t);if(Number.isFinite(r))return s;return[s[0],s[1],0]}(e,i));for(const i of t){const t=i.clone().translate(new oi.P(e.center).negate()),r=s.map(e=>t.transform(e)),o=(new Rn.k).ortho({left:Math.min(...r.map(e=>e[0])),right:Math.max(...r.map(e=>e[0])),bottom:Math.min(...r.map(e=>e[1])),top:Math.max(...r.map(e=>e[1])),near:Math.min(...r.map(e=>-e[2])),far:Math.max(...r.map(e=>-e[2]))});n.push(o.multiplyRight(i))}return n}),vi=[0,0,0,1],yi=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];const wi={name:"shadow",dependencies:[hi.A],vs:gi,fs:mi,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=hi.A.getUniforms(n),r=bi({viewport:n.viewport,center:i.center}),s=[],o=_i({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 oi.P(n.viewport.center).negate());i.coordinateSystem===(0,fi.LB)("lnglat")&&i.projectionMode===Mn.Kx.WEB_MERCATOR?(o[t]=a,s[t]=r):(o[t]=e.clone().multiplyRight(yi),s[t]=a.transform(r))}const a={drawShadowMap:Boolean(e.drawToShadowMap),useShadowMap:!!e.shadowMaps&&e.shadowMaps.length>0,color:e.shadowColor||vi,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>"}},xi={color:[255,255,255],intensity:1},Ti=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],Ei=[0,0,0,200/255];class LightingEffect{constructor(e={}){this.id="lighting-effect",this.shadowColor=Ei,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(wi),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.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(wi))}_calculateMatrices(){const e=[];for(const t of this.directionalLights){const n=(new Rn.k).lookAt({eye:new oi.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(xi),this.directionalLights.push(new DirectionalLight(Ti[0]),new DirectionalLight(Ti[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 Si=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,dn.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(Si),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 ui.A{shouldDrawLayer(e){const{operation:t}=e.props;return t.includes("draw")||t.includes("terrain")}render(e){return this._render(e)}}var Ci=n(92189);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 Ci.A(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){if(!e.viewports.length)return;const t=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,n={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};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++,Ne("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()}_resizeRenderBuffers(){const{renderBuffers:e}=this,t=this.device.canvasContext.getDrawingBufferSize(),[n,i]=t;0===e.length&&[0,1].map(t=>{const r=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:n,height:i});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${t}`,colorAttachments:[r]}))});for(const n of e)n.resize(t)}_postRender(e,t){const{renderBuffers:n}=this,i={...t,inputBuffer:n[0],swapBuffer:n[1]};for(const r of e)if(r.postRender){i.target=r.id===this.lastPostProcessEffect?t.target:void 0;const e=r.postRender(i);i.inputBuffer=e,i.swapBuffer=e===n[0]?n[1]:n[0]}}}var Pi=n(80698),Ri=n(26839);const Mi={pickedColor:null,pickedObjectIndex:-1};function Li({pickedColors:e,decodePickingColor:t,deviceX:n,deviceY:i,deviceRadius:r,deviceRect:s}){const{x:o,y:a,width:l,height:c}=s;let A=r*r,u=-1,h=0;for(let t=0;t<c;t++){const r=t+a-i,s=r*r;if(s>A)h+=4*l;else for(let t=0;t<l;t++){if(e[h+3]-1>=0){const e=t+o-n,i=e*e+s;i<=A&&(A=i,u=h)}h+=4}}if(u>=0){const n=e.slice(u,u+4),i=t(n);if(i){const e=Math.floor(u/4/l),t=u/4-e*l;return{...i,pickedColor:n,pickedX:o+t,pickedY:a+e}}Ie.A.error("Picked non-existent layer. Is picking buffer corrupt?")()}return Mi}function Ii({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}):Ie.A.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(n.values())}function Oi({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 Bi(e){const{pickInfo:t,lastPickedInfo:n,mode:i,layers:r}=e,{pickedColor:s,pickedLayer:o,pickedObjectIndex:a}=t,l=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&&l.unshift(e)}n.layerId=i,n.index=a,n.info=null}}const c=Oi(e),A=new Map;return A.set(null,c),l.forEach(e=>{let t={...c};e===o&&(t.color=s,t.index=a,t.picked=!0),t=Ni({layer:e,info:t,mode:i});const r=t.layer;e===o&&"hover"===i&&(n.info=t),A.set(r.id,t),"hover"===i&&r.updateAutoHighlight(t)}),A}function Ni({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 Ci.A(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,l=o&&i.find(e=>e.id===o)||i[0],c=l&&l.unproject([e-l.x,t-l.y]),A={x:e,y:t,viewport:l,coordinate:c,layer:a};return{...r,...A}}_resizeBuffer(e=this.device.getDefaultCanvasContext()){if(!this.pickingFBO){const e=this.device.createTexture({format:"rgba8unorm",width:1,height:1,usage:Pi.g.RENDER_ATTACHMENT|Pi.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:Pi.g.RENDER_ATTACHMENT|Pi.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:l,canvasContext:c=this.device.getDefaultCanvasContext(),onViewportActive:A,effects:u}){const h=c.cssToDeviceRatio(),d=this._getPickable(e);if(!d||0===n.length)return{result:[],emptyInfo:Oi({viewports:n,x:i,y:r,pixelRatio:h})};this._resizeBuffer(c);const f=c.cssToDevicePixels([i,r],!0),p=[f.x+Math.floor(f.width/2),f.y+Math.floor(f.height/2)],g=Math.round(s*h),{width:m,height:b}=this.pickingFBO,_=this._getPickingRect({deviceX:p[0],deviceY:p[1],deviceRadius:g,deviceWidth:m,deviceHeight:b}),v={x:i-s,y:r-s,width:2*s+1,height:2*s+1};let y;const w=[],x=new Set;for(let e=0;e<o;e++){let s,c;if(_){s=Li({...await this._drawAndSampleAsync({layers:d,views:t,viewports:n,onViewportActive:A,deviceRect:_,cullRect:v,effects:u,pass:`picking:${a}`}),deviceX:p[0],deviceY:p[1],deviceRadius:g,deviceRect:_})}else s={pickedColor:null,pickedObjectIndex:-1};const f=this._getDepthLayers(s,d,l);if(f.length>0){const{pickedColors:e}=await this._drawAndSampleAsync({layers:f,views:t,viewports:n,onViewportActive:A,deviceRect:{x:s.pickedX??p[0],y:s.pickedY??p[1],width:1,height:1},cullRect:v,effects:u,pass:`picking:${a}:z`},!0);e[3]&&(c=e[0])}s.pickedLayer&&e+1<o&&(x.add(s.pickedLayer),s.pickedLayer.disablePickingIndex(s.pickedObjectIndex)),y=Bi({pickInfo:s,lastPickedInfo:this.lastPickedInfo,mode:a,layers:d,viewports:n,x:i,y:r,z:c,pixelRatio:h});for(const e of y.values())e.layer&&w.push(e);if(!s.pickedColor)break}for(const e of x)e.restorePickingColors();return{result:w,emptyInfo:y.get(null)}}_pickClosestObject({layers:e,views:t,viewports:n,x:i,y:r,radius:s=0,depth:o=1,mode:a="query",unproject3D:l,canvasContext:c=this.device.getDefaultCanvasContext(),onViewportActive:A,effects:u}){const h=c.cssToDeviceRatio(),d=this._getPickable(e);if(!d||0===n.length)return{result:[],emptyInfo:Oi({viewports:n,x:i,y:r,pixelRatio:h})};this._resizeBuffer(c);const f=c.cssToDevicePixels([i,r],!0),p=[f.x+Math.floor(f.width/2),f.y+Math.floor(f.height/2)],g=Math.round(s*h),{width:m,height:b}=this.pickingFBO,_=this._getPickingRect({deviceX:p[0],deviceY:p[1],deviceRadius:g,deviceWidth:m,deviceHeight:b}),v={x:i-s,y:r-s,width:2*s+1,height:2*s+1};let y;const w=[],x=new Set;for(let e=0;e<o;e++){let s,c;if(_){s=Li({...this._drawAndSample({layers:d,views:t,viewports:n,onViewportActive:A,deviceRect:_,cullRect:v,effects:u,pass:`picking:${a}`}),deviceX:p[0],deviceY:p[1],deviceRadius:g,deviceRect:_})}else s={pickedColor:null,pickedObjectIndex:-1};const f=this._getDepthLayers(s,d,l);if(f.length>0){const{pickedColors:e}=this._drawAndSample({layers:f,views:t,viewports:n,onViewportActive:A,deviceRect:{x:s.pickedX??p[0],y:s.pickedY??p[1],width:1,height:1},cullRect:v,effects:u,pass:`picking:${a}:z`},!0);e[3]&&(c=e[0])}s.pickedLayer&&e+1<o&&(x.add(s.pickedLayer),s.pickedLayer.disablePickingIndex(s.pickedObjectIndex)),y=Bi({pickInfo:s,lastPickedInfo:this.lastPickedInfo,mode:a,layers:d,viewports:n,x:i,y:r,z:c,pixelRatio:h});for(const e of y.values())e.layer&&w.push(e);if(!s.pickedColor)break}for(const e of x)e.restorePickingColors();return{result:w,emptyInfo:y.get(null)}}async _pickVisibleObjectsAsync({layers:e,views:t,viewports:n,x:i,y:r,width:s=1,height:o=1,mode:a="query",maxObjects:l=null,canvasContext:c=this.device.getDefaultCanvasContext(),onViewportActive:A,effects:u}){const h=this._getPickable(e);if(!h||0===n.length)return[];this._resizeBuffer(c);const d=c.cssToDeviceRatio(),f=c.cssToDevicePixels([i,r],!0),p=f.x,g=f.y+f.height,m=c.cssToDevicePixels([i+s,r+o],!0),b=m.x+m.width,_=m.y,v={x:p,y:_,width:b-p,height:g-_},y=Ii(await this._drawAndSampleAsync({layers:h,views:t,viewports:n,onViewportActive:A,deviceRect:v,cullRect:{x:i,y:r,width:s,height:o},effects:u,pass:`picking:${a}`})),w=new Map,x=[],T=Number.isFinite(l);for(let e=0;e<y.length&&!(T&&x.length>=l);e++){const t=y[e];let n={color:t.pickedColor,layer:null,index:t.pickedObjectIndex,picked:!0,x:i,y:r,pixelRatio:d};n=Ni({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),l=n.object??n.index;o.has(l)||(o.add(l),x.push(n))}return x}_pickVisibleObjects({layers:e,views:t,viewports:n,x:i,y:r,width:s=1,height:o=1,mode:a="query",maxObjects:l=null,canvasContext:c=this.device.getDefaultCanvasContext(),onViewportActive:A,effects:u}){const h=this._getPickable(e);if(!h||0===n.length)return[];this._resizeBuffer(c);const d=c.cssToDeviceRatio(),f=c.cssToDevicePixels([i,r],!0),p=f.x,g=f.y+f.height,m=c.cssToDevicePixels([i+s,r+o],!0),b=m.x+m.width,_=m.y,v={x:p,y:_,width:b-p,height:g-_},y=Ii(this._drawAndSample({layers:h,views:t,viewports:n,onViewportActive:A,deviceRect:v,cullRect:{x:i,y:r,width:s,height:o},effects:u,pass:`picking:${a}`})),w=new Map,x=[],T=Number.isFinite(l);for(let e=0;e<y.length&&!(T&&x.length>=l);e++){const t=y[e];let n={color:t.pickedColor,layer:null,index:t.pickedObjectIndex,picked:!0,x:i,y:r,pixelRatio:d};n=Ni({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),l=n.object??n.index;o.has(l)||(o.add(l),x.push(n))}return x}async _drawAndSampleAsync({layers:e,views:t,viewports:n,onViewportActive:i,deviceRect:r,cullRect:s,effects:o,pass:a},l=!1){const c=l?this.depthFBO:this.pickingFBO,A={layers:e,layerFilter:this.layerFilter,views:t,viewports:n,onViewportActive:i,pickingFBO:c,deviceRect:r,cullRect:s,effects:o,pass:a,pickZ:l,preRenderStats:{},isPicking:!0};for(const e of o)e.useInPicking&&(A.preRenderStats[e.id]=e.preRender(A));const{decodePickingColor:u,stats:h}=this.pickLayersPass.render(A);this._updateStats(h);const{x:d,y:f,width:p,height:g}=r,m=c.colorAttachments[0]?.texture;if(!m)throw new Error("Picking framebuffer color attachment is missing");const b=await this._readTextureDataAsync(m,{x:d,y:f,width:p,height:g},l?Float32Array:Uint8Array);if(!l){let e=!1;for(let t=3;t<b.length;t+=4)if(0!==b[t]){e=!0;break}!e&&b.length>0&&Ie.A.warn("Async pick readback returned only zero alpha values",{deviceRect:r,bytes:Array.from(b.subarray(0,Math.min(b.length,16)))})()}return{pickedColors:b,decodePickingColor:u}}async _readTextureDataAsync(e,t,n){const{width:i,height:r}=t,s=e.computeMemoryLayout(t),o=this.device.createBuffer({byteLength:s.byteLength,usage:Ri.h.COPY_DST|Ri.h.MAP_READ});try{e.readBuffer(t,o);const a=await o.readAsync(0,s.byteLength),l=n.BYTES_PER_ELEMENT;if(s.bytesPerRow%l!==0)throw new Error(`Texture readback row stride ${s.bytesPerRow} is not aligned to ${l}-byte elements.`);const c=new n(a.buffer,a.byteOffset,s.byteLength/l),A=4*i,u=s.bytesPerRow/l;if(u<A)throw new Error(`Texture readback row stride ${u} is smaller than packed row length ${A}.`);const h=new n(i*r*4);for(let e=0;e<r;e++){const t=e*u;h.set(c.subarray(t,t+A),e*A)}return h}finally{o.destroy()}}_drawAndSample({layers:e,views:t,viewports:n,onViewportActive:i,deviceRect:r,cullRect:s,effects:o,pass:a},l=!1){const c=l?this.depthFBO:this.pickingFBO,A={layers:e,layerFilter:this.layerFilter,views:t,viewports:n,onViewportActive:i,pickingFBO:c,deviceRect:r,cullRect:s,effects:o,pass:a,pickZ:l,preRenderStats:{},isPicking:!0};for(const e of o)e.useInPicking&&(A.preRenderStats[e.id]=e.preRender(A));const{decodePickingColor:u,stats:h}=this.pickLayersPass.render(A);this._updateStats(h);const{x:d,y:f,width:p,height:g}=r,m=new(l?Float32Array:Uint8Array)(p*g*4);return this.device.readPixelsToArrayWebGL(c,{sourceX:d,sourceY:f,sourceWidth:p,sourceHeight:g,target:m}),{pickedColors:m,decodePickingColor:u}}_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,l=Math.min(r,t+n+1)-o;return a<=0||l<=0?null:{x:s,y:o,width:a,height:l}}}const ki={"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}},Fi="top-left",Di="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,dn.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)}}onEvent(e,t){const n=Mn.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=Fi}=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||Di;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,ki[t]),i.append(r)),r}_updateContainers(){const e=this.deck.width,t=this.deck.height;for(const n in this.containers){const i=this.lastViewports[n]||null,r=n===Di||i,s=this.containers[n];r?(s.style.display="block",s.style.left=`${i?i.x:0}px`,s.style.top=`${i?i.y:0}px`,s.style.width=`${i?i.width:e}px`,s.style.height=`${i?i.height:t}px`):s.style.display="none"}}}function Ui(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,dn.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]=""}),Ui(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)),Ui(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 Vi={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,Vi),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);this.setTooltip(i,e.x,e.y)}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 zi=n(23459),Gi=n(83909),ji=n(76028),Hi=n(29651);const Wi="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.";class Luma{static defaultProps={...Gi.pF.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0};stats=ji.d;log=Hi.R;VERSION="9.3.6";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw Hi.R.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),Hi.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");Hi.R.error("This version of luma.gl has already been initialized")()}Hi.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(Wi);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(Wi);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||Hi.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?Hi.R.warn("WebGL1 is not supported",e)():Hi.R.warn("Unknown handle type",e)(),null)}}const qi=new Luma;var Ki=n(16769);class Adapter{get pageLoaded(){return function(){Xi||(Xi=Qi&&"complete"===document.readyState||"undefined"==typeof window?Promise.resolve():new Promise(e=>window.addEventListener("load",()=>e())));return Xi}()}}const Qi=(0,Ki.B)()&&"undefined"!=typeof document;let Xi=null;const $i={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:{}},Zi=e=>({drawBuffersWEBGL:t=>e.drawBuffers(t),COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),Yi=e=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES:()=>e.createVertexArray(),deleteVertexArrayOES:t=>e.deleteVertexArray(t),isVertexArrayOES:t=>e.isVertexArray(t),bindVertexArrayOES:t=>e.bindVertexArray(t)}),Ji=e=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE:(...t)=>e.drawArraysInstanced(...t),drawElementsInstancedANGLE:(...t)=>e.drawElementsInstanced(...t),vertexAttribDivisorANGLE:(...t)=>e.vertexAttribDivisor(...t)});function er(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={...$i,WEBGL_disjoint_timer_query:e.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:Zi(e),OES_vertex_array_object:Yi(e),ANGLE_instanced_arrays:Ji(e)},n=e.getExtension;e.getExtension=function(i){const r=n.call(e,i);return r||(i in t?t[i]: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 tr=n(25299),nr=n(89869);const ir=new class WebGLAdapter extends Adapter{type="webgl";constructor(){super(),Gi.pF.defaultProps={...Gi.pF.defaultProps,...tr.ic}}enforceWebGL2(e){er(e)}isSupported(){return"undefined"!=typeof WebGL2RenderingContext}isDeviceHandle(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||("undefined"!=typeof WebGLRenderingContext&&e instanceof WebGLRenderingContext&&Hi.R.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){const{WebGLDevice:i}=await Promise.resolve().then(()=>n(62738));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");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(62738)),i=[];(e.debugWebGL||e.debug)&&i.push((0,nr.$)()),e.debugSpectorJS&&i.push((0,tr._G)(e));const r=await Promise.allSettled(i);for(const e of r)"rejected"===e.status&&Hi.R.error(`Failed to initialize debug libraries ${e.reason}`)();try{const n=new t(e);Hi.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 Hi.R.probe(1,i)(),Hi.R.table(1,n.info)(),n}finally{Hi.R.groupEnd(1)(),Hi.R.info(1,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}};let rr=0;class AnimationLoop{static defaultAnimationLoopProps={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:void 0,autoResizeViewport:!1};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 lt.A({id:"animation-loop-"+rr++}),this.sharedStats=qi.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}),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.props.onError(e),this._error=e}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){const e=this._needsRedraw;return this._needsRedraw=!1,e}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),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(){return this._running&&(this.animationProps&&!this._error&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0),this}redraw(e){return this.device?.isLost||this._error||(this._beginFrameTimers(e),this._setupFrame(),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=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)}(this._animationFrame.bind(this)))}_cancelAnimationFrame(){null!==this._animationFrameId&&(!function(e){const t="undefined"!=typeof window?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;t?t.call(window,e):clearTimeout(e)}(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e){this._running&&(this.redraw(e),this._requestAnimationFrame())}_renderFrame(e){this.display?this.display._renderFrame(e):(this.props.onRender(this._getAnimationProps()),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,_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 sr=n(19852);function or(){}const ar={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,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:or,onWebGLInitialized:or,onResize:or,onViewStateChange:or,onInteractionStateChange:or,onBeforeRender:or,onAfterRender:or,onLoad:or,onError:e=>Ie.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.widgetManager=null,this.tooltip=null,this.animationLoop=null,this._canvasContext=null,this._deviceResizeHandler=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new lt.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._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=e=>{const{_pickRequest:t}=this;if("pointerleave"===e.type)t.x=-1,t.y=-1,t.radius=0;else{if(e.leftButton||e.rightButton)return;{const n=e.offsetCenter;if(!n)return;t.x=n.x,t.y=n.y,t.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:t.x,y:t.y}),t.event=e},this._onEvent=e=>{const t=Mn.tg[e.type],n=e.offsetCenter;if(!t||!n||!this.layerManager)return;const i=this.layerManager.getLayers(),r=this._getInternalPickingMode();if(!r)return;if("sync"===r){const t="click"===e.type&&this._shouldUnproject3D(i)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(n.x,n.y,{unproject3D:!0},i))):this._getLastPointerDownPickingInfo(n.x,n.y,i);return void this._dispatchPickingEvent(t,e)}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(n.x,n.y,i))).then(t=>{this._dispatchPickingEvent(t,e)}).catch(e=>this.props.onError?.(e))},this._onPointerDown=e=>{const t=e.offsetCenter;if(!t)return;const n=this._getInternalPickingMode();if(!n)return;const i=this.layerManager?.getLayers()||[],r=++this._pointerDownPickSequence;if("sync"===n){const e=this._pickPointSync({x:t.x,y:t.y,radius:this.props.pickingRadius}),n=this._getFirstPickedInfo(e);return this._lastPointerDownInfo=n,void(this._lastPointerDownInfoPromise=Promise.resolve(n))}const s=this._pickPointAsync(this._getPointPickOptions(t.x,t.y,{},i)).then(e=>this._getFirstPickedInfo(e)).then(e=>(r===this._pointerDownPickSequence&&(this._lastPointerDownInfo=e),e)).catch(e=>{this.props.onError?.(e);const n=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(t.x,t.y,i):{};return r===this._pointerDownPickSequence&&(this._lastPointerDownInfo=n),n});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=s};const t=e;this.props={...ar,...e},(e=this.props).viewState&&e.initialViewState&&Ie.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&&Ie.A.error("WebGL1 context not supported.")(),n=ir.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps})),n||(n=this._createDevice(e)),this.animationLoop=this._createAnimationLoop(n,e),this.setProps(t),e._typedArrayManagerProps&&zi.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,this.eventManager?.destroy(),this.eventManager=null,this.widgetManager?.finalize(),this.widgetManager=null,this.props.canvas||this.props.device||this.props.gl||!this.canvas||(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null),this._canvasContext=null}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&Ie.A.removed("onLayerHover","onHover")(),"onLayerClick"in e&&Ie.A.removed("onLayerClick","onClick")(),e.initialViewState&&!(0,dn.b)(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._validateInternalPickingMode(),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()}),e.device&&e.device.id!==this.device?.id){const t=e.device.getDefaultCanvasContext();this.animationLoop?.stop(),this.canvas!==t.canvas&&(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),this._setDeviceCanvasContext(e.device),Ie.A.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()}this.animationLoop?.setProps(t),void 0!==e.useDevicePixels&&this._canvasContext?.setProps&&this._canvasContext.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 Pn(this.viewManager),this.viewManager.views}getView(e){return Pn(this.viewManager),this.viewManager.getView(e)}getViewports(e){return Pn(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}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){return"sync"!==this._getInternalPickingMode()?null:this.pickObject({x:e,y:t,radius:0,unproject3D:!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,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=this.layerManager?.getLayers()||[]){return this.deckPicker.getLastPickedObject({x:e,y:t,layers:n,viewports:this.getViewports({x:e,y:t})},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=Mn.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){Pn(this.deckPicker);const{stats:i}=this;i.get("Pick Count").incrementCount(),i.get(t).timeStart();const r=this.deckPicker[e]({layers:this.layerManager.getLayers(n),views:this.viewManager.getViews(),viewports:this.getViewports(n),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...n,canvasContext:this._canvasContext||void 0});return i.get(t).timeEnd(),r}_pick(e,t,n){Pn(this.deckPicker);const{stats:i}=this;i.get("Pick Count").incrementCount(),i.get(t).timeStart();const r=this.deckPicker[e]({layers:this.layerManager.getLayers(n),views:this.viewManager.getViews(),viewports:this.getViewports(n),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...n,canvasContext:this._canvasContext||void 0});return i.get(t).timeEnd(),r}_createCanvas(e){let t=e.canvas;if("string"==typeof t&&(t=document.getElementById(t),Pn(t)),!t){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)}return Object.assign(t.style,e.style),t}_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=>{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=or),this._deviceResizeHandler=null}_setCanvasSize(e){if(!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}}_updateCanvasSize(e=this._canvasContext){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)}_createAnimationLoop(e,t){const{gl:n,onError:i}=t;return new AnimationLoop({device:e,autoResizeDrawingBuffer:!n,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};i.adapters.includes(ir)||i.adapters.push(ir);const r={alphaMode:"webgpu"===this.props.deviceProps?.type?"premultiplied":void 0};return qi.createDevice({_reuseDevices:!0,type:"webgl",...i,createCanvasContext:{...r,...n,canvas:this._createCanvas(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 ni({id:"default-view"})];return t.length&&this.props.controller&&(t[0].props.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,{radius:e.radius,mode:e.mode},n),r=this._getInternalPickingMode(),s=++this._hoverPickSequence;if(e.event=null,!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.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){if(this.device=e,this._validateInternalPickingMode(),!this.animationLoop)return;this._setDeviceCanvasContext(e,{syncDrawingBuffer:Boolean(this.props.gl&&this.props.device!==e)}),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;t.play(),this.animationLoop.attachTimeline(t);const n=this.props.parent?.querySelector(".deck-events-root")||this.canvas;this.eventManager=new sr.EU(n,{touchAction:this.props.touchAction,recognizers:Object.keys(Mn.We).map(e=>{const[t,n,i,r]=Mn.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 Mn.tg)this.eventManager.on(e,this._onEvent);this.viewManager=new ViewManager({timeline:t,eventManager:this.eventManager,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 i=this.viewManager.getViewports()[0];this.layerManager=new LayerManager(this.device,{deck:this,stats:this.stats,viewport:i,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 r=this.props.parent?.querySelector(".deck-widgets-root")||this.canvas?.parentElement;this.widgetManager=new WidgetManager({deck:this,parentElement:r}),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};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(),Ie.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.updateAttributesCount=t.get("Layers updated").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=qi.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=ar,Deck.VERSION=Fe;const lr=Deck;var cr=n(62738),Ar=n(72246),ur=n(57285);const hr=ur.r.getDataType.bind(ur.r);function dr(e,t,n){if(t.size>4)return null;const i="webgpu"===n&&"uint8"===t.type?"unorm8":t.type;return{attribute:e,format:t.size>1?`${i}x${t.size}`:t.type,byteOffset:t.offset||0}}function fr(e){return e.stride||e.size*e.bytesPerElement}function pr(e,t){t.offset&&Ie.A.removed("shaderAttribute.offset","vertexOffset, elementOffset")();const n=fr(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:o}=t;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0),s=r?"float32":!i&&t.isIndexed?"uint32":i||"float32";let a=function(e){switch(e){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return(0,Ar.Ak)(e)}}(i||s);this.doublePrecision=r,r&&!1===t.fp64&&(a=Float32Array),this.value=null,this.settings={...t,defaultType:a,defaultValue:o,logicalType:i,type:s,normalized:s.includes("norm"),size:this.size,bytesPerElement:a.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*fr(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),zi.A.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,t=null){const n={};if(this.state.constant){const i=this.value;if(t){const r=pr(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.value instanceof Float64Array?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:fr(n)};if(this.doublePrecision){const r=function(e,t){const n=pr(e,t);return{high:n,low:{...n,offset:n.offset+4*e.size}}}(n,t||{});i.push(dr(e,{...n,...r.high},this.device.type),dr(`${e}64Low`,{...n,...r.low},this.device.type))}else if(t){const r=pr(n,t);i.push(dr(e,{...n,...r},this.device.type))}else i.push(dr(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 Ri.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=hr(n.value);i.type=i.normalized?e.replace("int","norm"):e}}i.bytesPerElement=n.value.BYTES_PER_ELEMENT,i.stride=fr(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);let e=n.value;t.externalBuffer=null,t.constant=!1,this.value=e;let{buffer:r}=this;const s=fr(i),o=(i.vertexOffset||0)*s;if(this.doublePrecision&&e instanceof Float64Array&&(e=(0,Jn.cT)(e,i)),this.settings.isIndexed){const t=this.settings.defaultType;e.constructor!==t&&(e=new t(e))}const a=e.byteLength+o+2*s;(!r||r.byteLength<a)&&(r=this._createBuffer(a)),r.write(e,o)}return this.setAccessor(i),!0}updateSubBuffer(e={}){this.state.bounds=null;const t=this.value,{startOffset:n=0,endOffset:i}=e;this.buffer.write(this.doublePrecision&&t instanceof Float64Array?(0,Jn.cT)(t,{size:this.size,startIndex:n,endIndex:i}):t.subarray(n,i),n*t.BYTES_PER_ELEMENT+this.byteOffset)}allocate(e,t=!1){const{state:n}=this,i=n.allocatedValue,r=zi.A.allocate(i,e+1,{size:this.size,type:this.settings.defaultType,copy:t});this.value=r;const{byteOffset:s}=this;let{buffer:o}=this;return(!o||o.byteLength<r.byteLength+s)&&(o=this._createBuffer(r.byteLength+s),t&&i&&o.write(i instanceof Float64Array?(0,Jn.cT)(i,this):i,s)),n.allocatedValue=r,n.constant=!1,n.externalBuffer=null,this.setAccessor(this.settings),!0}_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||Ie.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;return this._buffer=this.device.createBuffer({...this._buffer?.props,id:this.id,usage:(t?Ri.h.INDEX:Ri.h.VERTEX)|Ri.h.COPY_DST,indexType:t?n:void 0,byteLength:e}),this._buffer}}const gr=[],mr=[];function br(e,t=0,n=1/0){let i=gr;const r={index:-1,data:e,target:[]};return e?"function"==typeof e[Symbol.iterator]?i=e:e.length>0&&(mr.length=e.length,i=mr):i=gr,(t>0||Number.isFinite(n))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(t,n),r.index=t-1),{iterable:i,objectInfo:r}}function _r(e){return e&&e[Symbol.asyncIterator]}function vr(e,t){const{size:n,stride:i,offset:r,startIndices:s,nested:o}=t,a=e.BYTES_PER_ELEMENT,l=i?i/a:n,c=r?r/a:0,A=Math.floor((e.length-c)/l);return(t,{index:i,target:r})=>{if(!s){const t=i*l+c;for(let i=0;i<n;i++)r[i]=e[t+i];return r}const a=s[i],u=s[i+1]||A;let h;if(o){h=new Array(u-a);for(let t=a;t<u;t++){const i=t*l+c;r=new Array(n);for(let t=0;t<n;t++)r[t]=e[i+t];h[t-a]=r}}else if(l===n)h=e.subarray(a*n+c,u*n+c);else{h=new e.constructor((u-a)*n);let t=0;for(let i=a;i<u;i++){const r=i*l+c;for(let i=0;i<n;i++)h[t++]=e[r+i]}}return h}}const yr=[],wr=[[0,1/0]];const xr={interpolation:{duration:0,easing:e=>e},spring:{stiffness:.05,damping:.5}};function Tr(e,t){if(!e)return null;Number.isFinite(e)&&(e={type:"interpolation",duration:e});const n=e.type||"interpolation";return{...xr[n],...t,...e,type:n}}class Attribute extends DataColumn{constructor(e,t){super(e,t,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:wr}),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&&fr(n)===fr(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 Tr(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===wr)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=wr}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=yr}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){const{state:t,settings:n}=this;return!n.noAlloc&&(!!n.update&&(super.allocate(e,t.updateRanges!==wr),!0))}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)this.constant?this.setConstantValue(i,this.value):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){if(void 0===t||"function"==typeof t)return!1;const n=this.settings.transform&&e?this.settings.transform.call(e,t):t;if("webgpu"===this.device.type)return this.setConstantBufferValue(n,this.numInstances);return this.setData({constant:!0,value:n})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0}setConstantBufferValue(e,t){const n=this.settings.defaultType,i=this._normalizeValue(e,new n(this.size),0);if(this._hasConstantBufferValue(i,t))return this.constant=!1,this.clearNeedsUpdate(),!1;const r=new n(Math.max(t,1)*this.size);for(let e=0;e<r.length;e+=this.size)r.set(i,e);const s=this.setData({value:r});return this.constant=!1,this.clearNeedsUpdate(),s&&this.setNeedsRedraw(),s}_hasConstantBufferValue(e,t){const n=this.value,i=Math.max(t,1)*this.size;if(!ArrayBuffer.isView(n)||n.length!==i||n.length%this.size!==0)return!1;for(let t=0;t<n.length;t+=this.size)for(let i=0;i<this.size;i++)if(n[t+i]!==e[i])return!1;return!0}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;Pn(ArrayBuffer.isView(r.value),`invalid ${i.accessor}`);const s=Boolean(r.size)&&r.size!==this.size;return n.binaryAccessor=vr(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:l,size:c,startIndices:A}=e,{accessor:u,transform:h}=o,d=a.binaryAccessor||("function"==typeof u?u:r[u]);Pn("function"==typeof d,`accessor "${u}" is not a function`);let f=e.getVertexOffset(n);const{iterable:p,objectInfo:g}=br(t,n,i);for(const t of p){g.index++;let n=d(t,g);if(h&&(n=h.call(this,n)),A){const t=(g.index<A.length-1?A[g.index+1]:s)-A[g.index];if(n&&Array.isArray(n[0])){let t=f;for(const i of n)e._normalizeValue(i,l,t),t+=c}else n&&n.length>c?l.set(n,f):(e._normalizeValue(n,g.target,0),at({target:l,source:g.target,start:f,count:t}));f+=t*c}else e._normalizeValue(n,l,f),f+=c}}_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}`)}}}function Er(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 Sr=n(62814);class BufferTransform{device;model;transformFeedback;static defaultProps={...Sr.K.defaultProps,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 Sr.K(this.device,{id:t.id||"buffer-transform-model",fs:t.fs||Er(),topology:t.topology||"point-list",varyings:t.outputs||t.varyings,...t}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:t.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}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(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 Ri.h)return t.readAsync();const{buffer:n,byteOffset:i=0,byteLength:r=n.byteLength}=t;return n.readAsync(i,r)}}var Cr=n(54071);function Pr(e){const{source:t,target:n,start:i=0,size:r,getData:s}=e,o=e.end||n.length,a=t.length,l=o-i;if(a>l)return void n.set(t.subarray(0,l),i);if(n.set(t,i),!s)return;let c=a;for(;c<l;){const e=s(c,t);for(let t=0;t<r;t++)n[i+c]=e[t]||0,c++}}function Rr(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 Mr(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 Lr(e){e.push(e.shift())}function Ir({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 Or({device:e,buffer:t,attribute:n,fromLength:i,toLength:r,fromStartIndices:s,getData:o=e=>e}){const a=n.doublePrecision&&n.value instanceof Float64Array?2:1,l=n.size*a,c=n.byteOffset,A=n.settings.bytesPerElement<4?c/n.settings.bytesPerElement*4:c,u=n.startIndices,h=s&&u,d=n.isConstant;if(!h&&t&&i>=r)return t;const f=n.value instanceof Float64Array?Float32Array:n.value.constructor,p=d?n.value:new f(n.getBuffer().readSyncWebGL(c,r*f.BYTES_PER_ELEMENT).buffer);if(n.settings.normalized&&!d){const e=o;o=(t,i)=>n.normalizeConstant(e(t,i))}const g=d?(e,t)=>o(p,t):(e,t)=>o(p.subarray(e+c,e+c+l),t),m=t?new Float32Array(t.readSyncWebGL(A,4*i).buffer):new Float32Array(0),b=new Float32Array(r);return function({source:e,target:t,size:n,getData:i,sourceStartIndices:r,targetStartIndices:s}){if(!r||!s)return Pr({source:e,target:t,size:n,getData:i}),t;let o=0,a=0;const l=i&&((e,t)=>i(e+a,t)),c=Math.min(r.length,s.length);for(let i=1;i<c;i++){const c=r[i]*n,A=s[i]*n;Pr({source:e.subarray(o,c),target:t,start:a,end:A,size:n,getData:l}),o=c,a=A}a<t.length&&Pr({source:[],target:t,start:a,size:n,getData:l})}({source:m,target:b,sourceStartIndices:s,targetStartIndices:u,size:l,getData:g}),(!t||t.byteLength<b.byteLength+A)&&(t?.destroy(),t=e.createBuffer({byteLength:b.byteLength+A,usage:35050})),t.write(b,A),t}class GPUTransitionBase{constructor({device:e,attribute:t,timeline:n}){this.buffers=[],this.currentLength=0,this.device=e,this.transition=new Transition(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{doublePrecision:n,settings:i,value:r,size:s}=e,o=n&&r instanceof Float64Array?2:1;let a=0;const{shaderAttributes:l}=e.settings;if(l)for(const e of Object.values(l))a=Math.max(a,e.vertexOffset??0);return(i.noAlloc?r.length:(t+a)*s)*o}(this.attribute,t),this.transition.start({...e,duration:n})}update(){const e=this.transition.update();return e&&this.onUpdate(),e}setBuffer(e){this.attributeInTransition.setData({buffer:e,normalized:this.attribute.settings.normalized,value:this.attributeInTransition.value})}cancel(){this.transition.cancel()}delete(){this.cancel();for(const e of this.buffers)e.destroy();this.buffers.length=0}}const Br={name:"interpolation",vs:"layout(std140) uniform interpolationUniforms {\n float time;\n} interpolation;\n",uniformTypes:{time:"f32"}},Nr="#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",kr="#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 Fr(e){return e.doublePrecision&&e.value instanceof Float64Array}const Dr={name:"spring",vs:"layout(std140) uniform springUniforms {\n float damping;\n float stiffness;\n} spring;\n",uniformTypes:{damping:"f32",stiffness:"f32"}},Ur="#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",Vr="#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 zr={interpolation:class GPUInterpolationTransition extends GPUTransitionBase{constructor({device:e,attribute:t,timeline:n}){super({device:e,attribute:t,timeline:n}),this.type="interpolation",this.transform=function(e,t){const n=t.size,i=Rr(n),r=Mr(n),s=t.getBufferLayout();if(Fr(t))return new BufferTransform(e,{vs:kr,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:[Cr.d,Br],defines:{ATTRIBUTE_TYPE:i,ATTRIBUTE_SIZE:n},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0});return new BufferTransform(e,{vs:Nr,bufferLayout:[{name:"aFrom",format:r},{name:"aTo",format:s.attributes[0].format}],modules:[Br],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;Lr(r),r[0]=Or({device:this.device,buffer:r[0],attribute:s,fromLength:n,toLength:this.currentLength,fromStartIndices:i,getData:e.enter}),r[1]=Ir({device:this.device,source:r[0],target:r[1]}),this.setBuffer(r[1]);const{transform:o}=this,a=o.model;let l=Math.floor(this.currentLength/s.size);Fr(s)&&(l/=2),a.setVertexCount(l),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})}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=Rr(t.size),i=Mr(t.size);return new BufferTransform(e,{vs:Ur,fs:Vr,bufferLayout:[{name:"aPrev",format:i},{name:"aCur",format:i},{name:"aTo",format:t.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[Dr],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]=Or({device:this.device,buffer:r[t],attribute:s,fromLength:n,toLength:this.currentLength,fromStartIndices:i,getData:e.enter});r[2]=Ir({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]}),Lr(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=zr[n.type];s?this.transitions[e]=new s({attribute:t,timeline:this.timeline,device:this.device}):(Ie.A.error(`unsupported transition type '${n.type}'`)(),r=!1)}(r||t.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(n,this.numInstances))}}const Gr="attributeManager.invalidate";class AttributeManager{constructor(e,{id:t="attribute-manager",stats:n,timeline:i}={}){this.mergeBoundsMemoized=(0,di.A)(Jn._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}),Object.seal(this)}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);Ne(Gr,this,e,n)}invalidateAll(e){for(const t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);Ne(Gr,this,"all")}update({data:e,numInstances:t,startIndices:n=null,transitions:i,props:r={},buffers:s={},context:o={}}){let a=!1;Ne("attributeManager.updateStart",this),this.stats&&this.stats.get("Update Attributes").timeStart();for(const i in this.attributes){const l=this.attributes[i],c=l.settings.accessor;l.startIndices=n,l.numInstances=t,r[i]&&Ie.A.removed(`props.${i}`,`data.attributes.${i}`)(),l.setExternalBuffer(s[i])||l.setBinaryValue("string"==typeof c?s[c]:void 0,e.startIndices)||"string"==typeof c&&!s[c]&&l.setConstantValue(o,r[c])||l.needsUpdate()&&(a=!0,this._updateAttribute({attribute:l,numInstances:t,data:e,props:r,context:o})),this.needsRedraw=this.needsRedraw||l.needsRedraw()}a&&Ne("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 Object.values(this.getAttributes()).map(t=>t.getBufferLayout(e))}_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(Ne("attribute.updateStart",t),t.constant)return void t.setConstantValue(e.context,t.value);t.allocate(n)&&Ne("attribute.allocate",t,n);t.updateBuffer(e)&&(this.needsRedraw=!0,Ne("attribute.updateEnd",t,n))}}const jr=1e-5;function Hr(e,t,n,i,r){const s=t-e;return(n-t)*r+-s*i+s+t}function Wr(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)}const qr={interpolation:class CPUInterpolationTransition extends Transition{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,xn.Cc)(t,n,s)}},spring:class CPUSpringTransition extends Transition{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]=Hr(e[o],t[o],n[o],i,r);return s}return Hr(e,t,n,i,r)}(r,s,t,n,i);const a=Wr(o,t),l=Wr(o,s);a<jr&&l<jr&&(o=t,this.end()),this._prevValue=s,this._currValue=o}}};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=Tr(i)))return;const s=qr[i.type];if(!s)return void Ie.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)}}function Kr(e,t){const n=Xr({newProps:e,oldProps:t,propTypes:e[et],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(Yr(e,t,"all"))return{all:!0}}const n={};let i=!1;for(const r in e.updateTriggers)if("all"!==r){Yr(e,t,r)&&(n[r]=!0,i=!0)}return!!i&&n}(e,t)),{dataChanged:i,propsChanged:n,updateTriggersChanged:r,extensionsChanged:Zr(e,t),transitionsChanged:Qr(e,t)}}function Qr(e,t){if(!e.transitions)return!1;const n={},i=e[et];let r=!1;for(const s in e.transitions){const o=i[s],a=o&&o.type;("number"===a||"color"===a||"array"===a)&&$r(e[s],t[s],o)&&(n[s]=!0,r=!0)}return!!r&&n}function Xr({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=$r(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=$r(e[s],t[s],i[s]);if(n)return`${r}.${s} ${n}`}}return!1}function $r(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 Zr(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 Yr(e,t,n){let i=e.updateTriggers[n];i=i??{};let r=t.updateTriggers[n];r=r??{};return Xr({oldProps:r,newProps:i,triggerName:n})}function Jr(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 es=n(66540);const ts=[0,0,0];function ns(e,t,n=!1){const i=t.projectPosition(e);if(n&&t instanceof wn.A){const[n,r,s=0]=e,o=t.getDistanceScales([n,r]);i[2]=s*o.unitsPerMeter[2]}return i}function is(e,{viewport:t,modelMatrix:n,coordinateSystem:i,coordinateOrigin:r,offsetMode:s}){let[o,a,l=0]=e;switch(n&&([o,a,l]=On.Z0([],[o,a,l,1],n)),i){case"default":return is(e,{viewport:t,modelMatrix:n,coordinateSystem:t.isGeospatial?"lnglat":"cartesian",coordinateOrigin:r,offsetMode:s});case"lnglat":return ns([o,a,l],t,s);case"lnglat-offsets":return ns([o+r[0],a+r[1],l+(r[2]||0)],t,s);case"meter-offsets":return ns((0,Ln.dT)(r,[o,a,l]),t,s);case"cartesian":return t.isGeospatial?[o+r[0],a+r[1],l+r[2]]:t.projectPosition([o,a,l]);default:throw new Error(`Invalid coordinateSystem: ${i}`)}}function rs(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:l=!0}=t,{geospatialOrigin:c=ts,shaderCoordinateOrigin:A=ts,offsetMode:u=!1}=l?(0,fi.ow)(n,i,r):{},h=is(e,{viewport:n,modelMatrix:s,coordinateSystem:o,coordinateOrigin:a,offsetMode:u});if(u){const e=n.projectPosition(c||A);In.jb(h,h,e)}return h}const ss={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},os={};const as={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||As(e)&&(3===e.length||4===e.length),equal:(e,t,n)=>(0,dn.b)(e,t,1)},accessor:{validate(e,t){const n=us(e);return"function"===n||n===us(t.value)},equal:(e,t,n)=>"function"==typeof t||(0,dn.b)(e,t,1)},array:{validate:(e,t)=>t.optional&&!e||As(e),equal(e,t,n){const{compare:i}=n,r=Number.isInteger(i)?i:i?1:0;return i?(0,dn.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,dn.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 Pi.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:{...ss,...r,...i},mipLevels:t.getMipLevelCount(s,o)});return"webgl"===t.type?a.generateMipmapsWebGL():"webgpu"===t.type&&t.generateMipmapsWebGPU(a),os[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 Pi.g&&os[r.id]===i&&(r.delete(),delete os[r.id])}}};function ls(e,t){switch(us(t)){case"object":return cs(e,t);case"array":return cs(e,{type:"array",value:t,compare:!1});case"boolean":return cs(e,{type:"boolean",value:t});case"number":return cs(e,{type:"number",value:t});case"function":return cs(e,{type:"function",value:t,compare:!0});default:return{name:e,type:"unknown",value:t}}}function cs(e,t){return"type"in t?{name:e,...as[t.type],...t}:"value"in t?{name:e,type:us(t.value),...t}:{name:e,type:"object",value:t}}function As(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function us(e){return As(e)?"array":null===e?"null":typeof e}function hs(e,t){if(!(e instanceof ms.constructor))return{};let n="_mergedDefaultProps";if(t)for(const e of t){const t=e.constructor;t&&(n+=`:${t.extensionName||t.name}`)}const i=ps(e,n);return i||(e[n]=function(e,t){const n=e.prototype;if(!n)return null;const i=Object.getPrototypeOf(e),r=hs(i),s=ps(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=ls(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),l=Object.assign(Object.create(null),r?.[et],o.propTypes),c=Object.assign(Object.create(null),r?.[tt],o.deprecatedProps);for(const e of t){const t=hs(e.constructor);t&&(Object.assign(a,t),Object.assign(l,t[et]),Object.assign(c,t[tt]))}(function(e,t){const n=function(e){const t=e.componentName;t||Ie.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]=ds(s))}e[nt]=n,e[it]={},Object.defineProperties(e,i)}(a,l),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])fs(this,i)||(this[i]=e);Ie.A.deprecated(i,t[n].join("/"))()}})}(a,c),a[et]=l,a[tt]=c,0!==t.length||fs(e,"_propTypes")||(e._propTypes=l);return a}(e,t||[]))}function ds(e){return{enumerable:!0,set(t){"string"==typeof t||t instanceof Promise||_r(t)?this[it][e]=t:this[rt][e]=t},get(){if(this[rt]){if(e in this[rt]){return this[rt][e]||this[nt][e]}if(e in this[it]){const t=this[Je]&&this[Je].internalState;if(t&&t.hasAsyncProp(e))return t.getAsyncProp(e)||this[nt][e]}}return this[nt][e]}}}function fs(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ps(e,t){return fs(e,t)&&e[t]}let gs=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=hs(e.constructor,n),r=Object.create(i);r[Je]=e,r[it]={},r[rt]={};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=gs++}clone(e){const{props:t}=this,n={};for(const e in t[nt])e in t[rt]?n[e]=t[rt][e]:e in t[it]&&(n[e]=t[it][e]);return new this.constructor({...t,...n,...e})}}Component.componentName="Component",Component.defaultProps={};const ms=Component,bs=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||bs}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[Je]||this.component;const t=e[rt]||{},n=e[it]||e,i=e[nt]||{};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):_r(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[et];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}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}`)}}const _s=2**24-1,vs=Object.freeze([]),ys=(0,di.A)(({oldViewport:e,viewport:t})=>e.equals(t));let ws=new Uint8ClampedArray(0);const xs={data:{type:"data",value:vs,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:un(e,i),persistent:!1}),a=!0),a?o.subscribe({resourceId:e,onChange:e=>n.internalState?.reloadAsyncProp(t,e),consumerId:n.id,requestId:t}):un(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 ms{constructor(){super(...arguments),this.internalState=null,this.lifecycle=Ke,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){Pn(this.internalState);const t=this.internalState.viewport||this.context.viewport,n=is(e,{viewport:t,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[i,r,s]=(0,Ln.VJ)(n,t.pixelProjectionMatrix);return 2===e.length?[i,r]:[i,r,s]}unproject(e){Pn(this.internalState);return(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,t){Pn(this.internalState);return rs(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){Pn(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:Jr(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,es.n)(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(const t of this.props.extensions)e=(0,es.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{pickingColors:e,instancePickingColors:n}=t.attributes,i=e||n;i&&(r&&i.constant&&(i.constant=!1,t.invalidate(i.id)),i.value||r||(i.constant=!0,i.value=[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&&ys({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(ws.length/4);this.internalState.usesPickingColorCache=!0;const i=t>0&&0===ws[0];if(n<t||i){t>_s&&Ie.A.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),ws=zi.A.allocate(ws,t,{size:4,copy:!0,maxCount:Math.max(t,_s)});const e=Math.floor(ws.length/4),r=[0,0,0];for(let t=i?0:n;t<e;t++)this.encodePickingColor(t,r),ws[4*t+0]=r[0],ws[4*t+1]=r[1],ws[4*t+2]=r[2],ws[4*t+3]=0}e.value=ws.subarray(0,4*t)}_setModelAttributes(e,t,n=!1){if(!Object.keys(t).length)return;if(n){const n=this.getAttributeManager();e.setBufferLayout(n.getBufferLayouts(e)),t=n.getAttributes()}const i=e.userData?.excludeAttributes||{},r={},s={};for(const n in t){if(i[n])continue;const o=t[n].getValue();for(const i in o){const a=o[i];a instanceof Ri.h?t[n].settings.isIndexed?e.setIndexBuffer(a):r[i]=a:a&&(s[i]=a)}}e.setAttributes(r),e.setConstantAttributes(s)}disablePickingIndex(e){const t=this.props.data;if(!("attributes"in t))return void this._disablePickingIndex(e);const{pickingColors:n,instancePickingColors:i}=this.getAttributeManager().attributes,r=n||i,s=r&&t.attributes&&t.attributes[r.id];if(s&&s.value){const n=s.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{pickingColors:t,instancePickingColors:n}=this.getAttributeManager().attributes,i=t||n;if(!i)return;const r=i.getVertexOffset(e),s=i.getVertexOffset(e+1);i.buffer.write(new Uint8Array(s-r),r)}restorePickingColors(){const{pickingColors:e,instancePickingColors:t}=this.getAttributeManager().attributes,n=e||t;n&&(this.internalState.usesPickingColorCache&&n.value.buffer!==ws.buffer&&(n.value=ws.subarray(0,n.value.length)),n.updateSubBuffer({startOffset:0}))}_initialize(){Pn(!this.internalState),Ne("layer.initialize",this);const e=this._getAttributeManager();e&&e.addInstanced({instancePickingColors:{type:"uint8",size:4,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new LayerState({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(Ie.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){Ne("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(Ne("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(){Ne("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,s=this.context;this.props=this.internalState.propsInTransition||r;try{t&&this.setShaderModuleProps(t);const{getPolygonOffset:r}=this.props,o=r&&r(n)||[0,0];s.device instanceof cr.WebGLDevice&&s.device.setParametersWebGL({polygonOffset:o});const a=s.device instanceof cr.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?(Es(r,t),r.setParameters({...r.parameters,...i?.pipelineParameters})):r.setParameters(n)}(this.getModels(),e,i,a),s.device instanceof cr.WebGLDevice)s.device.withParametersWebGL(i,()=>{const r={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:i,context:s};for(const e of this.props.extensions)e.draw.call(this,r,e);this.draw(r)});else{a?.renderPassParameters&&e.setParameters(a.renderPassParameters);const r={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:i,context:s};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&&Ne("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=Kr(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[et];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=xs,Layer.layerName="Layer";const Ts=Layer;function Es(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"))}class CompositeLayer extends Ts{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:o,autoHighlight:a,highlightColor:l,coordinateSystem:c,coordinateOrigin:A,wrapLongitude:u,positionFormat:h,modelMatrix:d,extensions:f,fetch:p,operation:g,_subLayerProps:m}=this.props,b={id:"",updateTriggers:{},opacity:t,pickable:n,visible:i,parameters:r,getPolygonOffset:s,highlightedObjectIndex:o,autoHighlight:a,highlightColor:l,coordinateSystem:c,coordinateOrigin:A,wrapLongitude:u,positionFormat:h,modelMatrix:d,extensions:f,fetch:p,operation:g},_=m&&e.id&&m[e.id],v=_&&_.updateTriggers,y=e.id||"sublayer";if(_){const t=this.props[et],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}-${y}`,b.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...v};for(const e of f){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){n=st(this.renderLayers(),Boolean),this.internalState.subLayers=n}Ne("compositeLayer.renderLayers",this,i,n);for(const e of n)e.parent=this}}CompositeLayer.layerName="CompositeLayer";const Ss=CompositeLayer,Cs=1e-6;class SphericalCoordinates{constructor({phi:e=0,theta:t=0,radius:n=1,bearing:i,pitch:r,altitude:s,radiusScale:o=6371e3}={}){this.phi=e,this.theta=t,this.radius=n||s||1,this.radiusScale=o||1,void 0!==i&&(this.bearing=i),void 0!==r&&(this.pitch=r),this.check()}toString(){return this.formatString(xn.$W)}formatString({printTypes:e=!1}){const t=xn.Fl;return`${e?"Spherical":""}[rho:${t(this.radius)},theta:${t(this.theta)},phi:${t(this.phi)}]`}equals(e){return(0,xn.aI)(this.radius,e.radius)&&(0,xn.aI)(this.theta,e.theta)&&(0,xn.aI)(this.phi,e.phi)}exactEquals(e){return this.radius===e.radius&&this.theta===e.theta&&this.phi===e.phi}get bearing(){return 180-(0,xn.uj)(this.phi)}set bearing(e){this.phi=Math.PI-(0,xn.F2)(e)}get pitch(){return(0,xn.uj)(this.theta)}set pitch(e){this.theta=(0,xn.F2)(e)}get longitude(){return(0,xn.uj)(this.phi)}get latitude(){return(0,xn.uj)(this.theta)}get lng(){return(0,xn.uj)(this.phi)}get lat(){return(0,xn.uj)(this.theta)}get z(){return(this.radius-1)*this.radiusScale}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this.check()}clone(){return(new SphericalCoordinates).copy(this)}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this.check()}fromLngLatZ([e,t,n]){return this.radius=1+n/this.radiusScale,this.phi=(0,xn.F2)(t),this.theta=(0,xn.F2)(e),this.check()}fromVector3(e){return this.radius=In.Bw(e),this.radius>0&&(this.theta=Math.atan2(e[0],e[1]),this.phi=Math.acos((0,xn.qE)(e[2]/this.radius,-1,1))),this.check()}toVector3(){return new oi.P(0,0,this.radius).rotateX({radians:this.theta}).rotateZ({radians:this.phi})}makeSafe(){return this.phi=Math.max(Cs,Math.min(Math.PI-Cs,this.phi)),this}check(){if(!(Number.isFinite(this.phi)&&Number.isFinite(this.theta)&&this.radius>0))throw new Error("SphericalCoordinates: some fields set to invalid numbers");return this}}class FirstPersonViewport extends hn.A{constructor(e){const{longitude:t,latitude:n,modelMatrix:i,bearing:r=0,pitch:s=0,up:o=[0,0,1]}=e,a=new SphericalCoordinates({bearing:r,pitch:-90===s?1e-4:90+s}).toVector3().normalize(),l=i?new Rn.k(i).transformAsVector(a):a,c=Number.isFinite(n)?(0,Ln.fO)({latitude:n}):0,A=Math.pow(2,c),u=(new Rn.k).lookAt({eye:[0,0,0],center:l,up:o}).scale(A);super({...e,zoom:c,viewMatrix:u}),this.latitude=n,this.longitude=t,this.pitch=s,this.bearing=r,this.up=o}}FirstPersonViewport.displayName="FirstPersonViewport";const Ps=FirstPersonViewport,Rs=20;class FirstPersonState extends ViewState{constructor(e){const{width:t,height:n,position:i=[0,0,0],bearing:r=0,pitch:s=0,longitude:o=null,latitude:a=null,maxPitch:l=90,minPitch:c=-90,maxBounds:A=null,startRotatePos:u,startBearing:h,startPitch:d,startZoomPosition:f,startPanPos:p,startPanPosition:g}=e;super({width:t,height:n,position:i,bearing:r,pitch:s,longitude:o,latitude:a,maxPitch:l,minPitch:c,maxBounds:A},{startRotatePos:u,startBearing:h,startPitch:d,startZoomPosition:f,startPanPos:p,startPanPosition:g},e.makeViewport)}panStart({pos:e}){const{position:t}=this.getViewportProps();return this._getUpdatedState({startPanPos:e,startPanPosition:t})}pan({pos:e}){if(!e)return this;const{startPanPos:t=[0,0],startPanPosition:n=[0,0]}=this.getState(),{width:i,height:r,bearing:s,pitch:o}=this.getViewportProps(),a=500*(e[0]-t[0])/i,l=500*(e[1]-t[1])/r,c=new SphericalCoordinates({bearing:s,pitch:o}),A=new SphericalCoordinates({bearing:s,pitch:-90}),u=c.toVector3().normalize(),h=A.toVector3().cross(u).normalize();return this._getUpdatedState({position:new oi.P(n).add(h.scale(a)).add(u.scale(l))})}panEnd(){return this._getUpdatedState({startPanPos:null,startPanPosition:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:n=0}){const{startRotatePos:i,startBearing:r,startPitch:s}=this.getState(),{width:o,height:a}=this.getViewportProps();if(!i||void 0===r||void 0===s)return this;let l;if(e){l={bearing:r-180*((e[0]-i[0])/o),pitch:s-90*((e[1]-i[1])/a)}}else l={bearing:r-t,pitch:s-n};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startBearing:null,startPitch:null})}zoomStart(){return this._getUpdatedState({startZoomPosition:this.getViewportProps().position})}zoom({pos:e,scale:t}){const n=this.getViewportProps(),i=this.getState().startZoomPosition||n.position,r=this.makeViewport(n),{projectionMatrix:s,width:o}=r,a=2*Math.atan(1/s[0])*(e[0]/o-.5),l=this.getDirection(!0);return this._move(l.rotateZ({radians:-a}),Math.log2(t)*Rs,i)}zoomEnd(){return this._getUpdatedState({startZoomPosition:null})}moveLeft(e=20){const t=this.getDirection(!0);return this._move(t.rotateZ({radians:Math.PI/2}),e)}moveRight(e=20){const t=this.getDirection(!0);return this._move(t.rotateZ({radians:-Math.PI/2}),e)}moveUp(e=20){const t=this.getDirection(!0);return this._move(t,e)}moveDown(e=20){const t=this.getDirection(!0);return this._move(t.negate(),e)}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})}zoomIn(e=20){return this._move(new oi.P(0,0,1),e)}zoomOut(e=20){return this._move(new oi.P(0,0,-1),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),null!==r&&null!==t.longitude&&Math.abs(r-t.longitude)>180&&(n.longitude=r<0?r+360:r-360),n}_move(e,t,n=this.getViewportProps().position){const i=e.scale(t);return this._getUpdatedState({position:new oi.P(n).add(i)})}getDirection(e=!1){return new SphericalCoordinates({bearing:this.getViewportProps().bearing,pitch:e?90:90+this.getViewportProps().pitch}).toVector3().normalize()}_getUpdatedState(e){return new FirstPersonState({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){const{pitch:t,maxPitch:n,minPitch:i,longitude:r,position:s,bearing:o,maxBounds:a}=e;if(e.pitch=(0,xn.qE)(t,i,n),null!==r&&(r<-180||r>180)&&(e.longitude=(0,Jn.zi)(r+180,360)-180),(o<-180||o>180)&&(e.bearing=(0,Jn.zi)(o+180,360)-180),a){const t=(0,xn.qE)(s[0],a[0][0],a[1][0]),n=(0,xn.qE)(s[1],a[0][1],a[1][1]),i=(0,xn.qE)(s[2]??0,a[0][2]??0,a[1][2]??0);t===s[0]&&n===s[1]&&i===s[2]||(e.position=[t,n,i])}return e}}class FirstPersonController extends Controller{constructor(){super(...arguments),this.ControllerState=FirstPersonState,this.transition={transitionDuration:300,transitionInterpolator:new LinearInterpolator(["position","pitch","bearing"])}}}class FirstPersonView extends View{constructor(e={}){super(e)}getViewportType(){return Ps}get ControllerType(){return FirstPersonController}}FirstPersonView.displayName="FirstPersonView";const Ms=FirstPersonView,Ls=Math.PI/180;function Is({height:e,focalDistance:t,orbitAxis:n,rotationX:i,rotationOrbit:r,zoom:s}){const o="Z"===n?[0,0,1]:[0,1,0],a="Z"===n?[0,-t,0]:[0,0,t],l=(new Rn.k).lookAt({eye:a,up:o});l.rotateX(i*Ls),"Z"===n?l.rotateZ(r*Ls):l.rotateY(r*Ls);const c=Math.pow(2,s)/e;return l.scale(c),l}class OrbitViewport extends hn.A{constructor(e){const{height:t,projectionMatrix:n,fovy:i=50,orbitAxis:r="Z",target:s=[0,0,0],rotationX:o=0,rotationOrbit:a=0,zoom:l=0}=e,c=n?n[5]/2:(0,Ln.wZ)(i);super({...e,longitude:void 0,viewMatrix:Is({height:t||1,focalDistance:c,orbitAxis:r,rotationX:o,rotationOrbit:a,zoom:l}),fovy:i,focalDistance:c,position:s,zoom:l}),this.target=s,this.orbitAxis=r,this.rotationX=o,this.rotationOrbit=a,this.fovy=i,this.projectedCenter=this.project(this.center)}unproject(e,{topLeft:t=!0}={}){const[n,i,r=this.projectedCenter[2]]=e,s=t?i:this.height-i,[o,a,l]=(0,Ln.xJ)([n,s,r],this.pixelUnprojectionMatrix);return[o,a,l]}panByPosition(e,t,n){const i=this.project(e),{near:r,far:s}=(0,Jn.om)(this.projectionMatrix),o=r*s/(s-i[2]*(s-r))/(r*s/(s-this.projectedCenter[2]*(s-r))),a=[this.width/2+(i[0]-t[0])*o,this.height/2+(i[1]-t[1])*o,this.projectedCenter[2]];return{target:this.unproject(a)}}}OrbitViewport.displayName="OrbitViewport";const Os=OrbitViewport;class OrbitState extends ViewState{constructor(e){const{width:t,height:n,rotationX:i=0,rotationOrbit:r=0,target:s=[0,0,0],zoom:o=0,minRotationX:a=-90,maxRotationX:l=90,minZoom:c=-1/0,maxZoom:A=1/0,maxBounds:u=null,startPanPosition:h,startRotatePos:d,startRotationX:f,startRotationOrbit:p,startZoomPosition:g,startZoom:m}=e;super({width:t,height:n,rotationX:i,rotationOrbit:r,target:s,zoom:o,minRotationX:a,maxRotationX:l,minZoom:c,maxZoom:A,maxBounds:u},{startPanPosition:h,startRotatePos:d,startRotationX:f,startRotationOrbit:p,startZoomPosition:g,startZoom:m},e.makeViewport),this.unproject3D=e.unproject3D}panStart({pos:e}){return this._getUpdatedState({startPanPosition:this._unproject(e)})}pan({pos:e,startPosition:t}){const n=this.getState().startPanPosition||t;if(!n)return this;const i=this.makeViewport(this.getViewportProps()).panByPosition(n,e);return this._getUpdatedState(i)}panEnd(){return this._getUpdatedState({startPanPosition:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startRotationX:this.getViewportProps().rotationX,startRotationOrbit:this.getViewportProps().rotationOrbit})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:n=0}){const{startRotatePos:i,startRotationX:r,startRotationOrbit:s}=this.getState(),{width:o,height:a}=this.getViewportProps();if(!i||void 0===r||void 0===s)return this;let l;if(e){let t=(e[0]-i[0])/o;(r<-90||r>90)&&(t*=-1),l={rotationX:r+180*((e[1]-i[1])/a),rotationOrbit:s+180*t}}else l={rotationX:r+n,rotationOrbit:s+t};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotationX:null,startRotationOrbit:null})}shortestPathFrom(e){const t=e.getViewportProps(),n={...this.getViewportProps()},{rotationOrbit:i}=n;return Math.abs(i-t.rotationOrbit)>180&&(n.rotationOrbit=i<0?i+360:i-360),n}zoomStart({pos:e}){return this._getUpdatedState({startZoomPosition:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:t,scale:n}){let{startZoom:i,startZoomPosition:r}=this.getState();if(r||(i=this.getViewportProps().zoom,r=this._unproject(t||e)),!r)return this;const s=this._calculateNewZoom({scale:n,startZoom:i}),o=this.makeViewport({...this.getViewportProps(),zoom:s});return this._getUpdatedState({zoom:s,...o.panByPosition(r,e)})}zoomEnd(){return this._getUpdatedState({startZoomPosition:null,startZoom:null})}zoomIn(e=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:e})})}zoomOut(e=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:1/e})})}moveLeft(e=50){return this._panFromCenter([-e,0])}moveRight(e=50){return this._panFromCenter([e,0])}moveUp(e=50){return this._panFromCenter([0,-e])}moveDown(e=50){return this._panFromCenter([0,e])}rotateLeft(e=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit-e})}rotateRight(e=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit+e})}rotateUp(e=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX-e})}rotateDown(e=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX+e})}_project(e){return this.makeViewport(this.getViewportProps()).project(e)}_unproject(e){const t=this.unproject3D?.(e);if(t)return t;return this.makeViewport(this.getViewportProps()).unproject(e)}_calculateNewZoom({scale:e,startZoom:t}){void 0===t&&(t=this.getViewportProps().zoom);const n=t+Math.log2(e);return this._constrainZoom(n)}_panFromCenter(e){const{target:t}=this.getViewportProps(),n=this._project(t);return this.pan({startPosition:t,pos:[n[0]+e[0],n[1]+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){const{maxRotationX:t,minRotationX:n,rotationOrbit:i}=e;return e.zoom=this._constrainZoom(e.zoom,e),e.rotationX=(0,xn.qE)(e.rotationX,n,t),(i<-180||i>180)&&(e.rotationOrbit=(0,Jn.zi)(i+180,360)-180),e.target=this._constrainTarget(e),e}_constrainZoom(e,t){t||(t=this.getViewportProps());const{maxZoom:n,maxBounds:i}=t;let{minZoom:r}=t;if(i&&t.width>0&&t.height>0){const e=i[1][0]-i[0][0],s=i[1][1]-i[0][1],o=(i[1][2]??0)-(i[0][2]??0),a=Math.sqrt(e*e+s*s+o*o);a>0&&(r=Math.max(r,Math.log2(Math.min(t.width,t.height)/a)),r>n&&(r=n))}return(0,xn.qE)(e,r,n)}_constrainTarget(e){const{target:t,maxBounds:n}=e;if(!n)return t;const[[i,r,s=0],[o,a,l=0]]=n;if(t[0]>=i&&t[0]<=o&&t[1]>=r&&t[1]<=a&&t[2]>=s&&t[2]<=l)return t;const c=this.makeViewport?.(e);if(c){const{cameraPosition:e}=c,n=e[0]-t[0],A=e[1]-t[1],u=e[2]-t[2],h=n*t[0]+A*t[1]+u*t[2];if((n||A||u)&&h>=n*(n>=0?i:o)+A*(A>=0?r:a)+u*(u>=0?s:l)&&h<=n*(n>=0?o:i)+A*(A>=0?a:r)+u*(u>=0?l:s)){const e=e=>(0,xn.qE)(e,i,o),c=e=>(0,xn.qE)(e,r,a),d=e=>(0,xn.qE)(e,s,l),f=i=>n*e(t[0]-i*n)+A*c(t[1]-i*A)+u*d(t[2]-i*u)-h;let p=-1,g=1,m=f(p),b=f(g);for(;m<0;)g=p,b=m,p*=2,m=f(p);for(;b>0;)p=g,m=b,g*=2,b=f(g);for(let e=0;e<30;e++){const e=(p+g)/2;f(e)>0?p=e:g=e}const _=(p+g)/2;return[e(t[0]-_*n),c(t[1]-_*A),d(t[2]-_*u)]}}return[(0,xn.qE)(t[0],i,o),(0,xn.qE)(t[1],r,a),(0,xn.qE)(t[2],s,l)]}}class OrbitController extends Controller{constructor(){super(...arguments),this.ControllerState=OrbitState,this.transition={transitionDuration:300,transitionInterpolator:new LinearInterpolator({transitionProps:{compare:["target","zoom","rotationX","rotationOrbit"],required:["target","zoom"]}})},this._unproject3D=e=>{if(this.pickPosition){const{x:t,y:n}=this.props,i=this.pickPosition(t+e[0],n+e[1]);if(i&&i.coordinate)return i.coordinate}return null}}setProps(e){e.unproject3D=this._unproject3D,super.setProps(e)}}class OrbitView extends View{constructor(e={}){super(e),this.props.orbitAxis=e.orbitAxis||"Z"}getViewportType(){return Os}get ControllerType(){return OrbitController}}OrbitView.displayName="OrbitView";const Bs=OrbitView;var Ns=n(95896);function ks({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)}}class OrthographicState extends ViewState{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:l=o,maxZoomX:c=a,minZoomY:A=o,maxZoomY:u=a,maxBounds:h=null,startPanPosition:d,startZoomPosition:f,startZoom:p}=e,{zoomX:g,zoomY:m}=ks(e);super({width:t,height:n,target:i,zoom:r,zoomX:g,zoomY:m,zoomAxis:s,minZoomX:l,maxZoomX:c,minZoomY:A,maxZoomY:u,maxBounds:h},{startPanPosition:d,startZoomPosition:f,startZoom:p},e.makeViewport)}panStart({pos:e}){return this._getUpdatedState({startPanPosition:this._unproject(e)})}pan({pos:e,startPosition:t}){const n=this.getState().startPanPosition||t;if(!n)return this;const i=this.makeViewport(this.getViewportProps()).panByPosition(n,e);return this._getUpdatedState(i)}panEnd(){return this._getUpdatedState({startPanPosition:null})}rotateStart(){return this}rotate(){return this}rotateEnd(){return this}shortestPathFrom(e){e.getViewportProps();return{...this.getViewportProps()}}zoomStart({pos:e}){const{zoomX:t,zoomY:n}=this.getViewportProps();return this._getUpdatedState({startZoomPosition:this._unproject(e),startZoom:[t,n]})}zoom({pos:e,startPos:t,scale:n}){let{startZoom:i,startZoomPosition:r}=this.getState();if(!r){const{zoomX:n,zoomY:s}=this.getViewportProps();i=[n,s],r=this._unproject(t||e)}if(!r)return this;const s=this._constrainZoom(this._calculateNewZoom({scale:n,startZoom:i})),o=this.makeViewport({...this.getViewportProps(),...s});return this._getUpdatedState({...s,...o.panByPosition(r,e)})}zoomEnd(){return this._getUpdatedState({startZoomPosition:null,startZoom:null})}zoomIn(e=2){return this._getUpdatedState(this._calculateNewZoom({scale:e}))}zoomOut(e=2){return this._getUpdatedState(this._calculateNewZoom({scale:1/e}))}moveLeft(e=50){return this._panFromCenter([-e,0])}moveRight(e=50){return this._panFromCenter([e,0])}moveUp(e=50){return this._panFromCenter([0,-e])}moveDown(e=50){return this._panFromCenter([0,e])}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){return this.makeViewport(this.getViewportProps()).unproject(e)}_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){const{target:t}=this.getViewportProps(),n=this._project(t);return this.pan({startPosition:t,pos:[n[0]+e[0],n[1]+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){const{zoomX:t,zoomY:n}=this._constrainZoom(e,e);e.zoomX=t,e.zoomY=n,e.zoom=Array.isArray(e.zoom)||e.zoomX!==e.zoomY?[e.zoomX,e.zoomY]:e.zoomX;const{maxBounds:i,target:r}=e;if(i){const s=e.width/2/2**t,o=e.height/2/2**n,a=i[0][0]+s,l=i[1][0]-s,c=i[0][1]+o,A=i[1][1]-o,u=(0,xn.qE)(r[0],a,l),h=(0,xn.qE)(r[1],c,A);u===r[0]&&h===r[1]||(e.target=r.slice(),e.target[0]=u,e.target[1]=h)}return e}_constrainZoom({zoomX:e,zoomY:t},n){n||(n=this.getViewportProps());const{zoomAxis:i,maxZoomX:r,maxZoomY:s,maxBounds:o}=n;let{minZoomX:a,minZoomY:l}=n;if(null!==o&&n.width>0&&n.height>0){const e=o[0],t=o[1],i=t[0]-e[0],c=t[1]-e[1];Number.isFinite(i)&&i>0&&(a=Math.max(a,Math.log2(n.width/i)),a>r&&(a=r)),Number.isFinite(c)&&c>0&&(l=Math.max(l,Math.log2(n.height/c)),l>s&&(l=s))}switch(i){case"X":e=(0,xn.qE)(e,a,r);break;case"Y":t=(0,xn.qE)(t,l,s);break;default:let n=Math.min(r-e,s-t,0);0===n&&(n=Math.max(a-e,l-t,0)),0!==n&&(e+=n,t+=n)}return{zoomX:e,zoomY:t}}}class OrthographicController extends Controller{constructor(){super(...arguments),this.ControllerState=OrthographicState,this.transition={transitionDuration:300,transitionInterpolator:new LinearInterpolator(["target","zoomX","zoomY"])},this.dragMode="pan"}setProps(e){Object.assign(e,ks(e)),super.setProps(e)}_onPanRotate(){return!1}}class OrthographicView extends View{constructor(e={}){super(e)}getViewportType(){return Ns.A}get ControllerType(){return OrthographicController}}OrthographicView.displayName="OrthographicView";const Fs=OrthographicView,Ds=Math.PI/180,Us=180/Math.PI;function Vs(e,t=0){const n=Math.min(180,e)*Ds;return 512*Math.sin(n/2)*Math.pow(2,t)}function zs(e,t=0){const n=e/Math.pow(2,t);return 2*Math.asin(Math.min(1,n/256/2))*Us}class GlobeState extends MapState{constructor(e){const{startPanPos:t,...n}=e;n.normalize=!1,super(n),void 0!==t&&(this._state.startPanPos=t)}panStart({pos:e}){const{latitude:t,longitude:n,zoom:i}=this.getViewportProps();return this._getUpdatedState({startPanLngLat:[n,t],startPanPos:e,startZoom:i})}pan({pos:e,startPos:t}){const n=this.getState(),i=n.startPanLngLat||this._unproject(t);if(!i)return this;const r=n.startZoom??this.getViewportProps().zoom,s=n.startPanPos||t,o=[i[0],i[1],r],a=this.makeViewport(this.getViewportProps()).panByPosition(o,e,s);return this._getUpdatedState(a)}panEnd(){return this._getUpdatedState({startPanLngLat:null,startPanPos:null,startZoom:null})}zoom({scale:e}){const t=(this.getState().startZoom||this.getViewportProps().zoom)+Math.log2(e);return this._getUpdatedState({zoom:t})}applyConstraints(e){const{longitude:t,latitude:n,maxBounds:i}=e;if(e.zoom=this._constrainZoom(e.zoom,e),(t<-180||t>180)&&(e.longitude=(0,Jn.zi)(t+180,360)-180),e.latitude=(0,xn.qE)(n,-Ln.aH,Ln.aH),i&&(e.longitude=(0,xn.qE)(e.longitude,i[0][0],i[1][0]),e.latitude=(0,xn.qE)(e.latitude,i[0][1],i[1][1])),i){const t=e.zoom-Vn(n),r=i[1][0]-i[0][0],s=i[1][1]-i[0][1];if(s>0&&s<2*Ln.aH){const n=Math.min(zs(e.height,t),s)/2;e.latitude=(0,xn.qE)(e.latitude,i[0][1]+n,i[1][1]-n)}if(r>0&&r<360){const n=Math.min(zs(e.width/Math.cos(e.latitude*Ds),t),r)/2;e.longitude=(0,xn.qE)(e.longitude,i[0][0]+n,i[1][0]-n)}}return e.latitude!==n&&(e.zoom+=Vn(e.latitude)-Vn(n)),e}_constrainZoom(e,t){t||(t=this.getViewportProps());const{latitude:n,maxZoom:i,maxBounds:r}=t;let{minZoom:s}=t;const o=Vn(0),a=Vn(n)-o;if(null!==r&&t.width>0&&t.height>0){const e=r[0][1],n=r[1][1],a=Math.sign(e)===Math.sign(n)?Math.min(Math.abs(e),Math.abs(n)):0,l=Vs(r[1][0]-r[0][0])*Math.cos(a*Ds),c=Vs(r[1][1]-r[0][1]);l>0&&(s=Math.max(s,Math.log2(t.width/l)+o)),c>0&&(s=Math.max(s,Math.log2(t.height/c)+o)),s>i&&(s=i)}return(0,xn.qE)(e,s+a,i+a)}}class GlobeController extends Controller{constructor(){super(...arguments),this.ControllerState=GlobeState,this.transition={transitionDuration:300,transitionInterpolator:new LinearInterpolator(["longitude","latitude","zoom"])},this.dragMode="pan"}setProps(e){super.setProps(e),this.dragRotate=!1,this.touchRotate=!1}}const Gs={cullMode:"back"};class GlobeView extends View{constructor(e={}){super({...e,parameters:{...Gs,...e.parameters}})}getViewportType(e){return e.zoom>12?wn.A:Un}get ControllerType(){return GlobeController}}GlobeView.displayName="GlobeView";const js=GlobeView;class TerrainController extends MapController{constructor(){super(...arguments),this._terrainAltitude=void 0,this._terrainAltitudeTarget=void 0,this._pickFrameId=null,this._lastPickTime=0}setProps(e){if(super.setProps({rotationPivot:"3d",...e}),null===this._pickFrameId){const e=()=>{const t=Date.now();if(t-this._lastPickTime>500&&!this.isDragging()&&(this._lastPickTime=t,this._pickTerrainCenterAltitude(),void 0===this._terrainAltitude&&void 0!==this._terrainAltitudeTarget)){this._terrainAltitude=this._terrainAltitudeTarget;const e=new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),t=this._rebaseViewport(this._terrainAltitudeTarget,e);if(t){const e=new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state,...t});super.updateViewport(e)}}this._pickFrameId=requestAnimationFrame(e)};this._pickFrameId=requestAnimationFrame(e)}}finalize(){null!==this._pickFrameId&&(cancelAnimationFrame(this._pickFrameId),this._pickFrameId=null),super.finalize()}updateViewport(e,t=null,n={}){if(void 0===this._terrainAltitude)return void super.updateViewport(e,t,n);this._terrainAltitude+=.05*(this._terrainAltitudeTarget-this._terrainAltitude);const i=e.getViewportProps().position||[0,0,0];t={...t,position:[i[0],i[1],this._terrainAltitude]},super.updateViewport(e,t,n)}_pickTerrainCenterAltitude(){if(!this.pickPosition)return;const{x:e,y:t,width:n,height:i}=this.props,r=this.pickPosition(e+n/2,t+i/2);r?.coordinate&&r.coordinate.length>=3&&(this._terrainAltitudeTarget=r.coordinate[2])}_rebaseViewport(e,t){const n=t.getViewportProps(),i=this.makeViewport({...n,position:[0,0,0]}),r=i.cameraPosition,s=e*i.distanceScales.unitsPerMeter[2],o=r[2],a=o-s;if(a<=0)return null;const l=Math.log2(o/a),c=n.zoom+l,A=this.makeViewport({...n,zoom:c,position:[0,0,e]}),{width:u,height:h}=n,d=[u/2,h/2],f=i.unproject(d,{targetZ:e});if(f&&"panByPosition3D"in A&&"function"==typeof A.panByPosition3D){return{position:[0,0,e],zoom:c,...A.panByPosition3D(f,d)}}return null}}const Hs={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=>({})};function Ws(e,t=!0){return e??t}function qs(e=[0,0,0],t=!0){return t?e.map(e=>e/255):[...e]}const Ks={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={},i=Ws(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=function(e,t=!0){const n=qs(e.slice(0,3),t),i=Number.isFinite(e[3]),r=i?e[3]:1;return[n[0],n[1],n[2],t&&i?r/255:r]}(e.highlightColor,i));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}};const Qs={...Ks,source:"struct pickingUniforms {\n isActive: f32,\n isAttribute: f32,\n isHighlightActive: f32,\n useByteColors: f32,\n highlightedObjectColor: vec3<f32>,\n highlightColor: 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",defaultUniforms:{...Ks.defaultUniforms,useByteColors:!0},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 "}}},Xs={name:"project32",dependencies:[hi.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"},$s="layout(std140) uniform floatColorsUniforms {\n float useByteColors;\n} floatColors;\n\nvec3 floatColors_normalize(vec3 inputColor) {\n return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor;\n}\n\nvec4 floatColors_normalize(vec4 inputColor) {\n return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor;\n}\n\nvec4 floatColors_premultiplyAlpha(vec4 inputColor) {\n return vec4(inputColor.rgb * inputColor.a, inputColor.a);\n}\n\nvec4 floatColors_unpremultiplyAlpha(vec4 inputColor) {\n return inputColor.a > 0.0 ? vec4(inputColor.rgb / inputColor.a, inputColor.a) : vec4(0.0);\n}\n\nvec4 floatColors_premultiply_alpha(vec4 inputColor) {\n return floatColors_premultiplyAlpha(inputColor);\n}\n\nvec4 floatColors_unpremultiply_alpha(vec4 inputColor) {\n return floatColors_unpremultiplyAlpha(inputColor);\n}\n",Zs={name:"floatColors",props:{},uniforms:{},vs:$s,fs:$s,source:"struct floatColorsUniforms {\n useByteColors: f32\n};\n\n@group(0) @binding(auto) var<uniform> floatColors : floatColorsUniforms;\n\nfn floatColors_normalize(inputColor: vec3<f32>) -> vec3<f32> {\n return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5);\n}\n\nfn floatColors_normalize4(inputColor: vec4<f32>) -> vec4<f32> {\n return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5);\n}\n\nfn floatColors_premultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> {\n return vec4<f32>(inputColor.rgb * inputColor.a, inputColor.a);\n}\n\nfn floatColors_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 floatColors_premultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {\n return floatColors_premultiplyAlpha(inputColor);\n}\n\nfn floatColors_unpremultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {\n return floatColors_unpremultiplyAlpha(inputColor);\n}\n",uniformTypes:{useByteColors:"f32"},defaultUniforms:{useByteColors:!0}},Ys="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",Js={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:io(),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:Ys,fs:Ys,getUniforms:function(e,t={}){if(!(e=e?{...e}:e))return io();e.lights&&(e={...e,...to(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{...io(),enabled:0};const a={...io(),...eo({useByteColors:n,ambientLight:i,pointLights:r,spotLights:s,directionalLights:o})};void 0!==e.enabled&&(a.enabled=e.enabled?1:0);return a}};function eo({useByteColors:e,ambientLight:t,pointLights:n=[],spotLights:i=[],directionalLights:r=[]}){const s=ro();let o=0,a=0,l=0,c=0;for(const t of n){if(o>=5)break;s[o]={...s[o],color:no(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:no(t,e),position:t.position,direction:t.direction,attenuation:t.attenuation||[1,0,0],coneCos:so(t)},o++,l++}for(const t of r){if(o>=5)break;s[o]={...s[o],color:no(t,e),direction:t.direction},o++,c++}return n.length+i.length+r.length>5&&Hi.R.warn("MAX_LIGHTS exceeded, truncating to 5")(),{ambientColor:no(t,e),directionalLightCount:c,pointLightCount:a,spotLightCount:l,lights:s}}function to(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 no(e={},t){const{color:n=[0,0,0],intensity:i=1}=e;return qs(n,Ws(t,!0)).map(e=>e*i)}function io(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:ro()}}function ro(){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 so(e){const t=e.innerConeAngle??0,n=e.outerConeAngle??Math.PI/4;return[Math.cos(t),Math.cos(n)]}const oo="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",ao="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",lo="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",co={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:ao.replace("phongMaterial","gouraudMaterial"),fs:oo.replace("phongMaterial","gouraudMaterial"),source:lo.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[Js,Zs],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=>({...co.defaultUniforms,...e})},Ao={name:"phongMaterial",firstBindingSlot:0,bindingLayout:[{name:"phongMaterial",group:3}],dependencies:[Js,Zs],source:lo,vs:oo,fs:ao,defines:{LIGHTING_FRAGMENT:!0},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=>({...Ao.defaultUniforms,...e})},uo={bearing:0,pitch:0,position:[0,0,0]},ho={speed:1.2,curve:1.414};class FlyToInterpolator extends TransitionInterpolator{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={...ho,...e}}interpolateProps(e,t,n){const i=(0,Ln.rj)(e,t,n,this.opts);for(const r in uo)i[r]=(0,xn.Cc)(e[r]||uo[r],t[r]||uo[r],n);return i}getDuration(e,t){let{transitionDuration:n}=t;return"auto"===n&&(n=(0,Ln.v7)(e,t,this.opts)),n}}var fo=n(16094),po=n(4500);class Geometry{id;topology;vertexCount;indices;attributes;userData={};constructor(e){const{attributes:t={},indices:n=null,vertexCount:i=null}=e;this.id=e.id||(0,po.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 this.attributes[e]=t}this.indices&&void 0!==this.indices.isIndexed&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=i||this._calculateVertexCount(this.attributes,this.indices)}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)){const{value:e,size:i,constant:r}=t;!r&&e&&void 0!==i&&i>=1&&(n=Math.min(n,e.length/i))}return n}}const go=[-1,-1,1,-1,-1,1,1,1];class ClipSpace extends Sr.K{constructor(e,t){const n=go.map(e=>-1===e?0:e);t.source&&(t={...t,source:`struct VertexInputs {\n @location(0) clipSpacePositions: vec2<f32>,\n @location(1) texCoords: vec2<f32>,\n @location(2) coordinates: vec2<f32>\n}\n\nstruct FragmentInputs {\n @builtin(position) Position : vec4<f32>,\n @location(0) position : vec2<f32>,\n @location(1) coordinate : vec2<f32>,\n @location(2) uv : vec2<f32>\n};\n\n@vertex\nfn vertexMain(inputs: VertexInputs) -> FragmentInputs {\n var outputs: FragmentInputs;\n outputs.Position = vec4(inputs.clipSpacePositions, 0., 1.);\n outputs.position = inputs.clipSpacePositions;\n outputs.coordinate = inputs.coordinates;\n outputs.uv = inputs.texCoords;\n return outputs;\n}\n\n${t.source}`}),super(e,{id:t.id||(0,po.L)("clip-space"),...t,vs:"#version 300 es\nin vec2 clipSpacePositions;\nin vec2 texCoords;\nin vec2 coordinates;\n\nout vec2 position;\nout vec2 coordinate;\nout vec2 uv;\n\nvoid main(void) {\n gl_Position = vec4(clipSpacePositions, 0., 1.);\n position = clipSpacePositions;\n coordinate = coordinates;\n uv = texCoords;\n}\n",vertexCount:4,geometry:new Geometry({topology:"triangle-strip",vertexCount:4,attributes:{clipSpacePositions:{size:2,value:new Float32Array(go)},texCoords:{size:2,value:new Float32Array(n)},coordinates:{size:2,value:new Float32Array(n)}}})})}}var mo=n(8036);const bo={name:"screen",fs:"layout(std140) uniform screenUniforms {\n vec2 texSize;\n} screen;\n",uniformTypes:{texSize:"vec2<f32>"}};class ScreenPass extends mo.A{constructor(e,t){super(e,t);const{module:n,fs:i,id:r}=t;this.model=new ClipSpace(e,{id:r,fs:i,modules:[n,bo],parameters:{depthWriteEnabled:!1,depthCompare:"always",depthBias:0,blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one-minus-src-alpha",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",blendColorOperation:"add",blendAlphaOperation:"add"}})}render(e){this._renderPass(this.device,e)}delete(){this.model.destroy(),this.model=null}_renderPass(e,t){const{clearCanvas:n,inputBuffer:i,outputBuffer:r}=t,s=[i.width,i.height],o={texSrc:i.colorAttachments[0],texSize:s};this.model.shaderInputs.setProps({screen:o,...t.moduleProps});const a=this.device.beginRenderPass({framebuffer:r,parameters:{viewport:[0,0,...s]},clearColor:!!n&&[0,0,0,0],clearDepth:1,clearStencil:!1});this.model.draw(a),a.end()}}class PostProcessEffect{constructor(e,t){this.id=`${e.name}-pass`,this.props=t,(0,fo.UK)(e),this.module=e}setup({device:e}){this.passes=function(e,t,n){return t.passes.map((i,r)=>{const s=function(e,t){if(t.filter){return(e=>`${_o}\nvoid main() {\n fragColor = texture(texSrc, coordinate);\n fragColor = ${e}(fragColor, screen.texSize, coordinate);\n}\n`)("string"==typeof t.filter?t.filter:`${e.name}_filterColor_ext`)}if(t.sampler){return(e=>`${_o}\nvoid main() {\n fragColor = ${e}(texSrc, screen.texSize, coordinate);\n}\n`)("string"==typeof t.sampler?t.sampler:`${e.name}_sampleColor`)}return""}(t,i);return new ScreenPass(e,{id:`${n}-${r}`,module:t,fs:s})})}(e,this.module,this.id)}setProps(e){this.props=e}preRender(){}postRender(e){const t=this.passes,{target:n}=e;let i=e.inputBuffer,r=e.swapBuffer;for(let s=0;s<t.length;s++){const o=s===t.length-1,a=void 0!==n&&o;a&&(r=n);const l=!a||Boolean(e.clearCanvas),c={},A=this.module.passes[s].uniforms;c[this.module.name]={...this.props,...A},t[s].render({clearCanvas:l,inputBuffer:i,outputBuffer:r,moduleProps:c});const u=r;r=i,i=u}return i}cleanup(){if(this.passes){for(const e of this.passes)e.delete();this.passes=void 0}}}const _o="#version 300 es\nuniform sampler2D texSrc;\n\nin vec2 position;\nin vec2 coordinate;\nin vec2 uv;\n\nout vec4 fragColor;\n";const vo=[255,255,255],yo=1,wo=[1,0,0],xo=[0,0,1];let To=0;class PointLight{constructor(e={}){this.type="point";const{color:t=vo}=e,{intensity:n=yo}=e,{position:i=xo}=e;this.id=e.id||"point-"+To++,this.color=t,this.intensity=n,this.type="point",this.position=i,this.attenuation=function(e){if(e.attenuation)return e.attenuation;return wo}(e),this.projectedLight={...this}}getProjectedLight({layer:e}){const{projectedLight:t}=this,n=e.context.viewport,{coordinateSystem:i,coordinateOrigin:r}=e.props,s=rs(this.position,{viewport:n,coordinateSystem:i,coordinateOrigin:r,fromCoordinateSystem:n.isGeospatial?Mn.rf.LNGLAT:Mn.rf.CARTESIAN,fromCoordinateOrigin:[0,0,0]});return t.color=this.color,t.intensity=this.intensity,t.position=s,t}}class Tesselator{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;const{attributes:t={}}=e;this.typedArrayManager=zi.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:s,dataChanged:o,normalize:a=!0}=this.opts;if(this.data=t,this.getGeometry=i,this.positionSize=r&&r.size||("XY"===s?2:3),this.buffers=n,this.normalize=a,r&&(Pn(t.startIndices),this.getGeometry=this.getGeometryFromBuffer(r),a||(n.vertexPositions=r)),this.geometryBuffer=n.vertexPositions,Array.isArray(o))for(const e of o)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)?vr(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:i,getGeometry:r}=this,{iterable:s,objectInfo:o}=br(i,t,n);for(const t of s){o.index++;e(r?r(t,o):null,o.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:t,vertexStarts:n,instanceCount:i}=this;const{data:r,geometryBuffer:s}=this,{startRow:o=0,endRow:a=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)},o,a),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 Ri.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 c={};this._forEachGeometry((e,r)=>{const s=l[r]||e;c.vertexStart=n[r],c.indexStart=t[r];const o=r<n.length-1?n[r+1]:i;c.geometrySize=o-n[r],c.geometryIndex=r,this.updateGeometryAttributes(s,c)},o,a),this.vertexCount=t[t.length-1]}}var Eo=n(18742);const So="layout(std140) uniform arcUniforms {\n bool greatCircle;\n bool useShortestPath;\n float numSegments;\n float widthScale;\n float widthMinPixels;\n float widthMaxPixels;\n highp int widthUnits;\n} arc;\n",Co={name:"arc",vs:So,fs:So,uniformTypes:{greatCircle:"f32",useShortestPath:"f32",numSegments:"f32",widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",widthUnits:"i32"}},Po=[0,0,0,255],Ro={getSourcePosition:{type:"accessor",value:e=>e.sourcePosition},getTargetPosition:{type:"accessor",value:e=>e.targetPosition},getSourceColor:{type:"accessor",value:Po},getTargetColor:{type:"accessor",value:Po},getWidth:{type:"accessor",value:1},getHeight:{type:"accessor",value:1},getTilt:{type:"accessor",value:0},greatCircle:!1,numSegments:{type:"number",value:50,min:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}};class ArcLayer extends Ts{getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME arc-layer-vertex-shader\nin vec4 instanceSourceColors;\nin vec4 instanceTargetColors;\nin vec3 instanceSourcePositions;\nin vec3 instanceSourcePositions64Low;\nin vec3 instanceTargetPositions;\nin vec3 instanceTargetPositions64Low;\nin vec3 instancePickingColors;\nin float instanceWidths;\nin float instanceHeights;\nin float instanceTilts;\nout vec4 vColor;\nout vec2 uv;\nout float isValid;\nfloat paraboloid(float distance, float sourceZ, float targetZ, float ratio) {\nfloat deltaZ = targetZ - sourceZ;\nfloat dh = distance * instanceHeights;\nif (dh == 0.0) {\nreturn sourceZ + deltaZ * ratio;\n}\nfloat unitZ = deltaZ / dh;\nfloat p2 = unitZ * unitZ + 1.0;\nfloat dir = step(deltaZ, 0.0);\nfloat z0 = mix(sourceZ, targetZ, dir);\nfloat r = mix(ratio, 1.0 - ratio, dir);\nreturn sqrt(r * (p2 - r)) * dh + z0;\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) {\nvec2 dir_screenspace = normalize(line_clipspace * project.viewportSize);\ndir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\nreturn dir_screenspace * offset_direction * width / 2.0;\n}\nfloat getSegmentRatio(float index) {\nreturn smoothstep(0.0, 1.0, index / (arc.numSegments - 1.0));\n}\nvec3 interpolateFlat(vec3 source, vec3 target, float segmentRatio) {\nfloat distance = length(source.xy - target.xy);\nfloat z = paraboloid(distance, source.z, target.z, segmentRatio);\nfloat tiltAngle = radians(instanceTilts);\nvec2 tiltDirection = normalize(target.xy - source.xy);\nvec2 tilt = vec2(-tiltDirection.y, tiltDirection.x) * z * sin(tiltAngle);\nreturn vec3(\nmix(source.xy, target.xy, segmentRatio) + tilt,\nz * cos(tiltAngle)\n);\n}\nfloat getAngularDist (vec2 source, vec2 target) {\nvec2 sourceRadians = radians(source);\nvec2 targetRadians = radians(target);\nvec2 sin_half_delta = sin((sourceRadians - targetRadians) / 2.0);\nvec2 shd_sq = sin_half_delta * sin_half_delta;\nfloat a = shd_sq.y + cos(sourceRadians.y) * cos(targetRadians.y) * shd_sq.x;\nreturn 2.0 * asin(sqrt(a));\n}\nvec3 interpolateGreatCircle(vec3 source, vec3 target, vec3 source3D, vec3 target3D, float angularDist, float t) {\nvec2 lngLat;\nif(abs(angularDist - PI) < 0.001) {\nlngLat = (1.0 - t) * source.xy + t * target.xy;\n} else {\nfloat a = sin((1.0 - t) * angularDist);\nfloat b = sin(t * angularDist);\nvec3 p = source3D.yxz * a + target3D.yxz * b;\nlngLat = degrees(vec2(atan(p.y, -p.x), atan(p.z, length(p.xy))));\n}\nfloat z = paraboloid(angularDist * EARTH_RADIUS, source.z, target.z, t);\nreturn vec3(lngLat, z);\n}\nvoid main(void) {\ngeometry.worldPosition = instanceSourcePositions;\ngeometry.worldPositionAlt = instanceTargetPositions;\nfloat segmentIndex = float(gl_VertexID / 2);\nfloat segmentSide = mod(float(gl_VertexID), 2.) == 0. ? -1. : 1.;\nfloat segmentRatio = getSegmentRatio(segmentIndex);\nfloat prevSegmentRatio = getSegmentRatio(max(0.0, segmentIndex - 1.0));\nfloat nextSegmentRatio = getSegmentRatio(min(arc.numSegments - 1.0, segmentIndex + 1.0));\nfloat indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\nisValid = 1.0;\nuv = vec2(segmentRatio, segmentSide);\ngeometry.uv = uv;\ngeometry.pickingColor = instancePickingColors;\nvec4 curr;\nvec4 next;\nvec3 source;\nvec3 target;\nif ((arc.greatCircle || project.projectionMode == PROJECTION_MODE_GLOBE) && project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nsource = project_globe_(vec3(instanceSourcePositions.xy, 0.0));\ntarget = project_globe_(vec3(instanceTargetPositions.xy, 0.0));\nfloat angularDist = getAngularDist(instanceSourcePositions.xy, instanceTargetPositions.xy);\nvec3 prevPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, prevSegmentRatio);\nvec3 currPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, segmentRatio);\nvec3 nextPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, nextSegmentRatio);\nif (abs(currPos.x - prevPos.x) > 180.0) {\nindexDir = -1.0;\nisValid = 0.0;\n} else if (abs(currPos.x - nextPos.x) > 180.0) {\nindexDir = 1.0;\nisValid = 0.0;\n}\nnextPos = indexDir < 0.0 ? prevPos : nextPos;\nnextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio;\nif (isValid == 0.0) {\nnextPos.x += nextPos.x > 0.0 ? -360.0 : 360.0;\nfloat t = ((currPos.x > 0.0 ? 180.0 : -180.0) - currPos.x) / (nextPos.x - currPos.x);\ncurrPos = mix(currPos, nextPos, t);\nsegmentRatio = mix(segmentRatio, nextSegmentRatio, t);\n}\nvec3 currPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, segmentRatio);\nvec3 nextPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, nextSegmentRatio);\ncurr = project_position_to_clipspace(currPos, currPos64Low, vec3(0.0), geometry.position);\nnext = project_position_to_clipspace(nextPos, nextPos64Low, vec3(0.0));\n} else {\nvec3 source_world = instanceSourcePositions;\nvec3 target_world = instanceTargetPositions;\nif (arc.useShortestPath) {\nsource_world.x = mod(source_world.x + 180., 360.0) - 180.;\ntarget_world.x = mod(target_world.x + 180., 360.0) - 180.;\nfloat deltaLng = target_world.x - source_world.x;\nif (deltaLng > 180.) target_world.x -= 360.;\nif (deltaLng < -180.) source_world.x -= 360.;\n}\nsource = project_position(source_world, instanceSourcePositions64Low);\ntarget = project_position(target_world, instanceTargetPositions64Low);\nfloat antiMeridianX = 0.0;\nif (arc.useShortestPath) {\nif (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {\nantiMeridianX = -(project.coordinateOrigin.x + 180.) / 360. * TILE_SIZE;\n}\nfloat thresholdRatio = (antiMeridianX - source.x) / (target.x - source.x);\nif (prevSegmentRatio <= thresholdRatio && nextSegmentRatio > thresholdRatio) {\nisValid = 0.0;\nindexDir = sign(segmentRatio - thresholdRatio);\nsegmentRatio = thresholdRatio;\n}\n}\nnextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio;\nvec3 currPos = interpolateFlat(source, target, segmentRatio);\nvec3 nextPos = interpolateFlat(source, target, nextSegmentRatio);\nif (arc.useShortestPath) {\nif (nextPos.x < antiMeridianX) {\ncurrPos.x += TILE_SIZE;\nnextPos.x += TILE_SIZE;\n}\n}\ncurr = project_common_position_to_clipspace(vec4(currPos, 1.0));\nnext = project_common_position_to_clipspace(vec4(nextPos, 1.0));\ngeometry.position = vec4(currPos, 1.0);\n}\nfloat widthPixels = clamp(\nproject_size_to_pixel(instanceWidths * arc.widthScale, arc.widthUnits),\narc.widthMinPixels, arc.widthMaxPixels\n);\nvec3 offset = vec3(\ngetExtrusionOffset((next.xy - curr.xy) * indexDir, segmentSide, widthPixels),\n0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\nDECKGL_FILTER_GL_POSITION(curr, geometry);\ngl_Position = curr + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0);\nvec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio);\nvColor = vec4(color.rgb, color.a * layer.opacity);\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME arc-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nin vec2 uv;\nin float isValid;\nout vec4 fragColor;\nvoid main(void) {\nif (isValid == 0.0) {\ndiscard;\n}\nfragColor = vColor;\ngeometry.uv = uv;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[Xs,Qs,Co]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceSourceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getSourceColor",defaultValue:Po},instanceTargetColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getTargetColor",defaultValue:Po},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1},instanceHeights:{size:1,transition:!0,accessor:"getHeight",defaultValue:1},instanceTilts:{size:1,transition:!0,accessor:"getTilt",defaultValue:0}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{widthUnits:t,widthScale:n,widthMinPixels:i,widthMaxPixels:r,greatCircle:s,wrapLongitude:o,numSegments:a}=this.props,l={numSegments:a,widthUnits:Mn.p5[t],widthScale:n,widthMinPixels:i,widthMaxPixels:r,greatCircle:s,useShortestPath:o},c=this.state.model;c.shaderInputs.setProps({arc:l}),c.setVertexCount(2*a),c.draw(this.context.renderPass)}_getModel(){return new Sr.K(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-strip",isInstanced:!0})}}ArcLayer.layerName="ArcLayer",ArcLayer.defaultProps=Ro;const Mo=ArcLayer,Lo=new Uint32Array([0,2,1,0,3,2]),Io=new Float32Array([0,1,0,0,1,0,1,1]);function Oo(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:Lo,texCoords:Io}}(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),l=new Float32Array(r*s*2),c=new Float64Array(r*s*3);let A=0,u=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=Bo(e,n,r);c[3*A+0]=o[0],c[3*A+1]=o[1],c[3*A+2]=o[2]||0,l[2*A+0]=n,l[2*A+1]=1-r,t>0&&i>0&&(a[u++]=A-s,a[u++]=A-s-1,a[u++]=A-1,a[u++]=A-s,a[u++]=A-1,a[u++]=A),A++}}return{vertexCount:o,positions:c,indices:a,texCoords:l}}function Bo(e,t,n){return(0,xn.Cc)((0,xn.Cc)(e[0],e[1],n),(0,xn.Cc)(e[3],e[2],n),t)}const No="layout(std140) uniform bitmapUniforms {\n vec4 bounds;\n float coordinateConversion;\n float desaturate;\n vec3 tintColor;\n vec4 transparentColor;\n} bitmap;\n",ko={name:"bitmap",vs:No,fs:No,uniformTypes:{bounds:"vec4<f32>",coordinateConversion:"f32",desaturate:"f32",tintColor:"vec3<f32>",transparentColor:"vec4<f32>"}};class BitmapLayer extends Ts{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",modules:[Xs,Qs,ko]})}initializeState(){const e=this.getAttributeManager();e.remove(["instancePickingColors"]);const t=!0;e.add({indices:{size:1,isIndexed:!0,update:e=>e.value=this.state.mesh.indices,noAlloc:t},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:e=>e.value=this.state.mesh.positions,noAlloc:t},texCoords:{size:2,update:e=>e.value=this.state.mesh.texCoords,noAlloc:t}})}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 Do(e)&&(t=[[e[0],e[1]],[e[0],e[3]],[e[2],e[3]],[e[2],e[1]]]),Oo(t,this.context.viewport.resolution)}_getModel(){return new Sr.K(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),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:l,tintColor:c}=this.props;if((!t.picking.isActive||!s)&&o&&n){const e={bitmapTexture:o,bounds:r,coordinateConversion:i,desaturate:a,tintColor:c.slice(0,3).map(e=>e/255),transparentColor:l.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(!Do(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,Ln.Gw)([t[0],t[1]]),n=(0,Ln.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 Fo=BitmapLayer;function Do(e){return Number.isFinite(e[0])}const Uo="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",Vo={name:"icon",vs:Uo,fs:Uo,uniformTypes:{sizeScale:"f32",iconsTextureDim:"vec2<f32>",sizeBasis:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",billboard:"f32",sizeUnits:"i32",alphaCutoff:"f32"}},zo=()=>{},Go={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},jo={x:0,y:0,width:0,height:0};function Ho(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 Wo(e){return e&&(e.id||e.url)}function qo(e){const{device:t}=e;"webgl"===t.type?e.generateMipmapsWebGL():"webgpu"===t.type&&t.generateMipmapsWebGPU(e)}function Ko(e,t,n){for(let i=0;i<t.length;i++){const{icon:r,xOffset:s}=t[i];e[Wo(r)]={...r,x:s,y:n}}}class IconManager{constructor(e,{onUpdate:t=zo,onError:n=zo}){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?Wo(e):e;return this._mapping[t]||jo}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}=br(e);for(const e of r){s.index++;const r=t(e,s),o=Wo(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 l=0;l<e.length;l++){const c=e[l];if(!n[Wo(c)]){const{height:e,width:l}=c;i+l+t>o&&(Ko(n,a,r),i=0,r=s+r+t,s=0,a=[]),a.push({icon:c,xOffset:i}),i=i+l+t,s=Math.max(s,e)}}return a.length>0&&Ko(n,a,r),{mapping:n,rowHeight:s,xOffset:i,yOffset:r,canvasWidth:o,canvasHeight:(l=s+r+t,Math.pow(2,Math.ceil(Math.log2(l))))};var l}({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||Go,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)}),l=o.createCommandEncoder();l.copyTextureToTexture({sourceTexture:e,destinationTexture:a,width:r,height:s});const c=l.finish();return o.submit(c),qo(a),e.destroy(),a}(this._texture,this._canvasWidth,this._canvasHeight,this._samplerParameters||Go)),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++,un(n.url,this._loadOptions).then(e=>{const i=Wo(n),r=this._mapping[i],{x:s,y:o,width:a,height:l}=r,{image:c,width:A,height:u}=Ho(t,e,a,l),h=s+(a-A)/2,d=o+(l-u)/2;this._texture?.copyExternalImage({image:c,x:h,y:d,width:A,height:u}),r.x=h,r.y=d,r.width=A,r.height=u,this._texture&&qo(this._texture),this.onUpdate(A!==a||u!==l)}).catch(e=>{this.onError({url:n.url,source:n.source,sourceIndex:n.sourceIndex,loadOptions:this._loadOptions,error:e})}).finally(()=>{this._pendingCount--})}}const Qo=[0,0,0,255],Xo={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:Qo},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 Ts{getShaders(){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;\nin vec3 instancePickingColors;\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;\ngeometry.pickingColor = instancePickingColors;\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:'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 @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) instancePickingColors: vec3<f32>,\n @location(7) instanceIconFrames: vec4<f32>,\n @location(8) instanceColorModes: f32,\n @location(9) instanceOffsets: vec2<f32>,\n @location(10) instancePixelOffset: vec2<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 // write geometry fields used by filters + FS\n geometry.worldPosition = inp.instancePositions;\n geometry.uv = inp.positions;\n geometry.pickingColor = inp.instancePickingColors;\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 = inp.instancePickingColors;\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',modules:[Xs,Hs,Qs,Vo]})}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,accessor:"getSize",defaultValue:1},instanceIconDefs:{size:7,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,accessor:"getColor",defaultValue:Qo},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(e){super.updateState(e);const{props:t,oldProps:n,changeFlags:i}=e,r=this.getAttributeManager(),{iconAtlas:s,iconMapping:o,data:a,getIcon:l,textureParameters:c}=t,{iconManager:A}=this.state;if("string"==typeof s)return;const u=s||this.internalState.isAsyncPropLoading("iconAtlas");A.setProps({loadOptions:t.loadOptions,autoPacking:!u,iconAtlas:s,iconMapping:u?o:null,textureParameters:c}),u?n.iconMapping!==t.iconMapping&&r.invalidate("getIcon"):(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getIcon))&&A.packIcons(a,l),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}){const{sizeScale:t,sizeBasis:n,sizeMinPixels:i,sizeMaxPixels:r,sizeUnits:s,billboard:o,alphaCutoff:a}=this.props,{iconManager:l}=this.state,c=l.getTexture();if(c){const e=this.state.model,l={iconsTexture:c,iconsTextureDim:[c.width,c.height],sizeUnits:Mn.p5[s],sizeScale:t,sizeBasis:"height"===n?1:0,sizeMinPixels:i,sizeMaxPixels:r,billboard:o,alphaCutoff:a};e.shaderInputs.setProps({icon:l}),e.draw(this.context.renderPass)}}_getModel(){return new Sr.K(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Geometry({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):Ie.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=Xo,IconLayer.layerName="IconLayer";const $o=IconLayer,Zo="layout(std140) uniform lineUniforms {\n float widthScale;\n float widthMinPixels;\n float widthMaxPixels;\n float useShortestPath;\n highp int widthUnits;\n} line;\n",Yo={name:"line",source:"",vs:Zo,fs:Zo,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",useShortestPath:"f32",widthUnits:"i32"}},Jo={getSourcePosition:{type:"accessor",value:e=>e.sourcePosition},getTargetPosition:{type:"accessor",value:e=>e.targetPosition},getColor:{type:"accessor",value:[0,0,0,255]},getWidth:{type:"accessor",value:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}};class LineLayer extends Ts{getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME line-layer-vertex-shader\nin vec3 positions;\nin vec3 instanceSourcePositions;\nin vec3 instanceTargetPositions;\nin vec3 instanceSourcePositions64Low;\nin vec3 instanceTargetPositions64Low;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin float instanceWidths;\nout vec4 vColor;\nout vec2 uv;\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) {\nvec2 dir_screenspace = normalize(line_clipspace * project.viewportSize);\ndir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\nreturn dir_screenspace * offset_direction * width / 2.0;\n}\nvec3 splitLine(vec3 a, vec3 b, float x) {\nfloat t = (x - a.x) / (b.x - a.x);\nreturn vec3(x, mix(a.yz, b.yz, t));\n}\nvoid main(void) {\ngeometry.worldPosition = instanceSourcePositions;\ngeometry.worldPositionAlt = instanceTargetPositions;\nvec3 source_world = instanceSourcePositions;\nvec3 target_world = instanceTargetPositions;\nvec3 source_world_64low = instanceSourcePositions64Low;\nvec3 target_world_64low = instanceTargetPositions64Low;\nif (line.useShortestPath > 0.5 || line.useShortestPath < -0.5) {\nsource_world.x = mod(source_world.x + 180., 360.0) - 180.;\ntarget_world.x = mod(target_world.x + 180., 360.0) - 180.;\nfloat deltaLng = target_world.x - source_world.x;\nif (deltaLng * line.useShortestPath > 180.) {\nsource_world.x += 360. * line.useShortestPath;\nsource_world = splitLine(source_world, target_world, 180. * line.useShortestPath);\nsource_world_64low = vec3(0.0);\n} else if (deltaLng * line.useShortestPath < -180.) {\ntarget_world.x += 360. * line.useShortestPath;\ntarget_world = splitLine(source_world, target_world, 180. * line.useShortestPath);\ntarget_world_64low = vec3(0.0);\n} else if (line.useShortestPath < 0.) {\ngl_Position = vec4(0.);\nreturn;\n}\n}\nvec4 source_commonspace;\nvec4 target_commonspace;\nvec4 source = project_position_to_clipspace(source_world, source_world_64low, vec3(0.), source_commonspace);\nvec4 target = project_position_to_clipspace(target_world, target_world_64low, vec3(0.), target_commonspace);\nfloat segmentIndex = positions.x;\nvec4 p = mix(source, target, segmentIndex);\ngeometry.position = mix(source_commonspace, target_commonspace, segmentIndex);\nuv = positions.xy;\ngeometry.uv = uv;\ngeometry.pickingColor = instancePickingColors;\nfloat widthPixels = clamp(\nproject_size_to_pixel(instanceWidths * line.widthScale, line.widthUnits),\nline.widthMinPixels, line.widthMaxPixels\n);\nvec3 offset = vec3(\ngetExtrusionOffset(target.xy - source.xy, positions.y, widthPixels),\n0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\nDECKGL_FILTER_GL_POSITION(p, geometry);\ngl_Position = p + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0);\nvColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME line-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nin vec2 uv;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = uv;\nfragColor = vColor;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:'// ---------- Helper Structures & Functions ----------\n\n// Placeholder filter functions.\nfn deckgl_filter_size(offset: vec3<f32>, geometry: Geometry) -> vec3<f32> {\n return offset;\n}\nfn deckgl_filter_gl_position(p: vec4<f32>, geometry: Geometry) -> vec4<f32> {\n if (picking.isAttribute > 0.5) {\n // For depth picking, write normalized depth into the picking payload.\n // This mirrors the legacy DECKGL_FILTER_GL_POSITION hook on WebGL.\n }\n return p;\n}\n\n// Compute an extrusion offset given a line direction (in clipspace),\n// an offset direction (-1 or 1), and a width in pixels.\n// Assumes a uniform "project" with a viewportSize field is available.\nfn getExtrusionOffset(line_clipspace: vec2<f32>, offset_direction: f32, width: f32) -> vec2<f32> {\n // project.viewportSize should be provided as a uniform (not shown here)\n let dir_screenspace = normalize(line_clipspace * project.viewportSize);\n // Rotate by 90°: (x,y) becomes (-y,x)\n let rotated = vec2<f32>(-dir_screenspace.y, dir_screenspace.x);\n return rotated * offset_direction * width / 2.0;\n}\n\n// Splits the line between two points at a given x coordinate.\n// Interpolates the y and z components.\nfn splitLine(a: vec3<f32>, b: vec3<f32>, x: f32) -> vec3<f32> {\n let t: f32 = (x - a.x) / (b.x - a.x);\n return vec3<f32>(x, a.yz + t * (b.yz - a.yz));\n}\n\n// ---------- Uniforms & Global Structures ----------\n\nstruct LineUniforms {\n widthScale: f32,\n widthMinPixels: f32,\n widthMaxPixels: f32,\n useShortestPath: f32,\n widthUnits: i32,\n};\n\n@group(0) @binding(0)\nvar<uniform> line: LineUniforms;\n\n\n\n// ---------- Vertex Output Structure ----------\n\nstruct Varyings {\n @builtin(position) gl_Position: vec4<f32>,\n @location(0) vColor: vec4<f32>,\n @location(1) uv: vec2<f32>,\n @location(2) pickingColor: vec3<f32>,\n};\n\n// ---------- Vertex Shader Entry Point ----------\n\n@vertex\nfn vertexMain(\n @location(0) positions: vec3<f32>,\n @location(1) instanceSourcePositions: vec3<f32>,\n @location(2) instanceTargetPositions: vec3<f32>,\n @location(3) instanceSourcePositions64Low: vec3<f32>,\n @location(4) instanceTargetPositions64Low: vec3<f32>,\n @location(5) instanceColors: vec4<f32>,\n @location(6) instancePickingColors: vec3<f32>,\n @location(7) instanceWidths: f32\n) -> Varyings {\n geometry.worldPosition = instanceSourcePositions;\n geometry.worldPositionAlt = instanceTargetPositions;\n\n var source_world: vec3<f32> = instanceSourcePositions;\n var target_world: vec3<f32> = instanceTargetPositions;\n var source_world_64low: vec3<f32> = instanceSourcePositions64Low;\n var target_world_64low: vec3<f32> = instanceTargetPositions64Low;\n\n // Apply shortest-path adjustments if needed.\n if (line.useShortestPath > 0.5 || line.useShortestPath < -0.5) {\n source_world.x = (source_world.x + 180.0 % 360.0) - 180.0;\n target_world.x = (target_world.x + 180.0 % 360.0) - 180.0;\n let deltaLng: f32 = target_world.x - source_world.x;\n\n if (deltaLng * line.useShortestPath > 180.0) {\n source_world.x = source_world.x + 360.0 * line.useShortestPath;\n source_world = splitLine(source_world, target_world, 180.0 * line.useShortestPath);\n source_world_64low = vec3<f32>(0.0, 0.0, 0.0);\n } else if (deltaLng * line.useShortestPath < -180.0) {\n target_world.x = target_world.x + 360.0 * line.useShortestPath;\n target_world = splitLine(source_world, target_world, 180.0 * line.useShortestPath);\n target_world_64low = vec3<f32>(0.0, 0.0, 0.0);\n } else if (line.useShortestPath < 0.0) {\n var abortOut: Varyings;\n abortOut.gl_Position = vec4<f32>(0.0);\n abortOut.vColor = vec4<f32>(0.0);\n abortOut.uv = vec2<f32>(0.0);\n return abortOut;\n }\n }\n\n // Project Pos and target positions to clip space.\n let sourceResult = project_position_to_clipspace_and_commonspace(source_world, source_world_64low, vec3<f32>(0.0));\n let targetResult = project_position_to_clipspace_and_commonspace(target_world, target_world_64low, vec3<f32>(0.0));\n let sourcePos: vec4<f32> = sourceResult.clipPosition;\n let targetPos: vec4<f32> = targetResult.clipPosition;\n let source_commonspace: vec4<f32> = sourceResult.commonPosition;\n let target_commonspace: vec4<f32> = targetResult.commonPosition;\n\n // Interpolate along the line segment.\n let segmentIndex: f32 = positions.x;\n let p: vec4<f32> = sourcePos + segmentIndex * (targetPos - sourcePos);\n geometry.position = source_commonspace + segmentIndex * (target_commonspace - source_commonspace);\n let uv: vec2<f32> = positions.xy;\n geometry.uv = uv;\n geometry.pickingColor = instancePickingColors;\n\n // Determine width in pixels.\n let widthPixels: f32 = clamp(\n project_unit_size_to_pixel(instanceWidths * line.widthScale, line.widthUnits),\n line.widthMinPixels, line.widthMaxPixels\n );\n\n // Compute extrusion offset.\n let extrusion: vec2<f32> = getExtrusionOffset(targetPos.xy - sourcePos.xy, positions.y, widthPixels);\n let offset: vec3<f32> = vec3<f32>(extrusion, 0.0);\n\n // Apply deck.gl filter functions.\n let filteredOffset = deckgl_filter_size(offset, geometry);\n let filteredP = deckgl_filter_gl_position(p, geometry);\n\n let clipOffset: vec2<f32> = project_pixel_size_to_clipspace(filteredOffset.xy);\n let finalPosition: vec4<f32> = filteredP + vec4<f32>(clipOffset, 0.0, 0.0);\n\n // Compute color.\n var vColor: vec4<f32> = vec4<f32>(instanceColors.rgb, instanceColors.a * layer.opacity);\n // vColor = deckgl_filter_color(vColor, geometry);\n\n var output: Varyings;\n output.gl_Position = finalPosition;\n output.vColor = vColor;\n output.uv = uv;\n output.pickingColor = instancePickingColors;\n return output;\n}\n\n@fragment\nfn fragmentMain(\n @location(0) vColor: vec4<f32>,\n @location(1) uv: vec2<f32>,\n @location(2) pickingColor: vec3<f32>\n) -> @location(0) vec4<f32> {\n // Create and initialize geometry with the provided uv.\n var geometry: Geometry;\n geometry.uv = uv;\n\n // Start with the input color.\n var fragColor: vec4<f32> = vColor;\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(pickingColor)) {\n discard;\n }\n return vec4<f32>(pickingColor, 1.0);\n }\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(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}\n',modules:[Xs,Hs,Qs,Yo]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:[0,0,0,255]},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{widthUnits:t,widthScale:n,widthMinPixels:i,widthMaxPixels:r,wrapLongitude:s}=this.props,o=this.state.model,a={widthUnits:Mn.p5[t],widthScale:n,widthMinPixels:i,widthMaxPixels:r,useShortestPath:s?1:0};o.shaderInputs.setProps({line:a}),o.draw(this.context.renderPass),s&&(o.shaderInputs.setProps({line:{...a,useShortestPath:-1}}),o.draw(this.context.renderPass))}_getModel(){return new Sr.K(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Geometry({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array([0,-1,0,0,1,0,1,-1,0,1,1,0])}}}),isInstanced:!0})}}LineLayer.layerName="LineLayer",LineLayer.defaultProps=Jo;const ea=LineLayer,ta="layout(std140) uniform pointCloudUniforms {\n float radiusPixels;\n highp int sizeUnits;\n} pointCloud;\n",na={name:"pointCloud",source:"",vs:ta,fs:ta,uniformTypes:{radiusPixels:"f32",sizeUnits:"i32"}},ia=[0,0,0,255],ra=[0,0,1],sa={sizeUnits:"pixels",pointSize:{type:"number",min:0,value:10},getPosition:{type:"accessor",value:e=>e.position},getNormal:{type:"accessor",value:ra},getColor:{type:"accessor",value:ia},material:!0,radiusPixels:{deprecatedFor:"pointSize"}};class PointCloudLayer extends Ts{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME point-cloud-layer-vertex-shader\nin vec3 positions;\nin vec3 instanceNormals;\nin vec4 instanceColors;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec3 instancePickingColors;\nout vec4 vColor;\nout vec2 unitPosition;\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.normal = project_normal(instanceNormals);\nunitPosition = positions.xy;\ngeometry.uv = unitPosition;\ngeometry.pickingColor = instancePickingColors;\nvec3 offset = vec3(positions.xy * project_size_to_pixel(pointCloud.radiusPixels, pointCloud.sizeUnits), 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\nvec3 lightColor = lighting_getLightColor(instanceColors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\nvColor = vec4(lightColor, instanceColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME point-cloud-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nin vec2 unitPosition;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = unitPosition.xy;\nfloat distToCenter = length(unitPosition);\nif (distToCenter > 1.0) {\ndiscard;\n}\nfragColor = vColor;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:"struct PointCloudUniforms {\n radiusPixels: f32,\n sizeUnits: i32,\n};\n\n@group(0) @binding(0)\nvar<uniform> pointCloudUniforms: PointCloudUniforms;\n\nstruct ConstantAttributes {\n instanceNormals: vec3<f32>,\n instanceColors: vec4<f32>,\n instancePositions: vec3<f32>,\n instancePositions64Low: vec3<f32>,\n instancePickingColors: vec3<f32>\n};\n\nconst constants = ConstantAttributes(\n vec3<f32>(1.0, 0.0, 0.0),\n vec4<f32>(0.0, 0.0, 0.0, 1.0),\n vec3<f32>(0.0),\n vec3<f32>(0.0),\n vec3<f32>(0.0)\n);\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) instanceNormals: vec3<f32>,\n @location(4) instanceColors: vec4<f32>,\n @location(5) instancePickingColors: vec3<f32>\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n @location(0) vColor: vec4<f32>,\n @location(1) unitPosition: vec2<f32>,\n @location(2) pickingColor: vec3<f32>,\n};\n\n@vertex\nfn vertexMain(attributes: Attributes) -> Varyings {\n var varyings: Varyings;\n\n geometry.worldPosition = attributes.instancePositions;\n\n let centerResult = project_position_to_clipspace_and_commonspace(\n attributes.instancePositions,\n attributes.instancePositions64Low,\n vec3<f32>(0.0)\n );\n geometry.position = centerResult.commonPosition;\n geometry.normal = project_normal(attributes.instanceNormals);\n\n // position on the containing square in [-1, 1] space\n varyings.unitPosition = attributes.positions.xy;\n geometry.uv = varyings.unitPosition;\n geometry.pickingColor = attributes.instancePickingColors;\n\n // Find the center of the point and add the current vertex\n let offset = vec3<f32>(\n attributes.positions.xy *\n project_unit_size_to_pixel(pointCloudUniforms.radiusPixels, pointCloudUniforms.sizeUnits),\n 0.0\n );\n // DECKGL_FILTER_SIZE(offset, geometry);\n\n varyings.position = centerResult.clipPosition;\n // DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n let clipPixels = project_pixel_size_to_clipspace(offset.xy);\n varyings.position.x += clipPixels.x;\n varyings.position.y += clipPixels.y;\n\n // Apply lighting\n let lightColor = lighting_getLightColor2(attributes.instanceColors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\n\n // Apply opacity to instance color, or return instance picking color\n varyings.vColor = vec4(lightColor, attributes.instanceColors.a * layer.opacity);\n // DECKGL_FILTER_COLOR(vColor, geometry);\n varyings.pickingColor = attributes.instancePickingColors;\n\n return varyings;\n}\n\n@fragment\nfn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {\n // var geometry: Geometry;\n // geometry.uv = unitPosition.xy;\n\n let distToCenter = length(varyings.unitPosition);\n if (distToCenter > 1.0) {\n discard;\n }\n\n var fragColor: vec4<f32>;\n\n fragColor = varyings.vColor;\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}\n",modules:[Xs,Hs,co,Qs,na]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceNormals:{size:3,transition:!0,accessor:"getNormal",defaultValue:ra},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:ia}})}updateState(e){const{changeFlags:t,props:n}=e;super.updateState(e),t.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),t.dataChanged&&function(e){const{header:t,attributes:n}=e;if(t&&n&&(e.length=t.vertexCount,n.POSITION&&(n.instancePositions=n.POSITION),n.NORMAL&&(n.instanceNormals=n.NORMAL),n.COLOR_0)){const{size:e,value:t}=n.COLOR_0;n.instanceColors={size:e,type:"unorm8",value:t}}}(n.data)}draw({uniforms:e}){const{pointSize:t,sizeUnits:n}=this.props,i=this.state.model,r={sizeUnits:Mn.p5[n],radiusPixels:t};i.shaderInputs.setProps({pointCloud:r}),i.draw(this.context.renderPass)}_getModel(){const e=[];for(let t=0;t<3;t++){const n=t/3*Math.PI*2;e.push(2*Math.cos(n),2*Math.sin(n),0)}return new Sr.K(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Geometry({topology:"triangle-list",attributes:{positions:new Float32Array(e)}}),isInstanced:!0})}}PointCloudLayer.layerName="PointCloudLayer",PointCloudLayer.defaultProps=sa;const oa=PointCloudLayer,aa="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",la={name:"scatterplot",vs:aa,fs:aa,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"}},ca=[0,0,0,255],Aa={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:ca},getLineColor:{type:"accessor",value:ca},getLineWidth:{type:"accessor",value:1},getPixelOffset:{type:"accessor",value:[0,0]},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}};class ScatterplotLayer extends Ts{getShaders(){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;\nin vec3 instancePickingColors;\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;\ngeometry.pickingColor = instancePickingColors;\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:"// 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\nstruct ConstantAttributeUniforms {\n instancePositions: vec3<f32>,\n instancePositions64Low: vec3<f32>,\n instanceRadius: f32,\n instanceLineWidths: f32,\n instanceFillColors: vec4<f32>,\n instanceLineColors: vec4<f32>,\n instancePickingColors: vec3<f32>,\n instancePixelOffset: vec2<f32>,\n\n instancePositionsConstant: i32,\n instancePositions64LowConstant: i32,\n instanceRadiusConstant: i32,\n instanceLineWidthsConstant: i32,\n instanceFillColorsConstant: i32,\n instanceLineColorsConstant: i32,\n instancePickingColorsConstant: i32,\n instancePixelOffsetConstant: i32\n};\n\n@group(0) @binding(0) var<uniform> scatterplot: ScatterplotUniforms;\n\nstruct ConstantAttributes {\n instancePositions: vec3<f32>,\n instancePositions64Low: vec3<f32>,\n instanceRadius: f32,\n instanceLineWidths: f32,\n instanceFillColors: vec4<f32>,\n instanceLineColors: vec4<f32>,\n instancePickingColors: vec3<f32>,\n instancePixelOffset: vec2<f32>\n};\n\nconst constants = ConstantAttributes(\n vec3<f32>(0.0),\n vec3<f32>(0.0),\n 0.0,\n 0.0,\n vec4<f32>(0.0, 0.0, 0.0, 1.0),\n vec4<f32>(0.0, 0.0, 0.0, 1.0),\n vec3<f32>(0.0),\n vec2<f32>(0.0)\n);\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) instancePickingColors: vec3<f32>,\n @location(8) instancePixelOffset: vec2<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) unitPosition: vec2<f32>,\n @location(3) innerUnitRadius: f32,\n @location(4) outerRadiusPixels: f32,\n @location(5) pickingColor: vec3<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 let edgePadding = select(\n (varyings.outerRadiusPixels + SMOOTH_EDGE_RADIUS) / varyings.outerRadiusPixels,\n 1.0,\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 = attributes.instancePickingColors;\n\n varyings.innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / varyings.outerRadiusPixels;\n\n if (scatterplot.billboard != 0) {\n varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, vec3<f32>(0.0)); // TODO , geometry.position);\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 } 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 varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, offset); // TODO , geometry.position);\n // DECKGL_FILTER_GL_POSITION(varyings.position, geometry);\n }\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 = attributes.instancePickingColors;\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 smoothedge(distToCenter, varyings.outerRadiusPixels),\n step(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 smoothedge(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter),\n step(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 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",modules:[Xs,Hs,Qs,la]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}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:l,lineWidthUnits:c,lineWidthScale:A,lineWidthMinPixels:u,lineWidthMaxPixels:h}=this.props,d={stroked:s,filled:o,billboard:a,antialiasing:l,radiusUnits:Mn.p5[t],radiusScale:n,radiusMinPixels:i,radiusMaxPixels:r,lineWidthUnits:Mn.p5[c],lineWidthScale:A,lineWidthMinPixels:u,lineWidthMaxPixels:h},f=this.state.model;f.shaderInputs.setProps({scatterplot:d}),f.draw(this.context.renderPass)}_getModel(){return new Sr.K(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Geometry({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=Aa,ScatterplotLayer.layerName="ScatterplotLayer";const ua=ScatterplotLayer;class CubeGeometry extends Geometry{constructor(e={}){const{id:t=(0,po.L)("cube-geometry"),indices:n=!0}=e;super(n?{...e,id:t,topology:"triangle-list",indices:{size:1,value:ha},attributes:{..._a,...e.attributes}}:{...e,id:t,topology:"triangle-list",indices:void 0,attributes:{...va,...e.attributes}})}}const ha=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),da=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1]),fa=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),pa=new Float32Array([0,0,1,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1]),ga=new Float32Array([1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,-1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,1,-1,1,1,1,-1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1]),ma=new Float32Array([1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,0]),ba=new Float32Array([1,0,1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1,0,1,0,0,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,0,1,0,1,0,1,1,1,0,1,1,0,0,1,0,1,0,1]),_a={POSITION:{size:3,value:da},NORMAL:{size:3,value:fa},TEXCOORD_0:{size:2,value:pa}},va={POSITION:{size:3,value:ga},TEXCOORD_0:{size:2,value:ma},COLOR_0:{size:3,value:ba}};var ya=n(18135);class ColumnGeometry extends Geometry{constructor(e){const{indices:t,attributes:n}=function(e){const{radius:t,height:n=1,nradial:i=10}=e;let{vertices:r}=e;r&&(Ie.A.assert(r.length>=i),r=r.flatMap(e=>[e[0],e[1]]),(0,ya.UD)(r,ya.rJ.COUNTER_CLOCKWISE));const s=n>0,o=i+1,a=s?3*o+1:i,l=2*Math.PI/i,c=new Uint16Array(s?3*i*2:0),A=new Float32Array(3*a),u=new Float32Array(3*a);let h=0;if(s){for(let e=0;e<o;e++){const s=e*l,o=e%i,a=Math.sin(s),c=Math.cos(s);for(let e=0;e<2;e++)A[h+0]=r?r[2*o]:c*t,A[h+1]=r?r[2*o+1]:a*t,A[h+2]=(.5-e)*n,u[h+0]=r?r[2*o]:c,u[h+1]=r?r[2*o+1]:a,h+=3}A[h+0]=A[h-3],A[h+1]=A[h-2],A[h+2]=A[h-1],h+=3}for(let e=s?0:1;e<o;e++){const s=Math.floor(e/2)*Math.sign(.5-e%2),o=s*l,a=(s+i)%i,c=Math.sin(o),d=Math.cos(o);A[h+0]=r?r[2*a]:d*t,A[h+1]=r?r[2*a+1]:c*t,A[h+2]=n/2,u[h+2]=1,h+=3}if(s){let e=0;for(let t=0;t<i;t++)c[e++]=2*t+0,c[e++]=2*t+2,c[e++]=2*t+0,c[e++]=2*t+1,c[e++]=2*t+1,c[e++]=2*t+3}return{indices:c,attributes:{POSITION:{size:3,value:A},NORMAL:{size:3,value:u}}}}(e);super({...e,indices:t,attributes:n})}}const wa="layout(std140) uniform columnUniforms {\n float radius;\n float angle;\n vec2 offset;\n bool extruded;\n bool stroked;\n bool isStroke;\n float coverage;\n float elevationScale;\n float edgeDistance;\n float widthScale;\n float widthMinPixels;\n float widthMaxPixels;\n highp int radiusUnits;\n highp int widthUnits;\n} column;\n",xa={name:"column",vs:wa,fs:wa,uniformTypes:{radius:"f32",angle:"f32",offset:"vec2<f32>",extruded:"f32",stroked:"f32",isStroke:"f32",coverage:"f32",elevationScale:"f32",edgeDistance:"f32",widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",radiusUnits:"i32",widthUnits:"i32"}},Ta=[0,0,0,255],Ea={diskResolution:{type:"number",min:4,value:20},vertices:null,radius:{type:"number",min:0,value:1e3},angle:{type:"number",value:0},offset:{type:"array",value:[0,0]},coverage:{type:"number",min:0,max:1,value:1},elevationScale:{type:"number",min:0,value:1},radiusUnits:"meters",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,extruded:!0,wireframe:!1,filled:!0,stroked:!1,flatShading:!1,getPosition:{type:"accessor",value:e=>e.position},getFillColor:{type:"accessor",value:Ta},getLineColor:{type:"accessor",value:Ta},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0,getColor:{deprecatedFor:["getFillColor","getLineColor"]}};class ColumnLayer extends Ts{getShaders(){const e={},{flatShading:t}=this.props;return t&&(e.FLAT_SHADING=1),super.getShaders({vs:"#version 300 es\n#define SHADER_NAME column-layer-vertex-shader\nin vec3 positions;\nin vec3 normals;\nin vec3 instancePositions;\nin float instanceElevations;\nin vec3 instancePositions64Low;\nin vec4 instanceFillColors;\nin vec4 instanceLineColors;\nin float instanceStrokeWidths;\nin vec3 instancePickingColors;\nout vec4 vColor;\n#ifdef FLAT_SHADING\nout vec3 cameraPosition;\nout vec4 position_commonspace;\n#endif\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\nvec4 color = column.isStroke ? instanceLineColors : instanceFillColors;\nmat2 rotationMatrix = mat2(cos(column.angle), sin(column.angle), -sin(column.angle), cos(column.angle));\nfloat elevation = 0.0;\nfloat strokeOffsetRatio = 1.0;\nif (column.extruded) {\nelevation = instanceElevations * (positions.z + 1.0) / 2.0 * column.elevationScale;\n} else if (column.stroked) {\nfloat widthPixels = clamp(\nproject_size_to_pixel(instanceStrokeWidths * column.widthScale, column.widthUnits),\ncolumn.widthMinPixels, column.widthMaxPixels) / 2.0;\nfloat halfOffset = project_pixel_size(widthPixels) / project_size(column.edgeDistance * column.coverage * column.radius);\nif (column.isStroke) {\nstrokeOffsetRatio -= sign(positions.z) * halfOffset;\n} else {\nstrokeOffsetRatio -= halfOffset;\n}\n}\nfloat shouldRender = float(color.a > 0.0 && instanceElevations >= 0.0);\nfloat dotRadius = column.radius * column.coverage * shouldRender;\ngeometry.pickingColor = instancePickingColors;\nvec3 centroidPosition = vec3(instancePositions.xy, instancePositions.z + elevation);\nvec3 centroidPosition64Low = instancePositions64Low;\nvec2 offset = (rotationMatrix * positions.xy * strokeOffsetRatio + column.offset) * dotRadius;\nif (column.radiusUnits == UNIT_METERS) {\noffset = project_size(offset);\n} else if (column.radiusUnits == UNIT_PIXELS) {\noffset = project_pixel_size(offset);\n}\nvec3 pos = vec3(offset, 0.);\nDECKGL_FILTER_SIZE(pos, geometry);\ngl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position);\ngeometry.normal = project_normal(vec3(rotationMatrix * normals.xy, normals.z));\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nif (column.extruded && !column.isStroke) {\n#ifdef FLAT_SHADING\ncameraPosition = project.cameraPosition;\nposition_commonspace = geometry.position;\nvColor = vec4(color.rgb, color.a * layer.opacity);\n#else\nvec3 lightColor = lighting_getLightColor(color.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\nvColor = vec4(lightColor, color.a * layer.opacity);\n#endif\n} else {\nvColor = vec4(color.rgb, color.a * layer.opacity);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME column-layer-fragment-shader\nprecision highp float;\nout vec4 fragColor;\nin vec4 vColor;\n#ifdef FLAT_SHADING\nin vec3 cameraPosition;\nin vec4 position_commonspace;\n#endif\nvoid main(void) {\nfragColor = vColor;\ngeometry.uv = vec2(0.);\n#ifdef FLAT_SHADING\nif (column.extruded && !column.isStroke && !bool(picking.isActive)) {\nvec3 normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\nfragColor.rgb = lighting_getLightColor(vColor.rgb, cameraPosition, position_commonspace.xyz, normal);\n}\n#endif\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",defines:e,modules:[Xs,t?Ao:co,Qs,xa]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceElevations:{size:1,transition:!0,accessor:"getElevation"},instanceFillColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getFillColor",defaultValue:Ta},instanceLineColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getLineColor",defaultValue:Ta},instanceStrokeWidths:{size:1,accessor:"getLineWidth",transition:!0}})}updateState(e){super.updateState(e);const{props:t,oldProps:n,changeFlags:i}=e,r=i.extensionsChanged||t.flatShading!==n.flatShading;r&&(this.state.models?.forEach(e=>e.destroy()),this.setState(this._getModels()),this.getAttributeManager().invalidateAll());const s=this.getNumInstances();this.state.fillModel.setInstanceCount(s),this.state.wireframeModel.setInstanceCount(s),(r||t.diskResolution!==n.diskResolution||t.vertices!==n.vertices||(t.extruded||t.stroked)!==(n.extruded||n.stroked))&&this._updateGeometry(t)}getGeometry(e,t,n){const i=new ColumnGeometry({radius:1,height:n?2:0,vertices:t,nradial:e});let r=0;if(t)for(let n=0;n<e;n++){const i=t[n];r+=Math.sqrt(i[0]*i[0]+i[1]*i[1])/e}else r=1;return this.setState({edgeDistance:Math.cos(Math.PI/e)*r}),i}_getModels(){const e=this.getShaders(),t=this.getAttributeManager().getBufferLayouts(),n=new Sr.K(this.context.device,{...e,id:`${this.props.id}-fill`,bufferLayout:t,isInstanced:!0}),i=new Sr.K(this.context.device,{...e,id:`${this.props.id}-wireframe`,bufferLayout:t,isInstanced:!0});return{fillModel:n,wireframeModel:i,models:[i,n]}}_updateGeometry({diskResolution:e,vertices:t,extruded:n,stroked:i}){const r=this.getGeometry(e,t,n||i);this.setState({fillVertexCount:r.attributes.POSITION.value.length/3});const s=this.state.fillModel,o=this.state.wireframeModel,{POSITION:a,NORMAL:l}=r.attributes,c=new Geometry({topology:"triangle-strip",attributes:{POSITION:a,NORMAL:l}});s.setGeometry(c),o.setGeometry(r),o.setTopology("line-list")}draw({uniforms:e}){const{lineWidthUnits:t,lineWidthScale:n,lineWidthMinPixels:i,lineWidthMaxPixels:r,radiusUnits:s,elevationScale:o,extruded:a,filled:l,stroked:c,wireframe:A,offset:u,coverage:h,radius:d,angle:f}=this.props,p=this.state.fillModel,g=this.state.wireframeModel,{fillVertexCount:m,edgeDistance:b}=this.state,_={radius:d,angle:f/180*Math.PI,offset:u,extruded:a,stroked:c,coverage:h,elevationScale:o,edgeDistance:b,radiusUnits:Mn.p5[s],widthUnits:Mn.p5[t],widthScale:n,widthMinPixels:i,widthMaxPixels:r};a&&A&&(g.shaderInputs.setProps({column:{..._,isStroke:!0}}),g.draw(this.context.renderPass)),l&&(p.setVertexCount(m),p.shaderInputs.setProps({column:{..._,isStroke:!1}}),p.draw(this.context.renderPass)),!a&&c&&(p.setVertexCount(2*m/3),p.shaderInputs.setProps({column:{..._,isStroke:!0}}),p.draw(this.context.renderPass))}}ColumnLayer.layerName="ColumnLayer",ColumnLayer.defaultProps=Ea;const Sa=ColumnLayer;class GridCellLayer extends Sa{_updateGeometry(){const e=new CubeGeometry;this.state.fillModel.setGeometry(e)}draw({uniforms:e}){const{elevationScale:t,extruded:n,offset:i,coverage:r,cellSize:s,angle:o,radiusUnits:a}=this.props,l=this.state.fillModel,c={radius:s/2,radiusUnits:Mn.p5[a],angle:o,offset:i,extruded:n,stroked:!1,coverage:r,elevationScale:t,edgeDistance:1,isStroke:!1,widthUnits:0,widthScale:0,widthMinPixels:0,widthMaxPixels:0};l.shaderInputs.setProps({column:c}),l.draw(this.context.renderPass)}}GridCellLayer.layerName="GridCellLayer",GridCellLayer.defaultProps={cellSize:{type:"number",min:0,value:1e3},offset:{type:"array",value:[1,1]}};const Ca=GridCellLayer;function Pa(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 Ra(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}function Ma(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 La(e,t){const n=t.length;for(let i=0;i<n;i++)e[i]=t[i]}function Ia(e,t,n,i,r=[]){const s=i+t*n;for(let t=0;t<n;t++)r[t]=e[s+t];return r}function Oa(e,t){const{size:n=2,broken:i=!1,gridResolution:r=10,gridOffset:s=[0,0],startIndex:o=0,endIndex:a=e.length}=t||{},l=(a-o)/n;let c=[];const A=[c],u=Ia(e,0,n,o);let h,d;const f=ka(u,r,s,[]),p=[];Ma(c,u);for(let t=1;t<l;t++){for(h=Ia(e,t,n,o,h),d=Ra(h,f);d;){Pa(u,h,d,f,p);const e=Ra(p,f);e&&(Pa(u,p,e,f,p),d=e),Ma(c,p),La(u,p),Fa(f,r,d),i&&c.length>n&&(c=[],A.push(c),Ma(c,u)),d=Ra(h,f)}Ma(c,h),La(u,h)}return i?A:A[0]}function Ba(e,t=null,n){if(!e.length)return[];const{size:i=2,gridResolution:r=10,gridOffset:s=[0,0],edgeTypes:o=!1}=n||{},a=[],l=[{pos:e,types:o?new Array(e.length/i).fill(1):null,holes:t||[]}],c=[[],[]];let A=[];for(;l.length;){const{pos:e,types:t,holes:n}=l.shift();Da(e,i,n[0]||e.length,c),A=ka(c[0],r,s,A);const u=Ra(c[1],A);if(u){let r=Na(e,t,i,0,n[0]||e.length,A,u);const s={pos:r[0].pos,types:r[0].types,holes:[]},a={pos:r[1].pos,types:r[1].types,holes:[]};l.push(s,a);for(let l=0;l<n.length;l++)r=Na(e,t,i,n[l],n[l+1]||e.length,A,u),r[0]&&(s.holes.push(s.pos.length),s.pos=Ua(s.pos,r[0].pos),o&&(s.types=Ua(s.types,r[0].types))),r[1]&&(a.holes.push(a.pos.length),a.pos=Ua(a.pos,r[1].pos),o&&(a.types=Ua(a.types,r[1].types)))}else{const i={positions:e};o&&(i.edgeTypes=t),n.length&&(i.holeIndices=n),a.push(i)}}return a}function Na(e,t,n,i,r,s,o){const a=(r-i)/n,l=[],c=[],A=[],u=[],h=[];let d,f,p;const g=Ia(e,a-1,n,i);let m=Math.sign(8&o?g[1]-s[3]:g[0]-s[2]),b=t&&t[a-1],_=0,v=0;for(let r=0;r<a;r++)d=Ia(e,r,n,i,d),f=Math.sign(8&o?d[1]-s[3]:d[0]-s[2]),p=t&&t[i/n+r],f&&m&&m!==f&&(Pa(g,d,o,s,h),Ma(l,h)&&A.push(b),Ma(c,h)&&u.push(b)),f<=0?(Ma(l,d)&&A.push(p),_-=f):A.length&&(A[A.length-1]=0),f>=0?(Ma(c,d)&&u.push(p),v+=f):u.length&&(u[u.length-1]=0),La(g,d),m=f,b=p;return[_?{pos:l,types:t&&A}:null,v?{pos:c,types:t&&u}:null]}function ka(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 Fa(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 Da(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 Ua(e,t){for(let n=0;n<t.length;n++)e.push(t[n]);return e}function Va(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 za(e,t,n,i,r=85.051129){const s=e[n],o=e[i-t];if(Math.abs(s-o)>180){const i=Ia(e,0,t,n);i[0]+=360*Math.round((o-s)/360),Ma(e,i),i[1]=Math.sign(i[1])*r,Ma(e,i),i[0]=s,Ma(e,i)}}function Ga(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 ja(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}function Ha(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?Oa(r,{size:t,gridResolution:n}):i?function(e,t){const{size:n=2,startIndex:i=0,endIndex:r=e.length,normalize:s=!0}=t||{},o=e.slice(i,r);Ga(o,n,0,r-i);const a=Oa(o,{size:n,broken:!0,gridResolution:360,gridOffset:[-180,-180]});if(s)for(const e of a)ja(e,n);return a}(r,{size:t}):r}class PathTesselator extends Tesselator{constructor(e){super({...e,attributes:{positions:{size:3,padding:18,initialize:!0,type:e.fp64?Float64Array:Float32Array},segmentTypes:{size:1,type:Uint8ClampedArray}}})}get(e){return this.attributes[e]}getGeometryFromBuffer(e){return this.normalize?super.getGeometryFromBuffer(e):null}normalizeGeometry(e){return this.normalize?Ha(e,this.positionSize,this.opts.resolution,this.opts.wrapLongitude):e}getGeometrySize(e){if(Wa(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&&Wa(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 Wa(e){return Array.isArray(e[0])}const qa="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",Ka={name:"path",vs:qa,fs:qa,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}},Qa=[0,0,0,255],Xa={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},billboard:!1,_pathType:null,getPath:{type:"accessor",value:e=>e.path},getColor:{type:"accessor",value:Qa},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},$a={enter:(e,t)=>t.length?t.subarray(t.length-e.length):e};class PathLayer extends Ts{getShaders(){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 vec3 instancePickingColors;\nuniform float opacity;\nout vec4 vColor;\nout vec2 vCornerOffset;\nout float vMiterLength;\nout vec2 vPathPosition;\nout float vPathLength;\nout float vJointType;\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) {\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;\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}\nvPathLength = L;\nvCornerOffset = offsetVec;\nvMiterLength = dot(vCornerOffset, miterVec * turnDirection);\nvMiterLength = isCap ? isJoint : vMiterLength;\nvec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd);\nvPathPosition = vec2(\ndot(offsetFromStartOfPath, perp),\ndot(offsetFromStartOfPath, dir)\n);\ngeometry.uv = vPathPosition;\nfloat isValid = step(instanceTypes, 3.5);\nvec3 offset = vec3(offsetVec * width * isValid, 0.0);\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}\nvoid main() {\ngeometry.pickingColor = instancePickingColors;\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) {\nvec4 prevPositionScreen = project_position_to_clipspace(prevPosition, prevPosition64Low, ZERO_OFFSET);\nvec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position);\nvec4 nextPositionScreen = project_position_to_clipspace(nextPosition, nextPosition64Low, ZERO_OFFSET);\nclipLine(prevPositionScreen, currPositionScreen);\nclipLine(nextPositionScreen, currPositionScreen);\nclipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd));\nwidth = vec3(widthPixels, 0.0);\nDECKGL_FILTER_SIZE(width, geometry);\nvec3 offset = getLineJoinOffset(\nprevPositionScreen.xyz / prevPositionScreen.w,\ncurrPositionScreen.xyz / currPositionScreen.w,\nnextPositionScreen.xyz / nextPositionScreen.w,\nproject_pixel_size_to_clipspace(width.xy)\n);\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);\nvec3 offset = getLineJoinOffset(prevPosition, currPosition, nextPosition, width.xy);\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;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = vPathPosition;\nif (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) {\nif (vJointType > 0.5 && length(vCornerOffset) > 1.0) {\ndiscard;\n}\nif (vJointType < 0.5 && vMiterLength > path.miterLimit + 1.0) {\ndiscard;\n}\n}\nfragColor = vColor;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[Xs,Qs,Ka]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){const e=!0;this.getAttributeManager().addInstanced({vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:$a,accessor:"getPath",update:this.calculatePositions,noAlloc:e,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}},instanceTypes:{size:1,type:"uint8",update:this.calculateSegmentTypes,noAlloc:e},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:$a,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:$a,defaultValue:Qa},instancePickingColors:{size:4,type:"uint8",accessor:(e,{index:t,target:n})=>this.encodePickingColor(e&&e.__source?e.__source.index:t,n)}}),this.setState({pathTesselator:new PathTesselator({fp64:this.use64bitPositions()})})}updateState(e){super.updateState(e);const{props:t,changeFlags:n}=e,i=this.getAttributeManager();if(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getPath)){const{pathTesselator:e}=this.state,r=t.data.attributes||{};e.updateGeometry({data:t.data,geometryBuffer:r.getPath,buffers:r,normalize:!t._pathType,loop:"loop"===t._pathType,getGeometry:t.getPath,positionFormat:t.positionFormat,wrapLongitude:t.wrapLongitude,resolution:this.context.viewport.resolution,dataChanged:n.dataChanged}),this.setState({numInstances:e.instanceCount,startIndices:e.vertexStarts}),n.dataChanged||i.invalidateAll()}n.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),i.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:l}=this.props,c=this.state.model,A={jointType:Number(t),capType:Number(n),billboard:i,widthUnits:Mn.p5[s],widthScale:o,miterLimit:r,widthMinPixels:a,widthMaxPixels:l};c.shaderInputs.setProps({path:A}),c.draw(this.context.renderPass)}_getModel(){return new Sr.K(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Geometry({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")}}PathLayer.defaultProps=Xa,PathLayer.layerName="PathLayer";const Za=PathLayer;i();const Ya=ya.rJ.CLOCKWISE,Ja=ya.rJ.COUNTER_CLOCKWISE,el={isClosed:!0};function tl(e){return"positions"in e?e.positions:e}function nl(e){return"holeIndices"in e?e.holeIndices:null}function il(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 el.start=t,el.end=s,el.size=i,(0,ya.UD)(e,r,el),s}function rl(e,t,n,i,r=0,s,o){const a=(s=s||n.length)-r;if(a<=0)return t;let l=t;for(let t=0;t<a;t++)e[l++]=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[l++]=n[r+t];return el.start=t,el.end=l,el.size=i,(0,ya.UD)(e,o,el),l}function sl(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=rl(n,e,r,t,s[o-1],s[o],0===o?Ya:Ja),i.push(e);return i.pop(),{positions:n,holeIndices:i}}e=r}if(!function(e){return Array.isArray(e[0])}(e))return rl(n,0,e,t,0,n.length,Ya),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=il(n,r,o,t,0===s?Ya:Ja),i.push(r);return i.pop(),{positions:n,holeIndices:i}}return il(n,0,e,t,Ya),n}function ol(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 al(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],l=e[r+2];e[r+t]=o,e[r+n]=a,e[r+i]=l}}class PolygonTesselator extends Tesselator{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=sl(e,this.positionSize);return this.opts.resolution?Ba(tl(t),nl(t),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?function(e,t=null,n){const{size:i=2,normalize:r=!0,edgeTypes:s=!1}=n||{};t=t||[];const o=[],a=[];let l=0,c=0;for(let r=0;r<=t.length;r++){const s=t[r]||e.length,A=c,u=Va(e,i,l,s);for(let t=u;t<s;t++)o[c++]=e[t];for(let t=l;t<u;t++)o[c++]=e[t];Ga(o,i,A,c),za(o,i,A,c,n?.maxLatitude),l=s,a[r]=c}a.pop();const A=Ba(o,a,{size:i,gridResolution:360,gridOffset:[-180,-180],edgeTypes:s});if(r)for(const e of A)ja(e.positions,i);return A}(tl(t),nl(t),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):t}return e}getGeometrySize(e){if(ll(e)){let t=0;for(const n of e)t+=this.getGeometrySize(n);return t}return tl(e).length/this.positionSize}getGeometryFromBuffer(e){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(e):null}updateGeometryAttributes(e,t){if(e&&ll(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 l=s.indices;if(!l||!e)return;let c=r;const A=function(e,t,n,r){let s=nl(e);s&&(s=s.map(e=>e/t));let o=tl(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=ol(o,0,1),t=ol(o,0,2),i=ol(o,1,2);if(!e&&!t&&!i)return[];e>t&&e>i||(t>i?(n||(o=o.slice()),al(o,0,2,1)):(n||(o=o.slice()),al(o,2,0,1)))}return i()(o,s,t)}(e,this.positionSize,this.opts.preproject,this.opts.full3d);l=a.allocate(l,r+A.length,{copy:!0});for(let e=0;e<A.length;e++)l[c++]=A[e]+n;o[t+1]=r+A.length,s.indices=l}_updatePositions(e,{vertexStart:t,geometrySize:n}){const{attributes:{positions:i},positionSize:r}=this;if(!i||!e)return;const s=tl(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&&nl(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 ll(e){return Array.isArray(e)&&e.length>0&&!Number.isFinite(e[0])}const cl="layout(std140) uniform solidPolygonUniforms {\n bool extruded;\n bool isWireframe;\n float elevationScale;\n} solidPolygon;\n",Al={name:"solidPolygon",vs:cl,fs:cl,uniformTypes:{extruded:"f32",isWireframe:"f32",elevationScale:"f32"}},ul="in vec4 fillColors;\nin vec4 lineColors;\nin vec3 pickingColors;\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 = pickingColors;\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",hl=`#version 300 es\n#define SHADER_NAME solid-polygon-layer-vertex-shader\nin vec3 vertexPositions;\nin vec3 vertexPositions64Low;\nin float elevations;\n${ul}\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`,dl=`#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${ul}\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`,fl=[0,0,0,255],pl={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:fl},getLineColor:{type:"accessor",value:fl},material:!0},gl={enter:(e,t)=>t.length?t.subarray(t.length-e.length):e};class SolidPolygonLayer extends Ts{getShaders(e){return super.getShaders({vs:"top"===e?hl:dl,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",defines:{RING_WINDING_ORDER_CW:this.props._normalize||"CCW"!==this.props._windingOrder?1:0},modules:[Xs,co,Qs,Al]})}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;r.remove(["instancePickingColors"]),r.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:s},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:gl,accessor:"getPolygon",update:this.calculatePositions,noAlloc:s,shaderAttributes:{nextVertexPositions:{vertexOffset:1}}},instanceVertexValid:{size:1,type:"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:s},elevations:{size:1,stepMode:"dynamic",transition:gl,accessor:"getElevation"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:gl,accessor:"getFillColor",defaultValue:fl},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:gl,accessor:"getLineColor",defaultValue:fl},pickingColors:{size:4,type:"uint8",stepMode:"dynamic",accessor:(e,{index:t,target:n})=>this.encodePickingColor(e&&e.__source?e.__source.index:t,n)}})}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:l}=this.state,c={extruded:Boolean(t),elevationScale:r,isWireframe:!1};a&&i&&(a.setInstanceCount(l.instanceCount-1),a.shaderInputs.setProps({solidPolygon:{...c,isWireframe:!0}}),a.draw(this.context.renderPass)),o&&n&&(o.setInstanceCount(l.instanceCount-1),o.shaderInputs.setProps({solidPolygon:c}),o.draw(this.context.renderPass)),s&&n&&(s.setVertexCount(l.vertexCount),s.shaderInputs.setProps({solidPolygon:c}),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.NON_INSTANCED_MODEL=1;const n=this.getAttributeManager().getBufferLayouts({isInstanced:!1});i=new Sr.K(this.context.device,{...t,id:`${e}-top`,topology:"triangle-list",bufferLayout:n,isIndexed:!0,userData:{excludeAttributes:{instanceVertexValid:!0}}})}if(n){const t=this.getAttributeManager().getBufferLayouts({isInstanced:!0});r=new Sr.K(this.context.device,{...this.getShaders("side"),id:`${e}-side`,bufferLayout:t,geometry:new Geometry({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 Sr.K(this.context.device,{...this.getShaders("side"),id:`${e}-wireframe`,bufferLayout:t,geometry:new Geometry({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){e.value=this.state.polygonTesselator.get("vertexValid")}}SolidPolygonLayer.defaultProps=pl,SolidPolygonLayer.layerName="SolidPolygonLayer";const ml=SolidPolygonLayer;function bl({data:e,getIndex:t,dataRange:n,replace:i}){const{startRow:r=0,endRow:s=1/0}=n,o=e.length;let a=o,l=o;for(let n=0;n<o;n++){const i=t(e[n]);if(a>n&&i>=r&&(a=n),i>=s){l=n;break}}let c=a;const A=l-a!==i.length?e.slice(l):void 0;for(let t=0;t<i.length;t++)e[c++]=i[t];if(A){for(let t=0;t<A.length;t++)e[c++]=A[t];e.length=c}return{startRow:a,endRow:a+i.length}}const _l=[0,0,0,255],vl={stroked:!0,filled:!0,extruded:!1,elevationScale:1,wireframe:!1,_normalize:!0,_windingOrder:"CW",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,lineJointRounded:!1,lineMiterLimit:4,getPolygon:{type:"accessor",value:e=>e.polygon},getFillColor:{type:"accessor",value:[0,0,0,255]},getLineColor:{type:"accessor",value:_l},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0};class PolygonLayer extends Ss{initializeState(){this.state={paths:[],pathsDiff:null},this.props.getLineDashArray&&Ie.A.removed("getLineDashArray","PathStyleExtension")()}updateState({changeFlags:e}){const t=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getPolygon);if(t&&Array.isArray(e.dataChanged)){const t=this.state.paths.slice(),n=e.dataChanged.map(e=>bl({data:t,getIndex:e=>e.__source.index,dataRange:e,replace:this._getPaths(e)}));this.setState({paths:t,pathsDiff:n})}else t&&this.setState({paths:this._getPaths(),pathsDiff:null})}_getPaths(e={}){const{data:t,getPolygon:n,positionFormat:i,_normalize:r}=this.props,s=[],o="XY"===i?2:3,{startRow:a,endRow:l}=e,{iterable:c,objectInfo:A}=br(t,a,l);for(const e of c){A.index++;let t=n(e,A);r&&(t=sl(t,o));const{holeIndices:i}=t,a=t.positions||t;if(i)for(let t=0;t<=i.length;t++){const n=a.slice(i[t-1]||0,i[t]||a.length);s.push(this.getSubLayerRow({path:n},e,A.index))}else s.push(this.getSubLayerRow({path:a},e,A.index))}return s}renderLayers(){const{data:e,_dataDiff:t,stroked:n,filled:i,extruded:r,wireframe:s,_normalize:o,_windingOrder:a,elevationScale:l,transitions:c,positionFormat:A}=this.props,{lineWidthUnits:u,lineWidthScale:h,lineWidthMinPixels:d,lineWidthMaxPixels:f,lineJointRounded:p,lineMiterLimit:g,lineDashJustified:m}=this.props,{getFillColor:b,getLineColor:_,getLineWidth:v,getLineDashArray:y,getElevation:w,getPolygon:x,updateTriggers:T,material:E}=this.props,{paths:S,pathsDiff:C}=this.state,P=this.getSubLayerClass("fill",ml),R=this.getSubLayerClass("stroke",Za),M=this.shouldRenderSubLayer("fill",S)&&new P({_dataDiff:t,extruded:r,elevationScale:l,filled:i,wireframe:s,_normalize:o,_windingOrder:a,getElevation:w,getFillColor:b,getLineColor:r&&s?_:_l,material:E,transitions:c},this.getSubLayerProps({id:"fill",updateTriggers:T&&{getPolygon:T.getPolygon,getElevation:T.getElevation,getFillColor:T.getFillColor,lineColors:r&&s,getLineColor:T.getLineColor}}),{data:e,positionFormat:A,getPolygon:x});return[!r&&M,!r&&n&&this.shouldRenderSubLayer("stroke",S)&&new R({_dataDiff:C&&(()=>C),widthUnits:u,widthScale:h,widthMinPixels:d,widthMaxPixels:f,jointRounded:p,miterLimit:g,dashJustified:m,_pathType:"loop",transitions:c&&{getWidth:c.getLineWidth,getColor:c.getLineColor,getPath:c.getPolygon},getColor:this.getSubLayerAccessor(_),getWidth:this.getSubLayerAccessor(v),getDashArray:this.getSubLayerAccessor(y)},this.getSubLayerProps({id:"stroke",updateTriggers:T&&{getWidth:T.getLineWidth,getColor:T.getLineColor,getDashArray:T.getLineDashArray}}),{data:S,positionFormat:A,getPath:e=>e.path}),r&&M]}}PolygonLayer.layerName="PolygonLayer",PolygonLayer.defaultProps=vl;const yl=PolygonLayer;const wl="layout(std140) uniform sdfUniforms {\n float gamma;\n bool enabled;\n float buffer;\n float outlineBuffer;\n vec4 outlineColor;\n} sdf;\n",xl={name:"sdf",vs:wl,fs:wl,uniformTypes:{gamma:"f32",enabled:"f32",buffer:"f32",outlineBuffer:"f32",outlineColor:"vec4<f32>"}},Tl={none:0,start:1,center:2,end:3},El={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 ${Tl.start}\n#define ALIGN_MODE_CENTER ${Tl.center}\n#define ALIGN_MODE_END ${Tl.end}\n`,getUniforms:({contentCutoffPixels:e=[0,0],contentAlignHorizontal:t="none",contentAlignVertical:n="none",fontSize:i,viewport:r})=>({cutoffPixels:e,align:[Tl[t],Tl[n]],fontSize:i,flipY:r?.flipY??!1}),uniformTypes:{cutoffPixels:"vec2<f32>",align:"vec2<i32>",fontSize:"f32",flipY:"f32"}},Sl=.75;class MultiIconLayer extends $o{getShaders(){const e=super.getShaders();return{...e,modules:[...e.modules,El,xl],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 vec3 instancePickingColors;\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 = instancePickingColors;\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"}}initializeState(){super.initializeState();const e=this.getAttributeManager();e.attributes.instanceIconDefs.settings.update=this.calculateInstanceIconDefs,e.addInstanced({instancePickingColors:{type:"uint8",size:4,accessor:(e,{index:t,target:n})=>this.encodePickingColor(t,n)},instanceClipRect:{size:4,accessor:"getContentBox",defaultValue:[0,0,-1,-1]}})}updateState(e){super.updateState(e);const{props:t,oldProps:n,changeFlags:i}=e,{outlineColor:r}=t;if(i.updateTriggersChanged&&(i.updateTriggersChanged.getIcon||i.updateTriggersChanged.getIconOffsets)&&this.getAttributeManager().invalidate("instanceIconDefs"),r!==n.outlineColor){const e=[r[0]/255,r[1]/255,r[2]/255,(r[3]??255)/255];this.setState({outlineColor:e})}!t.sdf&&t.outlineWidth&&Ie.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:l}=this.state,c=r?Math.max(n,Sl*(1-r)):-1,A=this.state.model,u={buffer:Sl,outlineBuffer:c,gamma:n,enabled:Boolean(t),outlineColor:l},h={contentCutoffPixels:s,contentAlignHorizontal:o,contentAlignVertical:a,fontSize:i,viewport:this.context.viewport};if(A.shaderInputs.setProps({sdf:u,text:h}),super.draw(e),t&&r){const{iconManager:e}=this.state;e.getTexture()&&(A.shaderInputs.setProps({sdf:{...u,outlineBuffer:Sl}}),A.draw(this.context.renderPass))}}calculateInstanceIconDefs(e,{startRow:t,endRow:n}){const{data:i,getIcon:r,getIconOffsets:s}=this.props;let o=e.getVertexOffset(t);const a=e.value,{iterable:l,objectInfo:c}=br(i,t,n);for(const t of l){c.index++;const n=r(t,c),i=s(t,c);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,a.set(n,o),o+=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 Cl=MultiIconLayer,Pl=1e20,Rl=new Float64Array(256);for(let e=0;e<256;e++){const t=.5-Math.pow(e/255,1/2.2);Rl[e]=t*Math.abs(t)}Rl[255]=-Pl;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}={}){this.buffer=t,this.radius=n,this.cutoff=i,this.lang=a;const l=this.size=e+4*t,c=this._createCanvas(l),A=this.ctx=c.getContext("2d",{willReadFrequently:!0});A.font=`${o} ${s} ${e}px ${r}`,A.textBaseline="alphabetic",A.textAlign="left",A.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_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),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s)-a)),c=Math.max(0,Math.min(this.size-this.buffer,o+Math.ceil(i))),A=l+2*this.buffer,u=c+2*this.buffer,h=Math.max(A*u,0),d=new Uint8ClampedArray(h),f={data:d,width:A,height:u,glyphWidth:l,glyphHeight:c,glyphTop:o,glyphLeft:a,glyphAdvance:t};if(0===l||0===c)return f;const{ctx:p,buffer:g,gridInner:m,gridOuter:b}=this;this.lang&&(p.lang=this.lang),p.clearRect(g,g,l,c),p.fillText(e,g-a,g+o);const _=p.getImageData(g,g,l,c);b.fill(Pl,0,h),m.fill(0,0,h);let v=3;for(let e=0;e<c;e++){let t=(e+g)*A+g;for(let e=0;e<l;e++,v+=4,t++){const e=_.data[v];if(0===e)continue;const n=Rl[e];b[t]=Math.max(0,n),m[t]=Math.max(0,-n)}}Ml(b,0,0,A,u,A,this.f,this.v,this.z);const y=Math.min(g,1);Ml(m,g-y,g-y,l+2*y,c+2*y,A,this.f,this.v,this.z);const w=255/this.radius,x=255*(1-this.cutoff);for(let e=0;e<h;e++){const t=Math.sqrt(b[e])-Math.sqrt(m[e]);d[e]=Math.round(x-w*t)}return f}}function Ml(e,t,n,i,r,s,o,a,l){for(let c=t;c<t+i;c++)Ll(e,n*s+c,s,r,o,a,l);for(let c=n;c<n+r;c++)Ll(e,c*s+t,1,i,o,a,l)}function Ll(e,t,n,i,r,s,o){s[0]=0,o[0]=-Pl,o[1]=Pl,r[0]=e[t];for(let a=1,l=0,c=0;a<i;a++){r[a]=e[t+a*n];const i=a*a;do{const e=s[l];c=(r[a]-r[e]+i-e*e)/(a-e)/2}while(c<=o[l]&&--l>-1);l++,s[l]=a,o[l]=c,o[l+1]=Pl}for(let a=0,l=0;a<i;a++){for(;o[l+1]<a;)l++;const i=s[l],c=a-i;e[t+a*n]=r[i]+c*c}}const Il=[];function Ol(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 Bl(e,t,n,i,r,s){let o=t,a=0;for(let l=t;l<n;l++){const t=Ol(e,l,l+1,r);a+t>i&&(o<l&&s.push(l),o=l,a=0),a+=t}return a}function Nl(e,t,n,i,r=0,s){void 0===s&&(s=e.length);const o=[];return"break-all"===t?Bl(e,r,s,n,i,o):function(e,t,n,i,r,s){let o=t,a=t,l=t,c=0;for(let A=t;A<n;A++)if(" "===e[A]?l=A+1:" "!==e[A+1]&&A+1!==n||(l=A+1),l>a){let t=Ol(e,a,l,r);c+t>i&&(o<a&&(s.push(a),o=a,c=0),t>i&&(t=Bl(e,a,l,i,r,s),o=s[s.length-1])),a=l,c+=t}}(e,r,s,n,i,o),o}function kl(e,t,n,i,r,s){let o=0,a=0;for(let r=t;r<n;r++){const t=i[e[r]];t&&(a=Math.max(a,t.height))}for(let s=t;s<n;s++){const t=e[s],n=i[t];n?(r[s]=o+n.anchorX,o+=n.advance):(Ie.A.warn(`Missing character: ${t} (${t.codePointAt(0)})`)(),r[s]=o,o+=32)}s[0]=o,s[1]=a}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 Fl={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 Dl=new LRUCache(3);function Ul(e,t,n,i){e.font=`${i} ${n}px ${t}`,e.fillStyle="#000",e.textBaseline="alphabetic",e.textAlign="left"}class FontAtlasManager{constructor(){this.props={...Fl}}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=Dl.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=Dl.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,Dl.set(this._key,i)}_generateFontAtlas(e,t){const{fontFamily:n,fontWeight:i,fontSize:r,buffer:s,sdf:o,radius:a,cutoff:l}=this.props;let c=t&&t.data;c||(c=document.createElement("canvas"),c.width=1024);const A=c.getContext("2d",{willReadFrequently:!0});Ul(A,n,r,i);const u=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}}(A,r,e);let h;this._getFontRenderer?h=this._getFontRenderer(this.props):o&&(h={measure:u,draw:Vl(this.props)});const{mapping:d,canvasHeight:f,xOffset:p,yOffsetMin:g,yOffsetMax:m}=function({characterSet:e,measureText:t,buffer:n,maxCanvasWidth:i,mapping:r={},xOffset:s=0,yOffsetMin:o=0,yOffsetMax:a=0}){let l=s,c=o,A=a;for(const s of e)if(!r[s]){const{advance:e,width:o,ascent:a,descent:u}=t(s),h=a+u;l+o+2*n>i&&(l=0,c=A),r[s]={x:l+n,y:c+n,width:o,height:h,advance:e,anchorX:o/2,anchorY:a},l+=o+2*n,A=Math.max(A,c+h+2*n)}return{mapping:r,xOffset:l,yOffsetMin:c,yOffsetMax:A,canvasHeight:(u=A,Math.pow(2,Math.ceil(Math.log2(u))))};var u}({measureText:e=>h?h.measure(e):u(e),buffer:s,characterSet:e,maxCanvasWidth:1024,...t&&{mapping:t.mapping,xOffset:t.xOffset,yOffsetMin:t.yOffsetMin,yOffsetMax:t.yOffsetMax}});if(c.height!==f){const e=c.height>0?A.getImageData(0,0,c.width,c.height):null;c.height=f,e&&A.putImageData(e,0,0)}if(Ul(A,n,r,i),h)for(const t of e){const e=d[t],{data:n,left:i=0,top:r=0}=h.draw(t),s=e.x-i,o=e.y-r,a=Math.max(0,Math.round(s)),l=Math.max(0,Math.round(o)),u=Math.min(n.width,c.width-a),f=Math.min(n.height,c.height-l);A.putImageData(n,a,l,0,0,u,f),e.x+=a-s,e.y+=l-o}else for(const t of e){const e=d[t];A.fillText(t,e.x,e.y+e.anchorY)}const b=h?h.measure():u();return{baselineOffset:(b.ascent-b.descent)/2,xOffset:p,yOffsetMin:g,yOffsetMax:m,mapping:d,data:c,width:c.width,height:c.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 Vl({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}}}const zl="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",Gl={name:"textBackground",vs:zl,fs:zl,uniformTypes:{billboard:"f32",sizeScale:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",borderRadius:"vec4<f32>",padding:"vec4<f32>",sizeUnits:"i32",stroked:"f32"}},jl={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 Ts{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;\nin vec3 instancePickingColors;\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 = instancePickingColors;\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",modules:[Xs,Qs,Gl,El]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instanceRects:{size:4,accessor:"getBoundingRect"},instanceClipRect:{size:4,accessor:"getClipRect",defaultValue:[0,0,-1,-1]},instancePixelOffsets:{size:2,transition:!0,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,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:l,borderRadius:c}=this.props;l.length<4&&(l=[l[0],l[1],l[0],l[1]]),Array.isArray(c)||(c=[c,c,c,c]);const A=this.state.model,u={billboard:t,stroked:Boolean(o),borderRadius:c,padding:l,sizeUnits:Mn.p5[i],sizeScale:n,sizeMinPixels:r,sizeMaxPixels:s},h={fontSize:a,viewport:this.context.viewport};A.shaderInputs.setProps({textBackground:u,text:h}),A.draw(this.context.renderPass)}_getModel(){return new Sr.K(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Geometry({topology:"triangle-strip",vertexCount:4,attributes:{positions:{size:2,value:new Float32Array([0,0,1,0,0,1,1,1])}}}),isInstanced:!0})}}TextBackgroundLayer.defaultProps=jl,TextBackgroundLayer.layerName="TextBackgroundLayer";const Hl=TextBackgroundLayer,Wl={start:1,middle:0,end:-1},ql={top:1,center:0,bottom:-1},Kl=[0,0,0,255],Ql={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:Kl},getBorderWidth:{type:"accessor",value:0},backgroundBorderRadius:{type:"object",value:0},backgroundPadding:{type:"array",value:[0,0,0,0]},characterSet:{type:"object",value:Fl.characterSet},fontFamily:Fl.fontFamily,fontWeight:Fl.fontWeight,lineHeight:1,outlineWidth:{type:"number",value:0,min:0},outlineColor:{type:"color",value:Kl},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:Kl},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 Ss{constructor(){super(...arguments),this.getBoundingRect=(e,t)=>{const{size:[n,i]}=this.transformParagraph(e,t),{getTextAnchor:r,getAlignmentBaseline:s}=this.props;return[(Wl["function"==typeof r?r(e,t):r]-1)*n/2,(ql["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),l=Wl["function"==typeof n?n(e,t):n],c=ql["function"==typeof i?i(e,t):i],A=r.length,u=new Array(2*A);let h=0;for(let e=0;e<A;e++)u[h++]=(l-1)*o[e]/2+r[e],u[h++]=(c-1)*a/2+s[e];return u}}initializeState(){this.state={styleVersion:0,fontAtlasManager:new FontAtlasManager},this.props.maxWidth>0&&Ie.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,s=e.startIndices;const o="auto"===t&&new Set;if(n&&s){const{texts:t,characterCount:a}=function({value:e,length:t,stride:n,offset:i,startIndices:r,characterSet:s}){const o=e.BYTES_PER_ELEMENT,a=n?n/o:1,l=i?i/o:0,c=r[t]||Math.ceil((e.length-l)/a),A=s&&new Set,u=new Array(t);let h=e;if(a>1||l>0){h=new(0,e.constructor)(c);for(let t=0;t<c;t++)h[t]=e[t*a+l]}for(let e=0;e<t;e++){const t=r[e],n=r[e+1]||c,i=h.subarray(t,n);u[e]=String.fromCodePoint.apply(null,i),A&&i.forEach(A.add,A)}if(A)for(const e of A)s.add(String.fromCodePoint(e));return{texts:u,characterCount:c}}({...ArrayBuffer.isView(n)?{value:n}:n,length:e.length,startIndices:s,characterSet:o});i=a,r=(e,{index:n})=>t[n]}else{const{iterable:t,objectInfo:n}=br(e);s=[0],i=0;for(const e of t){n.index++;const t=Array.from(r(e,n)||"");o&&t.forEach(o.add,o),i+=t.length,s.push(i)}}this.setState({getText:r,startIndices:s,numInstances:i,characterSet:o||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:l,maxWidth:c}=this.props;return function(e,t,n,i,r,s){const o=Array.from(e),a=o.length,l=new Array(a),c=new Array(a),A=new Array(a),u=("break-word"===i||"break-all"===i)&&isFinite(r)&&r>0,h=[0,0],d=[0,0];let f=0,p=t+n/2,g=0,m=0;for(let e=0;e<=a;e++){const t=o[e];if("\n"!==t&&e!==a||(m=e),m>g){const e=u?Nl(o,i,r,s,g,m):Il;for(let t=0;t<=e.length;t++){const i=0===t?g:e[t-1],r=t<e.length?e[t]:m;kl(o,i,r,s,l,d);for(let e=i;e<r;e++)c[e]=p,A[e]=d[0];f++,p+=n,h[0]=Math.max(h[0],d[0])}g=m}"\n"===t&&(l[g]=0,c[g]=0,A[g]=0,g++)}return h[1]=f*n,{x:l,y:c,rowWidth:A,size:h}}(o(e,t)||"",r,l*s,a,c*s,i)}renderLayers(){const{startIndices:e,numInstances:t,getText:n,fontAtlasManager:{atlas:i,mapping:r},styleVersion:s}=this.state,{data:o,_dataDiff:a,getPosition:l,getColor:c,getSize:A,getAngle:u,getPixelOffset:h,getBackgroundColor:d,getBorderColor:f,getBorderWidth:p,getContentBox:g,backgroundBorderRadius:m,backgroundPadding:b,background:_,billboard:v,fontSettings:y,outlineWidth:w,outlineColor:x,sizeScale:T,sizeUnits:E,sizeMinPixels:S,sizeMaxPixels:C,contentCutoffPixels:P,contentAlignHorizontal:R,contentAlignVertical:M,transitions:L,updateTriggers:I}=this.props,O=this.getSubLayerClass("characters",Cl),B=this.getSubLayerClass("background",Hl),{fontSize:N}=this.state.fontAtlasManager.props;return[_&&new B({getFillColor:d,getLineColor:f,getLineWidth:p,borderRadius:m,padding:b,getPosition:l,getSize:A,getAngle:u,getPixelOffset:h,getClipRect:g,billboard:v,sizeScale:T,sizeUnits:E,sizeMinPixels:S,sizeMaxPixels:C,fontSize:N,transitions:L&&{getPosition:L.getPosition,getAngle:L.getAngle,getSize:L.getSize,getFillColor:L.getBackgroundColor,getLineColor:L.getBorderColor,getLineWidth:L.getBorderWidth,getPixelOffset:L.getPixelOffset}},this.getSubLayerProps({id:"background",updateTriggers:{getPosition:I.getPosition,getAngle:I.getAngle,getSize:I.getSize,getFillColor:I.getBackgroundColor,getLineColor:I.getBorderColor,getLineWidth:I.getBorderWidth,getPixelOffset:I.getPixelOffset,getBoundingRect:{getText:I.getText,getTextAnchor:I.getTextAnchor,getAlignmentBaseline:I.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:y.sdf,smoothing:Number.isFinite(y.smoothing)?y.smoothing:Fl.smoothing,outlineWidth:w/(y.radius||Fl.radius),outlineColor:x,iconAtlas:i,iconMapping:r,getPosition:l,getColor:c,getSize:A,getAngle:u,getPixelOffset:h,getContentBox:g,billboard:v,sizeScale:T,sizeUnits:E,sizeMinPixels:S,sizeMaxPixels:C,fontSize:N,contentCutoffPixels:P,contentAlignHorizontal:R,contentAlignVertical:M,transitions:L&&{getPosition:L.getPosition,getAngle:L.getAngle,getColor:L.getColor,getSize:L.getSize,getPixelOffset:L.getPixelOffset,getContentBox:L.getContentBox}},this.getSubLayerProps({id:"characters",updateTriggers:{all:I.getText,getPosition:I.getPosition,getAngle:I.getAngle,getColor:I.getColor,getSize:I.getSize,getPixelOffset:I.getPixelOffset,getContentBox:I.getContentBox,getIconOffsets:{getTextAnchor:I.getTextAnchor,getAlignmentBaseline:I.getAlignmentBaseline,styleVersion:s}}}),{data:o,_dataDiff:a,startIndices:e,numInstances:t,getIconOffsets:this.getIconOffsets,getIcon:n})]}static set fontAtlasCacheLimit(e){!function(e){Ie.A.assert(Number.isFinite(e)&&e>=3,"Invalid cache limit"),Dl=new LRUCache(e)}(e)}}TextLayer.defaultProps=Ql,TextLayer.layerName="TextLayer";const Xl=TextLayer,$l={circle:{type:ua,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,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:Xl,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"}}},Zl={type:Za,props:{lineWidthUnits:"widthUnits",lineWidthScale:"widthScale",lineWidthMinPixels:"widthMinPixels",lineWidthMaxPixels:"widthMaxPixels",lineJointRounded:"jointRounded",lineCapRounded:"capRounded",lineMiterLimit:"miterLimit",lineBillboard:"billboard",getLineColor:"getColor",getLineWidth:"getWidth"}},Yl={type:ml,props:{extruded:"extruded",filled:"filled",wireframe:"wireframe",elevationScale:"elevationScale",material:"material",_full3d:"_full3d",getElevation:"getElevation",getFillColor:"getFillColor",getLineColor:"getLineColor"}};function Jl({type:e,props:t}){const n={};for(const i in t)n[i]=e.defaultProps[t[i]];return n}function ec(e,t){const{transitions:n,updateTriggers:i}=e.props,r={updateTriggers:{},transitions:n&&{getPosition:n.geometry}};for(const s in t){const o=t[s];let a=e.props[s];s.startsWith("get")&&(a=e.getSubLayerAccessor(a),r.updateTriggers[o]=i[s],n&&(r.transitions[o]=n[s])),r[o]=a}return r}function tc(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){Ie.A.assert(Array.isArray(s.geometries),"GeoJSON does not have geometries array");const{geometries:e}=s;for(let s=0;s<e.length;s++){nc(e[s],i,t,r,n)}}else nc(s,i,t,r,n)}return i}function nc(e,t,n,i,r){const{type:s,coordinates:o}=e,{pointFeatures:a,lineFeatures:l,polygonFeatures:c,polygonOutlineFeatures:A}=t;if(function(e,t){let n=ic[e];Ie.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":l.push(n({geometry:e},i,r));break;case"MultiLineString":o.forEach(e=>{l.push(n({geometry:{type:"LineString",coordinates:e}},i,r))});break;case"Polygon":c.push(n({geometry:e},i,r)),o.forEach(e=>{A.push(n({geometry:{type:"LineString",coordinates:e}},i,r))});break;case"MultiPolygon":o.forEach(e=>{c.push(n({geometry:{type:"Polygon",coordinates:e}},i,r)),e.forEach(e=>{A.push(n({geometry:{type:"LineString",coordinates:e}},i,r))})})}else Ie.A.warn(`${s} coordinates are malformed`)()}const ic={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4};function rc(e){return e.geometry.coordinates}function sc(e,t){const n={points:{},lines:{},polygons:{},polygonsOutline:{}},{points:i,lines:r,polygons:s}=e,o=function(e,t){const n={points:null,lines:null,polygons:null};for(const i in n){const r=e[i].globalFeatureIds.value;n[i]=new Uint8ClampedArray(4*r.length);const s=[];for(let e=0;e<r.length;e++)t(r[e],s),n[i][4*e+0]=s[0],n[i][4*e+1]=s[1],n[i][4*e+2]=s[2],n[i][4*e+3]=255}return n}(e,t);n.points.data={length:i.positions.value.length/i.positions.size,attributes:{...i.attributes,getPosition:i.positions,instancePickingColors:{size:4,value:o.points}},properties:i.properties,numericProps:i.numericProps,featureIds:i.featureIds},n.lines.data={length:r.pathIndices.value.length-1,startIndices:r.pathIndices.value,attributes:{...r.attributes,getPath:r.positions,instancePickingColors:{size:4,value:o.lines}},properties:r.properties,numericProps:r.numericProps,featureIds:r.featureIds},n.lines._pathType="open";const a=s.positions.value.length/s.positions.size,l=Array(a).fill(1);for(const e of s.primitivePolygonIndices.value)l[e-1]=0;return n.polygons.data={length:s.polygonIndices.value.length-1,startIndices:s.polygonIndices.value,attributes:{...s.attributes,getPolygon:s.positions,instanceVertexValid:{size:1,value:new Uint16Array(l)},pickingColors:{size:4,value:o.polygons}},properties:s.properties,numericProps:s.numericProps,featureIds:s.featureIds},n.polygons._normalize=!1,s.triangles&&(n.polygons.data.attributes.indices=s.triangles.value),n.polygonsOutline.data={length:s.primitivePolygonIndices.value.length-1,startIndices:s.primitivePolygonIndices.value,attributes:{...s.attributes,getPath:s.positions,instancePickingColors:{size:4,value:o.polygons}},properties:s.properties,numericProps:s.numericProps,featureIds:s.featureIds},n.polygonsOutline._pathType="open",n}const oc=["points","linestrings","polygons"],ac={...Jl($l.circle),...Jl($l.icon),...Jl($l.text),...Jl(Zl),...Jl(Yl),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 Ss{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=sc(e.data,this.encodePickingColor);this.setState({layerProps:n})}_updateStateJSON({props:e,changeFlags:t}){const n=function(e){if(Array.isArray(e))return e;switch(Ie.A.assert(e.type,"GeoJSON does not have type"),e.type){case"Feature":return[e];case"FeatureCollection":return Ie.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 s={};if(Array.isArray(t.dataChanged)){const e=this.state.features;for(const t in e)r[t]=e[t].slice(),s[t]=[];for(const o of t.dataChanged){const t=tc(n,i,o);for(const n in e)s[n].push(bl({data:r[n],getIndex:e=>e.__source.index,dataRange:o,replace:t[n]}))}}else r=tc(n,i);const o=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=rc,n.lines.data=r,n.lines._dataDiff=t.lineFeatures&&(()=>t.lineFeatures),n.lines.getPath=rc,n.polygons.data=s,n.polygons._dataDiff=t.polygonFeatures&&(()=>t.polygonFeatures),n.polygons.getPolygon=rc,n.polygonsOutline.data=o,n.polygonsOutline._dataDiff=t.polygonOutlineFeatures&&(()=>t.polygonOutlineFeatures),n.polygonsOutline.getPath=rc,n}(r,s);this.setState({features:r,featuresDiff:s,layerProps:o})}getPickingInfo(e){const t=super.getPickingInfo(e),{index:n,sourceLayer:i}=t;return t.featureType=oc.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,Yl.type);if(r){const s=ec(this,Yl.props),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,Zl.type),o=this.shouldRenderSubLayer(r,n.lines?.data)&&this.getSubLayerClass(r,Zl.type);if(s||o){const e=ec(this,Zl.props);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=$l[e],a=o&&this.shouldRenderSubLayer(r,t.points?.data)&&this.getSubLayerClass(r,o.type);if(a){const l=ec(this,o.props);let c=t.points;if("text"===e&&n){const{instancePickingColors:e,...t}=c.data.attributes;c={...c,data:{...c.data,attributes:t}}}s.push(new a(l,this.getSubLayerProps({id:r,updateTriggers:l.updateTriggers,highlightedObjectIndex:i}),c))}}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=ac;const lc=GeoJsonLayer;function cc(e,t,n){return e.createFramebuffer({width:t,height:n,colorAttachments:[e.createTexture({width:t,height:n,format:"rgba32float",sampler:{minFilter:"nearest",magFilter:"nearest"}})]})}const Ac={name:"binSorter",vs:"layout(std140) uniform binSorterUniforms {\n ivec4 binIdRange;\n ivec2 targetSize;\n} binSorter;\n",uniformTypes:{binIdRange:"vec4<i32>",targetSize:"vec2<i32>"}},uc=[1,2,4,8],hc=3e38,dc={SUM:0,MEAN:0,MIN:0,MAX:0,COUNT:0},fc=1024;class WebGLBinSorter{constructor(e,t){this.binsFBO=null,this.device=e,this.model=function(e,t){let n=t.vs;2===t.dimensions&&(n+="\nvoid getBin(out int binId) {\n ivec2 binId2;\n getBin(binId2);\n if (binId2.x < binSorter.binIdRange.x || binId2.x >= binSorter.binIdRange.y) {\n binId = -1;\n } else {\n binId = (binId2.y - binSorter.binIdRange.z) * (binSorter.binIdRange.y - binSorter.binIdRange.x) + binId2.x;\n }\n}\n");const i=`#version 300 es\n#define SHADER_NAME gpu-aggregation-sort-bins-vertex\n\n${n}\n\nout vec3 v_Value;\n\nvoid main() {\n int binIndex;\n getBin(binIndex);\n binIndex = binIndex - binSorter.binIdRange.x;\n if (binIndex < 0) {\n gl_Position = vec4(0.);\n return;\n }\n int row = binIndex / binSorter.targetSize.x;\n int col = binIndex - row * binSorter.targetSize.x;\n vec2 position = (vec2(col, row) + 0.5) / vec2(binSorter.targetSize) * 2.0 - 1.0;\n gl_Position = vec4(position, 0.0, 1.0);\n gl_PointSize = 1.0;\n\n#if NUM_CHANNELS == 3\n getValue(v_Value);\n#elif NUM_CHANNELS == 2\n getValue(v_Value.xy);\n#else\n getValue(v_Value.x);\n#endif\n}\n`,r="#version 300 es\n#define SHADER_NAME gpu-aggregation-sort-bins-fragment\n\nprecision highp float;\n\nin vec3 v_Value;\nout vec4 fragColor;\n\nvoid main() {\n fragColor.xyz = v_Value;\n\n #ifdef MODULE_GEOMETRY\n geometry.uv = vec2(0.);\n DECKGL_FILTER_COLOR(fragColor, geometry);\n #endif\n\n fragColor.w = 1.0;\n}\n",s=new Sr.K(e,{bufferLayout:t.bufferLayout,modules:[...t.modules||[],Ac],defines:{...t.defines,NON_INSTANCED_MODEL:1,NUM_CHANNELS:t.channelCount},isInstanced:!1,vs:i,fs:r,topology:"point-list",disableWarnings:!0});return s}(e,t)}get texture(){return this.binsFBO?this.binsFBO.colorAttachments[0].texture:null}destroy(){this.model.destroy(),this.binsFBO?.colorAttachments[0].texture.destroy(),this.binsFBO?.destroy()}getBinValues(e){if(!this.binsFBO)return null;const t=e%fc,n=Math.floor(e/fc),i=this.device.readPixelsToArrayWebGL(this.binsFBO,{sourceX:t,sourceY:n,sourceWidth:1,sourceHeight:1}).buffer;return new Float32Array(i)}setDimensions(e,t){const n=fc,i=Math.ceil(e/n);this.binsFBO?this.binsFBO.height<i&&this.binsFBO.resize({width:n,height:i}):this.binsFBO=cc(this.device,n,i);const r={binIdRange:[t[0][0],t[0][1],t[1]?.[0]||0,t[1]?.[1]||0],targetSize:[this.binsFBO.width,this.binsFBO.height]};this.model.shaderInputs.setProps({binSorter:r})}setModelProps(e){const t=this.model;e.attributes&&t.setAttributes(e.attributes),e.constantAttributes&&t.setConstantAttributes(e.constantAttributes),void 0!==e.vertexCount&&t.setVertexCount(e.vertexCount),e.shaderModuleProps&&t.shaderInputs.setProps(e.shaderModuleProps)}update(e){if(!this.binsFBO)return;const t=function(e){const t={...dc};for(let n=0;n<e.length;n++){const i=e[n];i&&(t[i]+=uc[n])}return t}(e);this._updateBins("SUM",t.SUM+t.MEAN),this._updateBins("MIN",t.MIN),this._updateBins("MAX",t.MAX)}_updateBins(e,t){if(0===t)return;t|=uc[3];const n=this.model,i=this.binsFBO,r="MAX"===e?-hc:"MIN"===e?hc:0,s=this.device.beginRenderPass({id:`gpu-aggregation-${e}`,framebuffer:i,parameters:{viewport:[0,0,i.width,i.height],colorMask:t},clearColor:[r,r,r,0],clearDepth:!1,clearStencil:!1});n.setParameters({blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendColorOperation:"MAX"===e?"max":"MIN"===e?"min":"add",blendAlphaOperation:"add"}),n.draw(s),s.end()}}const pc={name:"aggregatorTransform",vs:"layout(std140) uniform aggregatorTransformUniforms {\n ivec4 binIdRange;\n bvec3 isCount;\n bvec3 isMean;\n float naN;\n} aggregatorTransform;\n",uniformTypes:{binIdRange:"vec4<i32>",isCount:"vec3<f32>",isMean:"vec3<f32>",naN:"f32"}};class WebGLAggregationTransform{constructor(e,t){this.binBuffer=null,this.valueBuffer=null,this._domains=null,this.device=e,this.channelCount=t.channelCount,this.transform=function(e,t){const n="#version 300 es\n#define SHADER_NAME gpu-aggregation-domain-vertex\n\nuniform sampler2D bins;\n\n#if NUM_DIMS == 1\nout float binIds;\n#else\nout vec2 binIds;\n#endif\n\n#if NUM_CHANNELS == 1\nflat out float values;\n#elif NUM_CHANNELS == 2\nflat out vec2 values;\n#else\nflat out vec3 values;\n#endif\n\nconst float NAN = intBitsToFloat(-1);\n\nvoid main() {\n int row = gl_VertexID / SAMPLER_WIDTH;\n int col = gl_VertexID - row * SAMPLER_WIDTH;\n vec4 weights = texelFetch(bins, ivec2(col, row), 0);\n vec3 value3 = mix(\n mix(weights.rgb, vec3(weights.a), aggregatorTransform.isCount),\n weights.rgb / max(weights.a, 1.0),\n aggregatorTransform.isMean\n );\n if (weights.a == 0.0) {\n value3 = vec3(NAN);\n }\n\n#if NUM_DIMS == 1\n binIds = float(gl_VertexID + aggregatorTransform.binIdRange.x);\n#else\n int y = gl_VertexID / (aggregatorTransform.binIdRange.y - aggregatorTransform.binIdRange.x);\n int x = gl_VertexID - y * (aggregatorTransform.binIdRange.y - aggregatorTransform.binIdRange.x);\n binIds.y = float(y + aggregatorTransform.binIdRange.z);\n binIds.x = float(x + aggregatorTransform.binIdRange.x);\n#endif\n\n#if NUM_CHANNELS == 3\n values = value3;\n#elif NUM_CHANNELS == 2\n values = value3.xy;\n#else\n values = value3.x;\n#endif\n\n gl_Position = vec4(0., 0., 0., 1.);\n // This model renders into a 2x1 texture to obtain min and max simultaneously.\n // See comments in fragment shader\n gl_PointSize = 2.0;\n}\n",i="#version 300 es\n#define SHADER_NAME gpu-aggregation-domain-fragment\n\nprecision highp float;\n\n#if NUM_CHANNELS == 1\nflat in float values;\n#elif NUM_CHANNELS == 2\nflat in vec2 values;\n#else\nflat in vec3 values;\n#endif\n\nout vec4 fragColor;\n\nvoid main() {\n vec3 value3;\n#if NUM_CHANNELS == 3\n value3 = values;\n#elif NUM_CHANNELS == 2\n value3.xy = values;\n#else\n value3.x = values;\n#endif\n if (isnan(value3.x)) discard;\n // This shader renders into a 2x1 texture with blending=max\n // The left pixel yields the max value of each channel\n // The right pixel yields the min value of each channel\n if (gl_FragCoord.x < 1.0) {\n fragColor = vec4(value3, 1.0);\n } else {\n fragColor = vec4(-value3, 1.0);\n }\n}\n";"webgl"===e.type&&e.getExtension("GL_ARB_shader_bit_encoding");return new BufferTransform(e,{vs:n,fs:i,topology:"point-list",modules:[pc],parameters:{blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendColorOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendAlphaOperation:"max"},defines:{NUM_DIMS:t.dimensions,NUM_CHANNELS:t.channelCount,SAMPLER_WIDTH:1024},varyings:["binIds","values"],disableWarnings:!0})}(e,t),this.domainFBO=cc(e,2,1)}destroy(){this.transform.destroy(),this.binBuffer?.destroy(),this.valueBuffer?.destroy(),this.domainFBO.colorAttachments[0].texture.destroy(),this.domainFBO.destroy()}get domains(){if(!this._domains){const e=this.device.readPixelsToArrayWebGL(this.domainFBO).buffer,t=new Float32Array(e);this._domains=[[-t[4],t[0]],[-t[5],t[1]],[-t[6],t[2]]].slice(0,this.channelCount)}return this._domains}setDimensions(e,t){const{model:n,transformFeedback:i}=this.transform;n.setVertexCount(e);const r={binIdRange:[t[0][0],t[0][1],t[1]?.[0]||0,t[1]?.[1]||0]};n.shaderInputs.setProps({aggregatorTransform:r});const s=e*t.length*4;(!this.binBuffer||this.binBuffer.byteLength<s)&&(this.binBuffer?.destroy(),this.binBuffer=this.device.createBuffer({byteLength:s}),i.setBuffer("binIds",this.binBuffer));const o=e*this.channelCount*4;(!this.valueBuffer||this.valueBuffer.byteLength<o)&&(this.valueBuffer?.destroy(),this.valueBuffer=this.device.createBuffer({byteLength:o}),i.setBuffer("values",this.valueBuffer))}update(e,t){if(!e)return;const n=this.transform,i=this.domainFBO,r={isCount:[0,1,2].map(e=>"COUNT"===t[e]?1:0),isMean:[0,1,2].map(e=>"MEAN"===t[e]?1:0),bins:e};n.model.shaderInputs.setProps({aggregatorTransform:r}),n.run({id:"gpu-aggregation-domain",framebuffer:i,parameters:{viewport:[0,0,2,1]},clearColor:[-3e38,-3e38,-3e38,0],clearDepth:!1,clearStencil:!1}),this._domains=null}}class WebGLAggregator{static isSupported(e){return e.features.has("float32-renderable-webgl")&&e.features.has("texture-blend-float-webgl")}constructor(e,t){this.binCount=0,this.binIds=null,this.results=[],this.device=e,this.dimensions=t.dimensions,this.channelCount=t.channelCount,this.props={...t,pointCount:0,binIdRange:[[0,0]],operations:[],attributes:{},binOptions:{}},this.needsUpdate=new Array(this.channelCount).fill(!0),this.binSorter=new WebGLBinSorter(e,t),this.aggregationTransform=new WebGLAggregationTransform(e,t),this.setProps(t)}getBins(){const e=this.aggregationTransform.binBuffer;return e?(this.binIds?.buffer!==e&&(this.binIds={buffer:e,type:"float32",size:this.dimensions}),this.binIds):null}getResult(e){const t=this.aggregationTransform.valueBuffer;return!t||e>=this.channelCount?null:(this.results[e]?.buffer!==t&&(this.results[e]={buffer:t,type:"float32",size:1,stride:4*this.channelCount,offset:4*e}),this.results[e])}getResultDomain(e){return this.aggregationTransform.domains[e]}getBin(e){if(e<0||e>=this.binCount)return null;const{binIdRange:t}=this.props;let n;if(1===this.dimensions)n=[e+t[0][0]];else{const[[i,r],[s]]=t,o=r-i;n=[e%o+i,Math.floor(e/o)+s]}const i=this.binSorter.getBinValues(e);if(!i)return null;const r=i[3],s=[];for(let e=0;e<this.channelCount;e++){const t=this.props.operations[e];s[e]="COUNT"===t?r:0===r?NaN:"MEAN"===t?i[e]/r:i[e]}return{id:n,value:s,count:r}}destroy(){this.binSorter.destroy(),this.aggregationTransform.destroy()}setProps(e){const t=this.props;if("binIdRange"in e&&!(0,dn.b)(e.binIdRange,t.binIdRange,2)){const t=e.binIdRange;if(Ie.A.assert(t.length===this.dimensions),1===this.dimensions){const[[e,n]]=t;this.binCount=n-e}else{const[[e,n],[i,r]]=t;this.binCount=(n-e)*(r-i)}this.binSorter.setDimensions(this.binCount,t),this.aggregationTransform.setDimensions(this.binCount,t),this.setNeedsUpdate()}if(e.operations)for(let n=0;n<this.channelCount;n++)e.operations[n]!==t.operations[n]&&this.setNeedsUpdate(n);if(void 0!==e.pointCount&&e.pointCount!==t.pointCount&&(this.binSorter.setModelProps({vertexCount:e.pointCount}),this.setNeedsUpdate()),e.binOptions&&((0,dn.b)(e.binOptions,t.binOptions,2)||this.setNeedsUpdate(),this.binSorter.model.shaderInputs.setProps({binOptions:e.binOptions})),e.attributes){const t={},n={};for(const i of Object.values(e.attributes))for(const[e,r]of Object.entries(i.getValue()))ArrayBuffer.isView(r)?n[e]=r:r&&(t[e]=r);this.binSorter.setModelProps({attributes:t,constantAttributes:n})}e.shaderModuleProps&&this.binSorter.setModelProps({shaderModuleProps:e.shaderModuleProps}),Object.assign(this.props,e)}setNeedsUpdate(e){void 0===e?this.needsUpdate.fill(!0):this.needsUpdate[e]=!0}update(){}preDraw(){if(!this.needsUpdate.some(Boolean))return;const{operations:e}=this.props,t=this.needsUpdate.map((t,n)=>t?e[n]:null);this.binSorter.update(t),this.aggregationTransform.update(this.binSorter.texture,e);for(let e=0;e<this.channelCount;e++)this.needsUpdate[e]&&(this.needsUpdate[e]=!1,this.props.onUpdate?.({channel:e}))}}const gc=(e,t)=>{let n=0;for(const i of e)n+=t(i);return n},mc={COUNT:e=>e.length,SUM:gc,MEAN:(e,t)=>0===e.length?NaN:gc(e,t)/e.length,MIN:(e,t)=>{let n=1/0;for(const i of e){const e=t(i);e<n&&(n=e)}return n},MAX:(e,t)=>{let n=-1/0;for(const i of e){const e=t(i);e>n&&(n=e)}return n}};function bc({bins:e,getValue:t,operation:n,target:i}){(!i||i.length<e.length)&&(i=new Float32Array(e.length));let r=1/0,s=-1/0;for(let o=0;o<e.length;o++){const{points:a}=e[o];i[o]=n(a,t),i[o]<r&&(r=i[o]),i[o]>s&&(s=i[o])}return{value:i,domain:[r,s]}}function _c(e,t,n){const i={};for(const n of e.sources||[]){const e=t[n];if(!e)throw new Error(`Cannot find attribute ${n}`);i[n]=vc(e)}const r={};return t=>{for(const e in i)r[e]=i[e](t);return e.getValue(r,t,n)}}function vc(e){const t=e.value,{offset:n=0,stride:i,size:r}=e.getAccessor(),s=t.BYTES_PER_ELEMENT,o=n/s,a=i?i/s:r;if(1===r)return e.isConstant?()=>t[0]:e=>t[o+a*e];let l;return e.isConstant?(l=Array.from(t),()=>l):(l=new Array(r),e=>{const n=o+a*e;for(let e=0;e<r;e++)l[e]=t[n+e];return l})}class CPUAggregator{constructor(e){this.bins=[],this.binIds=null,this.results=[],this.dimensions=e.dimensions,this.channelCount=e.getValue.length,this.props={...e,binOptions:{},pointCount:0,operations:[],customOperations:[],attributes:{}},this.needsUpdate=!0,this.setProps(e)}destroy(){}get binCount(){return this.bins.length}setProps(e){const t=this.props;if(e.binOptions&&((0,dn.b)(e.binOptions,t.binOptions,2)||this.setNeedsUpdate()),e.operations)for(let n=0;n<this.channelCount;n++)e.operations[n]!==t.operations[n]&&this.setNeedsUpdate(n);if(e.customOperations)for(let n=0;n<this.channelCount;n++)Boolean(e.customOperations[n])!==Boolean(t.customOperations[n])&&this.setNeedsUpdate(n);void 0!==e.pointCount&&e.pointCount!==t.pointCount&&this.setNeedsUpdate(),e.attributes&&(e.attributes={...t.attributes,...e.attributes}),Object.assign(this.props,e)}setNeedsUpdate(e){void 0===e?this.needsUpdate=!0:!0!==this.needsUpdate&&(this.needsUpdate=this.needsUpdate||[],this.needsUpdate[e]=!0)}update(){if(!0===this.needsUpdate){this.bins=function({pointCount:e,getBinId:t}){const n=new Map;for(let i=0;i<e;i++){const e=t(i);if(null===e)continue;let r=n.get(String(e));r?r.points.push(i):(r={id:e,index:n.size,points:[i]},n.set(String(e),r))}return Array.from(n.values())}({pointCount:this.props.pointCount,getBinId:_c(this.props.getBin,this.props.attributes,this.props.binOptions)});const e=function({bins:e,dimensions:t,target:n}){const i=e.length*t;(!n||n.length<i)&&(n=new Float32Array(i));for(let i=0;i<e.length;i++){const{id:r}=e[i];Array.isArray(r)?n.set(r,i*t):n[i]=r}return n}({bins:this.bins,dimensions:this.dimensions,target:this.binIds?.value});this.binIds={value:e,type:"float32",size:this.dimensions}}for(let e=0;e<this.channelCount;e++)if(!0===this.needsUpdate||this.needsUpdate[e]){const t=this.props.customOperations[e]||mc[this.props.operations[e]],{value:n,domain:i}=bc({bins:this.bins,getValue:_c(this.props.getValue[e],this.props.attributes,void 0),operation:t,target:this.results[e]?.value});this.results[e]={value:n,domain:i,type:"float32",size:1},this.props.onUpdate?.({channel:e})}this.needsUpdate=!1}preDraw(){}getBins(){return this.binIds}getResult(e){return this.results[e]}getResultDomain(e){return this.results[e]?.domain??[1/0,-1/0]}getBin(e){const t=this.bins[e];if(!t)return null;const n=new Array(this.channelCount);for(let t=0;t<n.length;t++){const i=this.results[t];n[t]=i?.value[e]}return{id:t.id,value:n,count:t.points.length,pointIndices:t.points}}}class AggregationLayer extends Ss{get isDrawable(){return!0}initializeState(){this.getAttributeManager().remove(["instancePickingColors"])}updateState(e){super.updateState(e);const t=this.getAggregatorType();if(e.changeFlags.extensionsChanged||this.state.aggregatorType!==t){this.state.aggregator?.destroy();const e=this.createAggregator(t);return e.setProps({attributes:this.getAttributeManager()?.attributes}),this.setState({aggregator:e,aggregatorType:t}),!0}return!1}finalizeState(e){super.finalizeState(e),this.state.aggregator.destroy()}updateAttributes(e){const{aggregator:t}=this.state;t.setProps({attributes:e});for(const t in e)this.onAttributeChange(t);t.update()}draw({shaderModuleProps:e}){const{aggregator:t}=this.state;t.setProps({shaderModuleProps:e}),t.preDraw()}_getAttributeManager(){return new AttributeManager(this.context.device,{id:this.props.id,stats:this.context.stats})}}AggregationLayer.layerName="AggregationLayer";const yc=AggregationLayer,wc=[[255,255,178],[254,217,118],[254,178,76],[253,141,60],[240,59,32],[189,0,38]];function xc(e,t=!1,n=Float32Array){let i;if(Number.isFinite(e[0]))i=new n(e);else{i=new n(4*e.length);let t=0;for(let n=0;n<e.length;n++){const r=e[n];i[t++]=r[0],i[t++]=r[1],i[t++]=r[2],i[t++]=Number.isFinite(r[3])?r[3]:255}}if(t)for(let e=0;e<i.length;e++)i[e]/=255;return i}const Tc={linear:"linear",quantile:"nearest",quantize:"nearest",ordinal:"nearest"};function Ec(e,t){e.setSampler({minFilter:Tc[t],magFilter:Tc[t]})}function Sc(e,t,n="linear"){const i=xc(t,!1,Uint8Array);return e.createTexture({format:"rgba8unorm",sampler:{minFilter:Tc[n],magFilter:Tc[n],addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},data:i,width:i.length/4,height:1})}const Cc={name:"screenGrid",vs:"layout(std140) uniform screenGridUniforms {\n vec2 cellSizeClipspace;\n vec2 gridSizeClipspace;\n vec2 colorDomain;\n} screenGrid;\n",uniformTypes:{cellSizeClipspace:"vec2<f32>",gridSizeClipspace:"vec2<f32>",colorDomain:"vec2<f32>"}};class ScreenGridCellLayer extends Ts{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME screen-grid-layer-vertex-shader\n#define RANGE_COUNT 6\nin vec2 positions;\nin vec2 instancePositions;\nin float instanceWeights;\nin vec3 instancePickingColors;\nuniform sampler2D colorRange;\nout vec4 vColor;\nvec4 interp(float value, vec2 domain, sampler2D range) {\nfloat r = (value - domain.x) / (domain.y - domain.x);\nreturn texture(range, vec2(r, 0.5));\n}\nvoid main(void) {\nif (isnan(instanceWeights)) {\ngl_Position = vec4(0.);\nreturn;\n}\nvec2 pos = instancePositions * screenGrid.gridSizeClipspace + positions * screenGrid.cellSizeClipspace;\npos.x = pos.x - 1.0;\npos.y = 1.0 - pos.y;\ngl_Position = vec4(pos, 0., 1.);\nvColor = interp(instanceWeights, screenGrid.colorDomain, colorRange);\nvColor.a *= layer.opacity;\npicking_setPickingColor(instancePickingColors);\n}\n",fs:"#version 300 es\n#define SHADER_NAME screen-grid-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nout vec4 fragColor;\nvoid main(void) {\nfragColor = vColor;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[Qs,Cc]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:2,type:"float32",accessor:"getBin"},instanceWeights:{size:1,type:"float32",accessor:"getWeight"}}),this.state.model=this._getModel()}updateState(e){super.updateState(e);const{props:t,oldProps:n,changeFlags:i}=e,r=this.state.model;if(n.colorRange!==t.colorRange){this.state.colorTexture?.destroy(),this.state.colorTexture=Sc(this.context.device,t.colorRange,t.colorScaleType);const e={colorRange:this.state.colorTexture};r.shaderInputs.setProps({screenGrid:e})}else n.colorScaleType!==t.colorScaleType&&Ec(this.state.colorTexture,t.colorScaleType);if(n.cellMarginPixels!==t.cellMarginPixels||n.cellSizePixels!==t.cellSizePixels||i.viewportChanged){const{width:e,height:t}=this.context.viewport,{cellSizePixels:n,cellMarginPixels:i}=this.props,s=Math.max(n-i,0),o={gridSizeClipspace:[n/e*2,n/t*2],cellSizeClipspace:[s/e*2,s/t*2]};r.shaderInputs.setProps({screenGrid:o})}}finalizeState(e){super.finalizeState(e),this.state.colorTexture?.destroy()}draw({uniforms:e}){const t=this.props.colorDomain(),n=this.state.model,i={colorDomain:t};n.shaderInputs.setProps({screenGrid:i}),n.draw(this.context.renderPass)}_getModel(){return new Sr.K(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Geometry({topology:"triangle-strip",attributes:{positions:{value:new Float32Array([0,0,1,0,0,1,1,1]),size:2}}}),isInstanced:!0})}}ScreenGridCellLayer.layerName="ScreenGridCellLayer";const Pc=ScreenGridCellLayer,Rc={name:"binOptions",vs:"layout(std140) uniform binOptionsUniforms {\n float cellSizePixels;\n} binOptions;\n",uniformTypes:{cellSizePixels:"f32"}},Mc={cellSizePixels:{type:"number",value:100,min:1},cellMarginPixels:{type:"number",value:2,min:0},colorRange:wc,colorScaleType:"linear",getPosition:{type:"accessor",value:e=>e.position},getWeight:{type:"accessor",value:1},gpuAggregation:!0,aggregation:"SUM"};class ScreenGridLayer extends yc{getAggregatorType(){return this.props.gpuAggregation&&WebGLAggregator.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(e){return"cpu"!==e&&WebGLAggregator.isSupported(this.context.device)?new WebGLAggregator(this.context.device,{dimensions:2,channelCount:1,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[Xs,Rc],vs:"\n in vec3 positions;\n in vec3 positions64Low;\n in float counts;\n \n void getBin(out ivec2 binId) {\n vec4 pos = project_position_to_clipspace(positions, positions64Low, vec3(0.0));\n vec2 screenCoords = vec2(pos.x / pos.w + 1.0, 1.0 - pos.y / pos.w) / 2.0 * project.viewportSize.xy / project.devicePixelRatio;\n vec2 gridCoords = floor(screenCoords / binOptions.cellSizePixels);\n binId = ivec2(gridCoords);\n }\n void getValue(out float weight) {\n weight = counts;\n }\n "})}):new CPUAggregator({dimensions:2,getBin:{sources:["positions"],getValue:({positions:e},t,n)=>{const i=this.context.viewport,r=i.project(e),s=n.cellSizePixels;return r[0]<0||r[0]>=i.width||r[1]<0||r[1]>=i.height?null:[Math.floor(r[0]/s),Math.floor(r[1]/s)]}},getValue:[{sources:["counts"],getValue:({counts:e})=>e}]})}initializeState(){super.initializeState();this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},counts:{size:1,accessor:"getWeight"}})}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState(e){const t=super.updateState(e),{props:n,oldProps:i,changeFlags:r}=e,{cellSizePixels:s,aggregation:o}=n;if(t||r.dataChanged||r.updateTriggersChanged||r.viewportChanged||o!==i.aggregation||s!==i.cellSizePixels){const{width:e,height:t}=this.context.viewport,{aggregator:n}=this.state;n instanceof WebGLAggregator&&n.setProps({binIdRange:[[0,Math.ceil(e/s)],[0,Math.ceil(t/s)]]}),n.setProps({pointCount:this.getNumInstances(),operations:[o],binOptions:{cellSizePixels:s}})}return r.viewportChanged&&this.state.aggregator.setNeedsUpdate(),t}onAttributeChange(e){const{aggregator:t}=this.state;switch(e){case"positions":t.setNeedsUpdate();break;case"counts":t.setNeedsUpdate(0)}}renderLayers(){const{aggregator:e}=this.state,t=this.getSubLayerClass("cells",Pc),n=e.getBins(),i=e.getResult(0);return new t(this.props,this.getSubLayerProps({id:"cell-layer"}),{data:{length:e.binCount,attributes:{getBin:n,getWeight:i}},dataComparator:(e,t)=>e.length===t.length,updateTriggers:{getBin:[n],getWeight:[i]},parameters:{depthWriteEnabled:!1,...this.props.parameters},colorDomain:()=>this.props.colorDomain||e.getResultDomain(0),extensions:[]})}getPickingInfo(e){const t=e.info,{index:n}=t;if(n>=0){const e=this.state.aggregator.getBin(n);let i;e&&(i={col:e.id[0],row:e.id[1],value:e.value[0],count:e.count},e.pointIndices&&(i.pointIndices=e.pointIndices,i.points=Array.isArray(this.props.data)?e.pointIndices.map(e=>this.props.data[e]):[])),t.object=i}return t}}ScreenGridLayer.layerName="ScreenGridLayer",ScreenGridLayer.defaultProps=Mc;const Lc=ScreenGridLayer;class AttributeWithScale{constructor(e,t){this.props={scaleType:"linear",lowerPercentile:0,upperPercentile:100},this.domain=null,this.cutoff=null,this.input=e,this.inputLength=t,this.attribute=e}getScalePercentile(){if(!this._percentile){const e=Ic(this.input,this.inputLength);this._percentile=function(e,t=100){const n=Array.from(e).filter(Number.isFinite).sort(Oc);let i=0;const r=Math.max(1,t),s=new Array(r-1);for(;++i<r;)s[i-1]=Bc(n,i/r);return{attribute:{value:e.map(e=>Number.isFinite(e)?function(e,t){let n=0,i=e.length;for(;n<i;){const r=n+i>>>1;e[r]>t?i=r:n=r+1}return n}(s,e):NaN),type:"float32",size:1},domain:s}}(e)}return this._percentile}getScaleOrdinal(){if(!this._ordinal){const e=Ic(this.input,this.inputLength);this._ordinal=function(e){const t=new Set;for(const n of e)Number.isFinite(n)&&t.add(n);const n=Array.from(t).sort(),i=new Map;for(let e=0;e<n.length;e++)i.set(n[e],e);return{attribute:{value:e.map(e=>Number.isFinite(e)?i.get(e):NaN),type:"float32",size:1},domain:n}}(e)}return this._ordinal}getCutoff({scaleType:e,lowerPercentile:t,upperPercentile:n}){if("quantile"===e)return[t,n-1];if(t>0||n<100){const{domain:i}=this.getScalePercentile();let r=i[Math.floor(t)-1]??-1/0,s=i[Math.floor(n)-1]??1/0;if("ordinal"===e){const{domain:e}=this.getScaleOrdinal();r=e.findIndex(e=>e>=r),s=e.findIndex(e=>e>s)-1,-2===s&&(s=e.length-1)}return[r,s]}return null}update(e){const t=this.props;if(e.scaleType!==t.scaleType)switch(e.scaleType){case"quantile":{const{attribute:e}=this.getScalePercentile();this.attribute=e,this.domain=[0,99];break}case"ordinal":{const{attribute:e,domain:t}=this.getScaleOrdinal();this.attribute=e,this.domain=[0,t.length-1];break}default:this.attribute=this.input,this.domain=null}return e.scaleType===t.scaleType&&e.lowerPercentile===t.lowerPercentile&&e.upperPercentile===t.upperPercentile||(this.cutoff=this.getCutoff(e)),this.props=e,this}}function Ic(e,t){const n=(e.stride??4)/4,i=(e.offset??0)/4;let r=e.value;if(!r){const i=e.buffer?.readSyncWebGL(0,4*n*t);i&&(r=new Float32Array(i.buffer),e.value=r)}if(1===n)return r.subarray(0,t);const s=new Float32Array(t);for(let e=0;e<t;e++)s[e]=r[e*n+i];return s}function Oc(e,t){return e-t}function Bc(e,t){const n=e.length;if(t<=0||n<2)return e[0];if(t>=1)return e[n-1];const i=(n-1)*t,r=Math.floor(i),s=e[r];return s+(e[r+1]-s)*(i-r)}function Nc({dataBounds:e,getBinId:t,padding:n=0}){const i=[e[0],e[1],[e[0][0],e[1][1]],[e[1][0],e[0][1]]].map(e=>t(e)),r=Math.min(...i.map(e=>e[0]))-n,s=Math.min(...i.map(e=>e[1]))-n;return[[r,Math.max(...i.map(e=>e[0]))+n+1],[s,Math.max(...i.map(e=>e[1]))+n+1]]}const kc=Math.PI/3,Fc=2*Math.sin(kc),Dc=1.5,Uc=Array.from({length:6},(e,t)=>{const n=t*kc;return[Math.sin(n),-Math.cos(n)]});function Vc([e,t],n){let i=Math.round(t=t/n/Dc),r=Math.round(e=e/n/Fc-(1&i)/2);const s=t-i;if(3*Math.abs(s)>1){const n=e-r,o=r+(e<r?-1:1)/2,a=i+(t<i?-1:1),l=e-o,c=t-a;n*n+s*s>l*l+c*c&&(r=o+(1&i?1:-1)/2,i=a)}return[r,i]}const zc=`\nconst vec2 DIST = vec2(${Fc}, 1.5);\n\nivec2 pointToHexbin(vec2 p, float radius) {\n p /= radius * DIST;\n float pj = round(p.y);\n float pjm2 = mod(pj, 2.0);\n p.x -= pjm2 * 0.5;\n float pi = round(p.x);\n vec2 d1 = p - vec2(pi, pj);\n\n if (abs(d1.y) * 3. > 1.) {\n vec2 v2 = step(0.0, d1) - 0.5;\n v2.y *= 2.0;\n vec2 d2 = d1 - v2;\n if (dot(d1, d1) > dot(d2, d2)) {\n pi += v2.x + pjm2 - 0.5;\n pj += v2.y;\n }\n }\n return ivec2(pi, pj);\n}\n`;function Gc([e,t],n){return[(e+(1&t)/2)*n*Fc,t*n*Dc]}const jc=`#version 300 es\n#define SHADER_NAME hexagon-cell-layer-vertex-shader\nin vec3 positions;\nin vec3 normals;\nin vec2 instancePositions;\nin float instanceElevationValues;\nin float instanceColorValues;\nin vec3 instancePickingColors;\nuniform sampler2D colorRange;\nout vec4 vColor;\n${`\nconst vec2 DIST = vec2(${Fc}, 1.5);\n\nvec2 hexbinCentroid(vec2 binId, float radius) {\n binId.x += fract(binId.y * 0.5);\n return binId * DIST * radius;\n}\n`}\nfloat interp(float value, vec2 domain, vec2 range) {\nfloat r = min(max((value - domain.x) / (domain.y - domain.x), 0.), 1.);\nreturn mix(range.x, range.y, r);\n}\nvec4 interp(float value, vec2 domain, sampler2D range) {\nfloat r = (value - domain.x) / (domain.y - domain.x);\nreturn texture(range, vec2(r, 0.5));\n}\nvoid main(void) {\ngeometry.pickingColor = instancePickingColors;\nif (isnan(instanceColorValues) ||\ninstanceColorValues < hexagon.colorDomain.z ||\ninstanceColorValues > hexagon.colorDomain.w ||\ninstanceElevationValues < hexagon.elevationDomain.z ||\ninstanceElevationValues > hexagon.elevationDomain.w\n) {\ngl_Position = vec4(0.);\nreturn;\n}\nvec2 commonPosition = hexbinCentroid(instancePositions, column.radius) + (hexagon.originCommon - project.commonOrigin.xy);\ncommonPosition += positions.xy * column.radius * column.coverage;\ngeometry.position = vec4(commonPosition, 0.0, 1.0);\ngeometry.normal = project_normal(normals);\nfloat elevation = 0.0;\nif (column.extruded) {\nelevation = interp(instanceElevationValues, hexagon.elevationDomain.xy, hexagon.elevationRange);\nelevation = project_size(elevation);\ngeometry.position.z = (positions.z + 1.0) / 2.0 * elevation;\n}\ngl_Position = project_common_position_to_clipspace(geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvColor = interp(instanceColorValues, hexagon.colorDomain.xy, colorRange);\nvColor.a *= layer.opacity;\nif (column.extruded) {\nvColor.rgb = lighting_getLightColor(vColor.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n`,Hc={name:"hexagon",vs:"layout(std140) uniform hexagonUniforms {\n vec4 colorDomain;\n vec4 elevationDomain;\n vec2 elevationRange;\n vec2 originCommon;\n} hexagon;\n",uniformTypes:{colorDomain:"vec4<f32>",elevationDomain:"vec4<f32>",elevationRange:"vec2<f32>",originCommon:"vec2<f32>"}};class HexagonCellLayer extends Sa{getShaders(){const e=super.getShaders();return e.modules.push(Hc),{...e,vs:jc}}initializeState(){super.initializeState();const e=this.getAttributeManager();e.remove(["instanceElevations","instanceFillColors","instanceLineColors","instanceStrokeWidths"]),e.addInstanced({instancePositions:{size:2,type:"float32",accessor:"getBin"},instanceColorValues:{size:1,type:"float32",accessor:"getColorValue"},instanceElevationValues:{size:1,type:"float32",accessor:"getElevationValue"}})}updateState(e){super.updateState(e);const{props:t,oldProps:n}=e,i=this.state.fillModel;if(n.colorRange!==t.colorRange){this.state.colorTexture?.destroy(),this.state.colorTexture=Sc(this.context.device,t.colorRange,t.colorScaleType);const e={colorRange:this.state.colorTexture};i.shaderInputs.setProps({hexagon:e})}else n.colorScaleType!==t.colorScaleType&&Ec(this.state.colorTexture,t.colorScaleType)}finalizeState(e){super.finalizeState(e),this.state.colorTexture?.destroy()}draw({uniforms:e}){const{radius:t,hexOriginCommon:n,elevationRange:i,elevationScale:r,extruded:s,coverage:o,colorDomain:a,elevationDomain:l}=this.props,c=this.props.colorCutoff||[-1/0,1/0],A=this.props.elevationCutoff||[-1/0,1/0],u=this.state.fillModel;u.setVertexCount(this.state.fillVertexCount);const h={colorDomain:[Math.max(a[0],c[0]),Math.min(a[1],c[1]),Math.max(a[0]-1,c[0]),Math.min(a[1]+1,c[1])],elevationDomain:[Math.max(l[0],A[0]),Math.min(l[1],A[1]),Math.max(l[0]-1,A[0]),Math.min(l[1]+1,A[1])],elevationRange:[i[0]*r,i[1]*r],originCommon:n};u.shaderInputs.setProps({column:{extruded:s,coverage:o,radius:t},hexagon:h}),u.draw(this.context.renderPass)}}HexagonCellLayer.layerName="HexagonCellLayer";const Wc=HexagonCellLayer,qc={name:"binOptions",vs:"layout(std140) uniform binOptionsUniforms {\n vec2 hexOriginCommon;\n float radiusCommon;\n} binOptions;\n",uniformTypes:{hexOriginCommon:"vec2<f32>",radiusCommon:"f32"}};function Kc(){}const Qc={gpuAggregation:!0,colorDomain:null,colorRange:wc,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:Kc,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationScale:{type:"number",min:0,value:1},elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScaleType:"linear",onSetElevationDomain:Kc,radius:{type:"number",min:1,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:e=>e.position},hexagonAggregator:{type:"function",optional:!0,value:null},extruded:!1,material:!0};class HexagonLayer extends yc{getAggregatorType(){const{gpuAggregation:e,hexagonAggregator:t,getColorValue:n,getElevationValue:i}=this.props;return e&&(t||n||i)?(Ie.A.warn("Features not supported by GPU aggregation, falling back to CPU")(),"cpu"):e&&WebGLAggregator.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(e){if("cpu"===e){const{hexagonAggregator:e,radius:t}=this.props;return new CPUAggregator({dimensions:2,getBin:{sources:["positions"],getValue:({positions:n},i,r)=>{if(e)return e(n,t);const s=this.state.aggregatorViewport.projectPosition(n),{radiusCommon:o,hexOriginCommon:a}=r;return Vc([s[0]-a[0],s[1]-a[1]],o)}},getValue:[{sources:["colorWeights"],getValue:({colorWeights:e})=>e},{sources:["elevationWeights"],getValue:({elevationWeights:e})=>e}]})}return new WebGLAggregator(this.context.device,{dimensions:2,channelCount:2,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[Xs,qc],vs:`\n in vec3 positions;\n in vec3 positions64Low;\n in float colorWeights;\n in float elevationWeights;\n \n ${zc}\n\n void getBin(out ivec2 binId) {\n vec3 positionCommon = project_position(positions, positions64Low);\n binId = pointToHexbin(positionCommon.xy, binOptions.radiusCommon);\n }\n void getValue(out vec2 value) {\n value = vec2(colorWeights, elevationWeights);\n }\n `})})}initializeState(){super.initializeState();this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},colorWeights:{size:1,accessor:"getColorWeight"},elevationWeights:{size:1,accessor:"getElevationWeight"}})}updateState(e){const t=super.updateState(e),{props:n,oldProps:i,changeFlags:r}=e,{aggregator:s}=this.state;if(!r.dataChanged&&this.state.dataAsArray||!n.getColorValue&&!n.getElevationValue||(this.state.dataAsArray=Array.from(br(n.data).iterable)),t||r.dataChanged||n.radius!==i.radius||n.getColorValue!==i.getColorValue||n.getElevationValue!==i.getElevationValue||n.colorAggregation!==i.colorAggregation||n.elevationAggregation!==i.elevationAggregation){this._updateBinOptions();const{radiusCommon:e,hexOriginCommon:t,binIdRange:i,dataAsArray:r}=this.state;if(s.setProps({binIdRange:i,pointCount:this.getNumInstances(),operations:[n.colorAggregation,n.elevationAggregation],binOptions:{radiusCommon:e,hexOriginCommon:t},onUpdate:this._onAggregationUpdate.bind(this)}),r){const{getColorValue:e,getElevationValue:t}=this.props;s.setProps({customOperations:[e&&(t=>e(t.map(e=>r[e]),{indices:t,data:n.data})),t&&(e=>t(e.map(e=>r[e]),{indices:e,data:n.data}))]})}}return r.updateTriggersChanged&&r.updateTriggersChanged.getColorValue&&s.setNeedsUpdate(0),r.updateTriggersChanged&&r.updateTriggersChanged.getElevationValue&&s.setNeedsUpdate(1),t}_updateBinOptions(){const e=this.getBounds();let t=1,n=[0,0],i=[[0,1],[0,1]],r=this.context.viewport;if(e&&Number.isFinite(e[0][0])){let s=[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2];const{radius:o}=this.props,{unitsPerMeter:a}=r.getDistanceScales(s);t=a[0]*o;const l=Vc(r.projectFlat(s),t);s=r.unprojectFlat(Gc(l,t));const c=r.constructor;r=r.isGeospatial?new c({longitude:s[0],latitude:s[1],zoom:12}):new hn.A({position:[s[0],s[1],0],zoom:12}),n=[Math.fround(r.center[0]),Math.fround(r.center[1])],i=Nc({dataBounds:e,getBinId:e=>{const i=r.projectFlat(e);return i[0]-=n[0],i[1]-=n[1],Vc(i,t)},padding:1})}this.setState({radiusCommon:t,hexOriginCommon:n,binIdRange:i,aggregatorViewport:r})}draw(e){e.shaderModuleProps.project&&(e.shaderModuleProps.project.viewport=this.state.aggregatorViewport),super.draw(e)}_onAggregationUpdate({channel:e}){const t=this.getCurrentLayer().props,{aggregator:n}=this.state;if(0===e){const e=n.getResult(0);this.setState({colors:new AttributeWithScale(e,n.binCount)}),t.onSetColorDomain(n.getResultDomain(0))}else if(1===e){const e=n.getResult(1);this.setState({elevations:new AttributeWithScale(e,n.binCount)}),t.onSetElevationDomain(n.getResultDomain(1))}}onAttributeChange(e){const{aggregator:t}=this.state;switch(e){case"positions":t.setNeedsUpdate(),this._updateBinOptions();const{radiusCommon:e,hexOriginCommon:n,binIdRange:i}=this.state;t.setProps({binIdRange:i,binOptions:{radiusCommon:e,hexOriginCommon:n}});break;case"colorWeights":t.setNeedsUpdate(0);break;case"elevationWeights":t.setNeedsUpdate(1)}}renderLayers(){const{aggregator:e,radiusCommon:t,hexOriginCommon:n}=this.state,{elevationScale:i,colorRange:r,elevationRange:s,extruded:o,coverage:a,material:l,transitions:c,colorScaleType:A,lowerPercentile:u,upperPercentile:h,colorDomain:d,elevationScaleType:f,elevationLowerPercentile:p,elevationUpperPercentile:g,elevationDomain:m}=this.props,b=this.getSubLayerClass("cells",Wc),_=e.getBins(),v=this.state.colors?.update({scaleType:A,lowerPercentile:u,upperPercentile:h}),y=this.state.elevations?.update({scaleType:f,lowerPercentile:p,upperPercentile:g});return v&&y?new b(this.getSubLayerProps({id:"cells"}),{data:{length:e.binCount,attributes:{getBin:_,getColorValue:v.attribute,getElevationValue:y.attribute}},dataComparator:(e,t)=>e.length===t.length,updateTriggers:{getBin:[_],getColorValue:[v.attribute],getElevationValue:[y.attribute]},diskResolution:6,vertices:Uc,radius:t,hexOriginCommon:n,elevationScale:i,colorRange:r,colorScaleType:A,elevationRange:s,extruded:o,coverage:a,material:l,colorDomain:v.domain||d||e.getResultDomain(0),elevationDomain:y.domain||m||e.getResultDomain(1),colorCutoff:v.cutoff,elevationCutoff:y.cutoff,transitions:c&&{getFillColor:c.getColorValue||c.getColorWeight,getElevation:c.getElevationValue||c.getElevationWeight},extensions:[]}):null}getPickingInfo(e){const t=e.info,{index:n}=t;if(n>=0){const e=this.state.aggregator.getBin(n);let i;if(e){const t=Gc(e.id,this.state.radiusCommon),n=this.context.viewport.unprojectFlat(t);i={col:e.id[0],row:e.id[1],position:n,colorValue:e.value[0],elevationValue:e.value[1],count:e.count},e.pointIndices&&(i.pointIndices=e.pointIndices,i.points=Array.isArray(this.props.data)?e.pointIndices.map(e=>this.props.data[e]):[])}t.object=i}return t}}HexagonLayer.layerName="HexagonLayer",HexagonLayer.defaultProps=Qc;const Xc=HexagonLayer,$c=.5,Zc=1/6,Yc={N:[0,$c],E:[$c,0],S:[0,-.5],W:[-.5,0],NE:[$c,$c],NW:[-.5,$c],SE:[$c,-.5],SW:[-.5,-.5]},Jc=[Yc.W,Yc.SW,Yc.S],eA=[Yc.S,Yc.SE,Yc.E],tA=[Yc.E,Yc.NE,Yc.N],nA=[Yc.NW,Yc.W,Yc.N],iA=[[-.5,Zc],[-.5,-Zc],[-Zc,-.5],[Zc,-.5]],rA=[[-Zc,-.5],[Zc,-.5],[$c,-Zc],[$c,Zc]],sA=[[$c,-Zc],[$c,Zc],[Zc,$c],[-Zc,$c]],oA=[[-.5,Zc],[-.5,-Zc],[Zc,$c],[-Zc,$c]],aA=[Yc.W,Yc.SW,Yc.SE,Yc.E],lA=[Yc.S,Yc.SE,Yc.NE,Yc.N],cA=[Yc.NW,Yc.W,Yc.E,Yc.NE],AA=[Yc.NW,Yc.SW,Yc.S,Yc.N],uA=[[-.5,Zc],[-.5,-Zc],[$c,-Zc],[$c,Zc]],hA=[[-Zc,-.5],[Zc,-.5],[Zc,$c],[-Zc,$c]],dA=[Yc.NW,Yc.SW,Yc.SE,Yc.NE],fA=[Yc.NW,Yc.SW,Yc.SE,Yc.E,Yc.N],pA=[Yc.W,Yc.SW,Yc.SE,Yc.NE,Yc.N],gA=[Yc.NW,Yc.W,Yc.S,Yc.SE,Yc.NE],mA=[Yc.NW,Yc.SW,Yc.S,Yc.E,Yc.NE],bA=[Yc.NW,Yc.W,[$c,-Zc],[$c,Zc],Yc.N],_A=[[-Zc,-.5],[Zc,-.5],Yc.E,Yc.NE,Yc.N],vA=[[-.5,Zc],[-.5,-Zc],Yc.S,Yc.SE,Yc.E],yA=[Yc.W,Yc.SW,Yc.S,[Zc,$c],[-Zc,$c]],wA=[Yc.NW,Yc.W,[-Zc,-.5],[Zc,-.5],Yc.N],xA=[[-.5,Zc],[-.5,-Zc],Yc.E,Yc.NE,Yc.N],TA=[Yc.S,Yc.SE,Yc.E,[Zc,$c],[-Zc,$c]],EA=[Yc.W,Yc.SW,Yc.S,[$c,-Zc],[$c,Zc]],SA=[Yc.W,Yc.SW,Yc.SE,Yc.E,[Zc,$c],[-Zc,$c]],CA=[[-.5,Zc],[-.5,-Zc],Yc.S,Yc.SE,Yc.NE,Yc.N],PA=[Yc.NW,Yc.W,[-Zc,-.5],[Zc,-.5],Yc.E,Yc.NE],RA=[Yc.NW,Yc.SW,Yc.S,[$c,-Zc],[$c,Zc],Yc.N],MA=[Yc.W,Yc.SW,Yc.S,Yc.E,Yc.NE,Yc.N],LA=[Yc.NW,Yc.W,Yc.S,Yc.SE,Yc.E,Yc.N],IA=[[-.5,Zc],[-.5,-Zc],[-Zc,-.5],[Zc,-.5],Yc.E,Yc.NE,Yc.N],OA=[Yc.W,Yc.SW,Yc.S,[$c,-Zc],[$c,Zc],[Zc,$c],[-Zc,$c]],BA=[Yc.NW,Yc.W,[-Zc,-.5],[Zc,-.5],[$c,-Zc],[$c,Zc],Yc.N],NA=[[-.5,Zc],[-.5,-Zc],Yc.S,Yc.SE,Yc.E,[Zc,$c],[-Zc,$c]],kA=[[-.5,Zc],[-.5,-Zc],[-Zc,-.5],[Zc,-.5],[$c,-Zc],[$c,Zc],[Zc,$c],[-Zc,$c]],FA={0:[],1:[[Yc.W,Yc.S]],2:[[Yc.S,Yc.E]],3:[[Yc.W,Yc.E]],4:[[Yc.N,Yc.E]],5:{0:[[Yc.W,Yc.S],[Yc.N,Yc.E]],1:[[Yc.W,Yc.N],[Yc.S,Yc.E]]},6:[[Yc.N,Yc.S]],7:[[Yc.W,Yc.N]],8:[[Yc.W,Yc.N]],9:[[Yc.N,Yc.S]],10:{0:[[Yc.W,Yc.N],[Yc.S,Yc.E]],1:[[Yc.W,Yc.S],[Yc.N,Yc.E]]},11:[[Yc.N,Yc.E]],12:[[Yc.W,Yc.E]],13:[[Yc.S,Yc.E]],14:[[Yc.W,Yc.S]],15:[]};function DA(e){return parseInt(e,4)}const UA={[DA("0000")]:[],[DA("2222")]:[],[DA("2221")]:[Jc],[DA("2212")]:[eA],[DA("2122")]:[tA],[DA("1222")]:[nA],[DA("0001")]:[Jc],[DA("0010")]:[eA],[DA("0100")]:[tA],[DA("1000")]:[nA],[DA("2220")]:[iA],[DA("2202")]:[rA],[DA("2022")]:[sA],[DA("0222")]:[oA],[DA("0002")]:[iA],[DA("0020")]:[rA],[DA("0200")]:[sA],[DA("2000")]:[oA],[DA("0011")]:[aA],[DA("0110")]:[lA],[DA("1100")]:[cA],[DA("1001")]:[AA],[DA("2211")]:[aA],[DA("2112")]:[lA],[DA("1122")]:[cA],[DA("1221")]:[AA],[DA("2200")]:[uA],[DA("2002")]:[hA],[DA("0022")]:[uA],[DA("0220")]:[hA],[DA("1111")]:[dA],[DA("1211")]:[fA],[DA("2111")]:[pA],[DA("1112")]:[gA],[DA("1121")]:[mA],[DA("1011")]:[fA],[DA("0111")]:[pA],[DA("1110")]:[gA],[DA("1101")]:[mA],[DA("1200")]:[bA],[DA("0120")]:[_A],[DA("0012")]:[vA],[DA("2001")]:[yA],[DA("1022")]:[bA],[DA("2102")]:[_A],[DA("2210")]:[vA],[DA("0221")]:[yA],[DA("1002")]:[wA],[DA("2100")]:[xA],[DA("0210")]:[TA],[DA("0021")]:[EA],[DA("1220")]:[wA],[DA("0122")]:[xA],[DA("2012")]:[TA],[DA("2201")]:[EA],[DA("0211")]:[SA],[DA("2110")]:[CA],[DA("1102")]:[PA],[DA("1021")]:[RA],[DA("2011")]:[SA],[DA("0112")]:[CA],[DA("1120")]:[PA],[DA("1201")]:[RA],[DA("2101")]:[MA],[DA("0121")]:[MA],[DA("1012")]:[LA],[DA("1210")]:[LA],[DA("0101")]:{0:[Jc,tA],1:[MA],2:[MA]},[DA("1010")]:{0:[nA,eA],1:[LA],2:[LA]},[DA("2121")]:{0:[MA],1:[MA],2:[Jc,tA]},[DA("1212")]:{0:[LA],1:[LA],2:[nA,eA]},[DA("2120")]:{0:[IA],1:[IA],2:[iA,tA]},[DA("2021")]:{0:[OA],1:[OA],2:[Jc,sA]},[DA("1202")]:{0:[BA],1:[BA],2:[nA,rA]},[DA("0212")]:{0:[NA],1:[NA],2:[eA,oA]},[DA("0102")]:{0:[iA,tA],1:[IA],2:[IA]},[DA("0201")]:{0:[Jc,sA],1:[OA],2:[OA]},[DA("1020")]:{0:[nA,rA],1:[BA],2:[BA]},[DA("2010")]:{0:[eA,oA],1:[NA],2:[NA]},[DA("2020")]:{0:[oA,rA],1:[kA],2:[iA,sA]},[DA("0202")]:{0:[sA,iA],1:[kA],2:[oA,rA]}};function VA(e,t){return Number.isNaN(e)?0:Array.isArray(t)?e<t[0]?0:e<t[1]?1:2:e>=t?1:0}function zA(e){const{x:t,y:n,xRange:i,yRange:r,getValue:s,threshold:o}=e,a=t<i[0],l=t>=i[1]-1,c=n<r[0],A=n>=r[1]-1,u=a||l||c||A;let h,d,f,p,g=0;if(a||A)f=0;else{const e=s(t,n+1);f=VA(e,o),g+=e}if(l||A)p=0;else{const e=s(t+1,n+1);p=VA(e,o),g+=e}if(l||c)d=0;else{const e=s(t+1,n);d=VA(e,o),g+=e}if(a||c)h=0;else{const e=s(t,n);h=VA(e,o),g+=e}let m=-1;Number.isFinite(o)&&(m=f<<3|p<<2|d<<1|h),Array.isArray(o)&&(m=f<<6|p<<4|d<<2|h);let b=0;return u||(b=VA(g/4,o)),{code:m,meanCode:b}}function GA(e){const{x:t,y:n,z:i,code:r,meanCode:s}=e;let o=UA[r];Array.isArray(o)||(o=o[s]);const a=t+1,l=n+1,c=[];return o.forEach(e=>{const t=[];e.forEach(e=>{const n=a+e[0],r=l+e[1];t.push([n,r,i])}),c.push(t)}),c}function jA(e){const{x:t,y:n,z:i,code:r,meanCode:s}=e;let o=FA[r];Array.isArray(o)||(o=o[s]);const a=t+1,l=n+1,c=[];return o.forEach(e=>{e.forEach(e=>{const t=a+e[0],n=l+e[1];c.push([t,n,i])})}),c}function HA(e){const{aggregator:t,binIdRange:n,channel:i}=e;if(t instanceof WebGLAggregator){const e=t.getResult(i)?.buffer;if(e){return function(e,t){const[[n,i],[r,s]]=t,o=i-n,a=s-r;return(t,i)=>(i-=r,(t-=n)<0||t>=o||i<0||i>=a?NaN:e[i*o+t])}(new Float32Array(e.readSyncWebGL().buffer),n)}}if(t instanceof CPUAggregator){const e=t.getResult(i)?.value,n=t.getBins()?.value;if(n&&e)return function(e,t,n){const i={};for(let r=0;r<n;r++){const n=t[2*r],s=t[2*r+1];i[n]=i[n]||{},i[n][s]=e[r]}return(e,t)=>i[e]?.[t]??NaN}(e,n,t.binCount)}return null}const WA={name:"binOptions",vs:"layout(std140) uniform binOptionsUniforms {\n vec2 cellOriginCommon;\n vec2 cellSizeCommon;\n} binOptions;\n",uniformTypes:{cellOriginCommon:"vec2<f32>",cellSizeCommon:"vec2<f32>"}},qA=[255,255,255,255];class GridLayer extends yc{getAggregatorType(){return this.props.gpuAggregation&&WebGLAggregator.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(e){return"cpu"===e?new CPUAggregator({dimensions:2,getBin:{sources:["positions"],getValue:({positions:e},t,n)=>{const i=this.state.aggregatorViewport.projectPosition(e),{cellSizeCommon:r,cellOriginCommon:s}=n;return[Math.floor((i[0]-s[0])/r[0]),Math.floor((i[1]-s[1])/r[1])]}},getValue:[{sources:["counts"],getValue:({counts:e})=>e}],onUpdate:this._onAggregationUpdate.bind(this)}):new WebGLAggregator(this.context.device,{dimensions:2,channelCount:1,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[Xs,WA],vs:"\n in vec3 positions;\n in vec3 positions64Low;\n in float counts;\n\n void getBin(out ivec2 binId) {\n vec3 positionCommon = project_position(positions, positions64Low);\n vec2 gridCoords = floor(positionCommon.xy / binOptions.cellSizeCommon);\n binId = ivec2(gridCoords);\n }\n void getValue(out float value) {\n value = counts;\n }\n "}),onUpdate:this._onAggregationUpdate.bind(this)})}initializeState(){super.initializeState();this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},counts:{size:1,accessor:"getWeight"}})}updateState(e){const t=super.updateState(e),{props:n,oldProps:i,changeFlags:r}=e,{aggregator:s}=this.state;if(t||r.dataChanged||n.cellSize!==i.cellSize||!(0,dn.b)(n.gridOrigin,i.gridOrigin,1)||n.aggregation!==i.aggregation){this._updateBinOptions();const{cellSizeCommon:e,cellOriginCommon:t,binIdRange:i}=this.state;s.setProps({binIdRange:i,pointCount:this.getNumInstances(),operations:[n.aggregation],binOptions:{cellSizeCommon:e,cellOriginCommon:t}})}return(0,dn.b)(i.contours,n.contours,2)||this.setState({contourData:null}),t}_updateBinOptions(){const e=this.getBounds(),t=[1,1];let n=[0,0],i=[[0,1],[0,1]],r=this.context.viewport;if(e&&Number.isFinite(e[0][0])){let s=[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2];const{cellSize:o,gridOrigin:a}=this.props,{unitsPerMeter:l}=r.getDistanceScales(s);t[0]=l[0]*o,t[1]=l[1]*o;const c=r.projectFlat(s);n=[Math.floor((c[0]-a[0])/t[0])*t[0]+a[0],Math.floor((c[1]-a[1])/t[1])*t[1]+a[1]],s=r.unprojectFlat(n);const A=r.constructor;r=r.isGeospatial?new A({longitude:s[0],latitude:s[1],zoom:12}):new hn.A({position:[s[0],s[1],0],zoom:12}),n=[Math.fround(r.center[0]),Math.fround(r.center[1])],i=Nc({dataBounds:e,getBinId:e=>{const i=r.projectFlat(e);return[Math.floor((i[0]-n[0])/t[0]),Math.floor((i[1]-n[1])/t[1])]}})}this.setState({cellSizeCommon:t,cellOriginCommon:n,binIdRange:i,aggregatorViewport:r})}draw(e){e.shaderModuleProps.project&&(e.shaderModuleProps.project.viewport=this.state.aggregatorViewport),super.draw(e)}_onAggregationUpdate(){const{aggregator:e,binIdRange:t}=this.state;this.setState({aggregatedValueReader:HA({aggregator:e,binIdRange:t,channel:0}),contourData:null})}_getContours(){const{aggregatedValueReader:e}=this.state;if(!e)return null;if(!this.state.contourData){const{binIdRange:t}=this.state,{contours:n}=this.props,i=function({contours:e,getValue:t,xRange:n,yRange:i}){const r=[],s=[];let o=0,a=0;for(let l=0;l<e.length;l++){const c=e[l],A=c.zIndex??l,{threshold:u}=c;for(let e=n[0]-1;e<n[1];e++)for(let l=i[0]-1;l<i[1];l++){const{code:h,meanCode:d}=zA({getValue:t,threshold:u,x:e,y:l,xRange:n,yRange:i}),f={x:e,y:l,z:A,code:h,meanCode:d};if(Array.isArray(u)){const e=GA(f);for(const t of e)s[a++]={vertices:t,contour:c}}else{const e=jA(f);e.length>0&&(r[o++]={vertices:e,contour:c})}}}return{lines:r,polygons:s}}({contours:n,getValue:e,xRange:t[0],yRange:t[1]});this.state.contourData=i}return this.state.contourData}onAttributeChange(e){const{aggregator:t}=this.state;switch(e){case"positions":t.setNeedsUpdate(),this._updateBinOptions();const{cellSizeCommon:e,cellOriginCommon:n,binIdRange:i}=this.state;t.setProps({binIdRange:i,binOptions:{cellSizeCommon:e,cellOriginCommon:n}});break;case"counts":t.setNeedsUpdate(0)}}renderLayers(){const e=this._getContours();if(!e)return null;const{lines:t,polygons:n}=e,{zOffset:i}=this.props,{cellOriginCommon:r,cellSizeCommon:s}=this.state,o=this.getSubLayerClass("lines",Za),a=this.getSubLayerClass("bands",ml),l=(new Rn.k).translate([r[0],r[1],0]).scale([s[0],s[1],i]);return[t&&t.length>0&&new o(this.getSubLayerProps({id:"lines"}),{data:t,coordinateSystem:Mn.rf.CARTESIAN,modelMatrix:l,getPath:e=>e.vertices,getColor:e=>e.contour.color??qA,getWidth:e=>e.contour.strokeWidth??1,widthUnits:"pixels"}),n&&n.length>0&&new a(this.getSubLayerProps({id:"bands"}),{data:n,coordinateSystem:Mn.rf.CARTESIAN,modelMatrix:l,getPolygon:e=>e.vertices,getFillColor:e=>e.contour.color??qA})]}getPickingInfo(e){const t=e.info,{object:n}=t;return n&&(t.object={contour:n.contour}),t}}GridLayer.layerName="ContourLayer",GridLayer.defaultProps={cellSize:{type:"number",min:1,value:1e3},gridOrigin:{type:"array",compare:!0,value:[0,0]},getPosition:{type:"accessor",value:e=>e.position},getWeight:{type:"accessor",value:1},gpuAggregation:!0,aggregation:"SUM",contours:{type:"object",value:[{threshold:1}],optional:!0,compare:3},zOffset:.005};const KA=GridLayer,QA={name:"grid",vs:"layout(std140) uniform gridUniforms {\n vec4 colorDomain;\n vec4 elevationDomain;\n vec2 elevationRange;\n vec2 originCommon;\n vec2 sizeCommon;\n} grid;\n",uniformTypes:{colorDomain:"vec4<f32>",elevationDomain:"vec4<f32>",elevationRange:"vec2<f32>",originCommon:"vec2<f32>",sizeCommon:"vec2<f32>"}};class grid_cell_layer_GridCellLayer extends Sa{getShaders(){const e=super.getShaders();return e.modules.push(QA),{...e,vs:"#version 300 es\n#define SHADER_NAME grid-cell-layer-vertex-shader\nin vec3 positions;\nin vec3 normals;\nin vec2 instancePositions;\nin float instanceElevationValues;\nin float instanceColorValues;\nin vec3 instancePickingColors;\nuniform sampler2D colorRange;\nout vec4 vColor;\nfloat interp(float value, vec2 domain, vec2 range) {\nfloat r = min(max((value - domain.x) / (domain.y - domain.x), 0.), 1.);\nreturn mix(range.x, range.y, r);\n}\nvec4 interp(float value, vec2 domain, sampler2D range) {\nfloat r = (value - domain.x) / (domain.y - domain.x);\nreturn texture(range, vec2(r, 0.5));\n}\nvoid main(void) {\ngeometry.pickingColor = instancePickingColors;\nif (isnan(instanceColorValues) ||\ninstanceColorValues < grid.colorDomain.z ||\ninstanceColorValues > grid.colorDomain.w ||\ninstanceElevationValues < grid.elevationDomain.z ||\ninstanceElevationValues > grid.elevationDomain.w\n) {\ngl_Position = vec4(0.);\nreturn;\n}\nvec2 commonPosition = (instancePositions + (positions.xy + 1.0) / 2.0 * column.coverage) * grid.sizeCommon + grid.originCommon - project.commonOrigin.xy;\ngeometry.position = vec4(commonPosition, 0.0, 1.0);\ngeometry.normal = project_normal(normals);\nfloat elevation = 0.0;\nif (column.extruded) {\nelevation = interp(instanceElevationValues, grid.elevationDomain.xy, grid.elevationRange);\nelevation = project_size(elevation);\ngeometry.position.z = (positions.z + 1.0) / 2.0 * elevation;\n}\ngl_Position = project_common_position_to_clipspace(geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvColor = interp(instanceColorValues, grid.colorDomain.xy, colorRange);\nvColor.a *= layer.opacity;\nif (column.extruded) {\nvColor.rgb = lighting_getLightColor(vColor.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n"}}initializeState(){super.initializeState();const e=this.getAttributeManager();e.remove(["instanceElevations","instanceFillColors","instanceLineColors","instanceStrokeWidths"]),e.addInstanced({instancePositions:{size:2,type:"float32",accessor:"getBin"},instanceColorValues:{size:1,type:"float32",accessor:"getColorValue"},instanceElevationValues:{size:1,type:"float32",accessor:"getElevationValue"}})}updateState(e){super.updateState(e);const{props:t,oldProps:n}=e,i=this.state.fillModel;if(n.colorRange!==t.colorRange){this.state.colorTexture?.destroy(),this.state.colorTexture=Sc(this.context.device,t.colorRange,t.colorScaleType);const e={colorRange:this.state.colorTexture};i.shaderInputs.setProps({grid:e})}else n.colorScaleType!==t.colorScaleType&&Ec(this.state.colorTexture,t.colorScaleType)}finalizeState(e){super.finalizeState(e),this.state.colorTexture?.destroy()}_updateGeometry(){const e=new CubeGeometry;this.state.fillModel.setGeometry(e)}draw({uniforms:e}){const{cellOriginCommon:t,cellSizeCommon:n,elevationRange:i,elevationScale:r,extruded:s,coverage:o,colorDomain:a,elevationDomain:l}=this.props,c=this.props.colorCutoff||[-1/0,1/0],A=this.props.elevationCutoff||[-1/0,1/0],u=this.state.fillModel,h={colorDomain:[Math.max(a[0],c[0]),Math.min(a[1],c[1]),Math.max(a[0]-1,c[0]),Math.min(a[1]+1,c[1])],elevationDomain:[Math.max(l[0],A[0]),Math.min(l[1],A[1]),Math.max(l[0]-1,A[0]),Math.min(l[1]+1,A[1])],elevationRange:[i[0]*r,i[1]*r],originCommon:t,sizeCommon:n};u.shaderInputs.setProps({column:{extruded:s,coverage:o},grid:h}),u.draw(this.context.renderPass)}}grid_cell_layer_GridCellLayer.layerName="GridCellLayer";const XA={name:"binOptions",vs:"layout(std140) uniform binOptionsUniforms {\n vec2 cellOriginCommon;\n vec2 cellSizeCommon;\n} binOptions;\n",uniformTypes:{cellOriginCommon:"vec2<f32>",cellSizeCommon:"vec2<f32>"}};function $A(){}const ZA={gpuAggregation:!0,colorDomain:null,colorRange:wc,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:$A,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationScale:{type:"number",min:0,value:1},elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScaleType:"linear",onSetElevationDomain:$A,cellSize:{type:"number",min:0,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:e=>e.position},gridAggregator:{type:"function",optional:!0,value:null},extruded:!1,material:!0};class grid_layer_GridLayer extends yc{getAggregatorType(){const{gpuAggregation:e,gridAggregator:t,getColorValue:n,getElevationValue:i}=this.props;return e&&(t||n||i)?(Ie.A.warn("Features not supported by GPU aggregation, falling back to CPU")(),"cpu"):e&&WebGLAggregator.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(e){if("cpu"===e){const{gridAggregator:e,cellSize:t}=this.props;return new CPUAggregator({dimensions:2,getBin:{sources:["positions"],getValue:({positions:n},i,r)=>{if(e)return e(n,t);const s=this.state.aggregatorViewport.projectPosition(n),{cellSizeCommon:o,cellOriginCommon:a}=r;return[Math.floor((s[0]-a[0])/o[0]),Math.floor((s[1]-a[1])/o[1])]}},getValue:[{sources:["colorWeights"],getValue:({colorWeights:e})=>e},{sources:["elevationWeights"],getValue:({elevationWeights:e})=>e}]})}return new WebGLAggregator(this.context.device,{dimensions:2,channelCount:2,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[Xs,XA],vs:"\n in vec3 positions;\n in vec3 positions64Low;\n in float colorWeights;\n in float elevationWeights;\n\n void getBin(out ivec2 binId) {\n vec3 positionCommon = project_position(positions, positions64Low);\n vec2 gridCoords = floor(positionCommon.xy / binOptions.cellSizeCommon);\n binId = ivec2(gridCoords);\n }\n void getValue(out vec2 value) {\n value = vec2(colorWeights, elevationWeights);\n }\n "})})}initializeState(){super.initializeState();this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},colorWeights:{size:1,accessor:"getColorWeight"},elevationWeights:{size:1,accessor:"getElevationWeight"}})}updateState(e){const t=super.updateState(e),{props:n,oldProps:i,changeFlags:r}=e,{aggregator:s}=this.state;if(!r.dataChanged&&this.state.dataAsArray||!n.getColorValue&&!n.getElevationValue||(this.state.dataAsArray=Array.from(br(n.data).iterable)),t||r.dataChanged||n.cellSize!==i.cellSize||n.getColorValue!==i.getColorValue||n.getElevationValue!==i.getElevationValue||n.colorAggregation!==i.colorAggregation||n.elevationAggregation!==i.elevationAggregation){this._updateBinOptions();const{cellSizeCommon:e,cellOriginCommon:t,binIdRange:i,dataAsArray:r}=this.state;if(s.setProps({binIdRange:i,pointCount:this.getNumInstances(),operations:[n.colorAggregation,n.elevationAggregation],binOptions:{cellSizeCommon:e,cellOriginCommon:t},onUpdate:this._onAggregationUpdate.bind(this)}),r){const{getColorValue:e,getElevationValue:t}=this.props;s.setProps({customOperations:[e&&(t=>e(t.map(e=>r[e]),{indices:t,data:n.data})),t&&(e=>t(e.map(e=>r[e]),{indices:e,data:n.data}))]})}}return r.updateTriggersChanged&&r.updateTriggersChanged.getColorValue&&s.setNeedsUpdate(0),r.updateTriggersChanged&&r.updateTriggersChanged.getElevationValue&&s.setNeedsUpdate(1),t}_updateBinOptions(){const e=this.getBounds(),t=[1,1];let n=[0,0],i=[[0,1],[0,1]],r=this.context.viewport;if(e&&Number.isFinite(e[0][0])){let s=[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2];const{cellSize:o}=this.props,{unitsPerMeter:a}=r.getDistanceScales(s);t[0]=a[0]*o,t[1]=a[1]*o;const l=r.projectFlat(s);n=[Math.floor(l[0]/t[0])*t[0],Math.floor(l[1]/t[1])*t[1]],s=r.unprojectFlat(n);const c=r.constructor;r=r.isGeospatial?new c({longitude:s[0],latitude:s[1],zoom:12}):new hn.A({position:[s[0],s[1],0],zoom:12}),n=[Math.fround(r.center[0]),Math.fround(r.center[1])],i=Nc({dataBounds:e,getBinId:e=>{const i=r.projectFlat(e);return[Math.floor((i[0]-n[0])/t[0]),Math.floor((i[1]-n[1])/t[1])]}})}this.setState({cellSizeCommon:t,cellOriginCommon:n,binIdRange:i,aggregatorViewport:r})}draw(e){e.shaderModuleProps.project&&(e.shaderModuleProps.project.viewport=this.state.aggregatorViewport),super.draw(e)}_onAggregationUpdate({channel:e}){const t=this.getCurrentLayer().props,{aggregator:n}=this.state;if(0===e){const e=n.getResult(0);this.setState({colors:new AttributeWithScale(e,n.binCount)}),t.onSetColorDomain(n.getResultDomain(0))}else if(1===e){const e=n.getResult(1);this.setState({elevations:new AttributeWithScale(e,n.binCount)}),t.onSetElevationDomain(n.getResultDomain(1))}}onAttributeChange(e){const{aggregator:t}=this.state;switch(e){case"positions":t.setNeedsUpdate(),this._updateBinOptions();const{cellSizeCommon:e,cellOriginCommon:n,binIdRange:i}=this.state;t.setProps({binIdRange:i,binOptions:{cellSizeCommon:e,cellOriginCommon:n}});break;case"colorWeights":t.setNeedsUpdate(0);break;case"elevationWeights":t.setNeedsUpdate(1)}}renderLayers(){const{aggregator:e,cellOriginCommon:t,cellSizeCommon:n}=this.state,{elevationScale:i,colorRange:r,elevationRange:s,extruded:o,coverage:a,material:l,transitions:c,colorScaleType:A,lowerPercentile:u,upperPercentile:h,colorDomain:d,elevationScaleType:f,elevationLowerPercentile:p,elevationUpperPercentile:g,elevationDomain:m}=this.props,b=this.getSubLayerClass("cells",grid_cell_layer_GridCellLayer),_=e.getBins(),v=this.state.colors?.update({scaleType:A,lowerPercentile:u,upperPercentile:h}),y=this.state.elevations?.update({scaleType:f,lowerPercentile:p,upperPercentile:g});return v&&y?new b(this.getSubLayerProps({id:"cells"}),{data:{length:e.binCount,attributes:{getBin:_,getColorValue:v.attribute,getElevationValue:y.attribute}},dataComparator:(e,t)=>e.length===t.length,updateTriggers:{getBin:[_],getColorValue:[v.attribute],getElevationValue:[y.attribute]},cellOriginCommon:t,cellSizeCommon:n,elevationScale:i,colorRange:r,colorScaleType:A,elevationRange:s,extruded:o,coverage:a,material:l,colorDomain:v.domain||d||e.getResultDomain(0),elevationDomain:y.domain||m||e.getResultDomain(1),colorCutoff:v.cutoff,elevationCutoff:y.cutoff,transitions:c&&{getFillColor:c.getColorValue||c.getColorWeight,getElevation:c.getElevationValue||c.getElevationWeight},extensions:[]}):null}getPickingInfo(e){const t=e.info,{index:n}=t;if(n>=0){const e=this.state.aggregator.getBin(n);let i;e&&(i={col:e.id[0],row:e.id[1],colorValue:e.value[0],elevationValue:e.value[1],count:e.count},e.pointIndices&&(i.pointIndices=e.pointIndices,i.points=Array.isArray(this.props.data)?e.pointIndices.map(e=>this.props.data[e]):[])),t.object=i}return t}}grid_layer_GridLayer.layerName="GridLayer",grid_layer_GridLayer.defaultProps=ZA;const YA=grid_layer_GridLayer;const JA=new Float32Array(12);function eu(e,t=2){let n=0;for(const i of e)for(let e=0;e<t;e++)JA[n++]=i[e]||0;return JA}class TextureTransform{device;model;sampler;currentIndex=0;samplerTextureMap=null;bindings=[];resources={};constructor(e,t){this.device=e,this.sampler=e.createSampler({addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}),this.model=new Sr.K(this.device,{id:t.id||(0,po.L)("texture-transform-model"),fs:t.fs||Er({input:t.targetTextureVarying,inputChannels:t.targetTextureChannels,output:"transform_output"}),vertexCount:t.vertexCount,...t}),this._initialize(t),Object.seal(this)}destroy(){this.model.destroy();for(const e of this.bindings)e.framebuffer?.destroy()}delete(){this.destroy()}run(e){const{framebuffer:t}=this.bindings[this.currentIndex],n=this.device.beginRenderPass({framebuffer:t,...e});this.model.draw(n),n.end(),this.device.submit()}getTargetTexture(){const{targetTexture:e}=this.bindings[this.currentIndex];return e}getFramebuffer(){return this.bindings[this.currentIndex].framebuffer}_initialize(e){this._updateBindings(e)}_updateBindings(e){this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],e)}_updateBinding(e,{sourceBuffers:t,sourceTextures:n,targetTexture:i}){if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,n),Object.assign(e.sourceBuffers,t),i){e.targetTexture=i;const{width:t,height:n}=i;e.framebuffer&&e.framebuffer.destroy(),e.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:t,height:n,colorAttachments:[i]}),e.framebuffer.resize({width:t,height:n})}return e}_setSourceTextureParameters(){const e=this.currentIndex,{sourceTextures:t}=this.bindings[e];for(const e in t)t[e].sampler=this.sampler}}const tu="layout(std140) uniform triangleUniforms {\n float aggregationMode;\n vec2 colorDomain;\n float intensity;\n float threshold;\n} triangle;\n",nu={name:"triangle",vs:tu,fs:tu,uniformTypes:{aggregationMode:"f32",colorDomain:"vec2<f32>",intensity:"f32",threshold:"f32"}};class TriangleLayer extends Ts{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME heatp-map-layer-vertex-shader\nuniform sampler2D maxTexture;\nin vec3 positions;\nin vec2 texCoords;\nout vec2 vTexCoords;\nout float vIntensityMin;\nout float vIntensityMax;\nvoid main(void) {\ngl_Position = project_position_to_clipspace(positions, vec3(0.0), vec3(0.0));\nvTexCoords = texCoords;\nvec4 maxTexture = texture(maxTexture, vec2(0.5));\nfloat maxValue = triangle.aggregationMode < 0.5 ? maxTexture.r : maxTexture.g;\nfloat minValue = maxValue * triangle.threshold;\nif (triangle.colorDomain[1] > 0.) {\nmaxValue = triangle.colorDomain[1];\nminValue = triangle.colorDomain[0];\n}\nvIntensityMax = triangle.intensity / maxValue;\nvIntensityMin = triangle.intensity / minValue;\n}\n",fs:"#version 300 es\n#define SHADER_NAME triangle-layer-fragment-shader\nprecision highp float;\nuniform sampler2D weightsTexture;\nuniform sampler2D colorTexture;\nin vec2 vTexCoords;\nin float vIntensityMin;\nin float vIntensityMax;\nout vec4 fragColor;\nvec4 getLinearColor(float value) {\nfloat factor = clamp(value * vIntensityMax, 0., 1.);\nvec4 color = texture(colorTexture, vec2(factor, 0.5));\ncolor.a *= min(value * vIntensityMin, 1.0);\nreturn color;\n}\nvoid main(void) {\nvec4 weights = texture(weightsTexture, vTexCoords);\nfloat weight = weights.r;\nif (triangle.aggregationMode > 0.5) {\nweight /= max(1.0, weights.a);\n}\nif (weight <= 0.) {\ndiscard;\n}\nvec4 linearColor = getLinearColor(weight);\nlinearColor.a *= layer.opacity;\nfragColor = linearColor;\n}\n",modules:[Xs,nu]})}initializeState({device:e}){this.setState({model:this._getModel(e)})}_getModel(e){const{vertexCount:t,data:n}=this.props;return new Sr.K(e,{...this.getShaders(),id:this.props.id,attributes:n.attributes,bufferLayout:[{name:"positions",format:"float32x3"},{name:"texCoords",format:"float32x2"}],topology:"triangle-strip",vertexCount:t})}draw(){const{model:e}=this.state,{aggregationMode:t,colorDomain:n,intensity:i,threshold:r,colorTexture:s,maxTexture:o,weightsTexture:a}=this.props,l={aggregationMode:t,colorDomain:n,intensity:i,threshold:r,colorTexture:s,maxTexture:o,weightsTexture:a};e.shaderInputs.setProps({triangle:l}),e.draw(this.context.renderPass)}}TriangleLayer.layerName="TriangleLayer";const iu=TriangleLayer;function ru(e,t){const n={};for(const i in e)t.includes(i)||(n[i]=e[i]);return n}class aggregation_layer_AggregationLayer extends Ss{initializeAggregationLayer(e){super.initializeState(this.context),this.setState({ignoreProps:ru(this.constructor._propTypes,e.data.props),dimensions:e})}updateState(e){super.updateState(e);const{changeFlags:t}=e;if(t.extensionsChanged){const e=this.getShaders({});e&&e.defines&&(e.defines.NON_INSTANCED_MODEL=1),this.updateShaders(e)}this._updateAttributes()}updateAttributes(e){this.setState({changedAttributes:e})}getAttributes(){return this.getAttributeManager().getAttributes()}getModuleSettings(){const{viewport:e,mousePosition:t,device:n}=this.context;return Object.assign(Object.create(this.props),{viewport:e,mousePosition:t,picking:{isActive:0},devicePixelRatio:n.canvasContext.cssToDeviceRatio()})}updateShaders(e){}isAggregationDirty(e,t={}){const{props:n,oldProps:i,changeFlags:r}=e,{compareAll:s=!1,dimension:o}=t,{ignoreProps:a}=this.state,{props:l,accessors:c=[]}=o,{updateTriggersChanged:A}=r;if(r.dataChanged)return!0;if(A){if(A.all)return!0;for(const e of c)if(A[e])return!0}if(s)return!!r.extensionsChanged||Xr({oldProps:i,newProps:n,ignoreProps:a,propTypes:this.constructor._propTypes});for(const e of l)if(n[e]!==i[e])return!0;return!1}isAttributeChanged(e){const{changedAttributes:t}=this.state;return e?t&&void 0!==t[e]:!function(e){let t=!0;for(const n in e){t=!1;break}return t}(t)}_getAttributeManager(){return new AttributeManager(this.context.device,{id:this.props.id,stats:this.context.stats})}}aggregation_layer_AggregationLayer.layerName="AggregationLayer";const su=aggregation_layer_AggregationLayer;const ou="#version 300 es\nin vec3 positions;\nin vec3 positions64Low;\nin float weights;\nout vec4 weightsTexture;\nvoid main()\n{\nweightsTexture = vec4(weights * weight.weightsScale, 0., 0., 1.);\nfloat radiusTexels = project_pixel_size(weight.radiusPixels) * weight.textureWidth / (weight.commonBounds.z - weight.commonBounds.x);\ngl_PointSize = radiusTexels * 2.;\nvec3 commonPosition = project_position(positions, positions64Low);\ngl_Position.xy = (commonPosition.xy - weight.commonBounds.xy) / (weight.commonBounds.zw - weight.commonBounds.xy) ;\ngl_Position.xy = (gl_Position.xy * 2.) - (1.);\ngl_Position.w = 1.0;\n}\n",au="#version 300 es\nin vec4 weightsTexture;\nout vec4 fragColor;\nfloat gaussianKDE(float u){\nreturn pow(2.71828, -u*u/0.05555)/(1.77245385*0.166666);\n}\nvoid main()\n{\nfloat dist = length(gl_PointCoord - vec2(0.5, 0.5));\nif (dist > 0.5) {\ndiscard;\n}\nfragColor = weightsTexture * gaussianKDE(2. * dist);\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",lu={name:"weight",vs:"layout(std140) uniform weightUniforms {\n vec4 commonBounds;\n float radiusPixels;\n float textureWidth;\n float weightsScale;\n} weight;\n",uniformTypes:{commonBounds:"vec4<f32>",radiusPixels:"f32",textureWidth:"f32",weightsScale:"f32"}},cu={name:"maxWeight",vs:"layout(std140) uniform maxWeightUniforms {\n float textureSize;\n} maxWeight;\n",uniformTypes:{textureSize:"f32"}},Au={format:"rgba8unorm",dimension:"2d",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}},uu=[0,0],hu={SUM:0,MEAN:1},du={getPosition:{type:"accessor",value:e=>e.position},getWeight:{type:"accessor",value:1},intensity:{type:"number",min:0,value:1},radiusPixels:{type:"number",min:1,max:100,value:50},colorRange:wc,threshold:{type:"number",min:0,max:1,value:.05},colorDomain:{type:"array",value:null,optional:!0},aggregation:"SUM",weightsTextureSize:{type:"number",min:128,max:2048,value:2048},debounceTimeout:{type:"number",min:0,max:1e3,value:500}},fu=["float32-renderable-webgl","texture-blend-float-webgl"],pu={data:{props:["radiusPixels"]}};class HeatmapLayer extends su{getShaders(e){let t=[Xs];return e.modules&&(t=[...t,...e.modules]),super.getShaders({...e,modules:t})}initializeState(){super.initializeAggregationLayer(pu),this.setState({colorDomain:uu}),this._setupTextureParams(),this._setupAttributes(),this._setupResources()}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState(e){super.updateState(e),this._updateHeatmapState(e)}_updateHeatmapState(e){const{props:t,oldProps:n}=e,i=this._getChangeFlags(e);if((i.dataChanged||i.viewportChanged)&&(i.boundsChanged=this._updateBounds(i.dataChanged),this._updateTextureRenderingBounds()),i.dataChanged||i.boundsChanged){if(clearTimeout(this.state.updateTimer),this.setState({isWeightMapDirty:!0}),i.dataChanged){const e=this.getShaders({vs:ou,fs:au});this._createWeightsTransform(e)}}else i.viewportZoomChanged&&this._debouncedUpdateWeightmap();t.colorRange!==n.colorRange&&this._updateColorTexture(e),this.state.isWeightMapDirty&&this._updateWeightmap(),this.setState({zoom:e.context.viewport.zoom})}renderLayers(){const{weightsTexture:e,triPositionBuffer:t,triTexCoordBuffer:n,maxWeightsTexture:i,colorTexture:r,colorDomain:s}=this.state,{updateTriggers:o,intensity:a,threshold:l,aggregation:c}=this.props;return new(this.getSubLayerClass("triangle",iu))(this.getSubLayerProps({id:"triangle-layer",updateTriggers:o}),{coordinateSystem:"default",data:{attributes:{positions:t,texCoords:n}},vertexCount:4,maxTexture:i,colorTexture:r,aggregationMode:hu[c]||0,weightsTexture:e,intensity:a,threshold:l,colorDomain:s})}finalizeState(e){super.finalizeState(e);const{weightsTransform:t,weightsTexture:n,maxWeightTransform:i,maxWeightsTexture:r,triPositionBuffer:s,triTexCoordBuffer:o,colorTexture:a,updateTimer:l}=this.state;t?.destroy(),n?.destroy(),i?.destroy(),r?.destroy(),s?.destroy(),o?.destroy(),a?.destroy(),l&&clearTimeout(l)}_getAttributeManager(){return new AttributeManager(this.context.device,{id:this.props.id,stats:this.context.stats})}_getChangeFlags(e){const t={},{dimensions:n}=this.state;t.dataChanged=this.isAttributeChanged()?"attribute changed":this.isAggregationDirty(e,{compareAll:!0,dimension:n.data})&&"aggregation is dirty",t.viewportChanged=e.changeFlags.viewportChanged;const{zoom:i}=this.state;return e.context.viewport&&e.context.viewport.zoom===i||(t.viewportZoomChanged=!0),t}_createTextures(){const{textureSize:e,format:t}=this.state;this.setState({weightsTexture:this.context.device.createTexture({...Au,width:e,height:e,format:t}),maxWeightsTexture:this.context.device.createTexture({...Au,width:1,height:1,format:t})})}_setupAttributes(){this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"},weights:{size:1,accessor:"getWeight"}}),this.setState({positionAttributeName:"positions"})}_setupTextureParams(){const{device:e}=this.context,{weightsTextureSize:t}=this.props,n=Math.min(t,e.limits.maxTextureDimension2D),i=fu.every(t=>e.features.has(t)),r=i?"rgba32float":"rgba8unorm",s=i?1:1/255;this.setState({textureSize:n,format:r,weightsScale:s}),i||Ie.A.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)()}_createWeightsTransform(e){let{weightsTransform:t}=this.state;const{weightsTexture:n}=this.state,i=this.getAttributeManager();t?.destroy(),t=new TextureTransform(this.context.device,{id:`${this.id}-weights-transform`,...e,bufferLayout:i.getBufferLayouts(),vertexCount:1,targetTexture:n,parameters:{depthWriteEnabled:!1,blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},topology:"point-list",modules:[...e.modules,lu]}),this.setState({weightsTransform:t})}_setupResources(){this._createTextures();const{device:e}=this.context,{textureSize:t,weightsTexture:n,maxWeightsTexture:i}=this.state,r=this.getShaders({vs:ou,fs:au});this._createWeightsTransform(r);const s=this.getShaders({vs:"#version 300 es\nuniform sampler2D inTexture;\nout vec4 outTexture;\nvoid main()\n{\nint yIndex = gl_VertexID / int(maxWeight.textureSize);\nint xIndex = gl_VertexID - (yIndex * int(maxWeight.textureSize));\nvec2 uv = (0.5 + vec2(float(xIndex), float(yIndex))) / maxWeight.textureSize;\noutTexture = texture(inTexture, uv);\ngl_Position = vec4(0.0, 0.0, 0.0, 1.0);\ngl_PointSize = 1.0;\n}\n",fs:"#version 300 es\nin vec4 outTexture;\nout vec4 fragColor;\nvoid main() {\nfragColor = outTexture;\nfragColor.g = outTexture.r / max(1.0, outTexture.a);\n}\n",modules:[cu]}),o=new TextureTransform(e,{id:`${this.id}-max-weights-transform`,targetTexture:i,...s,vertexCount:t*t,topology:"point-list",parameters:{depthWriteEnabled:!1,blend:!0,blendColorOperation:"max",blendAlphaOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}}),a={inTexture:n,textureSize:t};o.model.shaderInputs.setProps({maxWeight:a}),this.setState({weightsTexture:n,maxWeightsTexture:i,maxWeightTransform:o,zoom:null,triPositionBuffer:e.createBuffer({byteLength:48}),triTexCoordBuffer:e.createBuffer({byteLength:48})})}updateShaders(e){this._createWeightsTransform({vs:ou,fs:au,...e})}_updateMaxWeightValue(){const{maxWeightTransform:e}=this.state;e.run({parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]})}_updateBounds(e=!1){const{viewport:t}=this.context,n=[t.unproject([0,0]),t.unproject([t.width,0]),t.unproject([0,t.height]),t.unproject([t.width,t.height])].map(e=>e.map(Math.fround)),i=function(e){const t=e.map(e=>e[0]),n=e.map(e=>e[1]),i=Math.min.apply(null,t),r=Math.max.apply(null,t);return[i,Math.min.apply(null,n),r,Math.max.apply(null,n)]}(n),r={visibleWorldBounds:i,viewportCorners:n};let s=!1;if(e||!this.state.worldBounds||(o=this.state.worldBounds,!((a=i)[0]>=o[0]&&a[2]<=o[2]&&a[1]>=o[1]&&a[3]<=o[3]))){const e=this._worldToCommonBounds(i),t=this._commonToWorldBounds(e);"lnglat"===this.props.coordinateSystem&&(t[1]=Math.max(t[1],-85.051129),t[3]=Math.min(t[3],85.051129),t[0]=Math.max(t[0],-360),t[2]=Math.min(t[2],360));const n=this._worldToCommonBounds(t);r.worldBounds=t,r.normalizedCommonBounds=n,s=!0}var o,a;return this.setState(r),s}_updateTextureRenderingBounds(){const{triPositionBuffer:e,triTexCoordBuffer:t,normalizedCommonBounds:n,viewportCorners:i}=this.state,{viewport:r}=this.context;e.write(eu(i,3));const s=i.map(e=>function(e,t){const[n,i,r,s]=t;return[(e[0]-n)/(r-n),(e[1]-i)/(s-i)]}(r.projectPosition(e),n));t.write(eu(s,2))}_updateColorTexture(e){const{colorRange:t}=e.props;let{colorTexture:n}=this.state;const i=xc(t,!1,Uint8Array);n?.destroy(),n=this.context.device.createTexture({...Au,data:i,width:t.length,height:1}),this.setState({colorTexture:n})}_updateWeightmap(){const{radiusPixels:e,colorDomain:t,aggregation:n}=this.props,{worldBounds:i,textureSize:r,weightsScale:s,weightsTexture:o}=this.state,a=this.state.weightsTransform;this.state.isWeightMapDirty=!1;const l=this._worldToCommonBounds(i,{useLayerCoordinateSystem:!0});if(t&&"SUM"===n){const{viewport:e}=this.context,n=e.distanceScales.metersPerUnit[2]*(l[2]-l[0])/r;this.state.colorDomain=[t[0]*n*s,t[1]*n*s]}else this.state.colorDomain=t||uu;const c=this.getAttributeManager().getAttributes(),A=this.getModuleSettings();this._setModelAttributes(a.model,c),a.model.setVertexCount(this.getNumInstances());const u={radiusPixels:e,commonBounds:l,textureWidth:r,weightsScale:s,weightsTexture:o},{viewport:h,devicePixelRatio:d,coordinateSystem:f,coordinateOrigin:p}=A,{modelMatrix:g}=this.props;a.model.shaderInputs.setProps({project:{viewport:h,devicePixelRatio:d,modelMatrix:g,coordinateSystem:f,coordinateOrigin:p},weight:u}),a.run({parameters:{viewport:[0,0,r,r]},clearColor:[0,0,0,0]}),this._updateMaxWeightValue()}_debouncedUpdateWeightmap(e=!1){let{updateTimer:t}=this.state;const{debounceTimeout:n}=this.props;e?(t=null,this._updateBounds(!0),this._updateTextureRenderingBounds(),this.setState({isWeightMapDirty:!0})):(this.setState({isWeightMapDirty:!1}),clearTimeout(t),t=setTimeout(this._debouncedUpdateWeightmap.bind(this,!0),n)),this.setState({updateTimer:t})}_worldToCommonBounds(e,t={}){const{useLayerCoordinateSystem:n=!1}=t,[i,r,s,o]=e,{viewport:a}=this.context,{textureSize:l}=this.state,{coordinateSystem:c}=this.props,A=n&&("lnglat-offsets"===c||"meter-offsets"===c),u=A?a.projectPosition(this.props.coordinateOrigin):[0,0],h=2*l/a.scale;let d,f;return n&&!A?(d=this.projectPosition([i,r,0]),f=this.projectPosition([s,o,0])):(d=a.projectPosition([i,r,0]),f=a.projectPosition([s,o,0])),function(e,t,n){const[i,r,s,o]=e,a=s-i,l=o-r;let c=a,A=l;a/l<t/n?c=t/n*l:A=n/t*a,c<t&&(c=t,A=n);const u=(s+i)/2,h=(o+r)/2;return[u-c/2,h-A/2,u+c/2,h+A/2]}([d[0]-u[0],d[1]-u[1],f[0]-u[0],f[1]-u[1]],h,h)}_commonToWorldBounds(e){const[t,n,i,r]=e,{viewport:s}=this.context,o=s.unprojectPosition([t,n]),a=s.unprojectPosition([i,r]);return o.slice(0,2).concat(a.slice(0,2))}}HeatmapLayer.layerName="HeatmapLayer",HeatmapLayer.defaultProps=du;const gu=HeatmapLayer,mu={...yl.defaultProps};class GeoCellLayer extends Ss{indexToBounds(){return null}renderLayers(){const{elevationScale:e,extruded:t,wireframe:n,filled:i,stroked:r,lineWidthUnits:s,lineWidthScale:o,lineWidthMinPixels:a,lineWidthMaxPixels:l,lineJointRounded:c,lineMiterLimit:A,lineDashJustified:u,getElevation:h,getFillColor:d,getLineColor:f,getLineWidth:p}=this.props,{updateTriggers:g,material:m,transitions:b}=this.props,_=this.getSubLayerClass("cell",yl),{updateTriggers:v,...y}=this.indexToBounds()||{};return new _({filled:i,wireframe:n,extruded:t,elevationScale:e,stroked:r,lineWidthUnits:s,lineWidthScale:o,lineWidthMinPixels:a,lineWidthMaxPixels:l,lineJointRounded:c,lineMiterLimit:A,lineDashJustified:u,material:m,transitions:b,getElevation:h,getFillColor:d,getLineColor:f,getLineWidth:p},this.getSubLayerProps({id:"cell",updateTriggers:g&&{...v,getElevation:g.getElevation,getFillColor:g.getFillColor,getLineColor:g.getLineColor,getLineWidth:g.getLineWidth}}),y)}}GeoCellLayer.layerName="GeoCellLayer",GeoCellLayer.defaultProps=mu;const bu=GeoCellLayer;var _u=Object.defineProperty,vu=(e,t)=>{for(var n in t)_u(e,n,{get:t[n],enumerable:!0})},yu={};vu(yu,{ARRAY_TYPE:()=>xu,EPSILON:()=>wu,RANDOM:()=>Tu,equals:()=>Pu,setMatrixArrayType:()=>Eu,toRadian:()=>Cu});var wu=1e-6,xu="undefined"!=typeof Float32Array?Float32Array:Array,Tu=Math.random;function Eu(e){xu=e}var Su=Math.PI/180;function Cu(e){return e*Su}function Pu(e,t){return Math.abs(e-t)<=wu*Math.max(1,Math.abs(e),Math.abs(t))}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var Ru={};function Mu(){var e=new xu(4);return xu!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}function Lu(e){var t=new xu(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function Iu(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function Ou(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e}function Bu(e,t,n,i){var r=new xu(4);return r[0]=e,r[1]=t,r[2]=n,r[3]=i,r}function Nu(e,t,n,i,r){return e[0]=t,e[1]=n,e[2]=i,e[3]=r,e}function ku(e,t){if(e===t){var n=t[1];e[1]=t[2],e[2]=n}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e}function Fu(e,t){var n=t[0],i=t[1],r=t[2],s=t[3],o=n*s-r*i;return o?(o=1/o,e[0]=s*o,e[1]=-i*o,e[2]=-r*o,e[3]=n*o,e):null}function Du(e,t){var n=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=n,e}function Uu(e){return e[0]*e[3]-e[2]*e[1]}function Vu(e,t,n){var i=t[0],r=t[1],s=t[2],o=t[3],a=n[0],l=n[1],c=n[2],A=n[3];return e[0]=i*a+s*l,e[1]=r*a+o*l,e[2]=i*c+s*A,e[3]=r*c+o*A,e}function zu(e,t,n){var i=t[0],r=t[1],s=t[2],o=t[3],a=Math.sin(n),l=Math.cos(n);return e[0]=i*l+s*a,e[1]=r*l+o*a,e[2]=i*-a+s*l,e[3]=r*-a+o*l,e}function Gu(e,t,n){var i=t[0],r=t[1],s=t[2],o=t[3],a=n[0],l=n[1];return e[0]=i*a,e[1]=r*a,e[2]=s*l,e[3]=o*l,e}function ju(e,t){var n=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=n,e[2]=-n,e[3]=i,e}function Hu(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e}function Wu(e){return"mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}function qu(e){return Math.hypot(e[0],e[1],e[2],e[3])}function Ku(e,t,n,i){return e[2]=i[2]/i[0],n[0]=i[0],n[1]=i[1],n[3]=i[3]-e[2]*n[1],[e,t,n]}function Qu(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function Xu(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e}function $u(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function Zu(e,t){var n=e[0],i=e[1],r=e[2],s=e[3],o=t[0],a=t[1],l=t[2],c=t[3];return Math.abs(n-o)<=wu*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-a)<=wu*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(r-l)<=wu*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(s-c)<=wu*Math.max(1,Math.abs(s),Math.abs(c))}function Yu(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function Ju(e,t,n,i){return e[0]=t[0]+n[0]*i,e[1]=t[1]+n[1]*i,e[2]=t[2]+n[2]*i,e[3]=t[3]+n[3]*i,e}vu(Ru,{LDU:()=>Ku,add:()=>Qu,adjoint:()=>Du,clone:()=>Lu,copy:()=>Iu,create:()=>Mu,determinant:()=>Uu,equals:()=>Zu,exactEquals:()=>$u,frob:()=>qu,fromRotation:()=>ju,fromScaling:()=>Hu,fromValues:()=>Bu,identity:()=>Ou,invert:()=>Fu,mul:()=>eh,multiply:()=>Vu,multiplyScalar:()=>Yu,multiplyScalarAndAdd:()=>Ju,rotate:()=>zu,scale:()=>Gu,set:()=>Nu,str:()=>Wu,sub:()=>th,subtract:()=>Xu,transpose:()=>ku});var eh=Vu,th=Xu;var nh={};vu(nh,{add:()=>Md,calculateW:()=>ld,clone:()=>Sd,conjugate:()=>pd,copy:()=>Pd,create:()=>Jh,dot:()=>Od,equals:()=>zd,exactEquals:()=>Vd,exp:()=>cd,fromEuler:()=>md,fromMat3:()=>gd,fromValues:()=>Cd,getAngle:()=>id,getAxisAngle:()=>nd,identity:()=>ed,invert:()=>fd,len:()=>kd,length:()=>Nd,lerp:()=>Bd,ln:()=>Ad,mul:()=>Ld,multiply:()=>rd,normalize:()=>Ud,pow:()=>ud,random:()=>dd,rotateX:()=>sd,rotateY:()=>od,rotateZ:()=>ad,rotationTo:()=>Gd,scale:()=>Id,set:()=>Rd,setAxes:()=>Hd,setAxisAngle:()=>td,slerp:()=>hd,sqlerp:()=>jd,sqrLen:()=>Dd,squaredLength:()=>Fd,str:()=>bd});var ih={};function rh(){var e=new xu(3);return xu!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function sh(e){var t=new xu(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function oh(e){var t=e[0],n=e[1],i=e[2];return Math.hypot(t,n,i)}function ah(e,t,n){var i=new xu(3);return i[0]=e,i[1]=t,i[2]=n,i}function lh(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function ch(e,t,n,i){return e[0]=t,e[1]=n,e[2]=i,e}function Ah(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e}function uh(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function hh(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e}function dh(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e}function fh(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function ph(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function gh(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e}function mh(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e}function bh(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e}function _h(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function vh(e,t,n,i){return e[0]=t[0]+n[0]*i,e[1]=t[1]+n[1]*i,e[2]=t[2]+n[2]*i,e}function yh(e,t){var n=t[0]-e[0],i=t[1]-e[1],r=t[2]-e[2];return Math.hypot(n,i,r)}function wh(e,t){var n=t[0]-e[0],i=t[1]-e[1],r=t[2]-e[2];return n*n+i*i+r*r}function xh(e){var t=e[0],n=e[1],i=e[2];return t*t+n*n+i*i}function Th(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function Eh(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function Sh(e,t){var n=t[0],i=t[1],r=t[2],s=n*n+i*i+r*r;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function Ch(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Ph(e,t,n){var i=t[0],r=t[1],s=t[2],o=n[0],a=n[1],l=n[2];return e[0]=r*l-s*a,e[1]=s*o-i*l,e[2]=i*a-r*o,e}function Rh(e,t,n,i){var r=t[0],s=t[1],o=t[2];return e[0]=r+i*(n[0]-r),e[1]=s+i*(n[1]-s),e[2]=o+i*(n[2]-o),e}function Mh(e,t,n,i,r,s){var o=s*s,a=o*(2*s-3)+1,l=o*(s-2)+s,c=o*(s-1),A=o*(3-2*s);return e[0]=t[0]*a+n[0]*l+i[0]*c+r[0]*A,e[1]=t[1]*a+n[1]*l+i[1]*c+r[1]*A,e[2]=t[2]*a+n[2]*l+i[2]*c+r[2]*A,e}function Lh(e,t,n,i,r,s){var o=1-s,a=o*o,l=s*s,c=a*o,A=3*s*a,u=3*l*o,h=l*s;return e[0]=t[0]*c+n[0]*A+i[0]*u+r[0]*h,e[1]=t[1]*c+n[1]*A+i[1]*u+r[1]*h,e[2]=t[2]*c+n[2]*A+i[2]*u+r[2]*h,e}function Ih(e,t){t=t||1;var n=2*Tu()*Math.PI,i=2*Tu()-1,r=Math.sqrt(1-i*i)*t;return e[0]=Math.cos(n)*r,e[1]=Math.sin(n)*r,e[2]=i*t,e}function Oh(e,t,n){var i=t[0],r=t[1],s=t[2],o=n[3]*i+n[7]*r+n[11]*s+n[15];return o=o||1,e[0]=(n[0]*i+n[4]*r+n[8]*s+n[12])/o,e[1]=(n[1]*i+n[5]*r+n[9]*s+n[13])/o,e[2]=(n[2]*i+n[6]*r+n[10]*s+n[14])/o,e}function Bh(e,t,n){var i=t[0],r=t[1],s=t[2];return e[0]=i*n[0]+r*n[3]+s*n[6],e[1]=i*n[1]+r*n[4]+s*n[7],e[2]=i*n[2]+r*n[5]+s*n[8],e}function Nh(e,t,n){var i=n[0],r=n[1],s=n[2],o=n[3],a=t[0],l=t[1],c=t[2],A=r*c-s*l,u=s*a-i*c,h=i*l-r*a,d=r*h-s*u,f=s*A-i*h,p=i*u-r*A,g=2*o;return A*=g,u*=g,h*=g,d*=2,f*=2,p*=2,e[0]=a+A+d,e[1]=l+u+f,e[2]=c+h+p,e}function kh(e,t,n,i){var r=[],s=[];return r[0]=t[0]-n[0],r[1]=t[1]-n[1],r[2]=t[2]-n[2],s[0]=r[0],s[1]=r[1]*Math.cos(i)-r[2]*Math.sin(i),s[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),e[0]=s[0]+n[0],e[1]=s[1]+n[1],e[2]=s[2]+n[2],e}function Fh(e,t,n,i){var r=[],s=[];return r[0]=t[0]-n[0],r[1]=t[1]-n[1],r[2]=t[2]-n[2],s[0]=r[2]*Math.sin(i)+r[0]*Math.cos(i),s[1]=r[1],s[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),e[0]=s[0]+n[0],e[1]=s[1]+n[1],e[2]=s[2]+n[2],e}function Dh(e,t,n,i){var r=[],s=[];return r[0]=t[0]-n[0],r[1]=t[1]-n[1],r[2]=t[2]-n[2],s[0]=r[0]*Math.cos(i)-r[1]*Math.sin(i),s[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),s[2]=r[2],e[0]=s[0]+n[0],e[1]=s[1]+n[1],e[2]=s[2]+n[2],e}function Uh(e,t){var n=e[0],i=e[1],r=e[2],s=t[0],o=t[1],a=t[2],l=Math.sqrt(n*n+i*i+r*r)*Math.sqrt(s*s+o*o+a*a),c=l&&Ch(e,t)/l;return Math.acos(Math.min(Math.max(c,-1),1))}function Vh(e){return e[0]=0,e[1]=0,e[2]=0,e}function zh(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"}function Gh(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function jh(e,t){var n=e[0],i=e[1],r=e[2],s=t[0],o=t[1],a=t[2];return Math.abs(n-s)<=wu*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(i-o)<=wu*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-a)<=wu*Math.max(1,Math.abs(r),Math.abs(a))}vu(ih,{add:()=>Ah,angle:()=>Uh,bezier:()=>Lh,ceil:()=>fh,clone:()=>sh,copy:()=>lh,create:()=>rh,cross:()=>Ph,dist:()=>Qh,distance:()=>yh,div:()=>Kh,divide:()=>dh,dot:()=>Ch,equals:()=>jh,exactEquals:()=>Gh,floor:()=>ph,forEach:()=>Yh,fromValues:()=>ah,hermite:()=>Mh,inverse:()=>Eh,len:()=>$h,length:()=>oh,lerp:()=>Rh,max:()=>mh,min:()=>gh,mul:()=>qh,multiply:()=>hh,negate:()=>Th,normalize:()=>Sh,random:()=>Ih,rotateX:()=>kh,rotateY:()=>Fh,rotateZ:()=>Dh,round:()=>bh,scale:()=>_h,scaleAndAdd:()=>vh,set:()=>ch,sqrDist:()=>Xh,sqrLen:()=>Zh,squaredDistance:()=>wh,squaredLength:()=>xh,str:()=>zh,sub:()=>Wh,subtract:()=>uh,transformMat3:()=>Bh,transformMat4:()=>Oh,transformQuat:()=>Nh,zero:()=>Vh});var Hh,Wh=uh,qh=hh,Kh=dh,Qh=yh,Xh=wh,$h=oh,Zh=xh,Yh=(Hh=rh(),function(e,t,n,i,r,s){var o,a;for(t||(t=3),n||(n=0),a=i?Math.min(i*t+n,e.length):e.length,o=n;o<a;o+=t)Hh[0]=e[o],Hh[1]=e[o+1],Hh[2]=e[o+2],r(Hh,Hh,s),e[o]=Hh[0],e[o+1]=Hh[1],e[o+2]=Hh[2];return e});!function(){var e,t=(e=new xu(4),xu!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();function Jh(){var e=new xu(4);return xu!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function ed(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function td(e,t,n){n*=.5;var 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 nd(e,t){var n=2*Math.acos(t[3]),i=Math.sin(n/2);return i>wu?(e[0]=t[0]/i,e[1]=t[1]/i,e[2]=t[2]/i):(e[0]=1,e[1]=0,e[2]=0),n}function id(e,t){var n=Od(e,t);return Math.acos(2*n*n-1)}function rd(e,t,n){var i=t[0],r=t[1],s=t[2],o=t[3],a=n[0],l=n[1],c=n[2],A=n[3];return e[0]=i*A+o*a+r*c-s*l,e[1]=r*A+o*l+s*a-i*c,e[2]=s*A+o*c+i*l-r*a,e[3]=o*A-i*a-r*l-s*c,e}function sd(e,t,n){n*=.5;var i=t[0],r=t[1],s=t[2],o=t[3],a=Math.sin(n),l=Math.cos(n);return e[0]=i*l+o*a,e[1]=r*l+s*a,e[2]=s*l-r*a,e[3]=o*l-i*a,e}function od(e,t,n){n*=.5;var i=t[0],r=t[1],s=t[2],o=t[3],a=Math.sin(n),l=Math.cos(n);return e[0]=i*l-s*a,e[1]=r*l+o*a,e[2]=s*l+i*a,e[3]=o*l-r*a,e}function ad(e,t,n){n*=.5;var i=t[0],r=t[1],s=t[2],o=t[3],a=Math.sin(n),l=Math.cos(n);return e[0]=i*l+r*a,e[1]=r*l-i*a,e[2]=s*l+o*a,e[3]=o*l-s*a,e}function ld(e,t){var n=t[0],i=t[1],r=t[2];return e[0]=n,e[1]=i,e[2]=r,e[3]=Math.sqrt(Math.abs(1-n*n-i*i-r*r)),e}function cd(e,t){var n=t[0],i=t[1],r=t[2],s=t[3],o=Math.sqrt(n*n+i*i+r*r),a=Math.exp(s),l=o>0?a*Math.sin(o)/o:0;return e[0]=n*l,e[1]=i*l,e[2]=r*l,e[3]=a*Math.cos(o),e}function Ad(e,t){var n=t[0],i=t[1],r=t[2],s=t[3],o=Math.sqrt(n*n+i*i+r*r),a=o>0?Math.atan2(o,s)/o:0;return e[0]=n*a,e[1]=i*a,e[2]=r*a,e[3]=.5*Math.log(n*n+i*i+r*r+s*s),e}function ud(e,t,n){return Ad(e,t),Id(e,e,n),cd(e,e),e}function hd(e,t,n,i){var r,s,o,a,l,c=t[0],A=t[1],u=t[2],h=t[3],d=n[0],f=n[1],p=n[2],g=n[3];return(s=c*d+A*f+u*p+h*g)<0&&(s=-s,d=-d,f=-f,p=-p,g=-g),1-s>wu?(r=Math.acos(s),o=Math.sin(r),a=Math.sin((1-i)*r)/o,l=Math.sin(i*r)/o):(a=1-i,l=i),e[0]=a*c+l*d,e[1]=a*A+l*f,e[2]=a*u+l*p,e[3]=a*h+l*g,e}function dd(e){var t=Tu(),n=Tu(),i=Tu(),r=Math.sqrt(1-t),s=Math.sqrt(t);return e[0]=r*Math.sin(2*Math.PI*n),e[1]=r*Math.cos(2*Math.PI*n),e[2]=s*Math.sin(2*Math.PI*i),e[3]=s*Math.cos(2*Math.PI*i),e}function fd(e,t){var 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;return e[0]=-n*a,e[1]=-i*a,e[2]=-r*a,e[3]=s*a,e}function pd(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function gd(e,t){var n,i=t[0]+t[4]+t[8];if(i>0)n=Math.sqrt(i+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{var r=0;t[4]>t[0]&&(r=1),t[8]>t[3*r+r]&&(r=2);var s=(r+1)%3,o=(r+2)%3;n=Math.sqrt(t[3*r+r]-t[3*s+s]-t[3*o+o]+1),e[r]=.5*n,n=.5/n,e[3]=(t[3*s+o]-t[3*o+s])*n,e[s]=(t[3*s+r]+t[3*r+s])*n,e[o]=(t[3*o+r]+t[3*r+o])*n}return e}function md(e,t,n,i){var r=.5*Math.PI/180;t*=r,n*=r,i*=r;var s=Math.sin(t),o=Math.cos(t),a=Math.sin(n),l=Math.cos(n),c=Math.sin(i),A=Math.cos(i);return e[0]=s*l*A-o*a*c,e[1]=o*a*A+s*l*c,e[2]=o*l*c-s*a*A,e[3]=o*l*A+s*a*c,e}function bd(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}var _d,vd,yd,wd,xd,Td,Ed,Sd=function(e){var t=new xu(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},Cd=function(e,t,n,i){var r=new xu(4);return r[0]=e,r[1]=t,r[2]=n,r[3]=i,r},Pd=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},Rd=function(e,t,n,i,r){return e[0]=t,e[1]=n,e[2]=i,e[3]=r,e},Md=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e},Ld=rd,Id=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e},Od=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},Bd=function(e,t,n,i){var r=t[0],s=t[1],o=t[2],a=t[3];return e[0]=r+i*(n[0]-r),e[1]=s+i*(n[1]-s),e[2]=o+i*(n[2]-o),e[3]=a+i*(n[3]-a),e},Nd=function(e){var t=e[0],n=e[1],i=e[2],r=e[3];return Math.hypot(t,n,i,r)},kd=Nd,Fd=function(e){var t=e[0],n=e[1],i=e[2],r=e[3];return t*t+n*n+i*i+r*r},Dd=Fd,Ud=function(e,t){var n=t[0],i=t[1],r=t[2],s=t[3],o=n*n+i*i+r*r+s*s;return o>0&&(o=1/Math.sqrt(o)),e[0]=n*o,e[1]=i*o,e[2]=r*o,e[3]=s*o,e},Vd=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},zd=function(e,t){var n=e[0],i=e[1],r=e[2],s=e[3],o=t[0],a=t[1],l=t[2],c=t[3];return Math.abs(n-o)<=wu*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-a)<=wu*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(r-l)<=wu*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(s-c)<=wu*Math.max(1,Math.abs(s),Math.abs(c))},Gd=(_d=rh(),vd=ah(1,0,0),yd=ah(0,1,0),function(e,t,n){var i=Ch(t,n);return i<-.999999?(Ph(_d,vd,t),$h(_d)<1e-6&&Ph(_d,yd,t),Sh(_d,_d),td(e,_d,Math.PI),e):i>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(Ph(_d,t,n),e[0]=_d[0],e[1]=_d[1],e[2]=_d[2],e[3]=1+i,Ud(e,e))}),jd=(wd=Jh(),xd=Jh(),function(e,t,n,i,r,s){return hd(wd,t,r,s),hd(xd,n,i,s),hd(e,wd,xd,2*s*(1-s)),e}),Hd=(Td=new xu(9),xu!=Float32Array&&(Td[1]=0,Td[2]=0,Td[3]=0,Td[5]=0,Td[6]=0,Td[7]=0),Td[0]=1,Td[4]=1,Td[8]=1,Ed=Td,function(e,t,n,i){return Ed[0]=n[0],Ed[3]=n[1],Ed[6]=n[2],Ed[1]=i[0],Ed[4]=i[1],Ed[7]=i[2],Ed[2]=-t[0],Ed[5]=-t[1],Ed[8]=-t[2],Ud(e,gd(e,Ed))}),Wd={};function qd(){var e=new xu(2);return xu!=Float32Array&&(e[0]=0,e[1]=0),e}function Kd(e){var t=new xu(2);return t[0]=e[0],t[1]=e[1],t}function Qd(e,t){var n=new xu(2);return n[0]=e,n[1]=t,n}function Xd(e,t){return e[0]=t[0],e[1]=t[1],e}function $d(e,t,n){return e[0]=t,e[1]=n,e}function Zd(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function Yd(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function Jd(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e}function ef(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e}function tf(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e}function nf(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e}function rf(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e}function sf(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e}function of(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e}function af(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function lf(e,t,n,i){return e[0]=t[0]+n[0]*i,e[1]=t[1]+n[1]*i,e}function cf(e,t){var n=t[0]-e[0],i=t[1]-e[1];return Math.hypot(n,i)}function Af(e,t){var n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}function uf(e){var t=e[0],n=e[1];return Math.hypot(t,n)}function hf(e){var t=e[0],n=e[1];return t*t+n*n}function df(e,t){return e[0]=-t[0],e[1]=-t[1],e}function ff(e,t){return e[0]=1/t[0],e[1]=1/t[1],e}function pf(e,t){var n=t[0],i=t[1],r=n*n+i*i;return r>0&&(r=1/Math.sqrt(r)),e[0]=t[0]*r,e[1]=t[1]*r,e}function gf(e,t){return e[0]*t[0]+e[1]*t[1]}function mf(e,t,n){var i=t[0]*n[1]-t[1]*n[0];return e[0]=e[1]=0,e[2]=i,e}function bf(e,t,n,i){var r=t[0],s=t[1];return e[0]=r+i*(n[0]-r),e[1]=s+i*(n[1]-s),e}function _f(e,t){t=t||1;var n=2*Tu()*Math.PI;return e[0]=Math.cos(n)*t,e[1]=Math.sin(n)*t,e}function vf(e,t,n){var i=t[0],r=t[1];return e[0]=n[0]*i+n[2]*r,e[1]=n[1]*i+n[3]*r,e}function yf(e,t,n){var i=t[0],r=t[1];return e[0]=n[0]*i+n[2]*r+n[4],e[1]=n[1]*i+n[3]*r+n[5],e}function wf(e,t,n){var i=t[0],r=t[1];return e[0]=n[0]*i+n[3]*r+n[6],e[1]=n[1]*i+n[4]*r+n[7],e}function xf(e,t,n){var i=t[0],r=t[1];return e[0]=n[0]*i+n[4]*r+n[12],e[1]=n[1]*i+n[5]*r+n[13],e}function Tf(e,t,n,i){var r=t[0]-n[0],s=t[1]-n[1],o=Math.sin(i),a=Math.cos(i);return e[0]=r*a-s*o+n[0],e[1]=r*o+s*a+n[1],e}function Ef(e,t){var n=e[0],i=e[1],r=t[0],s=t[1],o=Math.sqrt(n*n+i*i)*Math.sqrt(r*r+s*s),a=o&&(n*r+i*s)/o;return Math.acos(Math.min(Math.max(a,-1),1))}function Sf(e){return e[0]=0,e[1]=0,e}function Cf(e){return"vec2("+e[0]+", "+e[1]+")"}function Pf(e,t){return e[0]===t[0]&&e[1]===t[1]}function Rf(e,t){var n=e[0],i=e[1],r=t[0],s=t[1];return Math.abs(n-r)<=wu*Math.max(1,Math.abs(n),Math.abs(r))&&Math.abs(i-s)<=wu*Math.max(1,Math.abs(i),Math.abs(s))}vu(Wd,{add:()=>Zd,angle:()=>Ef,ceil:()=>tf,clone:()=>Kd,copy:()=>Xd,create:()=>qd,cross:()=>mf,dist:()=>Bf,distance:()=>cf,div:()=>Of,divide:()=>ef,dot:()=>gf,equals:()=>Rf,exactEquals:()=>Pf,floor:()=>nf,forEach:()=>Ff,fromValues:()=>Qd,inverse:()=>ff,len:()=>Mf,length:()=>uf,lerp:()=>bf,max:()=>sf,min:()=>rf,mul:()=>If,multiply:()=>Jd,negate:()=>df,normalize:()=>pf,random:()=>_f,rotate:()=>Tf,round:()=>of,scale:()=>af,scaleAndAdd:()=>lf,set:()=>$d,sqrDist:()=>Nf,sqrLen:()=>kf,squaredDistance:()=>Af,squaredLength:()=>hf,str:()=>Cf,sub:()=>Lf,subtract:()=>Yd,transformMat2:()=>vf,transformMat2d:()=>yf,transformMat3:()=>wf,transformMat4:()=>xf,zero:()=>Sf});var Mf=uf,Lf=Yd,If=Jd,Of=ef,Bf=cf,Nf=Af,kf=hf,Ff=function(){var e=qd();return function(t,n,i,r,s,o){var a,l;for(n||(n=2),i||(i=0),l=r?Math.min(r*n+i,t.length):t.length,a=i;a<l;a+=n)e[0]=t[a],e[1]=t[a+1],s(e,e,o),t[a]=e[0],t[a+1]=e[1];return t}}(),Df=(1+Math.sqrt(5))/2,Uf=(Math.PI,2*Math.PI/5),Vf=Math.PI/5,zf=Math.PI/10,Gf=2*Math.atan(Df),jf=Math.PI-Gf,Hf=(Math.PI,Math.acos(-1/Math.sqrt(3-Df)),(Math.sqrt(5)-1)/2),Wf=3-Math.sqrt(5),qf=Math.sqrt(3-Df),Kf=(Math.sqrt(3),6371007.2);Math.PI;yu.setMatrixArrayType(Float64Array);var Qf=class _PentagonShape{constructor(e){this.vertices=e,this.isWindingCorrect()||this.vertices.reverse()}getArea(){let e=0;const t=this.vertices.length;for(let n=0;n<t;n++){const i=(n+1)%t;e+=(this.vertices[i][0]-this.vertices[n][0])*(this.vertices[i][1]+this.vertices[n][1])}return e}isWindingCorrect(){return this.getArea()>=0}getVertices(){return this.vertices}scale(e){for(const t of this.vertices)Wd.scale(t,t,e);return this}rotate180(){for(const e of this.vertices)Wd.negate(e,e);return this}reflectY(){for(const e of this.vertices)e[1]=-e[1];return this.vertices.reverse(),this}translate(e){for(const t of this.vertices)Wd.add(t,t,e);return this}transform(e){for(const t of this.vertices)Wd.transformMat2(t,t,e);return this}transform2d(e){for(const t of this.vertices)Wd.transformMat2d(t,t,e);return this}clone(){return new _PentagonShape(this.vertices.map(e=>Wd.clone(e)))}getCenter(){const e=this.vertices.length;return this.vertices.reduce((t,n)=>[t[0]+n[0]/e,t[1]+n[1]/e],[0,0])}containsPoint(e){if(!this.isWindingCorrect())throw new Error("Pentagon is not counter-clockwise");const t=this.vertices.length;let n=1;for(let i=0;i<t;i++){const r=this.vertices[i],s=this.vertices[(i+1)%t],o=r[0]-s[0],a=r[1]-s[1],l=e[0]-r[0],c=e[1]-r[1],A=o*c-a*l;if(A<0){const e=Math.sqrt(l*l+c*c);n=Math.min(n,A/e)}}return n}splitEdges(e){if(e<=1)return this;const t=[],n=this.vertices.length;for(let i=0;i<n;i++){const r=this.vertices[i],s=this.vertices[(i+1)%n];t.push(Wd.clone(r));for(let n=1;n<e;n++){const i=n/e,o=Wd.create();Wd.lerp(o,r,s,i),t.push(o)}}return new _PentagonShape(t)}};yu.setMatrixArrayType(Float64Array);var Xf=[0,0],$f=[0,1],Zf=[.7885966681787006,1.6149108024237764],Yf=[1.6171013659387945,1.054928690397459],Jf=[Math.cos(zf),Math.sin(zf)],ep=2*Wd.length(Zf)*Math.cos(Vf),tp=Vf-Math.atan2(Zf[1],Zf[0]),np=2*Hf/ep;[Xf,$f,Zf,Yf,Jf].forEach(e=>{Wd.scale(e,e,np),Wd.rotate(e,e,[0,0],tp)});var ip=new Qf([Xf,$f,Zf,Yf,Jf]),rp=Math.atan2(Zf[1],Zf[0])-Vf,sp=Hf/Math.cos(Vf),op=rp+Vf,ap=[sp*Math.cos(op),sp*Math.sin(op)],lp=rp-Vf,cp=[sp*Math.cos(lp),sp*Math.sin(lp)],Ap=new Qf([[0,0],ap,cp]),up=Ru.fromValues(ap[0],ap[1],cp[0],cp[1]),hp=(Ru.invert(Ru.create(),up),new Float64Array([-.0022392098386786394,21308606513250217e-22,-2.559257686421274e-9,33701965267802837e-28,-4667545312611249e-30,667492870384816e-32])),dp=new Float64Array([.0022392089963541657,28831978048607556e-22,5.08622073997266e-9,102018123778161e-25,21912872306767718e-30,49284235482523806e-33]);yu.setMatrixArrayType(Float64Array);var fp=new class{applyCoefficients(e,t){const n=Math.sin(e),i=Math.cos(e),r=2*(i-n)*(i+n);let s,o;return s=r*t[5]+t[4],o=r*s+t[3],s=r*o-s+t[2],o=r*s-o+t[1],s=r*o-s+t[0],e+2*n*i*s}forward(e){return this.applyCoefficients(e,hp)}inverse(e){return this.applyCoefficients(e,dp)}};function pp(e){return e*(Math.PI/180)}function gp(e){return e*(180/Math.PI)}function mp(e){return[Wd.length(e),Math.atan2(e[1],e[0])]}function bp(e){const t=Math.atan2(e[1],e[0]),n=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);return[t,Math.acos(e[2]/n)]}function _p([e,t]){const n=Math.sin(t);return[n*Math.cos(e),n*Math.sin(e),Math.cos(t)]}function vp([e,t]){const n=pp(e+93),i=pp(t),r=fp.forward(i);return[n,Math.PI/2-r]}function yp(e){return((e+180)%360+360)%360-180}function wp([e,t]){const n=yp(gp(e)-93),i=Math.PI/2-t;return[n,gp(fp.inverse(i))]}yu.setMatrixArrayType(Float64Array);var xp=Math.sqrt(5),Tp=Math.sqrt(.2),Ep=Math.sqrt((1-Tp)/2),Sp=Math.sqrt((1+Tp)/2),Cp=.5,Pp=Math.sqrt((2.5-xp)/10),Rp=Math.sqrt((2.5+xp)/10),Mp=Math.sqrt((1+Tp)/8),Lp=Math.sqrt((1-Tp)/8),Ip=Math.sqrt((3-xp)/8),Op=Math.sqrt((3+xp)/8),Bp=[[0,0],[Ep,0],[Pp,Cp],[-Mp,Ip],[-Mp,-Ip],[Pp,-Cp],[-Sp,0],[-Lp,-Op],[Rp,-Cp],[Rp,Cp],[-Lp,Op],[0,0]].map(([e,t])=>[-t,e]).map((e,t)=>0===t?[0,0,0,1]:11===t?[0,-1,0,0]:[...e,0,t<6?Sp:Ep]);yu.setMatrixArrayType(Float64Array);var Np=["vu","uw","vw","vw","vw"],kp=["wu","uw","vw","vu","uw"],Fp=["wu","uv","wv","wu","uw"],Dp=["vu","uv","wv","wu","uw"],Up=[Np,Dp,Fp,kp,Fp,Dp,Fp,kp,kp,kp,Dp,Dp],Vp=[4,2,3,2,0,4,3,2,2,0,3,0],zp=[0,1,2,4,3,5,7,8,6,11,10,9],Gp=[];var jp=0;function Hp(e,t,n){if(jp>11)throw new Error(`Too many origins: ${jp}`);const i=nh.create();nh.conjugate(i,n);const r={id:jp,axis:e,quat:n,inverseQuat:i,angle:t,orientation:Up[jp],firstQuintant:Vp[jp]};Gp.push(r),jp++}function Wp(e,t){const n=t.orientation,i=n===Np||n===kp?-1:1,r=(e-t.firstQuintant+5)%5,s=n[r];return{quintant:(t.firstQuintant+i*r+5)%5,orientation:s}}!function(){Hp([0,0],0,Bp[0]);for(let e=0;e<5;e++){const t=e*Uf,n=t+Vf;Hp([t,jf],Vf,Bp[e+1]),Hp([n,Math.PI-jf],Vf,Bp[(e+3)%5+6])}Hp([0,Math.PI],0,Bp[11])}(),Gp.sort((e,t)=>zp.indexOf(e.id)-zp.indexOf(t.id)),Gp.forEach((e,t)=>e.id=t);var qp=class{forward([e,t]){return[Math.tan(t),e]}inverse([e,t]){return[t,Math.atan(e)]}},Kp=ih.create(),Qp=ih.create(),Xp=ih.create(),$p=ih.create();function Zp(e,t){ih.lerp(Kp,e,t,.5),ih.normalize(Kp,Kp),ih.cross(Kp,e,Kp);const n=ih.length(Kp);if(n<1e-8){const n=ih.subtract(ih.create(),e,t);return.5*ih.length(n)}return n}function Yp(e,t,n,i){const r=ih.angle(t,n);if(r<1e-12)return ih.lerp(e,t,n,i);const s=Math.sin((1-i)*r)/Math.sin(r),o=Math.sin(i*r)/Math.sin(r),a=ih.scale(ih.create(),t,s),l=ih.scale(ih.create(),n,o);return ih.add(e,a,l)}yu.setMatrixArrayType(Float64Array);var Jp=ih.create(),eg=ih.create(),tg=ih.create(),ng=ih.create(),ig=class{constructor(e){this._area=null,this.vertices=e,Object.freeze(this.vertices)}getBoundary(e=1,t=!0){const n=[],i=this.vertices.length;for(let t=0;t<i*e;t++){const i=t/e;n.push(this.slerp(i))}return t&&n.push(n[0]),n}slerp(e){const t=this.vertices.length,n=e%1,i=Math.floor(e%t),r=(i+1)%t;return Yp(ih.create(),this.vertices[i],this.vertices[r],n)}getTransformedVertices(e){const t=this.vertices.length,n=Math.floor(e%t),i=(n+1)%t,r=(n+t-1)%t,s=ih.clone(this.vertices[n]),o=ih.clone(this.vertices[i]),a=ih.clone(this.vertices[r]);return ih.sub(o,o,s),ih.sub(a,a,s),[s,o,a]}containsPoint(e){const t=this.vertices.length;let n=1/0;for(let i=0;i<t;i++){const[t,r,s]=this.getTransformedVertices(i),o=ih.sub(ih.create(),e,t);ih.normalize(o,o),ih.normalize(r,r),ih.normalize(s,s);const a=ih.cross(ih.create(),r,o),l=ih.cross(ih.create(),o,s),c=ih.dot(t,a),A=ih.dot(t,l);n=Math.min(n,c,A)}return n}getTriangleArea(e,t,n){ih.lerp(Jp,t,n,.5),ih.lerp(eg,n,e,.5),ih.lerp(tg,e,t,.5),ih.normalize(Jp,Jp),ih.normalize(eg,eg),ih.normalize(tg,tg);const i=(r=Jp,s=eg,o=tg,ih.cross(Qp,s,o),ih.dot(r,Qp));var r,s,o;const a=Math.max(-1,Math.min(1,i));return Math.abs(a)<1e-8?2*a:2*Math.asin(a)}getArea(){return null===this._area&&(this._area=this._getArea()),this._area}_getArea(){if(this.vertices.length<3)return 0;if(3===this.vertices.length)return this._area=this.getTriangleArea(this.vertices[0],this.vertices[1],this.vertices[2]),this._area;ih.set(ng,0,0,0);for(const e of this.vertices)ih.add(ng,ng,e);ih.normalize(ng,ng);let e=0;for(let t=0;t<this.vertices.length;t++){const n=this.vertices[t],i=this.vertices[(t+1)%this.vertices.length],r=this.getTriangleArea(ng,n,i);isNaN(r)||(e+=r)}return this._area=e,this._area}isWindingCorrect(){this.getArea()}};yu.setMatrixArrayType(Float64Array);var rg=class extends ig{constructor(e){if(3!==e.length)throw new Error("SphericalTriangleShape requires exactly 3 vertices");super(e)}};yu.setMatrixArrayType(Float64Array);var sg=class{forward(e,t,n){const[i,r,s]=t,o=new rg([i,r,s]),a=ih.subtract(ih.create(),e,i);ih.normalize(a,a);const l=function(e,t,n,i,r){ih.cross(Qp,i,r);const s=ih.dot(t,Qp),o=ih.dot(n,Qp);return ih.scale(Xp,t,o),ih.scale($p,n,s),ih.sub(e,$p,Xp)}(ih.create(),i,a,r,s);ih.normalize(l,l);const c=Zp(i,e)/Zp(i,l),A=c/o.getArea();return function(e,[t,n,i]){return[e[0]*t[0]+e[1]*n[0]+e[2]*i[0],e[0]*t[1]+e[1]*n[1]+e[2]*i[1]]}([1-c,A*new rg([i,l,s]).getArea(),A*new rg([i,r,l]).getArea()],n)}inverse(e,t,n){const[i,r,s]=n,o=new rg([i,r,s]),a=function(e,[t,n,i]){const r=[t[0]-i[0],t[1]-i[1]],s=[i[0]-n[0],i[1]-n[1]],o=[e[0]-i[0],e[1]-i[1]],a=s[0]*r[1]-s[1]*r[0],l=(s[0]*o[1]-s[1]*o[0])/a,c=(r[0]*o[1]-r[1]*o[0])/a;return[l,c,1-(l+c)]}(e,t),l=1-1e-14;if(a[0]>l)return i;if(a[1]>l)return r;if(a[2]>l)return s;const c=ih.create();ih.cross(c,r,s);const A=o.getArea(),u=1-a[0],h=a[2]/u*A,d=Math.sin(h),f=Math.sin(h/2),p=2*f*f,g=ih.dot(i,r),m=ih.dot(r,s),b=ih.dot(s,i),_=ih.length(c),v=d*ih.dot(i,c)+p*(g*m-b),y=p*_*(1+g),w=2/Math.acos(m)*Math.atan2(y,v),x=Yp(ih.create(),r,s,w),T=Zp(i,x);return Yp([0,0,0],i,x,this.safeAcos(u*T)/this.safeAcos(T))}safeAcos(e){return e<.001?2*e+e*e*e/3:Math.acos(1-2*e*e)}},og=-1;yu.setMatrixArrayType(Float64Array);var ag=([e,t])=>Wd.fromValues(e-t,t);yu.setMatrixArrayType(Float64Array);var lg=Wd.fromValues(1,0),cg=Wd.fromValues(0,1),Ag=Wd.negate(Wd.create(),lg),ug=Wd.negate(Wd.create(),cg),hg=Wd.fromValues(0,0),dg=(e,[t,n])=>{let i=hg,r=hg;switch(1===t&&1===n?(i=lg,r=cg):t===og&&1===n?(i=ug,r=Ag):1===t&&n===og?(i=cg,r=lg):t===og&&n===og&&(i=Ag,r=ug),e){case 0:return hg;case 1:return i;case 2:return Wd.add(Wd.create(),r,i);case 3:return Wd.scaleAndAdd(Wd.create(),r,i,2);default:throw new Error(`Invalid Quaternary value: ${e}`)}},fg=e=>[[1,1],[1,og],[1,1],[og,1]][e];function pg(e){return Array.from({length:e.length},(t,n)=>e.indexOf(n))}var gg=[0,1,3,4,5,6,7,2],mg=[0,1,2,7,3,4,5,6],bg=(pg(gg),pg(mg),(e,t,n,i,r)=>{if(t<=0)return;const s=e[t]||0,o=e[t-1];let a=!0,l=!0;if(i!==(0===n[0]+n[1])?(a=1===s||2===s,l=1===s):(a=s<2,l=0===s),!a)return;const c=l?o:o+4,A=r[c];e[t-1]=A%4,e[t]=(s+4+Math.floor(A/4)-Math.floor(c/4))%4});yu.setMatrixArrayType(Float64Array);var _g=Wd.fromValues(-1,1),vg=(e,t,n,i=true)=>{let r=BigInt(e);const s="wv"===n||"vw"===n,o="wu"===n||"uw"===n;("vu"===n||"wu"===n||"vw"===n)&&(r=(1n<<BigInt(2*t))-r-1n);const a=yg(r,t,s,o,i);if(o){const{offset:[e,t],flips:[n,i]}=a;a.offset=[t,e],n===og&&Wd.add(a.offset,a.offset,_g),i===og&&Wd.subtract(a.offset,a.offset,_g)}if(s){const{offset:[e,n],flips:i}=a,r=(1<<t)-(e+n);i[0]=-i[0],a.offset[1]=r,a.flips=i}return a},yg=(e,t,n,i,r=true)=>{const s=Wd.create(),o=[1,1];let a=BigInt(e);const l=[];for(;a>0n||l.length<t;)l.push(Number(a%4n)),a>>=2n;const c=i?mg:gg;for(let e=l.length-1;e>=0;e--)r&&bg(l,e,o,n,c),Wd.multiply(o,o,fg(l[e]));o[0]=1,o[1]=1;for(let e=l.length-1;e>=0;e--){Wd.scale(s,s,2);const t=dg(l[e],o);Wd.add(s,s,t),Wd.multiply(o,o,fg(l[e]))}return{q:l[0]||0,offset:ag(s),flips:o}},wg=.1;Math.cos(45*Math.PI/180),Math.sin(45*Math.PI/180),Math.cos(113*Math.PI/180),Math.sin(113*Math.PI/180),Math.cos(293*Math.PI/180),Math.sin(293*Math.PI/180),Math.cos(225*Math.PI/180),Math.sin(225*Math.PI/180);yu.setMatrixArrayType(Float64Array);var xg=Wd.clone(cp),Tg=Wd.negate(Wd.create(),cp),Eg=[0,1,2,3,4].map(e=>{const t=Ru.create();return Ru.fromRotation(t,Uf*e),t}),Sg=Wd.create();function Cg(e){const t=Ap.clone();return t.transform(Eg[e]),t}yu.setMatrixArrayType(Float64Array);yu.setMatrixArrayType(Float64Array);var Pg=new class{constructor(){if(this.vertices=[],this.invocations=0,this.addFaceCenters(),this.addVertices(),this.addMidpoints(),62!==this.vertices.length)throw new Error("Failed to construct CRS: vertices length is not 62");Object.freeze(this.vertices)}getVertex(e){this.invocations++,1e4===this.invocations&&console.warn("Too many CRS invocations, results should be cached");for(const t of this.vertices)if(ih.distance(e,t)<1e-5)return t;throw new Error("Failed to find vertex in CRS")}addFaceCenters(){Gp.forEach(e=>this.add(_p(e.axis)))}addVertices(){const e=Math.atan(Wf);for(const t of Gp)for(let n=0;n<5;n++){const i=_p([(2*n+1)*Math.PI/5+t.angle,e]);ih.transformQuat(i,i,t.quat),this.add(i)}}addMidpoints(){const e=Math.atan(Hf);for(const t of Gp)for(let n=0;n<5;n++){const i=_p([2*n*Math.PI/5+t.angle,e]);ih.transformQuat(i,i,t.quat),this.add(i)}}add(e){const t=ih.normalize(ih.create(),e);return!this.vertices.find(e=>ih.distance(t,e)<1e-5)&&(this.vertices.push(t),!0)}},Rg=30,Mg=58n;function Lg(e){if(0n===e)return-1;if(1n&e||0b100n==(0b111n&e)||0b10000n==(0b11111n&e))return Rg;let t=29,n=e>>1n;if(0n===n)return-1;let i,r=Number(0xFFFFFFFFn&n);for(0===r?(n>>=32n,t-=16,i=Number(n)):i=r,65535&i||(i>>=16,t-=8),t>=6&&!(255&i)&&(i>>=8,t-=4),t>=4&&!(15&i)&&(i>>=4,t-=2);t>-1&&!(1&i);)t-=1,i>>=t<2?1:2;return t}function Ig(e){const t=Lg(e);if(-1===t)return{origin:Gp[0],segment:0,S:0n,resolution:t};let n=Mg,i=0;if(t===Rg){const t=1n&e?1n:0b100n&e?3n:5n;n=Mg+t,i=1n===t?0:3n===t?32:40}const r=Number(e>>n)+i;let s,o;if(0===t)s=Gp[r],o=0;else{const e=Math.floor(r/5);s=Gp[e],o=(r+s.firstQuintant)%5}if(!s)throw new Error(`Could not parse origin: ${r}`);if(t<2)return{origin:s,segment:o,S:0n,resolution:t};return{origin:s,segment:o,S:(e&(1n<<n)-1n)>>n-BigInt(2*(t-2+1)),resolution:t}}yu.setMatrixArrayType(Float64Array);Ru.create();var Og=new class{constructor(){this.faceTriangles=[],this.sphericalTriangles=[],this.polyhedral=new sg,this.gnomonic=new qp}forward(e,t){const n=Gp[t],i=_p(e),r=ih.create();ih.transformQuat(r,i,n.inverseQuat);const s=bp(r),o=this.gnomonic.forward(s);o[1]=o[1]-n.angle;const a=this.getFaceTriangleIndex(o),l=this.shouldReflect(o);let c=this.getFaceTriangle(a,l,!1),A=this.getSphericalTriangle(a,t,l);return this.polyhedral.forward(i,A,c)}inverse(e,t){const n=mp(e),i=this.getFaceTriangleIndex(n),r=this.shouldReflect(n),s=this.getFaceTriangle(i,r,!1),o=this.getSphericalTriangle(i,t,r);return bp(this.polyhedral.inverse(e,s,o))}shouldReflect(e){const[t,n]=e,i=function([e,t]){return[e*Math.cos(t),e*Math.sin(t)]}([t,this.normalizeGamma(n)])[0];return i>Hf}getFaceTriangleIndex([e,t]){return(Math.floor(t/Vf)+10)%10}getFaceTriangle(e,t=!1,n=!1){let i=e;return t&&(i+=n?20:10),this.faceTriangles[i]||(this.faceTriangles[i]=t?this._getReflectedFaceTriangle(e,n):this._getFaceTriangle(e),Object.freeze(this.faceTriangles[i])),this.faceTriangles[i]}_getFaceTriangle(e){const t=Math.floor((e+1)/2)%5,[n,i,r]=Cg(t).getVertices(),s=Wd.create();Wd.lerp(s,i,r,.5);return e%2==0?[n,s,i]:[n,r,s]}_getReflectedFaceTriangle(e,t=!1){let[n,i,r]=this._getFaceTriangle(e).map(e=>Wd.clone(e));const s=e%2==0;Wd.negate(n,n);const o=s?i:r;return Wd.scaleAndAdd(n,n,o,t?1+1/Math.cos(jf):2),[n,r,i]}getSphericalTriangle(e,t,n=!1){let i=10*t+e;return n&&(i+=120),this.sphericalTriangles[i]||(this.sphericalTriangles[i]=this._getSphericalTriangle(e,t,n),Object.freeze(this.sphericalTriangles[i])),this.sphericalTriangles[i]}_getSphericalTriangle(e,t,n=!1){const i=Gp[t];return this.getFaceTriangle(e,n,!0).map(e=>{const[t,n]=mp(e),r=[t,n+i.angle],s=_p(this.gnomonic.inverse(r));return ih.transformQuat(s,s,i.quat),Pg.getVertex(s)})}normalizeGamma(e){const t=e/Uf;return(t-Math.round(t))*Uf}};function Bg({S:e,segment:t,origin:n,resolution:i}){const{quintant:r,orientation:s}=Wp(t,n);if(1===i){return Cg(r)}if(0===i)return function(){const e=[];for(const t of Eg)e.push(Wd.transformMat2(Wd.create(),ap,t));return e.reverse(),new Qf(e)}();const o=i-2+1;return function(e,t,n){const i=ip.clone();Wd.transformMat2(Sg,n.offset,up),1===n.flips[0]&&n.flips[1]===og&&i.rotate180();const{q:r}=n,s=n.flips[0]+n.flips[1];return((-2===s||2===s)&&r>1||0===s&&(0===r||3===r))&&i.reflectY(),n.flips[0]===og&&n.flips[1]===og?i.rotate180():n.flips[0]===og?i.translate(Tg):n.flips[1]===og&&i.translate(xg),i.translate(Sg),i.scale(1/2**e),i.transform(Eg[t]),i}(o,r,vg(e,o,s))}function Ng(e,{closedRing:t=!0,segments:n="auto"}={closedRing:!0,segments:"auto"}){if(0n===e)return[];const{S:i,segment:r,origin:s,resolution:o}=Ig(e);"auto"===n&&(n=Math.max(1,Math.pow(2,6-o)));const a=function(e){const t=e.map(e=>_p(vp(e))),n=ih.create();for(const e of t)ih.add(n,n,e);ih.normalize(n,n);let[i,r]=wp(bp(n));return(r>89.99||r<-89.99)&&(i=e[0][0]),i=yp(i),e.map(e=>{let[t,n]=e;for(;t-i>180;)t-=360;for(;t-i<-180;)t+=360;return[t,n]})}(Bg({S:i,segment:r,origin:s,resolution:o}).splitEdges(n).getVertices().map(e=>Og.inverse(e,s.id)).map(e=>wp(e)));return t&&a.push(a[0]),a.reverse(),a}var kg=12742014.4/Math.sqrt(15),Fg=new Array(31);Fg[0]=12742014.4/Math.sqrt(3);for(let e=1;e<=30;e++)Fg[e]=kg/(1<<e-1);yu.setMatrixArrayType(Float64Array);var Dg=function(e){var t,n=void 0!==(e=e||{})?e:{},i={};for(t in n)n.hasOwnProperty(t)&&(i[t]=n[t]);var r,s=[],o="";"undefined"!=typeof document&&document.currentScript&&(o=document.currentScript.src),o=0!==o.indexOf("blob:")?o.substr(0,o.lastIndexOf("/")+1):"",r=function(e,t,n){var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=function(){if(200==i.status||0==i.status&&i.response)t(i.response);else{var r=$(e);r?t(r.buffer):n()}},i.onerror=n,i.send(null)};var a=n.print||console.log.bind(console),l=n.printErr||console.warn.bind(console);for(t in i)i.hasOwnProperty(t)&&(n[t]=i[t]);i=null,n.arguments&&(s=n.arguments);var c=0;var A=!1;function u(e){var t,i=n["_"+e];return t="Cannot call unknown function "+e+", make sure it is exported",i||Ae("Assertion failed: "+t),i}function h(e,t,n,i,r){var s={string:function(e){var t=0;if(null!=e&&0!==e){var n=1+(e.length<<2);(function(e,t,n){(function(e,t,n,i){if(!(i>0))return 0;for(var r=n,s=n+i-1,o=0;o<e.length;++o){var a=e.charCodeAt(o);if(a>=55296&&a<=57343)a=65536+((1023&a)<<10)|1023&e.charCodeAt(++o);if(a<=127){if(n>=s)break;t[n++]=a}else if(a<=2047){if(n+1>=s)break;t[n++]=192|a>>6,t[n++]=128|63&a}else if(a<=65535){if(n+2>=s)break;t[n++]=224|a>>12,t[n++]=128|a>>6&63,t[n++]=128|63&a}else{if(n+3>=s)break;t[n++]=240|a>>18,t[n++]=128|a>>12&63,t[n++]=128|a>>6&63,t[n++]=128|63&a}}t[n]=0})(e,m,t,n)})(e,t=ne(n),n)}return t},array:function(e){var t=ne(e.length);return function(e,t){g.set(e,t)}(e,t),t}};var o=u(e),a=[],l=0;if(i)for(var c=0;c<i.length;c++){var A=s[n[c]];A?(0===l&&(l=re()),a[c]=A(i[c])):a[c]=i[c]}var h=o.apply(null,a);return h=function(e){return"string"===t?f(e):"boolean"===t?Boolean(e):e}(h),0!==l&&ie(l),h}var d="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function f(e,t){return e?function(e,t,n){for(var i=t+n,r=t;e[r]&&!(r>=i);)++r;if(r-t>16&&e.subarray&&d)return d.decode(e.subarray(t,r));for(var s="";t<r;){var o=e[t++];if(128&o){var a=63&e[t++];if(192!=(224&o)){var l=63&e[t++];if((o=224==(240&o)?(15&o)<<12|a<<6|l:(7&o)<<18|a<<12|l<<6|63&e[t++])<65536)s+=String.fromCharCode(o);else{var c=o-65536;s+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else s+=String.fromCharCode((31&o)<<6|a)}else s+=String.fromCharCode(o)}return s}(m,e,t):""}var p,g,m,b,_,v,y;"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");function w(e,t){return e%t>0&&(e+=t-e%t),e}function x(e){p=e,n.HEAP8=g=new Int8Array(e),n.HEAP16=b=new Int16Array(e),n.HEAP32=_=new Int32Array(e),n.HEAPU8=m=new Uint8Array(e),n.HEAPU16=new Uint16Array(e),n.HEAPU32=new Uint32Array(e),n.HEAPF32=v=new Float32Array(e),n.HEAPF64=y=new Float64Array(e)}var T=n.TOTAL_MEMORY||33554432;function E(e){for(;e.length>0;){var t=e.shift();if("function"!=typeof t){var i=t.func;"number"==typeof i?void 0===t.arg?n.dynCall_v(i):n.dynCall_vi(i,t.arg):i(void 0===t.arg?null:t.arg)}else t()}}T=(p=n.buffer?n.buffer:new ArrayBuffer(T)).byteLength,x(p),_[7096]=5271296;var S=[],C=[],P=[],R=[];function M(e){S.unshift(e)}function L(e){R.unshift(e)}var I=Math.abs,O=Math.ceil,B=Math.floor,N=Math.min,k=0,F=null,D=null;n.preloadedImages={},n.preloadedAudios={};var U,V,z=null,G="data:application/octet-stream;base64,";function j(e){return String.prototype.startsWith?e.startsWith(G):0===e.indexOf(G)}z="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAGC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+T8AAAAAAAAAABgtRFT7IQlAGC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAGC1EVPshCUAAAAAAAAAAABgtRFT7Ifm/GC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgtRFT7Ifm/GC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+b8AAAAAAAAAABgtRFT7IQnAGC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPshCcAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAMpi5RexJsw/BlIKPVwR5T95Wyu0/QjnP5PjoT7YYcu/mBhKZ6zrwj8wRYS7NebuP3qW6geh+Ls/SLrixebL3r+pcyymN9XrPwmkNHp7xec/GWNMZVAA17+82s+x2BLiPwn2ytbJ9ek/LgEH1sMS1j8yp/2LhTfeP+SnWwtQBbu/d38gkp5X7z8ytsuHaADGPzUYObdf1+m/7IauECWhwz+cjSACjzniP76Z+wUhN9K/1+GEKzup67+/GYr/04baPw6idWOvsuc/ZedTWsRa5b/EJQOuRzi0v/OncYhHPes/h49PixY53j+i8wWfC03Nvw2idWOvsue/ZedTWsRa5T/EJQOuRzi0P/KncYhHPeu/iY9PixY53r+i8wWfC03NP9anWwtQBbs/d38gkp5X778ytsuHaADGvzUYObdf1+k/74auECWhw7+cjSACjzniv8CZ+wUhN9I/1uGEKzup6z+/GYr/04bavwmkNHp7xee/F2NMZVAA1z+82s+x2BLivwr2ytbJ9em/KwEH1sMS1r8yp/2LhTfev81i5RexJsy/BlIKPVwR5b95Wyu0/Qjnv5DjoT7YYcs/nBhKZ6zrwr8wRYS7Nebuv3OW6geh+Lu/SLrixebL3j+pcyymN9Xrv8rHIFfWehZAMBwUdlo0DECTUc17EOb2PxpVB1SWChdAzjbhb9pTDUDQhmdvECX5P9FlMKCC9+g/IIAzjELgE0DajDngMv8GQFhWDmDPjNs/y1guLh96EkAxPi8k7DIEQJCc4URlhRhA3eLKKLwkEECqpNAyTBD/P6xpjXcDiwVAFtl//cQm4z+Ibt3XKiYTQM7mCLUb3QdAoM1t8yVv7D8aLZv2Nk8UQEAJPV5nQwxAtSsfTCoE9z9TPjXLXIIWQBVanC5W9AtAYM3d7Adm9j++5mQz1FoWQBUThyaVBghAwH5muQsV7T89Q1qv82MUQJoWGOfNuBdAzrkClkmwDkDQjKq77t37Py+g0dtitsE/ZwAMTwVPEUBojepluNwBQGYbtuW+t9w/HNWIJs6MEkDTNuQUSlgEQKxktPP5TcQ/ixbLB8JjEUCwuWjXMQYCQAS/R09FkRdAowpiZjhhDkB7LmlczD/7P01iQmhhsAVAnrtTwDy84z/Z6jfQ2TgTQChOCXMnWwpAhrW3daoz8z/HYJvVPI4VQLT3ik5FcA5Angi7LOZd+z+NNVzDy5gXQBXdvVTFUA1AYNMgOeYe+T8+qHXGCwkXQKQTOKwa5AJA8gFVoEMW0T+FwzJyttIRQAEAAAD/////BwAAAP////8xAAAA/////1cBAAD/////YQkAAP////+nQQAA/////5HLAQD/////95AMAP/////B9lcAAAAAAAAAAAAAAAAAAgAAAP////8OAAAA/////2IAAAD/////rgIAAP/////CEgAA/////06DAAD/////IpcDAP/////uIRkA/////4LtrwAAAAAAAAAAAAAAAAAAAAAAAgAAAP//////////AQAAAAMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////wIAAAD//////////wEAAAAAAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA/////////////////////wEAAAD///////////////8CAAAA////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD///////////////////////////////8CAAAA////////////////AQAAAP////////////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAAAQAAAP//////////AgAAAP//////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAAEAAAD//////////wIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAgAAAAAAAAACAAAAAQAAAAEAAAACAAAAAgAAAAAAAAAFAAAABQAAAAAAAAACAAAAAgAAAAMAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAABAAAAAgAAAAIAAAACAAAAAAAAAAUAAAAGAAAAAAAAAAIAAAACAAAAAwAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAIAAAAAAAAAAgAAAAEAAAADAAAAAgAAAAIAAAAAAAAABQAAAAcAAAAAAAAAAgAAAAIAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAgAAAAAAAAACAAAAAQAAAAQAAAACAAAAAgAAAAAAAAAFAAAACAAAAAAAAAACAAAAAgAAAAMAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAACAAAAAAAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAUAAAAJAAAAAAAAAAIAAAACAAAAAwAAAAUAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAIAAAACAAAAAAAAAAMAAAAOAAAAAgAAAAAAAAACAAAAAwAAAAAAAAAAAAAAAgAAAAIAAAADAAAABgAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAgAAAAIAAAAAAAAAAwAAAAoAAAACAAAAAAAAAAIAAAADAAAAAQAAAAAAAAACAAAAAgAAAAMAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAgAAAAAAAAADAAAACwAAAAIAAAAAAAAAAgAAAAMAAAACAAAAAAAAAAIAAAACAAAAAwAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAACAAAAAAAAAAMAAAAMAAAAAgAAAAAAAAACAAAAAwAAAAMAAAAAAAAAAgAAAAIAAAADAAAACQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAgAAAAIAAAAAAAAAAwAAAA0AAAACAAAAAAAAAAIAAAADAAAABAAAAAAAAAACAAAAAgAAAAMAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAgAAAAAAAAADAAAABgAAAAIAAAAAAAAAAgAAAAMAAAAPAAAAAAAAAAIAAAACAAAAAwAAAAsAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAIAAAACAAAAAAAAAAMAAAAHAAAAAgAAAAAAAAACAAAAAwAAABAAAAAAAAAAAgAAAAIAAAADAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAIAAAAAAAAAAwAAAAgAAAACAAAAAAAAAAIAAAADAAAAEQAAAAAAAAACAAAAAgAAAAMAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAACAAAAAgAAAAAAAAADAAAACQAAAAIAAAAAAAAAAgAAAAMAAAASAAAAAAAAAAIAAAACAAAAAwAAAA4AAAAAAAAAAAAAAAAAAAAAAAAACQAAAAIAAAACAAAAAAAAAAMAAAAFAAAAAgAAAAAAAAACAAAAAwAAABMAAAAAAAAAAgAAAAIAAAADAAAADwAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAgAAAAAAAAACAAAAAQAAABMAAAACAAAAAgAAAAAAAAAFAAAACgAAAAAAAAACAAAAAgAAAAMAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABEAAAACAAAAAAAAAAIAAAABAAAADwAAAAIAAAACAAAAAAAAAAUAAAALAAAAAAAAAAIAAAACAAAAAwAAABEAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAIAAAAAAAAAAgAAAAEAAAAQAAAAAgAAAAIAAAAAAAAABQAAAAwAAAAAAAAAAgAAAAIAAAADAAAAEgAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAACAAAAAQAAABEAAAACAAAAAgAAAAAAAAAFAAAADQAAAAAAAAACAAAAAgAAAAMAAAATAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAACAAAAAAAAAAIAAAABAAAAEgAAAAIAAAACAAAAAAAAAAUAAAAOAAAAAAAAAAIAAAACAAAAAwAAAAIAAAABAAAAAAAAAAEAAAACAAAAAAAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAEAAAAAAAAAAgAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAAAAAAAAAAABQAAAAQAAAAAAAAAAQAAAAUAAAAEAAAAAAAAAAUAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAgAAAAAAAAABAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAAAAAAAAAAABQAAAAQAAAAAAAAAAQAAAAUAAAAEAAAAAAAAAAUAAAAFAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAABAAAAAAEAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAEAAAAAAAAAAAAAOgehWlKfUEEz1zLi+JsiQa2og3wcMfVAWCbHorc0yEDi+Yn/Y6mbQJ11/mfsnG9At6bnG4UQQkBvMCQWKqUUQJVmwwswmOc/3hVgVBL3uj//qqOEOdGOPw/WDN4gnGE/H3ANkCUgND+AA8btKgAHPwTXBqJVSdo+XfRQAqsKrj4fc+zLYbSPQklEmCZHv2FCUP+uDso1NEKYtPhwphUHQptxnyFXYdpB7CddZAMmrkGAt1AxSTqBQUibBVdTsFNBSuX3MV+AJkFocv82SLf5QAqmgj7AY81A23VDSEnLoEDGEJVSeDFzQDYrqvBk70VA8U157pcRGUBWfEF+ZKbsP6phvycGBZRAJbod0OgwfkCp+L8jatBmQCjl3pGrPlFAfMWm114SOkButwtqS7UjQHQwbcjXyw1A8jnLuuyA9j9KwjL0VwHhPyotk0lcs8k/Q5PvEs9rsz+SfsOQEVqdPzUAKDojLoY/WJz/kcjCcD8YFu070FRZPyoLC2BdJEM/YOXQAuiMM0HIBz1bw3sdQdV46aaHRwZByatzjDPX8EDb3Jie8HXZQCJxj6ULP8NAUaG6uRAZrUCWdmou5/mVQLb9huRPm4BAhvoCHygZaUCuX/I3SPdSQC9/bC/1qTxAfKxsYQ6pJUCuslH+N14QQMS/cv7SvPg/Ol8maYKx4j8AAAAA/////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAD/////AAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAA/////wAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAP////8AAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////BQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAA/////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAUAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAEAAQAAAQEAAAAAAAEAAAABAAAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAKriWFiWZfg/Y2nmTbY/8z8MHSPSqmnjv6hnn18HR3c/quJYWJZl+D/jq5TzDdzyPwwdI9KqaeO/u0kC1eFSBECq4lhYlmX4P69pJmt7c/E/NnkJi6jSBsDESFlzKkr6P33ArMz7sfY/o2q2uqM08D+oZ59fB0d3PzEqCi3qrvK/kmm4ANp49D+4wS2wzhzvP9WJvyAnx+E/upcY75RVx7+95t+9y0T1P9L18g1caO0/k6CkRyVzAEBf99+e/GjxP6QMsuuLQ/U/PlP4Qr8q7j8Mb/GO2GMCwLl2K/DQIghAePiwytEp9D9UHrsuI/nqPzjMedJ+yuy/k6xgf58n/L+XoQtn22DzP2lzCnsYk+s/JhUSDI4P8z+8lFcBhgTcPxOqKRxEX/M/89MEdoPQ6j8OKQaXDob7vzWwNvblgAPAzGkxMcl88j9Nm4okPkbpP0vI89vxSgRAdac2Z6W2/T+6UFOMC3zyP/+2XEF3hug/QqhELwGKCMAwdlQerEoEQFcr/B+VnvE/hB1hfFzT5j8wdsE/Da64P0hIvnF/sOC/KH/hrXUg8T9bI5OQHaLlP+mYzla7td6/CtKG6iOm8b8FW3TV8oXwP8ORhtNuJ+c/q8JrTMz/AcC8PaUl+PUFwAXv9rkMT/A/m+sAswr15D+7hk/O3yvkP6c/yVsOHKI/qqAX9idJ8D/8hNz1KNPiP7xSXh3Ggvg/epbkiKr57T/23/LB1GLvP4GTTeNZi+M/W4TqlTheBcDupZgIdYUIQGwlcW3YZO8/tQvDXQ3H4j8Bt+sf9DkAQMdFie+nNvg/Z5Uh1wDX7j9h5X2d4KjhPxMJ1ZVT4Pa/evqB8xB//7+W183U9QLsPwzNxsC7AOA/af/LqCnK/r/lPceQ0FQDwHoY0nYIW+w/bHNSHrTg4D/DFcMAdabuv2sz5Ojhnve/FvLf01HN6z/tEDL2Hz/gP0bBv0KUhPA/pd7sEnMc4D8EGon4Lo7sP5NVbYtSON8/DAMC50odBkB+Z2J8MGYCQIhlM1gubOo/FssiPwWy4D8OIlGqRnkCQAd1vopp6f4/QS1keLLK6T9rfoBuT7LZP3KQbH5ugwjAjqVPXTmbBUBL/JxcqR3qP3oSeovuktg/Y6pRhJmqy7+0kwuU0Yjmv2wvsfFmQ+g/R98lJFqQ2T/IGb5gjLkCwK3mNff3kQbAqDznPFM86T+iiP0FfsvYP7fzKG6Mls0/h7+at2btzL8tsUTgk+LmP/YEIrTDINU/WmwKoVjA5L9aC02r6FHxvzzFCT/Qg+Y/nx0V97en0j8+1toJOm77P1kZ7h8KjfQ/GBbbqxgk5j9RGXM79G/SP+beHsWmweQ/9REi4eX0xD/V9s+kmMHkP+pb9yNs09A/c5ERjVDTAECqEr3OBCH7P14ILfMECOU/piRx4P8P0j+JYU//bfL0Pw62fw28B+w/l5YW2Ga45D9+CyKRbenOP5cH6fHy1/S/o/egk03++r91nTYRL/bjP3fHN6OJVdA/7xXQh1XLBcAB3g6tBdUIQKW2KnGYjeQ/SqIpagclyz8F9P3YgNL6v9H6NBsZ8QDAW2k5L5Qs4z/0axa1l6zLP1GE65Mu4wNAwfX+BYmWAEBBgJP90M3hP6/03qhPLdA/zqo5bJz2778/ESlPCTn1v7JkhGyvzuE/DM7sj5twwz/6xbXLavYGQH29RFRGkgNA7bOXVSJ54T9fEhTHO/TDP+8t+HMOiwDAxa0SbGTtA8Atii7y0mLgP4cecHFB3sM/uPUpyv+K7j8nktD1/WvhP2cWmi772d8/Fj7uU9kEvD8oKOESLzKmvwSdCqrHdNu/XCluGsvI3T929OW5md+uP9dP6rXcZNq/gXM+ggzL6b+eKjsPgJncP6i1e9aVu7E/2CnPNJyD1D/DnyGgSe+xvy8k7g9bp9s/nYmLvHn1sz9cFOwApH8IwGa6Mjy9cgZAJr95SiSW2z8rCkhOFvqdP3SIKmO/UwPAEy0zkN7bBsCds8Hg/13YP1zv413hVGi/FVtqixSn6L9XAPQGul3yv7SGu2BoCNk/n94bv7Maj79p13T6X9z3P45MPCW3WvI/rU/8/LRj1T9cgR6SXd+ZPymL2DstbPI/8s/pAkIz6z/fmoB+8efYPz2XyfWgYaa/6wys72AW/j8LZImhgrf3P729Zla/n9U/ySB8B3PBqL8O2nhevvbxv17+5A+n6fe/YrGIqEGB1T+wCEGbkhaxv989QHVE5wFAzd12PTu3/T9AHUPZY2DUP3SQDST0zq2/JCxAlIoj5T+Mhe1IJkrQP/cRpl8QhtU/amc4seFts79khiUSVaz3vxYfWtjPwf2/CHscxQqD0j/ctUBQ9my3v0POnFiyXv2/pjjn2Ju/AcDk45DwBhPRP/GjwlCrv7m/aT2ciwolBsAQOzHr/wUJQCzpq5UYvtI/gDCf3SlCwb+4i7S+mukEQBDA1f8mowFA2utnRN3KyT9T+9EYAVG6v9/IVZ0enrE/7NbRtdGfzr/8y8GpRz7LP3U0vTSk18e/JzHEcwiBB0AGm8Q7AJkEQNLciyt4Esk/gLou5zoQxr+RrOfM91oBwEzd36KybgTAgLou5zoQxj/S3IsreBLJv1gCch0OHO8/FD+RxSLN4j91NL00pNfHP/zLwalHPsu/nL7/By4Pyr8tSP5h7CPiv1P70RgBUbo/2utnRN3Kyb/KfllfCpUIwLkP5zj+NwdAgDCf3SlCwT8s6auVGL7Sv2aFPlaC4eC/XrS5UVH77b/xo8JQq7+5P+TjkPAGE9G/Q30/RYbn1z8FF/ISafuLv9y1QFD2bLc/CHscxQqD0r/fi+tPROX0P6vRc+19ie0/amc4seFtsz/3EaZfEIbVv77TYpahl/o/DDsu0CaC9D90kA0k9M6tP0AdQ9ljYNS/CCI0rxjZA8BgfCaLthgHwLAIQZuSFrE/YrGIqEGB1b8kvQ982+rsv4J8EWu7jPS/ySB8B3PBqD+9vWZWv5/VvwrAByWcJgBAxFujmE9a+j89l8n1oGGmP9+agH7x59i/N03cuJUt9L8X9v4GdIz6v1yBHpJd35m/rU/8/LRj1b8mz69sydf/vyu5idMqVQLAn94bv7Majz8AhrtgaAjZv+aCE66WZ/q/lA1Mgz/p/79c7+Nd4VRoP52zweD/Xdi/TJZpMTb4AkDLWZShPOb/PysKSE4W+p2/Jr95SiSW27/PkmbE7zjnP6UAiCDmMNI/nYmLvHn1s78vJO4PW6fbv5MWA2vqSrQ/V5WLwPB51b+otXvWlbuxv54qOw+Amdy/1keqzYeRBsApIEMHgZIIQHb05bmZ366/XCluGsvI3b8W44a9X9UFQEeQtDM4rwJAFj7uU9kEvL9nFpou+9nfv3Co+JcyyQhAcdkCX2KzBUCHHnBxQd7Dvy2KLvLSYuC/o6+5YTt/AcCHCNDW+8YEwF8SFMc79MO/7bOXVSJ54b9E/pfA2S3xPzD9xaBb0uQ/DM7sj5tww7+yZIRsr87hv7c4c0SEXNG/Tr79/9M+5r+v9N6oTy3Qv5uAk/3QzeG/XcI1OVQkAUAQSV9Z7Qr9P/RrFrWXrMu/W2k5L5Qs479Zo2IBM/vkv6FuipzkFvG/SqIpagcly7+ltipxmI3kv0pmis91cfc/gWQecsRh8D93xzejiVXQv3WdNhEv9uO/D7mgYy612j+PyVPNaT2jv34LIpFt6c6/l5YW2Ga45L+LUp+2A2z9P39i5xSpRfc/piRx4P8P0r9eCC3zBAjlv5n4OKmIUf2/jj/kUAwgAsDqW/cjbNPQv9X2z6SYweS/aTdljlWd8L94R8vZ8SL3v1EZczv0b9K/GBbbqxgk5r9XdfyikfEDwPILMvas0gfAnx0V97en0r88xQk/0IPmvxGErZ681fa/9kCaiOy2/b/2BCK0wyDVvy2xROCT4ua/+5EBLOXxA0B7p53+BnkAQKKI/QV+y9i/qDznPFM86b/snWGNkkgHwC+ByugkUwdAR98lJFqQ2b9sL7HxZkPovyJNGM67oek/HzNy6BqA1D96EnqL7pLYv0v8nFypHeq/axL/u1FnB0AkSEHvxn8DQGt+gG5Pstm/QS1keLLK6b/Sk/O6mtGzPxU8pLcPNty/FssiPwWy4L+IZTNYLmzqvw4szKfSouq/G+XJHY1a87+TVW2LUjjfvwQaifgujuy/3VARaoMl2L9NFodfK+/qv+0QMvYfP+C/FvLf01HN67+ETOQysd8AwH71iI/eGgXAbHNSHrTg4L96GNJ2CFvsv6BnExReeAFA5CakvxSl+j8MzcbAuwDgv5bXzdT1Auy/uVq8/8x58z+uvPMNqzTnP2HlfZ3gqOG/Z5Uh1wDX7r8PUbMSo2P7P9VfBrXlxPI/tQvDXQ3H4r9sJXFt2GTvvyDssGgO0PG/WxT/uE4N+r+Bk03jWYvjv/bf8sHUYu+/rUXN8hUe3j9m5HB1yZCzv/yE3PUo0+K/qqAX9idJ8L9mByqLMMH5v4kHC7KQowHAm+sAswr15L8F7/a5DE/wv2JLsGADFwTAKQjVGovZCMDDkYbTbifnvwVbdNXyhfC/malhH7yI7D+oevd0GWDZP1sjk5AdouW/KH/hrXUg8b8KWmrpQ0sFQAzEAF/pTgBAhB1hfFzT5r9XK/wflZ7xv18hRuqKXAjA/5rUd9v1BED/tlxBd4bov7pQU4wLfPK/4pnwn0T/sj/c277XPF3jv02biiQ+Rum/zGkxMcl88r8Yk0HhJVzjv62yUUFRjfS/89MEdoPQ6r8TqikcRF/zvxQxghHovfY/cfM1eFWE5j9pcwp7GJPrv5ehC2fbYPO/KUV2nGg0/795OhmUaqEFwFQeuy4j+eq/ePiwytEp9L8DuqWfW+8BQLytJylXHPY/PlP4Qr8q7r+kDLLri0P1vxT4ShWL+Oo/DMsWg0zlv7/S9fINXGjtv73m373LRPW/+xg/Gaxd8b94MdQEfW0AwLjBLbDOHO+/kmm4ANp49L+cShSMMbAEwKyjUgWirAdAo2q2uqM08L99wKzM+7H2v3RdlNBXFgnA8S9+ewyV/z+vaSZre3Pxv6riWFiWZfi/2J7VSZZ60j+LES81zPn3v+OrlPMN3PK/quJYWJZl+L/OZbufkEcEQLCNB/1lPOO/Y2nmTbY/87+q4lhYlmX4v7CNB/1lPOO/zmW7n5BHBEBwKD1Aa57LP/XsSsw7RbU/PMDPJGsfoD/TqningGKIPzFtCLYmb3I/qYfrJr7eWz9pQmleXRFFP0rWlJkA2i8/pCvcttgTGD9Dt8IWbjMCPyCG4GRlhOs+1JI2GhDN1D7ns8cGvXK/Pi8m8UTJxac+hNTfA2z4kT7GI8kjLyt7Pv//////HwAI//////8zEAj/////fzIgCP////9vMjAI/////2MyQAj///8/YjJQCP///zdiMmAI////M2IycAj//78zYjKACP//qzNiMpAI/3+rM2IyoAj/D6szYjKwCP8DqzNiMsAIvwOrM2Iy0AifA6szYjLgCJkDqzNiMvAI//////8/Dwj//////ysfCP////9/KS8I/////z8pPwj/////OSlPCP///z84KV8I////Dzgpbwj///8OOCl/CP//Hw44KY8I//8PDjgpnwj/fw0OOCmvCP8PDQ44Kb8I/w0NDjgpzwj/DA0OOCnfCMcMDQ44Ke8IxAwNDjgp/wgHAAAABwAAAAEAAAACAAAABAAAAAMAAAAAAAAAAAAAAAcAAAADAAAAAQAAAAIAAAAFAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAgAAAAEAAAADAAAADgAAAAYAAAALAAAAAgAAAAcAAAABAAAAGAAAAAUAAAAKAAAAAQAAAAYAAAAAAAAAJgAAAAcAAAAMAAAAAwAAAAgAAAACAAAAMQAAAAkAAAAOAAAAAAAAAAUAAAAEAAAAOgAAAAgAAAANAAAABAAAAAkAAAADAAAAPwAAAAsAAAAGAAAADwAAAAoAAAAQAAAASAAAAAwAAAAHAAAAEAAAAAsAAAARAAAAUwAAAAoAAAAFAAAAEwAAAA4AAAAPAAAAYQAAAA0AAAAIAAAAEQAAAAwAAAASAAAAawAAAA4AAAAJAAAAEgAAAA0AAAATAAAAdQAAAA8AAAATAAAAEQAAABIAAAAQAAAABgAAAAIAAAADAAAABQAAAAQAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAMAAAABAAAABQAAAAQAAAAAAAAAAAAAAAcAAAAFAAAAAwAAAAQAAAABAAAAAAAAAAIAAAAAAAAAAgAAAAMAAAABAAAABQAAAAQAAAAGAAAAAAAAAAAAAAAYLURU+yH5PxgtRFT7Ifm/GC1EVPshCUAYLURU+yEJwGFsZ29zLmMAaDNOZWlnaGJvclJvdGF0aW9ucwBjZWxsc1RvTXVsdGlQb2x5LmMAY2VsbFRvRWRnZUFyY3MAAAEDAgQABAMFAQJjYW5jZWxBcmNQYWlycwBjcmVhdGVTb3J0YWJsZUxvb3AAZGlyZWN0ZWRFZGdlLmMAZGlyZWN0ZWRFZGdlVG9Cb3VuZGFyeQBhZGphY2VudEZhY2VEaXJbdG1wRmlqay5mYWNlXVtmaWprLmZhY2VdID09IEtJAGZhY2VpamsuYwBfZmFjZUlqa1BlbnRUb0NlbGxCb3VuZGFyeQBhZGphY2VudEZhY2VEaXJbY2VudGVySUpLLmZhY2VdW2ZhY2UyXSA9PSBLSQBfZmFjZUlqa1RvQ2VsbEJvdW5kYXJ5AGgzSW5kZXguYwBjb21wYWN0Q2VsbHMAdmVjM1RvQ2VsbABjZWxsVG9DaGlsZFBvcwB2YWxpZGF0ZUNoaWxkUG9zAHJldkRpciAhPSBJTlZBTElEX0RJR0lUAGxvY2FsaWouYwBjZWxsVG9Mb2NhbElqawBiYXNlQ2VsbCAhPSBvcmlnaW5CYXNlQ2VsbAAhKG9yaWdpbk9uUGVudCAmJiBpbmRleE9uUGVudCkAYmFzZUNlbGwgPT0gb3JpZ2luQmFzZUNlbGwALi4vaW5jbHVkZS9jb29yZGlqay5oAF91cEFwN0NoZWNrZWQAX3VwQXA3ckNoZWNrZWQAYmFzZUNlbGwgIT0gSU5WQUxJRF9CQVNFX0NFTEwAbG9jYWxJamtUb0NlbGwAIV9pc0Jhc2VDZWxsUGVudGFnb24oYmFzZUNlbGwpAGJhc2VDZWxsUm90YXRpb25zID49IDAAZ3JpZFBhdGhDZWxsc0ludGVycG9sYXRlAHBvbHlmaWxsLmMAaXRlclN0ZXBQb2x5Z29uQ29tcGFjdAAwAHZlcnRleC5jAHZlcnRleFJvdGF0aW9ucwBjZWxsVG9WZXJ0ZXg=";function H(e){return e}function W(e){return e.replace(/\b__Z[\w\d_]+/g,function(e){return e===e?e:e+" ["+e+"]"})}function q(){var e=new Error;if(!e.stack){try{throw new Error(0)}catch(t){e=t}if(!e.stack)return"(no stack trace available)"}return e.stack.toString()}function K(){return g.length}function Q(e){try{var t=new ArrayBuffer(e);if(t.byteLength!=e)return;return new Int8Array(t).set(g),te(t),x(t),1}catch(e){}}var X="function"==typeof atob?atob:function(e){var t,n,i,r,s,o,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",c=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{t=a.indexOf(e.charAt(c++))<<2|(r=a.indexOf(e.charAt(c++)))>>4,n=(15&r)<<4|(s=a.indexOf(e.charAt(c++)))>>2,i=(3&s)<<6|(o=a.indexOf(e.charAt(c++))),l+=String.fromCharCode(t),64!==s&&(l+=String.fromCharCode(n)),64!==o&&(l+=String.fromCharCode(i))}while(c<e.length);return l};function $(e){if(j(e))return function(e){try{for(var t=X(e),n=new Uint8Array(t.length),i=0;i<t.length;++i)n[i]=t.charCodeAt(i);return n}catch(e){throw new Error("Converting base64 string to bytes failed.")}}(e.slice(G.length))}var Z,Y,J={a:Ae,b:function(e){c=e},c:function(){return c},d:function(e,t,n,i){Ae("Assertion failed: "+f(e)+", at: "+[t?f(t):"unknown filename",n,i?f(i):"unknown function"])},e:function(e){return n.___errno_location&&(_[n.___errno_location()>>2]=e),e},f:K,g:function(e,t,n){m.set(m.subarray(t,t+n),e)},h:function(e){var t=K(),n=16777216,i=2130706432;if(e>i)return!1;for(var r=Math.max(t,16777216);r<e;)r=r<=536870912?w(2*r,n):Math.min(w((3*r+2147483648)/4,n),i);return!!Q(r)},i:function(e){Ae("OOM")},j:H,k:W,l:Q,m:q,n:function(){var e=q();return n.extraStackTrace&&(e+="\n"+n.extraStackTrace()),W(e)},o:28400,p:28384},ee=function(e,t,n){var i=new e.Int8Array(n),r=new e.Int32Array(n),s=(new e.Uint8Array(n),new e.Float32Array(n),new e.Float64Array(n)),o=0|t.o,a=0|t.p,l=e.Math.floor,c=e.Math.abs,A=e.Math.sqrt,u=e.Math.cos,h=e.Math.sin,d=e.Math.tan,f=e.Math.acos,p=e.Math.asin,g=e.Math.atan,m=e.Math.atan2,b=e.Math.ceil,_=e.Math.imul,v=e.Math.min,y=e.Math.max,w=e.Math.clz32,x=t.a,T=t.b,E=t.c,S=t.d,C=t.e,P=t.f,R=t.g,M=t.h,L=t.i,I=28416;function O(e,t,n,i){return 0|B(e|=0,t|=0,n|=0,i|=0,0)}function B(e,t,n,i,s){var o,a=0,l=0,c=0,A=0;if(o=I,I=I+16|0,l=o,!(0|N(e|=0,t|=0,n|=0,i|=0,s|=0)))return I=o,0|(i=0);do{if((0|n)>=0){if((0|n)>13780509){if(0|(a=0|Qe(15,l)))break;l=0|r[(c=l)>>2],c=0|r[c+4>>2]}else A=0|kt(0|n,0|(a=((0|n)<0)<<31>>31),3,0),c=0|E(),a=0|Lt(0|n,0|a,1,0),a=0|Lt(0|(a=0|kt(0|A,0|c,0|a,0|E())),0|E(),1,0),c=0|E(),r[l>>2]=a,r[l+4>>2]=c,l=a;if(Qt(0|i,0,l<<3),0|s){Qt(0|s,0,l<<2),a=0|k(e,t,n,i,s,l,c,0);break}(a=0|Pt(l,4))?(A=0|k(e,t,n,i,a,l,c,0),Ct(a),a=A):a=13}else a=2}while(0);return I=o,0|(A=a)}function N(e,t,n,i,s){e|=0,t|=0,n|=0,i|=0,s|=0;var o,a,l=0,c=0,A=0,u=0,h=0,d=0,f=0,p=0,g=0;if(a=I,I=I+16|0,g=a+8|0,r[(p=o=a)>>2]=e,r[p+4>>2]=t,(0|n)<0)return I=a,0|(g=2);if(r[(l=i)>>2]=e,r[l+4>>2]=t,(l=!!(0|s))&&(r[s>>2]=0),0|Ee(e,t))return I=a,0|(g=9);r[g>>2]=0;e:do{if((0|n)>=1)if(l)for(d=1,h=0,f=0,p=1,l=e;;){if(!(h|f)){if(0|(l=0|F(l,t,4,g,o)))break e;if(0|Ee(l=0|r[(t=o)>>2],t=0|r[t+4>>2])){l=9;break e}}if(0|(l=0|F(l,t,0|r[26864+(f<<2)>>2],g,o)))break e;if(l=0|r[(t=o)>>2],t=0|r[t+4>>2],r[(e=i+(d<<3)|0)>>2]=l,r[e+4>>2]=t,r[s+(d<<2)>>2]=p,c=(0|(e=h+1|0))==(0|p),u=6==(0|(A=f+1|0)),0|Ee(l,t)){l=9;break e}if((0|(p=p+(u&c&1)|0))>(0|n)){l=0;break}d=d+1|0,h=c?0:e,f=c?u?0:A:f}else for(d=1,h=0,f=0,p=1,l=e;;){if(!(h|f)){if(0|(l=0|F(l,t,4,g,o)))break e;if(0|Ee(l=0|r[(t=o)>>2],t=0|r[t+4>>2])){l=9;break e}}if(0|(l=0|F(l,t,0|r[26864+(f<<2)>>2],g,o)))break e;if(l=0|r[(t=o)>>2],t=0|r[t+4>>2],r[(e=i+(d<<3)|0)>>2]=l,r[e+4>>2]=t,c=(0|(e=h+1|0))==(0|p),u=6==(0|(A=f+1|0)),0|Ee(l,t)){l=9;break e}if((0|(p=p+(u&c&1)|0))>(0|n)){l=0;break}d=d+1|0,h=c?0:e,f=c?u?0:A:f}else l=0}while(0);return I=a,0|(g=l)}function k(e,t,n,i,s,o,a,l){n|=0,i|=0,s|=0,l|=0;var c,A,u,h=0,d=0,f=0,p=0,g=0,m=0,b=0;if(u=I,I=I+16|0,c=u+8|0,A=u,h=0|Dt(0|(e|=0),0|(t|=0),0|(o|=0),0|(a|=0)),f=0|E(),!(!(0|(b=0|r[(m=p=i+(h<<3)|0)>>2]))&!(0|(m=0|r[m+4>>2]))|(d=(0|b)==(0|e)&(0|m)==(0|t))))do{h=0|Ft(0|(h=0|Lt(0|h,0|f,1,0)),0|E(),0|o,0|a),f=0|E(),d=(0|(m=0|r[(b=p=i+(h<<3)|0)>>2]))==(0|e)&(0|(b=0|r[b+4>>2]))==(0|t)}while(!(!(0|m)&!(0|b)|d));if(h=s+(h<<2)|0,d&&(0|r[h>>2])<=(0|l))return I=u,0|(b=0);if(r[(b=p)>>2]=e,r[b+4>>2]=t,r[h>>2]=l,(0|l)>=(0|n))return I=u,0|(b=0);switch(d=l+1|0,r[c>>2]=0,0|(h=0|F(e,t,2,c,A))){case 9:g=9;break;case 0:(h=0|k(0|r[(h=A)>>2],0|r[h+4>>2],n,i,s,o,a,d))||(g=9)}e:do{if(9==(0|g)){switch(r[c>>2]=0,0|(h=0|F(e,t,3,c,A))){case 9:break;case 0:if(0|(h=0|k(0|r[(h=A)>>2],0|r[h+4>>2],n,i,s,o,a,d)))break e;break;default:break e}switch(r[c>>2]=0,0|(h=0|F(e,t,1,c,A))){case 9:break;case 0:if(0|(h=0|k(0|r[(h=A)>>2],0|r[h+4>>2],n,i,s,o,a,d)))break e;break;default:break e}switch(r[c>>2]=0,0|(h=0|F(e,t,5,c,A))){case 9:break;case 0:if(0|(h=0|k(0|r[(h=A)>>2],0|r[h+4>>2],n,i,s,o,a,d)))break e;break;default:break e}switch(r[c>>2]=0,0|(h=0|F(e,t,4,c,A))){case 9:break;case 0:if(0|(h=0|k(0|r[(h=A)>>2],0|r[h+4>>2],n,i,s,o,a,d)))break e;break;default:break e}switch(r[c>>2]=0,0|(h=0|F(e,t,6,c,A))){case 9:break;case 0:if(0|(h=0|k(0|r[(h=A)>>2],0|r[h+4>>2],n,i,s,o,a,d)))break e;break;default:break e}return I=u,0|(b=0)}}while(0);return I=u,0|(b=h)}function F(e,t,n,i,s){e|=0,t|=0,s|=0;var o,a,l,c=0,A=0,u=0,h=0,d=0,f=0;if((n|=0)>>>0>6)return 0|(s=1);A=(0|r[(i|=0)>>2])%6|0,r[i>>2]=A;e:do{if((0|A)>0)for(c=0;;){switch(0|n){case 1:n=5;break;case 5:n=4;break;case 4:n=6;break;case 6:n=2;break;case 2:n=3;break;case 3:n=1}if((0|(c=c+1|0))==(0|A))break e}}while(0);if(l=0|Vt(0|e,0|t,45),E(),(a=127&l)>>>0>121)return 0|(s=5);o=0|Pe(e,t),c=0|Vt(0|e,0|t,52),E(),c&=15;e:do{if(c){for(;;){if(u=0|Vt(0|e,0|t,0|(A=3*(15-c|0)|0)),E(),7==(0|(u&=7))){t=5;break}if(f=!(0|Be(c)),c=c+-1|0,d=0|zt(7,0,0|A),t&=~E(),e=0|zt(0|r[(f?432:16)+(28*u|0)+(n<<2)>>2],0,0|A)|e&~d,t|=A=0|E(),!(n=0|r[(f?640:224)+(28*u|0)+(n<<2)>>2])){n=0;break e}if(!c){h=15;break e}}return 0|t}h=15}while(0);15==(0|h)&&(e|=0|zt(0|(f=0|r[848+(28*a|0)+(n<<2)>>2]),0,45),t=E()|-1040385&t,n=0|r[4272+(28*a|0)+(n<<2)>>2],127&~f||(f=0|zt(0|r[848+(28*a|0)+20>>2],0,45),t=E()|-1040385&t,n=0|r[4272+(28*a|0)+20>>2],e=0|Me(f|e,t),t=0|E(),r[i>>2]=1+(0|r[i>>2]))),u=0|Vt(0|e,0|t,45),E(),u&=127;e:do{if(0|j(u)){t:do{if(1==(0|Pe(e,t))){if((0|a)!=(0|u)){if(0|K(u,0|r[7696+(28*a|0)>>2])){e=0|Ie(e,t),A=1,t=0|E();break}S(27634,26928,533,26936)}switch(0|o){case 3:e=0|Me(e,t),t=0|E(),r[i>>2]=1+(0|r[i>>2]),A=0;break t;case 5:e=0|Ie(e,t),t=0|E(),r[i>>2]=5+(0|r[i>>2]),A=0;break t;case 0:return 0|(f=9);default:return 0|(f=1)}}else A=0}while(0);if((0|n)>0){c=0;do{e=0|Re(e,t),t=0|E(),c=c+1|0}while((0|c)!=(0|n))}if((0|a)!=(0|u)){if(!(0|H(u))){if(!!(0|A)|5!=(0|Pe(e,t)))break;r[i>>2]=1+(0|r[i>>2]);break}switch(127&l){case 8:case 118:break e}3!=(0|Pe(e,t))&&(r[i>>2]=1+(0|r[i>>2]))}}else if((0|n)>0){c=0;do{e=0|Me(e,t),t=0|E(),c=c+1|0}while((0|c)!=(0|n))}}while(0);return r[i>>2]=((0|r[i>>2])+n|0)%6|0,r[(f=s)>>2]=e,r[f+4>>2]=t,0|(f=0)}function D(e,t,n,i){e|=0,t|=0,n|=0,i|=0;var s,o,a=0,l=0,c=0,A=0,u=0,h=0,d=0,f=0,p=0;if(o=I,I=I+16|0,p=o+8|0,r[(f=s=o)>>2]=e,r[f+4>>2]=t,(0|n)<0)return I=o,0|(p=2);if(!n)return r[(p=i)>>2]=e,r[p+4>>2]=t,I=o,0|(p=0);r[p>>2]=0;e:do{if(0|Ee(e,t))e=9;else{a=0,f=e;do{if(0|(e=0|F(f,t,4,p,s)))break e;if(a=a+1|0,0|Ee(f=0|r[(t=s)>>2],t=0|r[t+4>>2])){e=9;break e}}while((0|a)<(0|n));r[(d=i)>>2]=f,r[d+4>>2]=t,d=n+-1|0,h=0,e=1;do{if(a=26864+(h<<2)|0,5==(0|h))for(c=0|r[a>>2],l=0,a=e;;){if(0|(e=0|F(0|r[(e=s)>>2],0|r[e+4>>2],c,p,s)))break e;if((0|l)!=(0|d)){if(A=0|r[(u=s)>>2],u=0|r[u+4>>2],r[(e=i+(a<<3)|0)>>2]=A,r[e+4>>2]=u,0|Ee(A,u)){e=9;break e}e=a+1|0}else e=a;if((0|(l=l+1|0))>=(0|n))break;a=e}else for(c=s,u=0|r[a>>2],A=0,a=e,l=0|r[c>>2],c=0|r[c+4>>2];;){if(0|(e=0|F(l,c,u,p,s)))break e;if(l=0|r[(c=s)>>2],c=0|r[c+4>>2],r[(e=i+(a<<3)|0)>>2]=l,r[e+4>>2]=c,e=a+1|0,0|Ee(l,c)){e=9;break e}if((0|(A=A+1|0))>=(0|n))break;a=e}h=h+1|0}while(h>>>0<6);e=(0|f)==(0|r[(e=s)>>2])&&(0|t)==(0|r[e+4>>2])?0:9}}while(0);return I=o,0|(p=e)}function U(e,t,n,i){e|=0,t|=0,i|=0;var s,o=0,a=0,l=0,c=0,A=0,u=0,h=0,d=0;if(s=I,I=I+16|0,l=s,!(n|=0))return r[i>>2]=e,r[i+4>>2]=t,I=s,0|(i=0);do{if((0|n)>=0){if((0|n)>13780509){if(0|(o=0|Qe(15,l)))break;o=0|r[(a=l)>>2],a=0|r[a+4>>2]}else h=0|kt(0|n,0|(o=((0|n)<0)<<31>>31),3,0),a=0|E(),o=0|Lt(0|n,0|o,1,0),o=0|Lt(0|(o=0|kt(0|h,0|a,0|o,0|E())),0|E(),1,0),a=0|E(),r[(h=l)>>2]=o,r[h+4>>2]=a;if(u=0|Pt(o,8)){if(!(h=0|Pt(o,4))){Ct(u),o=13;break}if(0|(o=0|k(e,t,n,u,h,o,a,0))){Ct(u),Ct(h);break}if(t=0|r[l>>2],(0|(l=0|r[l+4>>2]))>0|!(0|l)&t>>>0>0){o=0,c=0,A=0;do{!(0|(a=0|r[(e=u+(c<<3)|0)>>2]))&!(0|(e=0|r[e+4>>2]))||(0|r[h+(c<<2)>>2])!=(0|n)||(r[(d=i+(o<<3)|0)>>2]=a,r[d+4>>2]=e,o=o+1|0),c=0|Lt(0|c,0|A,1,0),A=0|E()}while((0|A)<(0|l)|(0|A)==(0|l)&c>>>0<t>>>0)}Ct(u),Ct(h),o=0}else o=13}else o=2}while(0);return I=s,0|(d=o)}function V(e,t,n,i){n|=0,i|=0;var s,o,a,l=0,c=0;for(a=I,I=I+16|0,s=a,o=a+8|0,l=(l=!(0|Ee(e|=0,t|=0)))?1:2;;){if(r[o>>2]=0,!(0|F(e,t,l,o,s))&((0|r[(c=s)>>2])==(0|n)?(0|r[c+4>>2])==(0|i):0)){e=4;break}if((l=l+1|0)>>>0>=7){l=7,e=4;break}}return 4==(0|e)?(I=a,0|l):0}function z(e,t,n,i,o,a,l){t|=0,n|=0,i|=0,o|=0,a|=0,l|=0;var c,A,u,h,d,f,p,g,m,b,_=0,v=0,y=0,w=0,x=0,T=0,S=0,C=0,P=0,R=0,M=0,L=0,O=0,B=0,N=0,k=0,F=0,D=0,U=0;if(b=I,I=I+64|0,p=b+48|0,g=b+32|0,m=b+24|0,c=b+8|0,A=b,(0|(v=0|r[(e|=0)>>2]))<=0)return I=b,0|(N=0);for(u=e+4|0,h=p+8|0,d=g+8|0,f=c+8|0,_=0,O=0;;){L=(y=0|r[u>>2])+(O<<4)|0,r[p>>2]=r[L>>2],r[p+4>>2]=r[L+4>>2],r[p+8>>2]=r[L+8>>2],r[p+12>>2]=r[L+12>>2],(0|O)==(v+-1|0)?(r[g>>2]=r[y>>2],r[g+4>>2]=r[y+4>>2],r[g+8>>2]=r[y+8>>2],r[g+12>>2]=r[y+12>>2]):(L=y+(O+1<<4)|0,r[g>>2]=r[L>>2],r[g+4>>2]=r[L+4>>2],r[g+8>>2]=r[L+8>>2],r[g+12>>2]=r[L+12>>2]),v=0|ie(p,g,i,m);e:do{if(v)y=0,_=v;else if(y=0|r[(v=m)>>2],(0|(v=0|r[v+4>>2]))>0|!(0|v)&y>>>0>0){M=0,L=0;t:for(;;){if(F=1/(+(y>>>0)+4294967296*+(0|v)),U=+s[p>>3],D=+((v=0|It(0|y,0|v,0|M,0|L))>>>0)+4294967296*+(0|E()),k=+(M>>>0)+4294967296*+(0|L),s[c>>3]=F*(U*D)+F*(+s[g>>3]*k),s[f>>3]=F*(+s[h>>3]*D)+F*(+s[d>>3]*k),0|(v=0|Ne(c,i,A))){_=v;break}T=0|Dt(0|(P=0|r[(R=A)>>2]),0|(R=0|r[R+4>>2]),0|t,0|n),w=0|E(),y=0|r[(x=v=l+(T<<3)|0)>>2],x=0|r[x+4>>2];n:do{if(!(0|y)&!(0|x))B=v,N=16;else for(S=0,C=0;;){if((0|S)>(0|n)|(0|S)==(0|n)&C>>>0>t>>>0){_=1;break t}if((0|y)==(0|P)&(0|x)==(0|R))break n;if(T=0|Ft(0|(v=0|Lt(0|T,0|w,1,0)),0|E(),0|t,0|n),w=0|E(),C=0|Lt(0|C,0|S,1,0),S=0|E(),!(0|(y=0|r[(x=v=l+(T<<3)|0)>>2]))&!(0|(x=0|r[x+4>>2]))){B=v,N=16;break}}}while(0);if(16!=(0|N)||(N=0,!(0|P)&!(0|R))||(r[(C=B)>>2]=P,r[C+4>>2]=R,C=a+(r[o>>2]<<3)|0,r[C>>2]=P,r[C+4>>2]=R,C=0|Lt(0|r[(C=o)>>2],0|r[C+4>>2],1,0),P=0|E(),r[(R=o)>>2]=C,r[R+4>>2]=P),M=0|Lt(0|M,0|L,1,0),L=0|E(),y=0|r[(v=m)>>2],!((0|(v=0|r[v+4>>2]))>(0|L)|(0|v)==(0|L)&y>>>0>M>>>0)){y=1;break e}}y=0}else y=1}while(0);if(O=O+1|0,!y){N=21;break}if((0|O)>=(0|(v=0|r[e>>2]))){_=0,N=21;break}}return 21==(0|N)?(I=b,0|_):0}function G(e,t){t|=0;var n,i=0,o=0,a=0,l=0,c=0,A=0,d=0,f=0,p=0;if((0|(l=0|r[(e|=0)>>2]))<=0)return o=(a=0)+(o=12.566370614359172-(o=0)),a=(l=a<0)?o:a,s[t>>3]=a,0;if(n=0|r[e+4>>2],e=1!=(0|l)&1,c=.5*+s[n>>3]+.7853981633974483,a=.5*+s[n+(e<<4)>>3]+.7853981633974483,i=+h(+c)*+h(+a),o=+s[n+(e<<4)+8>>3]-+s[n+8>>3],i=(o=(i=-2*+m(+ +h(+o)*i,+(+u(+c)*+u(+a)+ +u(+o)*i)))+0)-i,1==(0|l))return a=(c=o)+(a=12.566370614359172-(a=i)),c=(l=c<0)?a:c,s[t>>3]=c,0;for(e=1,a=o;f=e,p=(0|(e=e+1|0))%(0|l)|0,d=.5*+s[n+(f<<4)>>3]+.7853981633974483,A=.5*+s[n+(p<<4)>>3]+.7853981633974483,o=+h(+d)*+h(+A),c=+s[n+(p<<4)+8>>3]-+s[n+(f<<4)+8>>3],i=(o=a+(i=-2*+m(+ +h(+c)*o,+(+u(+d)*+u(+A)+ +u(+c)*o))-i))-a-i,!((0|e)>=(0|l));)a=o;return d=o+(d=12.566370614359172-i),d=(p=o<0)?d:o,s[t>>3]=d,0}function j(e){return(e|=0)>>>0>121?0|(e=0):0|(e=0|r[7696+(28*e|0)+16>>2])}function H(e){return 4==(0|(e|=0))|117==(0|e)|0}function W(e){return 0|r[11120+(216*(0|r[(e|=0)>>2])|0)+(72*(0|r[e+4>>2])|0)+(24*(0|r[e+8>>2])|0)+(r[e+12>>2]<<3)>>2]}function q(e){return 0|r[11120+(216*(0|r[(e|=0)>>2])|0)+(72*(0|r[e+4>>2])|0)+(24*(0|r[e+8>>2])|0)+(r[e+12>>2]<<3)+4>>2]}function K(e,t){return t|=0,(0|r[7696+(28*(e|=0)|0)+20>>2])==(0|t)?0|(t=1):0|(t=(0|r[7696+(28*e|0)+24>>2])==(0|t))}function Q(e,t){return 0|r[848+(28*(e|=0)|0)+((t|=0)<<2)>>2]}function X(e,t){return t|=0,(0|r[848+(28*(e|=0)|0)>>2])==(0|t)?0|(t=0):(0|r[848+(28*e|0)+4>>2])==(0|t)?0|(t=1):(0|r[848+(28*e|0)+8>>2])==(0|t)?0|(t=2):(0|r[848+(28*e|0)+12>>2])==(0|t)?0|(t=3):(0|r[848+(28*e|0)+16>>2])==(0|t)?0|(t=4):(0|r[848+(28*e|0)+20>>2])==(0|t)?0|(t=5):0|((0|r[848+(28*e|0)+24>>2])==(0|t)?6:7)}function $(e){var t,n,i;return t=(i=+s[(e|=0)+16>>3])-(n=+s[e+24>>3]),+(i<n?t+6.283185307179586:t)}function Z(e){return+(+s[(e|=0)>>3]-+s[e+8>>3])}function Y(e,t){e|=0;var n,i,r=0;return(r=+s[(t|=0)>>3])>=+s[e+8>>3]&&r<=+s[e>>3]?(n=+s[e+16>>3],r=+s[e+24>>3],t=(i=+s[t+8>>3])>=r,e=i<=n&1,n<r?t&&(e=1):t||(e=0),0|(t=!!(0|e))):0|(t=0)}function J(e,t){t|=0;var n,i,r,o,a,l=0,c=0,A=0,u=0;return+s[(e|=0)>>3]<+s[t+8>>3]||+s[e+8>>3]>+s[t>>3]?0|(l=0):(r=(c=+s[e+16>>3])<(u=+s[(n=e+24|0)>>3]),A=(a=+s[(l=t+16|0)>>3])<(o=+s[(i=t+24|0)>>3]),t=u-a<o-c,e=r?A|t?1:2:0,t=A?r?1:t?2:1:0,(c=+We(c,e))<+We(+s[i>>3],t)||(u=+We(+s[n>>3],e))>+We(+s[l>>3],t)?0|(A=0):0|(A=1))}function ee(e,t){t|=0;var n,i,r,o,a,l=0,c=0,A=0,u=0;return+s[(e|=0)>>3]<+s[t>>3]||+s[e+8>>3]>+s[t+8>>3]?0|(l=0):(r=(o=+s[(l=e+16|0)>>3])<(c=+s[e+24>>3]),A=(u=+s[(n=t+16|0)>>3])<(a=+s[(i=t+24|0)>>3]),t=c-u<a-o,e=r?A|t?1:2:0,t=A?r?1:t?2:1:0,(c=+We(c,e))<=+We(+s[i>>3],t)?0|(A=(u=+We(+s[l>>3],e))>=+We(+s[n>>3],t)):0|(A=0))}function te(e,t){e|=0,t|=0;var n,i,o,a,l,c=0;o=I,I=I+176|0,r[(i=o)>>2]=4,c=+s[t>>3],s[i+8>>3]=c,a=+s[t+16>>3],s[i+16>>3]=a,s[i+24>>3]=c,c=+s[t+24>>3],s[i+32>>3]=c,l=+s[t+8>>3],s[i+40>>3]=l,s[i+48>>3]=c,s[i+56>>3]=l,s[i+64>>3]=a,n=(t=i+72|0)+96|0;do{r[t>>2]=0,t=t+4|0}while((0|t)<(0|n));qt(0|e,0|i,168),I=o}function ne(e,t,n){e|=0,t|=0,n|=0;var i,a,A,u,h,d,f,p=0,g=0,m=0,_=0,y=0,w=0,x=0;d=I,I=I+288|0,h=d+264|0,_=d+96|0,g=(p=m=d)+96|0;do{r[p>>2]=0,p=p+4|0}while((0|p)<(0|g));return 0|(t=0|Ve(t,m))?(I=d,0|(w=t)):(De(m=0|r[(g=m)>>2],g=0|r[g+4>>2],h),Ue(m,g,_),u=+qe(h,_+8|0),s[h>>3]=+s[e>>3],s[(g=h+8|0)>>3]=+s[e+16>>3],s[_>>3]=+s[e+8>>3],s[(m=_+8|0)>>3]=+s[e+24>>3],a=+qe(h,_),x=+s[g>>3]-+s[m>>3],A=+c(+x),f=+s[h>>3]-+s[_>>3],i=+c(+f),!(0==x|0==f)&&(x=+jt(+A,+i),x=+b(+a*a/+Ht(+x/+Ht(+A,+i),3)/(u*(2.59807621135*u)*.8)),s[o>>3]=x,y=~~x>>>0,w=+c(x)>=1?x>0?~~+v(+l(x/4294967296),4294967295)>>>0:~~+b((x-+(~~x>>>0))/4294967296)>>>0:0,2146435072&~r[o+4>>2])?(_=!(0|y)&!(0|w),r[(t=n)>>2]=_?1:y,r[t+4>>2]=_?0:w,t=0):t=1,I=d,0|(w=t))}function ie(e,t,n,i){e|=0,t|=0,n|=0,i|=0;var a,A,u,h,d=0,f=0,p=0;h=I,I=I+288|0,A=h+264|0,u=h+96|0,a=(d=f=h)+96|0;do{r[d>>2]=0,d=d+4|0}while((0|d)<(0|a));return 0|(n=0|Ve(n,f))?(I=h,0|(i=n)):(De(d=0|r[(n=f)>>2],n=0|r[n+4>>2],A),Ue(d,n,u),p=+qe(A,u+8|0),p=+b(+ +qe(e,t)/(2*p)),s[o>>3]=p,n=~~p>>>0,d=+c(p)>=1?p>0?~~+v(+l(p/4294967296),4294967295)>>>0:~~+b((p-+(~~p>>>0))/4294967296)>>>0:0,2146435072&~r[o+4>>2]?(f=!(0|n)&!(0|d),r[i>>2]=f?1:n,r[i+4>>2]=f?0:d,I=h,0|(i=0)):(I=h,0|(i=1)))}function re(e,t,n,o){e|=0,o|=0;var a,l=0,c=0,A=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,b=0,_=0,v=0,y=0,w=0,x=0,T=0,C=0,P=0,R=0,M=0,L=0,O=0,B=0,N=0;if(a=I,I=I+224|0,L=a,C=a+48|0,(h=(0|(n|=0))>0|!(0|n)&(t|=0)>>>0>0)&(n>>>0>0|!(0|n)&t>>>0>17895697))return I=a,0|(N=14);if((0|n)<0)return I=a,0|(N=2);if(!(0|t)&!(0|n))return r[o>>2]=0,r[o+4>>2]=0,I=a,0|(N=0);for(l=0|_e(0|r[(l=e)>>2],0|r[l+4>>2]),A=0,u=0;;){if(!(0|ye(0|r[(N=c=e+(A<<3)|0)>>2],0|r[N+4>>2]))){l=5,O=159;break}if(N=(0|_e(0|r[(N=c)>>2],0|r[N+4>>2]))==(0|l),A=0|Lt(0|A,0|u,1,0),u=0|E(),!N){l=12,O=159;break}if(!((0|u)<(0|n)|(0|u)==(0|n)&A>>>0<t>>>0)){O=8;break}}if(8==(0|O)){do{if((0|n)>0|!(0|n)&t>>>0>1){if(!(A=0|St(l=t<<3)))return I=a,0|(N=13);for(qt(0|A,0|e,0|l),mt(A,t,8,1),l=1,c=0;N=A+(l+-1<<3)|0,N=(0|r[(B=A+(l<<3)|0)>>2])==(0|r[N>>2])?(0|r[B+4>>2])==(0|r[N+4>>2]):0,l=0|Lt(0|l,0|c,1,0),c=0|E(),!N;)if(!((0|c)<(0|n)|(0|c)==(0|n)&l>>>0<t>>>0)){O=14;break}if(14==(0|O)){Ct(A);break}return Ct(A),I=a,0|(N=10)}}while(0);if(l=0|kt(0|t,0|n,6,0),c=0|E(),h){A=0,u=0;do{l=0|Lt(0|l,0|c,0|(N=!!(0|Ee(0|r[(N=e+(u<<3)|0)>>2],0|r[N+4>>2]))<<31>>31),((0|N)<0)<<31>>31),c=0|E(),u=0|Lt(0|u,0|A,1,0),A=0|E()}while((0|A)<(0|n)|(0|A)==(0|n)&u>>>0<t>>>0);T=l,x=c}else T=l,x=c;if(y=0|kt(0|T,0|x,10,0),w=0|E(),!(B=0|St(T<<5)))return I=a,0|(N=13);if(!(N=0|Pt(y,4)))return Ct(B),I=a,0|(N=13);e:do{if(h){for(ae(0|r[(M=e)>>2],0|r[M+4>>2],L),m=B,b=0,_=0,l=0,v=0;;){c=(h=!(0|r[(h=L)>>2])&!(0|r[h+4>>2]))?26990:26995,A=h?5:6,h=L+((1&h)<<3)|0,d=0|Lt(0|A,0|(u=0),-1,-1),f=0|E(),p=0,g=0;do{P=0|r[(R=h+(p<<3)|0)+4>>2],r[(M=m+(p<<5)|0)>>2]=r[R>>2],r[M+4>>2]=P,i[m+(p<<5)+9|0]=0,i[m+(p<<5)+8|0]=0,r[m+(p<<5)+20>>2]=m,r[(M=m+(p<<5)+24|0)>>2]=1,r[M+4>>2]=0,M=0|i[c+p|0],P=0|Dt(0|(P=0|Lt(0|d,0|f,0|p,0|g)),0|E(),0|A,0|u),E(),P=0|i[c+P|0],p=0|Lt(0|p,0|g,1,0),g=0|E(),R=0|i[c+((0|p)==(0|A)&(0|g)==(0|u)?0:p)|0],r[m+((M&=255)<<5)+16>>2]=m+((255&P)<<5),r[m+(M<<5)+12>>2]=m+((255&R)<<5)}while(g>>>0<u>>>0|(0|g)==(0|u)&p>>>0<A>>>0);if(b=0|Lt(0|b,0|_,1,0),_=0|E(),l=0|Lt(0|A,0|u,0|l,0|v),v=0|E(),!((0|_)<(0|n)|(0|_)==(0|n)&b>>>0<t>>>0))break e;0|ae(0|r[(M=e+(b<<3)|0)>>2],0|r[M+4>>2],L)||(m=B+(l<<5)|0)}S(27634,26956,108,26975)}}while(0);if((0|x)>0|!(0|x)&T>>>0>0){u=0,h=0;do{if(l=0|Vt(0|(A=0|r[(c=B+(u<<5)|0)>>2]),0|(c=0|r[c+4>>2]),30),l=0|Vt(0|(c=0|kt(l^A|0,(0|E())^c,484763065,-1084733587)),0|(A=0|E()),27),c=0|Dt((l=0|Vt(0|(A=0|kt(l^c|0,(0|E())^A,321982955,-1798288965)),0|(c=0|E()),31))^A|0,(0|E())^c,0|y,0|w),A=0|E(),0|r[(l=N+(c<<2)|0)>>2])do{c=0|Ft(0|(l=0|Lt(0|c,0|A,1,0)),0|E(),0|y,0|w),A=0|E(),l=N+(c<<2)|0}while(0|r[l>>2]);r[l>>2]=B+(u<<5),u=0|Lt(0|u,0|h,1,0),h=0|E()}while((0|h)<(0|x)|(0|h)==(0|x)&u>>>0<T>>>0);p=0,g=0;do{if(u=B+(p<<5)|0,!(0|i[(h=B+(p<<5)+9|0)|0])){if(0|ce(0|r[(M=u)>>2],0|r[M+4>>2],L)){O=39;break}c=0|Vt(0|(d=0|r[(f=L)>>2]),0|(f=0|r[f+4>>2]),30),l=0|Vt(0|(c=0|kt(c^d|0,(0|E())^f,484763065,-1084733587)),0|(A=0|E()),27),c=0|Dt((l=0|Vt(0|(A=0|kt(l^c|0,(0|E())^A,321982955,-1798288965)),0|(c=0|E()),31))^A|0,(0|E())^c,0|y,0|w),A=0|E(),l=0|r[N+(c<<2)>>2];e:do{if(0|l){for(;(0|r[(M=l)>>2])!=(0|d)||(0|r[M+4>>2])!=(0|f);)if(c=0|Ft(0|(l=0|Lt(0|c,0|A,1,0)),0|E(),0|y,0|w),A=0|E(),!(l=0|r[N+(c<<2)>>2]))break e;i[h|0]=1,i[l+9|0]=1,c=l+16|0,r[16+(0|r[(M=B+(p<<5)+12|0)>>2])>>2]=r[c>>2],n=l+12|0,R=0|r[B+(p<<5)+16>>2],r[R+12>>2]=r[n>>2],r[16+(0|r[n>>2])>>2]=R,r[12+(0|r[c>>2])>>2]=r[M>>2],c=0|se(u),M=0|se(l),l=(R=(0|(n=0|r[(l=c+24|0)+4>>2]))<(0|(P=0|r[(R=M+24|0)+4>>2]))|((0|n)==(0|P)?(0|r[l>>2])>>>0<(0|r[R>>2])>>>0:0))?c:M,(0|(c=R?M:c))!=(0|l)&&(P=l+24|0,P=0|Lt(0|r[(R=M=c+24|0)>>2],0|r[R+4>>2],0|r[P>>2],0|r[P+4>>2]),R=0|E(),r[M>>2]=P,r[M+4>>2]=R,r[l+20>>2]=c)}}while(0)}p=0|Lt(0|p,0|g,1,0),g=0|E()}while((0|g)<(0|x)|(0|g)==(0|x)&p>>>0<T>>>0);39==(0|O)&&S(27634,26956,258,27001),l=0,c=0;do{i[B+(l<<5)+8|0]=0,l=0|Lt(0|l,0|c,1,0),c=0|E()}while((0|c)<(0|x)|(0|c)==(0|x)&l>>>0<T>>>0);for(d=0,A=0,h=0,f=0;;){if(l=B+(d<<5)|0,0|i[B+(d<<5)+8|0]||0|i[B+(d<<5)+9|0])u=h;else{c=0|r[(u=l)>>2],u=0|r[u+4>>2];do{i[l+8|0]=1,M=l=0|r[l+12>>2]}while((0|r[M>>2])!=(0|c)||(0|r[M+4>>2])!=(0|u));A=0|Lt(0|A,0|h,1,0),u=0|E()}if(d=0|Lt(0|d,0|f,1,0),!((0|(f=0|E()))<(0|x)|(0|f)==(0|x)&d>>>0<T>>>0))break;h=u}l=0,c=0;do{i[B+(l<<5)+8|0]=0,l=0|Lt(0|l,0|c,1,0),c=0|E()}while((0|c)<(0|x)|(0|c)==(0|x)&l>>>0<T>>>0);R=A,P=u,l=1}else R=0,P=0,l=0;M=0|St(24*R|0);e:do{if(0|M){t:do{if(l){e=0,y=0,n=0,t=0;n:for(;;){if(l=B+(e<<5)|0,0|i[B+(e<<5)+8|0]||0|i[B+(e<<5)+9|0])c=n,l=y;else{_=0|r[(v=l)>>2],v=0|r[v+4>>2],c=0,A=0;do{c=0|Lt(0|c,0|A,2,0),A=0|E(),w=l=0|r[l+12>>2]}while((0|r[w>>2])!=(0|_)||(0|r[w+4>>2])!=(0|v));if(!(b=0|St(c<<4)))break;c=_,A=v,m=0,g=0,u=0,h=0;do{if(0|le(c,A,C)){O=69;break n}if(p=((0|(f=(w=0|r[C>>2])+-1|0))<0)<<31>>31,(0|w)>1){A=u,d=0,c=h,u=0;do{h=C+8+(d<<4)|0,r[(w=b+(A<<4)|0)>>2]=r[h>>2],r[w+4>>2]=r[h+4>>2],r[w+8>>2]=r[h+8>>2],r[w+12>>2]=r[h+12>>2],A=0|Lt(0|A,0|c,1,0),c=0|E(),d=0|Lt(0|d,0|u,1,0),u=0|E()}while((0|u)<(0|p)|(0|u)==(0|p)&d>>>0<f>>>0);u=A,h=c}m=0|Lt(0|m,0|g,0|f,0|p),g=0|E(),i[l+8|0]=1,l=0|r[l+12>>2],c=0|r[(A=l)>>2],A=0|r[A+4>>2]}while(!((0|c)==(0|_)&(0|A)==(0|v)));if(!(c=0|Rt(b,m<<4))){O=75;break}v=0|se(l),w=0|r[v+4>>2],r[(l=M+(24*n|0)|0)>>2]=r[v>>2],r[l+4>>2]=w,r[(l=M+(24*n|0)+16|0)>>2]=m,r[M+(24*n|0)+20>>2]=c,r[L>>2]=r[l>>2],r[L+4>>2]=r[l+4>>2],G(L,M+(24*n|0)+8|0),c=0|Lt(0|n,0|y,1,0),l=0|E()}if(e=0|Lt(0|e,0|t,1,0),!((0|(t=0|E()))<(0|x)|(0|t)==(0|x)&e>>>0<T>>>0))break t;y=l,n=c}if(69==(0|O)?S(27634,26956,351,27016):75==(0|O)&&Ct(b),(0|y)>0|!(0|y)&n>>>0>0)for(u=0,h=0,l=n,A=y;(c=0|r[M+(24*u|0)+20>>2])?(Ct(c),c=y,l=n):c=A,u=0|Lt(0|u,0|h,1,0),(0|(h=0|E()))<(0|c)|(0|h)==(0|c)&u>>>0<l>>>0;)A=c;Ct(M);break e}}while(0);mt(M,R,24,2);t:do{if(!(0|R)&!(0|P)){if(0|(w=0|St(192))){if(r[w+16>>2]=0,r[w+20>>2]=0,r[(g=w+8|0)>>2]=3,l=0|St(48),r[(m=w+12|0)>>2]=l,0|l){r[l>>2]=r[3860],r[l+4>>2]=r[3861],r[l+8>>2]=r[3862],r[l+12>>2]=r[3863],r[(p=l+16|0)>>2]=r[3864],r[p+4>>2]=r[3865],r[p+8>>2]=r[3866],r[p+12>>2]=r[3867],r[(p=l+32|0)>>2]=r[3868],r[p+4>>2]=r[3869],r[p+8>>2]=r[3870],r[p+12>>2]=r[3871],r[L>>2]=r[g>>2],r[L+4>>2]=r[g+4>>2],G(L,w),r[w+40>>2]=0,r[w+44>>2]=0,r[(p=w+32|0)>>2]=3,l=0|St(48),r[(b=w+36|0)>>2]=l;do{if(l){if(r[l>>2]=r[3872],r[l+4>>2]=r[3873],r[l+8>>2]=r[3874],r[l+12>>2]=r[3875],r[(f=l+16|0)>>2]=r[3876],r[f+4>>2]=r[3877],r[f+8>>2]=r[3878],r[f+12>>2]=r[3879],r[(f=l+32|0)>>2]=r[3880],r[f+4>>2]=r[3881],r[f+8>>2]=r[3882],r[f+12>>2]=r[3883],r[L>>2]=r[p>>2],r[L+4>>2]=r[p+4>>2],G(L,w+24|0),r[w+64>>2]=0,r[w+68>>2]=0,r[(f=w+56|0)>>2]=3,l=0|St(48),r[(_=w+60|0)>>2]=l,!l){u=0,h=2;break}if(r[l>>2]=r[3884],r[l+4>>2]=r[3885],r[l+8>>2]=r[3886],r[l+12>>2]=r[3887],r[(d=l+16|0)>>2]=r[3888],r[d+4>>2]=r[3889],r[d+8>>2]=r[3890],r[d+12>>2]=r[3891],r[(d=l+32|0)>>2]=r[3892],r[d+4>>2]=r[3893],r[d+8>>2]=r[3894],r[d+12>>2]=r[3895],r[L>>2]=r[f>>2],r[L+4>>2]=r[f+4>>2],G(L,w+48|0),r[w+88>>2]=0,r[w+92>>2]=0,r[(d=w+80|0)>>2]=3,l=0|St(48),r[(v=w+84|0)>>2]=l,!l){u=0,h=3;break}if(r[l>>2]=r[3896],r[l+4>>2]=r[3897],r[l+8>>2]=r[3898],r[l+12>>2]=r[3899],r[(h=l+16|0)>>2]=r[3900],r[h+4>>2]=r[3901],r[h+8>>2]=r[3902],r[h+12>>2]=r[3903],r[(h=l+32|0)>>2]=r[3904],r[h+4>>2]=r[3905],r[h+8>>2]=r[3906],r[h+12>>2]=r[3907],r[L>>2]=r[d>>2],r[L+4>>2]=r[d+4>>2],G(L,w+72|0),r[w+112>>2]=0,r[w+116>>2]=0,r[(h=w+104|0)>>2]=3,l=0|St(48),r[(e=w+108|0)>>2]=l,!l){u=0,h=4;break}if(r[l>>2]=r[3908],r[l+4>>2]=r[3909],r[l+8>>2]=r[3910],r[l+12>>2]=r[3911],r[(u=l+16|0)>>2]=r[3912],r[u+4>>2]=r[3913],r[u+8>>2]=r[3914],r[u+12>>2]=r[3915],r[(u=l+32|0)>>2]=r[3916],r[u+4>>2]=r[3917],r[u+8>>2]=r[3918],r[u+12>>2]=r[3919],r[L>>2]=r[h>>2],r[L+4>>2]=r[h+4>>2],G(L,w+96|0),r[w+136>>2]=0,r[w+140>>2]=0,r[(u=w+128|0)>>2]=3,l=0|St(48),r[(t=w+132|0)>>2]=l,!l){u=0,h=5;break}if(r[l>>2]=r[3920],r[l+4>>2]=r[3921],r[l+8>>2]=r[3922],r[l+12>>2]=r[3923],r[(A=l+16|0)>>2]=r[3924],r[A+4>>2]=r[3925],r[A+8>>2]=r[3926],r[A+12>>2]=r[3927],r[(A=l+32|0)>>2]=r[3928],r[A+4>>2]=r[3929],r[A+8>>2]=r[3930],r[A+12>>2]=r[3931],r[L>>2]=r[u>>2],r[L+4>>2]=r[u+4>>2],G(L,w+120|0),r[w+160>>2]=0,r[w+164>>2]=0,r[(A=w+152|0)>>2]=3,l=0|St(48),r[(n=w+156|0)>>2]=l,!l){u=0,h=6;break}if(r[l>>2]=r[3932],r[l+4>>2]=r[3933],r[l+8>>2]=r[3934],r[l+12>>2]=r[3935],r[(c=l+16|0)>>2]=r[3936],r[c+4>>2]=r[3937],r[c+8>>2]=r[3938],r[c+12>>2]=r[3939],r[(c=l+32|0)>>2]=r[3940],r[c+4>>2]=r[3941],r[c+8>>2]=r[3942],r[c+12>>2]=r[3943],r[L>>2]=r[A>>2],r[L+4>>2]=r[A+4>>2],G(L,w+144|0),r[w+184>>2]=0,r[w+188>>2]=0,r[(c=w+176|0)>>2]=3,l=0|St(48),r[(y=w+180|0)>>2]=l,!l){u=0,h=7;break}if(r[l>>2]=r[3944],r[l+4>>2]=r[3945],r[l+8>>2]=r[3946],r[l+12>>2]=r[3947],r[(C=l+16|0)>>2]=r[3948],r[C+4>>2]=r[3949],r[C+8>>2]=r[3950],r[C+12>>2]=r[3951],r[(l=l+32|0)>>2]=r[3952],r[l+4>>2]=r[3953],r[l+8>>2]=r[3954],r[l+12>>2]=r[3955],r[L>>2]=r[c>>2],r[L+4>>2]=r[c+4>>2],G(L,w+168|0),mt(w,8,24,3),l=0|St(128),r[o+4>>2]=l,0|l){r[o>>2]=8,r[l>>2]=r[g>>2],r[l+4>>2]=r[g+4>>2],r[l+8>>2]=r[g+8>>2],r[l+12>>2]=r[g+12>>2],r[(O=l+16|0)>>2]=r[p>>2],r[O+4>>2]=r[p+4>>2],r[O+8>>2]=r[p+8>>2],r[O+12>>2]=r[p+12>>2],r[(O=l+32|0)>>2]=r[f>>2],r[O+4>>2]=r[f+4>>2],r[O+8>>2]=r[f+8>>2],r[O+12>>2]=r[f+12>>2],r[(O=l+48|0)>>2]=r[d>>2],r[O+4>>2]=r[d+4>>2],r[O+8>>2]=r[d+8>>2],r[O+12>>2]=r[d+12>>2],r[(O=l+64|0)>>2]=r[h>>2],r[O+4>>2]=r[h+4>>2],r[O+8>>2]=r[h+8>>2],r[O+12>>2]=r[h+12>>2],r[(O=l+80|0)>>2]=r[u>>2],r[O+4>>2]=r[u+4>>2],r[O+8>>2]=r[u+8>>2],r[O+12>>2]=r[u+12>>2],r[(O=l+96|0)>>2]=r[A>>2],r[O+4>>2]=r[A+4>>2],r[O+8>>2]=r[A+8>>2],r[O+12>>2]=r[A+12>>2],r[(O=l+112|0)>>2]=r[c>>2],r[O+4>>2]=r[c+4>>2],r[O+8>>2]=r[c+8>>2],r[O+12>>2]=r[c+12>>2],Ct(w),O=158;break t}0|(l=0|r[m>>2])&&Ct(l),0|(l=0|r[b>>2])&&Ct(l),0|(l=0|r[_>>2])&&Ct(l),0|(l=0|r[v>>2])&&Ct(l),0|(l=0|r[e>>2])&&Ct(l),0|(l=0|r[t>>2])&&Ct(l),0|(l=0|r[n>>2])&&Ct(l),0|(l=0|r[y>>2])&&Ct(l),Ct(w);break t}u=0,h=1}while(0);l=0,A=0;do{0|(c=0|r[w+(24*l|0)+12>>2])&&Ct(c),l=0|Lt(0|l,0|A,1,0),A=0|E()}while(A>>>0<u>>>0|(0|A)==(0|u)&l>>>0<h>>>0)}Ct(w),O=152}}else{if((0|P)>0|!(0|P)&R>>>0>0){A=0,u=0,h=0,c=0,l=0,d=0;do{L=u,O=h,c=0|Lt(0|c,0|l,1&((0|(u=0|r[(C=M+(24*A|0)|0)>>2]))!=(0|L)|(0|(h=0|r[C+4>>2]))!=(0|O)),0),l=0|E(),A=0|Lt(0|A,0|d,1,0),d=0|E()}while((0|d)<(0|P)|(0|d)==(0|P)&A>>>0<R>>>0);v=c,_=l}else v=0,_=0;if(e=0|St(24*v|0)){n:do{if((0|P)>=0){for(g=0,m=0,c=0,A=0,b=0,u=0;;){if((0|g)==(0|R)&(0|m)==(0|P)||(O=M+(24*g|0)|0,(0|r[(L=M+(24*c|0)|0)>>2])!=(0|r[O>>2])||(0|r[L+4>>2])!=(0|r[O+4>>2]))){if(f=M+(24*c|0)|0,p=0|Lt(0|(O=0|It(0|g,0|m,0|c,0|A)),0|(L=0|E()),-1,-1),A=0|E(),(0|L)>0|!(0|L)&O>>>0>1){if(!(l=0|St(p<<3)))break;h=0,d=0;do{O=h,h=0|Lt(0|h,0|d,1,0),d=0|E(),L=0|r[(C=f+(24*h|0)+16|0)+4>>2],r[(O=l+(O<<3)|0)>>2]=r[C>>2],r[O+4>>2]=L}while((0|d)<(0|A)|(0|d)==(0|A)&h>>>0<p>>>0)}else l=0;O=0|r[(L=M+(24*c|0)+16|0)+4>>2],r[(A=e+(24*u|0)+8|0)>>2]=r[L>>2],r[A+4>>2]=O,r[e+(24*u|0)+16>>2]=p,r[e+(24*u|0)+20>>2]=l,s[e+(24*u|0)>>3]=+s[M+(24*c|0)+8>>3],u=0|Lt(0|u,0|b,1,0),c=g,A=m,l=0|E()}else l=b;if(O=g,g=0|Lt(0|g,0|m,1,0),L=m,m=0|E(),!((0|L)<(0|P)|(0|L)==(0|P)&O>>>0<R>>>0))break n;b=l}if((0|b)>0|!(0|b)&u>>>0>0){l=0,A=0;do{0|(c=0|r[e+(24*l|0)+20>>2])&&Ct(c),l=0|Lt(0|l,0|A,1,0),A=0|E()}while((0|A)<(0|b)|(0|A)==(0|b)&l>>>0<u>>>0)}Ct(e),O=152;break t}}while(0);if(mt(e,v,24,3),l=0|St(v<<4),r[(A=o+4|0)>>2]=l,l){r[o>>2]=v;do{if((0|_)>0|!(0|_)&v>>>0>0){if(o=e+8|0,r[l>>2]=r[o>>2],r[l+4>>2]=r[o+4>>2],r[l+8>>2]=r[o+8>>2],r[l+12>>2]=r[o+12>>2],1==(0|v)&!(0|_))break;if(O=e+32|0,r[(o=l+16|0)>>2]=r[O>>2],r[o+4>>2]=r[O+4>>2],r[o+8>>2]=r[O+8>>2],r[o+12>>2]=r[O+12>>2],!((0|_)>0|!(0|_)&v>>>0>2))break;l=2,c=0;do{o=(0|r[A>>2])+(l<<4)|0,O=e+(24*l|0)+8|0,r[o>>2]=r[O>>2],r[o+4>>2]=r[O+4>>2],r[o+8>>2]=r[O+8>>2],r[o+12>>2]=r[O+12>>2],l=0|Lt(0|l,0|c,1,0),c=0|E()}while((0|c)<(0|_)|(0|c)==(0|_)&l>>>0<v>>>0)}}while(0);Ct(e),O=158;break}if((0|_)>0|!(0|_)&v>>>0>0){l=0,A=0;do{0|(c=0|r[e+(24*l|0)+20>>2])&&Ct(c),l=0|Lt(0|l,0|A,1,0),A=0|E()}while((0|A)<(0|_)|(0|A)==(0|_)&l>>>0<v>>>0)}Ct(e),O=152;break}O=152}}while(0);if(158==(0|O))return Ct(B),Ct(N),Ct(M),I=a,0|(N=0);if(152==(0|O)&&(0|P)>0|!(0|P)&R>>>0>0)for(u=0,h=0,l=R,A=P;(c=0|r[M+(24*u|0)+20>>2])?(Ct(c),c=P,l=R):c=A,u=0|Lt(0|u,0|h,1,0),(0|(h=0|E()))<(0|c)|(0|h)==(0|c)&u>>>0<l>>>0;)A=c;return Ct(M),Ct(B),Ct(N),I=a,0|(N=13)}}while(0);return Ct(B),Ct(N),I=a,0|(N=13)}return 159==(0|O)?(I=a,0|l):0}function se(e){var t,n=0;return(0|(n=0|r[(t=(e|=0)+20|0)>>2]))==(0|e)?0|e:(n=0|se(n),r[t>>2]=n,0|n)}function oe(e,t){var n=0;switch(n=0|Vt(0|(e|=0),0|(t|=0),56),E(),7&n){case 0:case 7:return 0|(n=0)}return n=-2130706433&t|134217728,!0&268435456==(2013265920&t)?!0&16777216==(117440512&t)&!!(0|Ee(e,n))?0|(n=0):0|(n=0|ye(e,n)):0|(n=0)}function ae(e,t,n){n|=0;var i,s=0;return i=!(0|Ee(e|=0,t|=0)),t&=-2130706433,r[(s=n)>>2]=i?e:0,r[s+4>>2]=i?285212672|t:0,r[(s=n+8|0)>>2]=e,r[s+4>>2]=301989888|t,r[(s=n+16|0)>>2]=e,r[s+4>>2]=318767104|t,r[(s=n+24|0)>>2]=e,r[s+4>>2]=335544320|t,r[(s=n+32|0)>>2]=e,r[s+4>>2]=352321536|t,r[(n=n+40|0)>>2]=e,r[n+4>>2]=369098752|t,0}function le(e,t,n){n|=0;var i,s,o=0,a=0;return s=I,I=I+16|0,i=s,a=-2130706433&(t|=0)|134217728,!0&268435456==(2013265920&t)?(o=0|Vt(0|(e|=0),0|t,56),E(),o=0|function(e,t,n){e|=0,t|=0,n|=0;var i=0,s=0,o=0;if(o=I,I=I+16|0,s=o,i=0|Ee(e,t),(n+-1|0)>>>0>5)return I=o,0|(s=-1);if(i=!!(0|i),1==(0|n)&i)return I=o,0|(s=-1);do{if(!(0|ft(e,t,s))){if(i){i=(5+(0|r[26416+(n<<2)>>2])-(0|r[s>>2])|0)%5|0;break}i=(6+(0|r[26448+(n<<2)>>2])-(0|r[s>>2])|0)%6|0;break}i=-1}while(0);return s=i,I=o,0|s}(e,a,7&o),-1==(0|o)?(r[n>>2]=0,I=s,0|(a=6)):(0|Fe(e,a,i)&&S(27634,27035,282,27050),t=0|Vt(0|e,0|t,52),E(),t&=15,0|Ee(e,a)?de(i,t,o,2,n):me(i,t,o,2,n),I=s,0|(a=0))):(I=s,0|(a=6))}function ce(e,t,n){e|=0,n|=0;var i,s=0,o=0,a=0;return i=I,I=I+16|0,o=i,a=-2130706433&(t|=0)|134217728,!0&268435456==(2013265920&t)?(r[(s=i+8|0)>>2]=0,t=0|Vt(0|e,0|t,56),E(),0|(t=0|F(e,a,7&t,s,o))?(I=i,0|(n=t)):7==(0|(t=0|V(s=0|r[o>>2],o=0|r[o+4>>2],e,a)))?(I=i,0|(n=11)):(e=0|zt(0|t,0,56),a=-2130706433&o|E()|268435456,r[n>>2]=s|e,r[n+4>>2]=a,I=i,0|(n=0))):(I=i,0|(n=6))}function Ae(e,t,n){e|=0,t|=0;var i,o,a=0,l=0,p=0,g=0,b=0,_=0,v=0,y=0,w=0,x=0,T=0,S=0,C=0,P=0,R=0,M=0,L=0;r[(n|=0)>>2]=0,v=+s[e>>3],y=+s[e+8>>3],_=+s[e+16>>3],l=0,p=5,a=5,e=0;do{(g=(T=+s[15888+(24*l|0)>>3]-v)*T+(x=+s[15888+(24*l|0)+8>>3]-y)*x+(g=+s[15888+(24*l|0)+16>>3]-_)*g)<a&&(r[n>>2]=l,p=g,e=l,a=g),l=l+1|0}while(20!=(0|l));if((p=+f(+(1-.5*p)))<1e-16)_=0,g=0;else{if(M=+s[16368+(24*e|0)>>3],P=+s[15888+(24*e|0)>>3],R=+s[15888+(24*e|0)+8>>3],g=P*(L=-((C=+s[15888+(24*e|0)+16>>3])+(0*P+0*R)))+0,T=R*L+0,g*=S=(S=+A(+((L=C*L+1)*L+(g*g+T*T))))>0?1/S:0,T*=S,S*=L,x=v+P*(L=-(v*P+y*R+_*C)),x*=y=(y=+A(+((v=_+C*L)*v+(x*x+(a=y+R*L)*a))))>0?1/y:0,a*=y,a=+He(M-+He(+m(+((y*=v)*(R*g-P*T)+(x*(C*T-R*S)+a*(P*S-C*g))),+(S*y+(g*x+T*a))))),g=0|Be(t)?+He(a+-.3334731722518321):a,a=2.618033988749896*+d(+p),(0|t)>0){e=0;do{a*=2.6457513110645907,e=e+1|0}while((0|e)!=(0|t))}_=+u(+g)*a,g=+h(+g)*a}t=n+4|0,r[(o=n+12|0)>>2]=0,p=1.1547005383792515*+c(+g),a=+c(+_)+.5*p,a-=+(0|(e=~~a)),p-=+(0|(l=~~p));do{if(a<.5){if(a<.3333333333333333){if(r[t>>2]=e,p<.5*(a+1)){r[n+8>>2]=l;break}l=l+1|0,r[n+8>>2]=l;break}if(l=(1&!(p<(L=1-a)))+l|0,r[n+8>>2]=l,L<=p&p<2*a){e=e+1|0,r[t>>2]=e;break}r[t>>2]=e;break}if(!(a<.6666666666666666)){if(e=e+1|0,r[t>>2]=e,p<.5*a){r[n+8>>2]=l;break}l=l+1|0,r[n+8>>2]=l;break}if(p<1-a){if(r[n+8>>2]=l,2*a-1<p){r[t>>2]=e;break}}else l=l+1|0,r[n+8>>2]=l;e=e+1|0,r[t>>2]=e}while(0);do{if(_<0){if(1&l){e=~~(+(0|e)-(2*(+((w=0|It(0|e,((0|e)<0)<<31>>31,0|(w=(l+1|0)/2|0),((0|w)<0)<<31>>31))>>>0)+4294967296*+(0|E()))+1)),r[t>>2]=e,w=t;break}e=~~(+(0|e)-2*(+((w=0|It(0|e,((0|e)<0)<<31>>31,0|(w=(0|l)/2|0),((0|w)<0)<<31>>31))>>>0)+4294967296*+(0|E()))),r[t>>2]=e,w=t;break}w=t}while(0);i=n+8|0,t=0-l|0,g<0?(n=e-((1|l<<1)/2|0)|0,r[w>>2]=n,r[i>>2]=t,l=t):n=e,e=l-n|0,t=0-n|0,(0|n)<0?(r[i>>2]=e,r[o>>2]=t,r[w>>2]=0,b=0):(e=l,b=n,t=0),n=b-e|0,l=t-e|0,(0|e)<0?(r[w>>2]=n,r[o>>2]=l,r[i>>2]=0,b=n,e=0):l=t,n=b-l|0,t=e-l|0,(0|l)<0?(r[w>>2]=n,r[i>>2]=t,r[o>>2]=0,l=0):(t=e,n=b),(0|(e=(0|l)<(0|(e=(0|t)<(0|n)?t:n))?l:e))<=0||(r[w>>2]=n-e,r[i>>2]=t-e,r[o>>2]=l-e)}function ue(e,t,n){t|=0,n|=0;var i,o,a,l;i=I,I=I+16|0,o=i,l=0|r[(e|=0)+12>>2],a=+((0|r[e+8>>2])-l|0),s[o>>3]=+((0|r[e+4>>2])-l|0)-.5*a,s[o+8>>3]=.8660254037844386*a,he(o,0|r[e>>2],t,0,n),I=i}function he(e,t,n,i,o){t|=0,n|=0,i|=0,o|=0;var a,l,c,d,f,p=0,b=0,_=0,v=0,y=0,w=0,x=0;if(p=+function(e){e|=0;var t=0,n=0;return n=+s[e>>3],t=+s[e+8>>3],+ +A(+(n*n+t*t))}(e|=0),p<1e-16)return t=15888+(24*t|0)|0,r[o>>2]=r[t>>2],r[o+4>>2]=r[t+4>>2],r[o+8>>2]=r[t+8>>2],r[o+12>>2]=r[t+12>>2],r[o+16>>2]=r[t+16>>2],void(r[o+20>>2]=r[t+20>>2]);if(b=+m(+ +s[e+8>>3],+ +s[e>>3]),(0|n)>0){e=0;do{p*=.37796447300922725,e=e+1|0}while((0|e)!=(0|n))}_=.3333333333333333*p,i?(n=!(0|Be(n)),p=+g(.381966011250105*(n?_:.37796447300922725*_))):(p=+g(.381966011250105*p),0|Be(n)&&(b=+He(b+.3334731722518321))),y=+He(+s[16368+(24*t|0)>>3]-b),_=+s[15888+(24*t|0)>>3],l=+s[15888+(24*t|0)+8>>3],v=_*(x=-((d=+s[15888+(24*t|0)+16>>3])+(0*_+0*l)))+0,b=l*x+0,v*=w=(w=+A(+((x=d*x+1)*x+(v*v+b*b))))>0?1/w:0,b*=w,w*=x,x=+u(+y),y=+h(+y),a=(f=+u(+p))*_+(c=+h(+p))*(x*v+y*(d*b-l*w)),p=f*l+c*(x*b+y*(_*w-d*v)),_=(_=+A(+((b=f*d+c*(x*w+y*(l*v-_*b)))*b+(a*a+p*p))))>0?1/_:0,s[o>>3]=a*_,s[o+8>>3]=p*_,s[o+16>>3]=b*_}function de(e,t,n,i,o){e|=0,t|=0,n|=0,i|=0,o|=0;var a,l,c,A,u,h,d,f,g,b,v,y,w,x,T,E,C,P,R,M,L,O,B,N,k,F,D,U=0,V=0,z=0,G=0,j=0,H=0,W=0,q=0,K=0,Q=0,X=0,$=0,Z=0,Y=0,J=0;if(D=I,I=I+256|0,K=D+224|0,N=D,k=D+208|0,F=D+192|0,P=D+168|0,R=D+152|0,M=D+136|0,L=D+120|0,O=D+104|0,B=D+80|0,r[(U=D+240|0)>>2]=t,r[K>>2]=r[e>>2],r[K+4>>2]=r[e+4>>2],r[K+8>>2]=r[e+8>>2],r[K+12>>2]=r[e+12>>2],fe(K,U,N),r[o>>2]=0,(0|(K=i+n+(5==(0|i)&1)|0))<=(0|n))I=D;else{d=k+4|0,u=k+8|0,h=k+12|0,g=F+8|0,b=n+5|0,v=16848+((f=0|r[U>>2])<<2)|0,y=P+8|0,w=16928+(f<<2)|0,x=R+8|0,T=M+8|0,E=L+8|0,C=F+8|0,a=P+8|0,c=P+16|0,l=B+8|0,A=B+16|0,q=n,i=0,V=0,z=0,G=0;e:for(;;){W=N+((0|q)%5<<4)|0,r[k>>2]=r[W>>2],r[k+4>>2]=r[W+4>>2],r[k+8>>2]=r[W+8>>2],r[k+12>>2]=r[W+12>>2];do{}while(2==(0|pe(k,f,0,1)));if((0|q)>(0|n)&!!(0|Be(t))){if(W=0|r[k>>2],e=0|r[d>>2],j=0|r[u>>2],U=0|r[h>>2],Q=+(z-G|0),s[F>>3]=+(V-G|0)-.5*Q,s[g>>3]=.8660254037844386*Q,G=0|r[17008+(80*W|0)+(i<<2)>>2],H=0|r[18608+(80*W|0)+(20*G|0)>>2],(0|(z=0|r[18608+(80*W|0)+(20*G|0)+16>>2]))>0){V=0,i=j;do{i=(($=(0|(j=i+e-((Y=(0|(Z=U+e|0))<0)?Z:0)|0))<0)?0:j)-((U=(0|(X=U+i-(Y?Z:0)-($?j:0)|0))<0)?X:0)|0,e=(e=(Y?0:Z)-($?j:0)-(U?X:0)|0)-((j=(0|(U=(0|(X=U?0:X))<(0|(U=(0|i)<(0|e)?i:e))?X:U))>0)?U:0)|0,i=i-(j?U:0)|0,U=X-(j?U:0)|0,V=V+1|0}while((0|V)<(0|z))}else i=j;switch(Y=3*(0|r[v>>2])|0,X=(0|_(Y,0|r[18608+(80*W|0)+(20*G|0)+4>>2]))+e|0,j=(0|_(Y,0|r[18608+(80*W|0)+(20*G|0)+8>>2]))+i|0,Y=(0|_(Y,0|r[18608+(80*W|0)+(20*G|0)+12>>2]))+U|0,X=((G=(0|X)<0)?0:X)-(($=(0|(j=j-(G?X:0)|0))<0)?j:0)-((Z=(0|(Y=Y+(G?0-X|0:0)+($?0-j|0:0)|0))<0)?Y:0)|0,Q=+((j=($?0:j)-(Z?Y:0)|0)-(($=(0|(Z=(0|(Y=Z?0:Y))<(0|(Z=(0|j)<(0|X)?j:X))?Y:Z))>0)?Z:0)-(Y=Y-($?Z:0)|0)|0),s[P>>3]=+(X-($?Z:0)-Y|0)-.5*Q,s[y>>3]=.8660254037844386*Q,Q=+(0|r[w>>2]),s[R>>3]=3*Q,s[x>>3]=0,J=-1.5*Q,s[M>>3]=J,s[T>>3]=2.598076211353316*Q,s[L>>3]=J,s[E>>3]=-2.598076211353316*Q,0|r[17008+(80*H|0)+(W<<2)>>2]){case 1:e=M,i=R;break;case 3:e=L,i=M;break;case 2:e=R,i=L;break;default:e=12;break e}ht(F,P,i,e,O),he(O,H,f,1,B),Y=0|r[o>>2],Q=+p(+ +s[A>>3]),J=+m(+ +s[l>>3],+ +s[B>>3]),s[o+8+(Y<<4)>>3]=Q,s[o+8+(Y<<4)+8>>3]=J,r[o>>2]=1+(0|r[o>>2])}if((0|q)<(0|b)&&(Y=0|r[h>>2],Q=+((0|r[u>>2])-Y|0),s[F>>3]=+((0|r[d>>2])-Y|0)-.5*Q,s[C>>3]=.8660254037844386*Q,he(F,0|r[k>>2],f,1,P),Y=0|r[o>>2],Q=+p(+ +s[c>>3]),J=+m(+ +s[a>>3],+ +s[P>>3]),s[o+8+(Y<<4)>>3]=Q,s[o+8+(Y<<4)+8>>3]=J,r[o>>2]=1+(0|r[o>>2])),(0|(q=q+1|0))>=(0|K)){e=3;break}i=0|r[k>>2],V=0|r[d>>2],z=0|r[u>>2],G=0|r[h>>2]}3!=(0|e)?12==(0|e)&&S(27073,27120,599,27130):I=D}}function fe(e,t,n){e|=0,t|=0,n|=0;var i,s,o,a,l=0,c=0,A=0,u=0,h=0,d=0,f=0,p=0;a=I,I=I+128|0,c=a,u=20208,h=(A=l=a+64|0)+60|0;do{r[A>>2]=r[u>>2],A=A+4|0,u=u+4|0}while((0|A)<(0|h));u=20272,h=(A=c)+60|0;do{r[A>>2]=r[u>>2],A=A+4|0,u=u+4|0}while((0|A)<(0|h));p=(p=!(0|Be(0|r[t>>2])))?l:c,A=0|r[(o=e+4|0)>>2],l=0|r[(i=e+8|0)>>2],c=0|r[(s=e+12|0)>>2],u=l+(A<<1)|0,r[o>>2]=u,l=c+(l<<1)|0,r[i>>2]=l,A=(c<<1)+A|0,r[s>>2]=A,c=l-u|0,h=A-u|0,(0|u)<0&&(r[i>>2]=c,r[s>>2]=h,r[o>>2]=0,l=c,u=0,A=h),h=u-l|0,c=A-l|0,(0|l)<0?(r[o>>2]=h,r[s>>2]=c,r[i>>2]=0,l=0):(c=A,h=u),u=h-c|0,A=l-c|0,(0|c)<0?(r[o>>2]=u,r[i>>2]=A,r[s>>2]=0,c=0):(A=l,u=h),(0|(l=(0|c)<(0|(l=(0|A)<(0|u)?A:u))?c:l))>0&&(c=c-l|0,A=A-l|0,u=u-l|0,r[o>>2]=u,r[i>>2]=A,r[s>>2]=c),d=(A<<1)+u|0,h=c+(u<<1)|0,r[o>>2]=h,r[i>>2]=d,A=(c<<1)+A|0,r[s>>2]=A,l=d-h|0,c=A-h|0,(0|h)<0?(r[i>>2]=l,r[s>>2]=c,r[o>>2]=0,h=0,A=c):l=d,u=h-l|0,c=A-l|0,(0|l)<0?(r[o>>2]=u,r[s>>2]=c,r[i>>2]=0,h=u,l=0):c=A,u=h-c|0,A=l-c|0,(0|c)<0?(r[o>>2]=u,r[i>>2]=A,r[s>>2]=0,c=0):(A=l,u=h),(0|(l=(0|c)<(0|(l=(0|A)<(0|u)?A:u))?c:l))>0&&(r[o>>2]=u-l,r[i>>2]=A-l,r[s>>2]=c-l),0|Be(0|r[t>>2])&&(A=0|r[o>>2],l=(3*(u=0|r[i>>2])|0)+A|0,A=(c=0|r[s>>2])+(3*A|0)|0,r[o>>2]=A,r[i>>2]=l,u=(3*c|0)+u|0,r[s>>2]=u,c=l-A|0,h=u-A|0,(0|A)<0?(r[i>>2]=c,r[s>>2]=h,r[o>>2]=0,l=c,d=0):(d=A,h=u),A=d-l|0,c=h-l|0,(0|l)<0?(r[o>>2]=A,r[s>>2]=c,r[i>>2]=0,d=A,u=0):(u=l,c=h),A=d-c|0,l=u-c|0,(0|c)<0?(r[o>>2]=A,r[i>>2]=l,r[s>>2]=0,u=l,c=0):A=d,(0|(l=(0|c)<(0|(l=(0|u)<(0|A)?u:A))?c:l))>0&&(r[o>>2]=A-l,r[i>>2]=u-l,r[s>>2]=c-l),r[t>>2]=1+(0|r[t>>2])),r[n>>2]=r[e>>2],c=0|r[i>>2],l=0|r[s>>2],t=0|r[p+4>>2],f=0|r[p+8>>2],u=(0|r[p>>2])+(0|r[o>>2])|0,r[(d=n+4|0)>>2]=u,c=t+c|0,r[(t=n+8|0)>>2]=c,l=f+l|0,r[(f=n+12|0)>>2]=l,A=c-u|0,(0|u)<0&&(l=l-u|0,r[t>>2]=A,r[f>>2]=l,r[d>>2]=0,c=A,u=0),(0|c)<0&&(u=u-c|0,r[d>>2]=u,l=l-c|0,r[f>>2]=l,r[t>>2]=0,c=0),h=u-l|0,A=c-l|0,(0|l)<0?(r[d>>2]=h,r[t>>2]=A,r[f>>2]=0,u=h,l=0):A=c,(0|(c=(0|l)<(0|(c=(0|A)<(0|u)?A:u))?l:c))>0&&(r[d>>2]=u-c,r[t>>2]=A-c,r[f>>2]=l-c),r[n+16>>2]=r[e>>2],c=0|r[i>>2],l=0|r[s>>2],t=0|r[p+16>>2],f=0|r[p+20>>2],u=(0|r[p+12>>2])+(0|r[o>>2])|0,r[(d=n+20|0)>>2]=u,c=t+c|0,r[(t=n+24|0)>>2]=c,l=f+l|0,r[(f=n+28|0)>>2]=l,A=c-u|0,(0|u)<0&&(l=l-u|0,r[t>>2]=A,r[f>>2]=l,r[d>>2]=0,c=A,u=0),(0|c)<0&&(u=u-c|0,r[d>>2]=u,l=l-c|0,r[f>>2]=l,r[t>>2]=0,c=0),h=u-l|0,A=c-l|0,(0|l)<0?(r[d>>2]=h,r[t>>2]=A,r[f>>2]=0,u=h,l=0):A=c,(0|(c=(0|l)<(0|(c=(0|A)<(0|u)?A:u))?l:c))>0&&(r[d>>2]=u-c,r[t>>2]=A-c,r[f>>2]=l-c),r[n+32>>2]=r[e>>2],c=0|r[i>>2],l=0|r[s>>2],t=0|r[p+28>>2],f=0|r[p+32>>2],u=(0|r[p+24>>2])+(0|r[o>>2])|0,r[(d=n+36|0)>>2]=u,c=t+c|0,r[(t=n+40|0)>>2]=c,l=f+l|0,r[(f=n+44|0)>>2]=l,A=c-u|0,(0|u)<0&&(l=l-u|0,r[t>>2]=A,r[f>>2]=l,r[d>>2]=0,c=A,u=0),(0|c)<0&&(u=u-c|0,r[d>>2]=u,l=l-c|0,r[f>>2]=l,r[t>>2]=0,c=0),h=u-l|0,A=c-l|0,(0|l)<0?(r[d>>2]=h,r[t>>2]=A,r[f>>2]=0,u=h,l=0):A=c,(0|(c=(0|l)<(0|(c=(0|A)<(0|u)?A:u))?l:c))>0&&(r[d>>2]=u-c,r[t>>2]=A-c,r[f>>2]=l-c),r[n+48>>2]=r[e>>2],c=0|r[i>>2],l=0|r[s>>2],t=0|r[p+40>>2],f=0|r[p+44>>2],u=(0|r[p+36>>2])+(0|r[o>>2])|0,r[(d=n+52|0)>>2]=u,c=t+c|0,r[(t=n+56|0)>>2]=c,l=f+l|0,r[(f=n+60|0)>>2]=l,A=c-u|0,(0|u)<0&&(l=l-u|0,r[t>>2]=A,r[f>>2]=l,r[d>>2]=0,c=A,u=0),(0|c)<0&&(u=u-c|0,r[d>>2]=u,l=l-c|0,r[f>>2]=l,r[t>>2]=0,c=0),h=u-l|0,A=c-l|0,(0|l)<0?(r[d>>2]=h,r[t>>2]=A,r[f>>2]=0,u=h,l=0):A=c,(0|(c=(0|l)<(0|(c=(0|A)<(0|u)?A:u))?l:c))>0&&(r[d>>2]=u-c,r[t>>2]=A-c,r[f>>2]=l-c),r[n+64>>2]=r[e>>2],A=0|r[i>>2],l=0|r[s>>2],f=0|r[p+52>>2],d=0|r[p+56>>2],u=(0|r[p+48>>2])+(0|r[o>>2])|0,r[(t=n+68|0)>>2]=u,A=f+A|0,r[(f=n+72|0)>>2]=A,l=d+l|0,r[(d=n+76|0)>>2]=l,c=A-u|0,(0|u)<0?(l=l-u|0,r[f>>2]=c,r[d>>2]=l,r[t>>2]=0,A=0):(c=A,A=u),(0|c)<0&&(A=A-c|0,r[t>>2]=A,l=l-c|0,r[d>>2]=l,r[f>>2]=0,c=0),h=A-l|0,u=c-l|0,(0|l)<0?(r[t>>2]=h,r[f>>2]=u,r[d>>2]=0,A=h,l=0):u=c,(0|(c=(0|l)<(0|(c=(0|u)<(0|A)?u:A))?l:c))<=0||(r[t>>2]=A-c,r[f>>2]=u-c,r[d>>2]=l-c),I=a}function pe(e,t,n,i){e|=0,n|=0,i|=0;var s,o,a,l=0,c=0,A=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,b=0;if(d=0|r[16928+((t|=0)<<2)>>2],d=(a=!!(0|i))?3*d|0:d,u=0|r[(o=e+4|0)>>2],c=0|r[(s=e+8|0)>>2],a){if((0|(l=c+u+(i=0|r[(A=e+12|0)>>2])|0))==(0|d))return 0|(d=1);h=A}else i=l=0|r[(h=e+12|0)>>2],l=c+u+l|0;if((0|l)<=(0|d))return 0|(d=0);do{if((0|i)>0){if(l=0|r[e>>2],(0|c)>0){l=18608+(80*l|0)+60|0,A=u;break}l=18608+(80*l|0)+40|0,n?(n=((f=(0|(n=c+(A=u-d|0)|0))<0)?0:n)-((u=(0|(c=i+c-(f?n:0)|0))<0)?c:0)-((A=(0|(i=i+A-(f?n:0)-(u?c:0)|0))<0)?i:0)|0,c=(c=(u?0:c)-(A?i:0)|0)-((u=(0|(A=(0|(i=A?0:i))<(0|(A=(0|c)<(0|n)?c:n))?i:A))>0)?A:0)|0,i=i-(u?A:0)|0,A=n-(u?A:0)+d|0,r[o>>2]=A,r[s>>2]=c,r[h>>2]=i):A=u}else l=18608+(80*(0|r[e>>2])|0)+20|0,A=u}while(0);if(r[e>>2]=r[l>>2],(0|(u=0|r[l+16>>2]))>0){n=0;do{(0|(e=(0|(i=(c=(0|(A=i+c-(b=(p=(0|(f=i+A|0))<0)?f:0)-(e=(m=(0|(g=c+A-b|0))<0)?g:0)|0))<0)?0:A))<(0|(e=(0|(c=(m?0:g)-(A=c?A:0)|0))<(0|(A=(p?0:f)-e-A|0))?c:A))?i:e))>0&&(A=A-e|0,c=c-e|0,i=i-e|0),n=n+1|0}while((0|n)<(0|u));r[o>>2]=A,r[s>>2]=c,r[h>>2]=i}return g=0|r[16848+(t<<2)>>2],m=0|_(g=a?3*g|0:g,0|r[l+8>>2]),b=0|_(g,0|r[l+12>>2]),A=(0|_(g,0|r[l+4>>2]))+A|0,r[o>>2]=A,c=m+c|0,r[s>>2]=c,i=b+i|0,r[h>>2]=i,l=c-A|0,(0|A)<0?(i=i-A|0,r[s>>2]=l,r[h>>2]=i,r[o>>2]=0,c=0):(l=c,c=A),(0|l)<0?(e=c-l|0,r[o>>2]=e,i=i-l|0,r[h>>2]=i,r[s>>2]=0,A=0):(e=c,A=l),c=e-i|0,l=A-i|0,(0|i)<0?(r[o>>2]=c,r[s>>2]=l,r[h>>2]=0,i=0):(l=A,c=e),(0|(A=(0|i)<(0|(A=(0|l)<(0|c)?l:c))?i:A))>0&&(c=c-A|0,l=l-A|0,i=i-A|0,r[o>>2]=c,r[s>>2]=l,r[h>>2]=i),a?0|(b=(l+c+i|0)==(0|d)?1:2):0|(b=2)}function ge(e,t){e|=0,t|=0;var n=0;do{n=0|pe(e,t,0,1)}while(2==(0|n));return 0|n}function me(e,t,n,i,o){e|=0,t|=0,n|=0,i|=0,o|=0;var a,l,c,A,u,h,d,f,g,b,_,v,y,w,x,T,E,C,P,R,M,L,O,B,N,k,F,D,U=0,V=0,z=0,G=0,j=0,H=0,W=0;if(D=I,I=I+272|0,V=D+240|0,N=D,k=D+224|0,F=D+208|0,P=D+184|0,R=D+168|0,M=D+152|0,L=D+136|0,O=D+120|0,B=D+96|0,r[(U=D+256|0)>>2]=t,r[V>>2]=r[e>>2],r[V+4>>2]=r[e+4>>2],r[V+8>>2]=r[e+8>>2],r[V+12>>2]=r[e+12>>2],be(V,U,N),r[o>>2]=0,(0|(C=i+n+(6==(0|i)&1)|0))<=(0|n))I=D;else{_=n+6|0,v=F+8|0,y=P+8|0,w=16928+((b=0|r[U>>2])<<2)|0,x=R+8|0,T=M+8|0,E=L+8|0,f=0|r[V>>2],u=k+4|0,h=k+8|0,d=k+12|0,g=F+8|0,a=P+8|0,c=P+16|0,l=B+8|0,A=B+16|0,V=0,z=n,i=-1;e:for(;;){if(e=N+((U=(0|z)%6|0)<<4)|0,r[k>>2]=r[e>>2],r[k+4>>2]=r[e+4>>2],r[k+8>>2]=r[e+8>>2],r[k+12>>2]=r[e+12>>2],e=V,V=0|pe(k,b,0,1),(0|z)>(0|n)&!!(0|Be(t))&&1!=(0|e)&(0|(G=0|r[k>>2]))!=(0|i)){switch(e=0|r[N+((W=(U+5|0)%6|0)<<4)+12>>2],j=+((0|r[N+(W<<4)+8>>2])-e|0),s[F>>3]=+((0|r[N+(W<<4)+4>>2])-e|0)-.5*j,s[v>>3]=.8660254037844386*j,e=0|r[N+(U<<4)+12>>2],j=+((0|r[N+(U<<4)+8>>2])-e|0),s[P>>3]=+((0|r[N+(U<<4)+4>>2])-e|0)-.5*j,s[y>>3]=.8660254037844386*j,j=+(0|r[w>>2]),s[R>>3]=3*j,s[x>>3]=0,H=-1.5*j,s[M>>3]=H,s[T>>3]=2.598076211353316*j,s[L>>3]=H,s[E>>3]=-2.598076211353316*j,0|r[17008+(80*f|0)+(((0|i)==(0|f)?G:i)<<2)>>2]){case 1:e=M,i=R;break;case 3:e=L,i=M;break;case 2:e=R,i=L;break;default:e=8;break e}ht(F,P,i,e,O),0|dt(F,O)||0|dt(P,O)||(he(O,f,b,1,B),W=0|r[o>>2],j=+p(+ +s[A>>3]),H=+m(+ +s[l>>3],+ +s[B>>3]),s[o+8+(W<<4)>>3]=j,s[o+8+(W<<4)+8>>3]=H,r[o>>2]=1+(0|r[o>>2]))}if((0|z)<(0|_)&&(W=0|r[d>>2],j=+((0|r[h>>2])-W|0),s[F>>3]=+((0|r[u>>2])-W|0)-.5*j,s[g>>3]=.8660254037844386*j,he(F,0|r[k>>2],b,1,P),W=0|r[o>>2],j=+p(+ +s[c>>3]),H=+m(+ +s[a>>3],+ +s[P>>3]),s[o+8+(W<<4)>>3]=j,s[o+8+(W<<4)+8>>3]=H,r[o>>2]=1+(0|r[o>>2])),(0|(z=z+1|0))>=(0|C)){e=3;break}i=0|r[k>>2]}3!=(0|e)?8==(0|e)&&S(27157,27120,766,27202):I=D}}function be(e,t,n){e|=0,t|=0,n|=0;var i,s,o,a,l=0,c=0,A=0,u=0,h=0,d=0,f=0,p=0,g=0;a=I,I=I+160|0,c=a,u=20336,h=(A=l=a+80|0)+72|0;do{r[A>>2]=r[u>>2],A=A+4|0,u=u+4|0}while((0|A)<(0|h));u=20416,h=(A=c)+72|0;do{r[A>>2]=r[u>>2],A=A+4|0,u=u+4|0}while((0|A)<(0|h));g=(g=!(0|Be(0|r[t>>2])))?l:c,A=0|r[(o=e+4|0)>>2],l=0|r[(i=e+8|0)>>2],c=0|r[(s=e+12|0)>>2],u=l+(A<<1)|0,r[o>>2]=u,l=c+(l<<1)|0,r[i>>2]=l,A=(c<<1)+A|0,r[s>>2]=A,c=l-u|0,h=A-u|0,(0|u)<0&&(r[i>>2]=c,r[s>>2]=h,r[o>>2]=0,l=c,u=0,A=h),h=u-l|0,c=A-l|0,(0|l)<0?(r[o>>2]=h,r[s>>2]=c,r[i>>2]=0,l=0):(c=A,h=u),u=h-c|0,A=l-c|0,(0|c)<0?(r[o>>2]=u,r[i>>2]=A,r[s>>2]=0,c=0):(A=l,u=h),(0|(l=(0|c)<(0|(l=(0|A)<(0|u)?A:u))?c:l))>0&&(c=c-l|0,A=A-l|0,u=u-l|0,r[o>>2]=u,r[i>>2]=A,r[s>>2]=c),d=(A<<1)+u|0,h=c+(u<<1)|0,r[o>>2]=h,r[i>>2]=d,A=(c<<1)+A|0,r[s>>2]=A,l=d-h|0,c=A-h|0,(0|h)<0?(r[i>>2]=l,r[s>>2]=c,r[o>>2]=0,h=0,A=c):l=d,u=h-l|0,c=A-l|0,(0|l)<0?(r[o>>2]=u,r[s>>2]=c,r[i>>2]=0,h=u,l=0):c=A,u=h-c|0,A=l-c|0,(0|c)<0?(r[o>>2]=u,r[i>>2]=A,r[s>>2]=0,c=0):(A=l,u=h),(0|(l=(0|c)<(0|(l=(0|A)<(0|u)?A:u))?c:l))>0&&(r[o>>2]=u-l,r[i>>2]=A-l,r[s>>2]=c-l),0|Be(0|r[t>>2])&&(A=0|r[o>>2],l=(3*(u=0|r[i>>2])|0)+A|0,A=(c=0|r[s>>2])+(3*A|0)|0,r[o>>2]=A,r[i>>2]=l,u=(3*c|0)+u|0,r[s>>2]=u,c=l-A|0,h=u-A|0,(0|A)<0?(r[i>>2]=c,r[s>>2]=h,r[o>>2]=0,l=c,d=0):(d=A,h=u),A=d-l|0,c=h-l|0,(0|l)<0?(r[o>>2]=A,r[s>>2]=c,r[i>>2]=0,d=A,u=0):(u=l,c=h),A=d-c|0,l=u-c|0,(0|c)<0?(r[o>>2]=A,r[i>>2]=l,r[s>>2]=0,u=l,c=0):A=d,(0|(l=(0|c)<(0|(l=(0|u)<(0|A)?u:A))?c:l))>0&&(r[o>>2]=A-l,r[i>>2]=u-l,r[s>>2]=c-l),r[t>>2]=1+(0|r[t>>2])),d=0;do{r[n+(d<<4)>>2]=r[e>>2],c=0|r[i>>2],l=0|r[s>>2],f=0|r[g+(12*d|0)+4>>2],p=0|r[g+(12*d|0)+8>>2],u=(0|r[g+(12*d|0)>>2])+(0|r[o>>2])|0,r[(t=n+(d<<4)+4|0)>>2]=u,c=f+c|0,r[(f=n+(d<<4)+8|0)>>2]=c,l=p+l|0,r[(p=n+(d<<4)+12|0)>>2]=l,A=c-u|0,(0|u)<0&&(l=l-u|0,r[f>>2]=A,r[p>>2]=l,r[t>>2]=0,c=A,u=0),(0|c)<0&&(u=u-c|0,r[t>>2]=u,l=l-c|0,r[p>>2]=l,r[f>>2]=0,c=0),h=u-l|0,A=c-l|0,(0|l)<0?(r[t>>2]=h,r[f>>2]=A,r[p>>2]=0,u=h,l=0):A=c,(0|(c=(0|l)<(0|(c=(0|A)<(0|u)?A:u))?l:c))>0&&(r[t>>2]=u-c,r[f>>2]=A-c,r[p>>2]=l-c),d=d+1|0}while(6!=(0|d));I=a}function _e(e,t){return t=0|Vt(0|(e|=0),0|(t|=0),52),E(),15&t}function ve(e,t){return t=0|Vt(0|(e|=0),0|(t|=0),45),E(),127&t}function ye(e,t){e|=0;var n=0,r=0,s=0,o=0;return!0&134217728==(-16777216&(t|=0))?(r=0|Vt(0|e,0|t,52),E(),r&=15,n=0|Vt(0|e,0|t,45),E(),(n&=127)>>>0>121?0|(e=0):!(613566756&(o=0|zt(0|(s=0|Vt(0|e,0|t,0|(o=3*(15^r)|0))),0|E(),0|o))&(0|It(-1227133514,-1171,0|o,0|(s=0|E()))))&!(4681&s&E())&&15==(0|r)|!(0|(o=0|Vt(0|(0|zt(0|~e,0|~t,0|(o=19+(3*r|0)|0))),0|E(),0|o)))&!(0|E())?0|i[20496+n|0]?!(0|e)&!(0|(t&=8191))?0|(o=1):(o=0|Gt(0|e,0|t,0),E(),0|!!((63-o|0)%3|0)):0|(o=1):0|(o=0)):0|(e=0)}function we(e,t,n,i){e|=0,n|=0,i|=0;var s=0,o=0,a=0,l=0;if(s=0|zt(0|(t|=0),0,52),o=0|E(),n=0|zt(0|n,0,45),n=0|o|E()|134225919,(0|t)<1)return o=-1,i=n,r[(t=e)>>2]=o,void(r[(e=e+4|0)>>2]=i);for(o=1,s=-1;l=0|zt(7,0,0|(a=3*(15-o|0)|0)),n&=~E(),s=s&~l|(a=0|zt(0|i,0,0|a)),n=0|n|E(),(0|o)!=(0|t);)o=o+1|0;r[(a=l=e)>>2]=s,r[(l=l+4|0)>>2]=n}function xe(e,t,n,i){n|=0,i|=0;var s=0,o=0;if(o=0|Vt(0|(e|=0),0|(t|=0),52),E(),n>>>0>15)return 0|(i=4);if((0|(o&=15))<(0|n))return 0|(i=12);if((0|o)==(0|n))return r[i>>2]=e,r[i+4>>2]=t,0|(i=0);if(s=0|zt(0|n,0,52),s|=e,e=E()|-15728641&t,(0|o)>(0|n))do{t=0|zt(7,0,3*(14-n|0)|0),n=n+1|0,s|=t,e=0|E()|e}while((0|n)<(0|o));return r[i>>2]=s,r[i+4>>2]=e,0|(i=0)}function Te(e,t,n,i){n|=0,i|=0;var s=0,o=0,a=0;if(o=0|Vt(0|(e|=0),0|(t|=0),52),E(),!((0|n)<16&(0|(o&=15))<=(0|n)))return 0|(i=4);s=n-o|0,n=0|Vt(0|e,0|t,45),E();e:do{if(0|j(127&n)){t:do{if(0|o){for(n=1;!((a=0|zt(7,0,3*(15-n|0)|0))&e|0)&!((0|E())&t);){if(!(n>>>0<o>>>0))break t;n=n+1|0}n=0|Je(7,0,s,((0|s)<0)<<31>>31),s=0|E();break e}}while(0);n=0|Lt(0|(n=0|kt(0|(n=0|Je(7,0,s,((0|s)<0)<<31>>31)),0|E(),5,0)),0|E(),-5,-1),n=0|Lt(0|(n=0|Nt(0|n,0|E(),6,0)),0|E(),1,0),s=0|E()}else n=0|Je(7,0,s,((0|s)<0)<<31>>31),s=0|E()}while(0);return r[(a=i)>>2]=n,r[a+4>>2]=s,0|(a=0)}function Ee(e,t){var n=0,i=0,r=0;if(r=0|Vt(0|(e|=0),0|(t|=0),45),E(),!(0|j(127&r)))return 0|(r=0);r=0|Vt(0|e,0|t,52),E(),r&=15;e:do{if(r)for(i=1;;){if(n=0|Vt(0|e,0|t,3*(15-i|0)|0),E(),0|(n&=7))break e;if(!(i>>>0<r>>>0)){n=0;break}i=i+1|0}else n=0}while(0);return 0|(r=1&!(0|n))}function Se(e,t,n,i){return e|=0,t|=0,(0|(i|=0))<(0|(n|=0))?(i=e,T(0|(n=t)),0|i):(n=0|zt(-1,-1,3+(3*(i-n|0)|0)|0),i=0|zt(0|~n,0|~E(),3*(15-i|0)|0),n=~E()&t,i=~i&e,T(0|n),0|i)}function Ce(e,t,n,i){n|=0,i|=0;var s=0;return s=0|Vt(0|(e|=0),0|(t|=0),52),E(),(0|n)<16&(0|(s&=15))<=(0|n)?((0|s)<(0|n)&&(s=0|zt(-1,-1,3+(3*(n+-1-s|0)|0)|0),s=0|zt(0|~s,0|~E(),3*(15-n|0)|0),t=~E()&t,e&=~s),s=0|zt(0|n,0,52),n=-15728641&t|E(),r[i>>2]=e|s,r[i+4>>2]=n,0|(i=0)):0|(i=4)}function Pe(e,t){var n=0,i=0,r=0;if(r=0|Vt(0|(e|=0),0|(t|=0),52),E(),!(r&=15))return 0|(r=0);for(i=1;;){if(n=0|Vt(0|e,0|t,3*(15-i|0)|0),E(),0|(n&=7)){i=5;break}if(!(i>>>0<r>>>0)){n=0,i=5;break}i=i+1|0}return 5==(0|i)?0|n:0}function Re(e,t){var n=0,i=0,r=0,s=0,o=0,a=0,l=0,c=0,A=0;if(A=0|Vt(0|(e|=0),0|(t|=0),52),E(),!(A&=15))return A=e,T(0|(c=t)),0|A;for(c=1,n=0;;){switch(s=e&~(a=0|zt(7,0,0|(i=3*(15-c|0)|0))),o=t&~(l=0|E()),e=0|Vt(0|e,0|t,0|i),E(),7&e){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1;break;default:e&=7}e=(i=0|zt(0|e,0,0|i))|s,t=(r=0|E())|o;e:do{if(!n)if(!(i&a|0)&!(r&l|0))n=0;else if(o=0|Vt(0|e,0|t,52),E(),o&=15){n=1;t:for(;;){switch(l=0|Vt(0|e,0|t,3*(15-n|0)|0),E(),7&l){case 1:break t;case 0:break;default:n=1;break e}if(!(n>>>0<o>>>0)){n=1;break e}n=n+1|0}for(s=1;;){switch(n=0|Vt(0|e,0|t,0|(r=3*(15-s|0)|0)),E(),i=e&~(i=0|zt(7,0,0|r)),t&=~E(),7&n){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1;break;default:e=7&n}if(e=0|zt(0|e,0,0|r),e|=i,t=0|E()|t,!(s>>>0<o>>>0)){n=1;break e}s=s+1|0}}else n=1}while(0);if(!(c>>>0<A>>>0))break;c=c+1|0}return T(0|t),0|e}function Me(e,t){var n=0,i=0,r=0,s=0,o=0;if(o=0|Vt(0|(e|=0),0|(t|=0),52),E(),!(o&=15))return o=e,T(0|(s=t)),0|o;for(s=1;;){switch(n=0|Vt(0|e,0|t,0|(r=3*(15-s|0)|0)),E(),i=e&~(i=0|zt(7,0,0|r)),t&=~E(),7&n){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1;break;default:e=7&n}if(e=0|zt(0|e,0,0|r),e|=i,t=0|E()|t,!(s>>>0<o>>>0))break;s=s+1|0}return T(0|t),0|e}function Le(e,t){var n=0,i=0,r=0,s=0,o=0,a=0,l=0,c=0,A=0;if(A=0|Vt(0|(e|=0),0|(t|=0),52),E(),!(A&=15))return A=e,T(0|(c=t)),0|A;for(c=1,n=0;;){switch(s=e&~(a=0|zt(7,0,0|(i=3*(15-c|0)|0))),o=t&~(l=0|E()),e=0|Vt(0|e,0|t,0|i),E(),7&e){case 1:e=3;break;case 3:e=2;break;case 2:e=6;break;case 6:e=4;break;case 4:e=5;break;case 5:e=1;break;default:e&=7}e=(i=0|zt(0|e,0,0|i))|s,t=(r=0|E())|o;e:do{if(!n)if(!(i&a|0)&!(r&l|0))n=0;else if(o=0|Vt(0|e,0|t,52),E(),o&=15){n=1;t:for(;;){switch(l=0|Vt(0|e,0|t,3*(15-n|0)|0),E(),7&l){case 1:break t;case 0:break;default:n=1;break e}if(!(n>>>0<o>>>0)){n=1;break e}n=n+1|0}for(s=1;;){switch(i=e&~(i=0|zt(7,0,0|(n=3*(15-s|0)|0))),r=t&~E(),e=0|Vt(0|e,0|t,0|n),E(),7&e){case 1:e=3;break;case 3:e=2;break;case 2:e=6;break;case 6:e=4;break;case 4:e=5;break;case 5:e=1;break;default:e&=7}if(e=0|zt(0|e,0,0|n),e|=i,t=0|E()|r,!(s>>>0<o>>>0)){n=1;break e}s=s+1|0}}else n=1}while(0);if(!(c>>>0<A>>>0))break;c=c+1|0}return T(0|t),0|e}function Ie(e,t){var n=0,i=0,r=0,s=0,o=0;if(o=0|Vt(0|(e|=0),0|(t|=0),52),E(),!(o&=15))return o=e,T(0|(s=t)),0|o;for(s=1;;){switch(n=e&~(n=0|zt(7,0,0|(i=3*(15-s|0)|0))),r=t&~E(),e=0|Vt(0|e,0|t,0|i),E(),7&e){case 1:e=3;break;case 3:e=2;break;case 2:e=6;break;case 6:e=4;break;case 4:e=5;break;case 5:e=1;break;default:e&=7}if(e=0|zt(0|e,0,0|i),e|=n,t=0|E()|r,!(s>>>0<o>>>0))break;s=s+1|0}return T(0|t),0|e}function Oe(e,t){e|=0;var n,i=0,s=0,o=0,a=0,l=0,c=0,A=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,b=0,_=0,v=0,y=0,w=0,x=0,S=0;if(n=I,I=I+16|0,y=n,zt(0|(t|=0),0,52),i=134225919|E(),!t)return(0|r[e+4>>2])>2||(0|r[e+8>>2])>2||(0|r[e+12>>2])>2?(y=0,T(0|(v=0)),I=n,0|y):(zt(0|W(e),0,45),v=0|E()|i,y=-1,T(0|v),I=n,0|y);r[y>>2]=r[e>>2],r[y+4>>2]=r[e+4>>2],r[y+8>>2]=r[e+8>>2],r[y+12>>2]=r[e+12>>2],v=y+4|0;e:do{if((0|t)>0)for(b=y+12|0,g=t,d=0|r[(m=y+8|0)>>2],f=0|r[b>>2],t=-1,h=0|r[y+4>>2];;){p=g,g=g+-1|0,e=h-f|0,s=d-f|0,1&p?(a=0|Et(.14285714285714285*+((3*e|0)-s|0)),r[v>>2]=a,e=0|Et(.14285714285714285*+((s<<1)+e|0)),r[m>>2]=e,r[b>>2]=0,s=e-a|0,o=0-a|0,(0|a)<0?(r[m>>2]=s,r[b>>2]=o,r[v>>2]=0,e=s,l=0):(l=a,o=0),a=l-e|0,s=o-e|0,(0|e)<0?(r[v>>2]=a,r[b>>2]=s,r[m>>2]=0,l=a,a=0):(s=o,a=e),e=l-s|0,o=a-s|0,(0|s)<0?(r[v>>2]=e,r[m>>2]=o,r[b>>2]=0,a=0):(o=a,e=l,a=s),(0|(s=(0|a)<(0|(s=(0|o)<(0|e)?o:e))?a:s))>0&&(a=a-s|0,o=o-s|0,e=e-s|0,r[v>>2]=e,r[m>>2]=o,r[b>>2]=a),A=(u=(0|(c=(0|(S=(c=(0|(s=(3*a|0)+e-((w=(0|(x=o+(3*e|0)|0))<0)?x:0)-((A=(0|(u=a+(3*o|0)-(w?x:0)|0))<0)?u:0)|0))<0)?0:s))<(0|(c=(0|(l=(A?0:u)-(c?s:0)|0))<(0|(s=(w?0:x)-(A?u:0)-(c?s:0)|0))?l:s))?S:c))>0)?c:0,l=l-(u?c:0)|0,c=S-(u?c:0)|0,u=a):(c=0|Et(.14285714285714285*+((e<<1)+s|0)),r[v>>2]=c,o=0|Et(.14285714285714285*+((3*s|0)-e|0)),r[m>>2]=o,r[b>>2]=0,s=o-c|0,e=0-c|0,(0|c)<0?(r[m>>2]=s,r[b>>2]=e,r[v>>2]=0,o=s,c=0):e=0,l=c-o|0,s=e-o|0,(0|o)<0?(r[v>>2]=l,r[b>>2]=s,r[m>>2]=0,a=s,o=0):(a=e,l=c),e=l-a|0,s=o-a|0,(0|a)<0?(r[v>>2]=e,r[m>>2]=s,r[b>>2]=0,o=s,a=0):e=l,(0|(s=(0|a)<(0|(s=(0|o)<(0|e)?o:e))?a:s))>0&&(a=a-s|0,o=o-s|0,e=e-s|0,r[v>>2]=e,r[m>>2]=o,r[b>>2]=a),A=(u=(0|(c=(0|(w=(c=(0|(s=(3*a|0)+o-((S=(0|(x=a+(3*e|0)|0))<0)?x:0)-((A=(0|(u=(3*o|0)+e-(S?x:0)|0))<0)?u:0)|0))<0)?0:s))<(0|(c=(0|(l=(A?0:u)-(c?s:0)|0))<(0|(s=(S?0:x)-(A?u:0)-(c?s:0)|0))?l:s))?w:c))>0)?c:0,l=l-(u?c:0)|0,c=w-(u?c:0)|0,u=a),c=(h=(0|(f=f-c+((a=(0|(s=h+(A-s)|0))<0)?0-s|0:0)+((l=(0|(A=d-l-(a?s:0)|0))<0)?0-A|0:0)|0))<0)?0:f,S=(l?0:A)-(h?f:0)|0,f=(f=(a?0:s)-(l?A:0)-(h?f:0)|0)-((A=(0|(h=(0|c)<(0|(h=(0|S)<(0|f)?S:f))?c:h))>0)?h:0)|0,s=t&~(s=0|zt(7,0,0|(l=3*(15-p|0)|0))),a=i&~E(),t=(t=(i=(0|(x=c-(A?h:0)-(x=(d=(0|f)<0)?f:0)+((w=(0|(S=S-(A?h:0)-x|0))<0)?0-S|0:0)|0))<0)?0:x)-(S=(0|(S=(0|t)<(0|(S=(0|(i=(w?0:S)-(x=i?x:0)|0))<(0|(x=(d?0:f)-(w?S:0)-x|0))?i:x))?t:S))>0?S:0)|0,i=i-S|0;t:do{switch(x-S|0){case 0:switch(0|i){case 0:t=0|t?1==(0|t)?1:7:0;break t;case 1:t=0|t?1==(0|t)?3:7:2;break t;default:_=36;break t}case 1:switch(0|i){case 0:t=0|t?1==(0|t)?5:7:4;break t;case 1:if(t){_=36;break t}t=6;break t;default:_=36;break t}default:_=36}}while(0);if(36==(0|_)&&(_=0,t=7),t=0|zt(0|t,0,0|l),t|=s,i=0|E()|a,(0|p)<=1)break e;d=o,f=u,h=e}else t=-1,e=0|r[v>>2]}while(0);e:do{if((0|e)<=2&&(0|r[y+8>>2])<=2&&(0|r[y+12>>2])<=2){if(t|=e=0|zt(0|(s=0|W(y)),0,45),e=E()|-1040385&i,A=0|q(y),!(0|j(s))){if((0|A)<=0)break;for(c=0;;){l=0|Vt(0|t,0|e,52),E(),l&=15;t:do{if(l)for(a=1;;){switch(i=0|Vt(0|t,0|e,0|(o=3*(15-a|0)|0)),E(),t&=~(s=0|zt(7,0,0|o)),s=e&~E(),7&i){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1;break;default:e=7&i}if(t|=e=0|zt(0|e,0,0|o),e=0|E()|s,!(a>>>0<l>>>0))break t;a=a+1|0}}while(0);if((0|(c=c+1|0))==(0|A))break e}}l=0|Vt(0|t,0|e,52),E(),l&=15;t:do{if(l){i=1;n:for(;;){switch(S=0|Vt(0|t,0|e,3*(15-i|0)|0),E(),7&S){case 1:break n;case 0:break;default:break t}if(!(i>>>0<l>>>0))break t;i=i+1|0}if(0|K(s,0|r[y>>2]))for(a=1;;){switch(s=t&~(s=0|zt(7,0,0|(i=3*(15-a|0)|0))),o=e&~E(),e=0|Vt(0|t,0|e,0|i),E(),7&e){case 1:e=3;break;case 3:e=2;break;case 2:e=6;break;case 6:e=4;break;case 4:e=5;break;case 5:e=1;break;default:e&=7}if(t=0|zt(0|e,0,0|i),t|=s,e=0|E()|o,!(a>>>0<l>>>0))break t;a=a+1|0}else for(a=1;;){switch(i=0|Vt(0|t,0|e,0|(o=3*(15-a|0)|0)),E(),t&=~(s=0|zt(7,0,0|o)),s=e&~E(),7&i){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1;break;default:e=7&i}if(t|=e=0|zt(0|e,0,0|o),e=0|E()|s,!(a>>>0<l>>>0))break t;a=a+1|0}}}while(0);if((0|A)>0){i=0;do{t=0|Re(t,e),e=0|E(),i=i+1|0}while((0|i)!=(0|A))}}else t=0,e=0}while(0);return S=t,T(0|(x=e)),I=n,0|S}function Be(e){return(0|(e|=0))%2|0}function Ne(e,t,n){n|=0;var i,a,l,c,A=0,d=0,f=0,p=0,g=0;if(l=I,I=I+64|0,a=l+24|0,p=l+48|0,g=l,(t|=0)>>>0>15)return I=l,0|(g=4);if(i=+s[(e|=0)>>3],s[o>>3]=i,!(2146435072&~r[o+4>>2]))return I=l,0|(g=3);if(A=+s[e+8>>3],s[o>>3]=A,!(2146435072&~r[o+4>>2]))return I=l,0|(g=3);c=(d=+u(+i))*+u(+A),d*=+h(+A),A=+h(+i),s[g>>3]=c,s[g+8>>3]=d,s[g+16>>3]=A,s[o>>3]=c;do{if(2146435072&~r[o+4>>2]&&(s[o>>3]=A,e=0|r[o+4>>2],s[o>>3]=d,!(!(2146435072&~r[o+4>>2])|!0&!(2146435072&~e)))){if(r[a>>2]=r[g>>2],r[a+4>>2]=r[g+4>>2],r[a+8>>2]=r[g+8>>2],r[a+12>>2]=r[g+12>>2],r[a+16>>2]=r[g+16>>2],r[a+20>>2]=r[g+20>>2],Ae(a,t,p),p=0|Oe(p,t),g=0|E(),r[n>>2]=p,r[n+4>>2]=g,!(!(0|p)&!(0|g))){f=0;break}S(27634,27225,1073,27248)}else f=2}while(0);return I=l,0|(g=f)}function ke(e,t,n){var i,s,o=0,a=0,l=0,c=0,A=0,u=0,h=0,d=0,f=0,p=0;if(s=(n|=0)+4|0,p=0|Vt(0|(e|=0),0|(t|=0),52),E(),p&=15,f=0|Vt(0|e,0|t,45),E(),o=!(0|p),0|j(127&f)){if(o)return 0|(p=1);o=1}else{if(o)return 0|(p=0);o=0|r[s>>2]||0|r[n+8>>2]?1:1&!!(0|r[n+12>>2])}for(f=n+8|0,i=n+12|0,d=1,n=0|r[s>>2],c=0|r[f>>2],l=0|r[i>>2];a=3*n|0,A=3*c|0,h=3*l|0,1&d?(u=c+a|0,r[s>>2]=u,l=l+A|0,r[f>>2]=l,a=h+n|0,r[i>>2]=a,n=l-u|0,c=a-u|0,(0|u)<0?(r[f>>2]=n,r[i>>2]=c,r[s>>2]=0,A=0,a=c):(n=l,A=u),c=A-n|0,l=a-n|0,(0|n)<0?(r[s>>2]=c,r[i>>2]=l,r[f>>2]=0,A=c,a=0):(l=a,a=n),n=A-l|0,c=a-l|0,(0|l)<0?(r[s>>2]=n,r[f>>2]=c,r[i>>2]=0,l=0):(c=a,n=A),(0|(a=(0|l)<(0|(a=(0|c)<(0|n)?c:n))?l:a))>0&&(l=l-a|0,c=c-a|0,n=n-a|0,r[s>>2]=n,r[f>>2]=c,r[i>>2]=l)):(u=A+n|0,A=l+a|0,r[s>>2]=A,r[f>>2]=u,a=h+c|0,r[i>>2]=a,n=u-A|0,l=a-A|0,(0|A)<0?(r[f>>2]=n,r[i>>2]=l,r[s>>2]=0,A=0,a=l):n=u,c=A-n|0,l=a-n|0,(0|n)<0?(r[s>>2]=c,r[i>>2]=l,r[f>>2]=0,A=c,a=0):(l=a,a=n),n=A-l|0,c=a-l|0,(0|l)<0?(r[s>>2]=n,r[f>>2]=c,r[i>>2]=0,l=0):(c=a,n=A),(0|(a=(0|l)<(0|(a=(0|c)<(0|n)?c:n))?l:a))>0&&(l=l-a|0,c=c-a|0,n=n-a|0,r[s>>2]=n,r[f>>2]=c,r[i>>2]=l)),a=0|Vt(0|e,0|t,3*(15-d|0)|0),E(),((a&=7)+-1|0)>>>0<6&&(u=0|r[22032+(12*a|0)+4>>2],h=0|r[22032+(12*a|0)+8>>2],A=(0|r[22032+(12*a|0)>>2])+n|0,r[s>>2]=A,c=u+c|0,r[f>>2]=c,n=h+l|0,r[i>>2]=n,l=c-A|0,a=n-A|0,(0|A)<0&&(r[f>>2]=l,r[i>>2]=a,r[s>>2]=0,A=0,n=a,c=l),a=A-c|0,l=n-c|0,(0|c)<0?(r[s>>2]=a,r[i>>2]=l,r[f>>2]=0,A=a,c=0):l=n,n=A-l|0,a=c-l|0,(0|l)<0?(r[s>>2]=n,r[f>>2]=a,r[i>>2]=0,c=a,l=0):n=A,(0|(a=(0|l)<(0|(a=(0|c)<(0|n)?c:n))?l:a))>0&&(l=l-a|0,c=c-a|0,n=n-a|0,r[s>>2]=n,r[f>>2]=c,r[i>>2]=l)),d>>>0<p>>>0;)d=d+1|0;return 0|o}function Fe(e,t,n){n|=0;var i,s,o,a=0,l=0,c=0,A=0,u=0,h=0,d=0,f=0,p=0;if(o=I,I=I+16|0,s=o,f=0|Vt(0|(e|=0),0|(t|=0),45),E(),(f&=127)>>>0>121)return r[n>>2]=0,r[n+4>>2]=0,r[n+8>>2]=0,r[n+12>>2]=0,I=o,0|(p=5);e:do{if(0|j(f)&&(u=0|Vt(0|e,0|t,52),E(),0|(u&=15))){a=1;t:for(;;){switch(p=0|Vt(0|e,0|t,3*(15-a|0)|0),E(),7&p){case 5:break t;case 0:break;default:d=t;break e}if(!(a>>>0<u>>>0)){d=t;break e}a=a+1|0}for(A=1,a=t;;){switch(l=e&~(l=0|zt(7,0,0|(t=3*(15-A|0)|0))),c=a&~E(),a=0|Vt(0|e,0|a,0|t),E(),7&a){case 1:a=3;break;case 3:a=2;break;case 2:a=6;break;case 6:a=4;break;case 4:a=5;break;case 5:a=1;break;default:a&=7}if(e=0|zt(0|a,0,0|t),e|=l,a=0|E()|c,!(A>>>0<u>>>0)){d=a;break e}A=A+1|0}}else d=t}while(0);if(p=7696+(28*f|0)|0,r[n>>2]=r[p>>2],r[n+4>>2]=r[p+4>>2],r[n+8>>2]=r[p+8>>2],r[n+12>>2]=r[p+12>>2],!(0|ke(e,d,n)))return I=o,0|(p=0);if(p=n+4|0,r[s>>2]=r[p>>2],r[s+4>>2]=r[p+4>>2],r[s+8>>2]=r[p+8>>2],h=0|Vt(0|e,0|d,52),E(),i=15&h,1&h?(c=0|r[p>>2],a=(3*(l=0|r[(u=n+8|0)>>2])|0)+c|0,c=(t=0|r[(h=n+12|0)>>2])+(3*c|0)|0,r[p>>2]=c,r[u>>2]=a,l=(3*t|0)+l|0,r[h>>2]=l,t=a-c|0,A=l-c|0,(0|c)<0&&(r[u>>2]=t,r[h>>2]=A,r[p>>2]=0,a=t,c=0,l=A),A=c-a|0,t=l-a|0,(0|a)<0?(r[p>>2]=A,r[h>>2]=t,r[u>>2]=0,a=0):(t=l,A=c),c=A-t|0,l=a-t|0,(0|t)<0?(r[p>>2]=c,r[u>>2]=l,r[h>>2]=0,t=0):(l=a,c=A),(0|(a=(0|t)<(0|(a=(0|l)<(0|c)?l:c))?t:a))>0&&(r[p>>2]=c-a,r[u>>2]=l-a,r[h>>2]=t-a),l=i+1|0):l=i,0|j(f)){e:do{if(i)for(t=1;;){if(a=0|Vt(0|e,0|d,3*(15-t|0)|0),E(),0|(a&=7))break e;if(!(t>>>0<i>>>0)){a=0;break}t=t+1|0}else a=0}while(0);a=4==(0|a)&1}else a=0;if(0|pe(n,l,a,0)){if(0|j(f))do{}while(0|pe(n,l,0,0));(0|l)!=(0|i)&&(e=0|r[(u=n+12|0)>>2],t=0|Et(.14285714285714285*+(((a=(0|r[p>>2])-e|0)<<1)+(e=(0|r[(A=n+8|0)>>2])-e|0)|0)),r[p>>2]=t,a=0|Et(.14285714285714285*+((3*e|0)-a|0)),r[A>>2]=a,r[u>>2]=0,e=a-t|0,l=0-t|0,(0|t)<0?(r[A>>2]=e,r[u>>2]=l,r[p>>2]=0,a=e,t=0):l=0,c=t-a|0,e=l-a|0,(0|a)<0?(r[p>>2]=c,r[u>>2]=e,r[A>>2]=0,t=c,a=0):e=l,c=t-e|0,l=a-e|0,(0|e)<0?(r[p>>2]=c,r[A>>2]=l,r[u>>2]=0,t=c,e=0):l=a,(0|(a=(0|e)<(0|(a=(0|l)<(0|t)?l:t))?e:a))>0&&(r[p>>2]=t-a,r[A>>2]=l-a,r[u>>2]=e-a))}else(0|l)!=(0|i)&&(r[p>>2]=r[s>>2],r[p+4>>2]=r[s+4>>2],r[p+8>>2]=r[s+8>>2]);return I=o,0|(p=0)}function De(e,t,n){n|=0;var i,r,o,a=0,l=0,c=0;return o=I,I=I+48|0,r=o,(a=0|Fe(e|=0,t|=0,i=o+24|0))?(I=o,0|a):(a=0|Vt(0|e,0|t,52),E(),ue(i,15&a,r),c=+p(+ +s[r+16>>3]),l=+m(+ +s[r+8>>3],+ +s[r>>3]),s[n>>3]=c,s[n+8>>3]=l,I=o,0|(a=0))}function Ue(e,t,n){n|=0;var i,r=0,s=0,o=0;if(i=I,I=I+16|0,0|(r=0|Fe(e|=0,t|=0,o=i)))return I=i,0|(o=r);r=0|Vt(0|e,0|t,45),E(),r=!(0|j(127&r)),s=0|Vt(0|e,0|t,52),E(),s&=15;e:do{if(!r){if(0|s)for(r=1;;){if(!(!((0|zt(7,0,3*(15-r|0)|0))&e|0)&!((0|E())&t)))break e;if(!(r>>>0<s>>>0))break;r=r+1|0}return de(o,s,0,5,n),I=i,0|0}}while(0);return me(o,s,0,6,n),I=i,0|0}function Ve(e,t){t|=0;var n=0,i=0,s=0,o=0,a=0,l=0,c=0;if((e|=0)>>>0>15)return 0|(l=4);if(zt(0|e,0,52),l=134225919|E(),!e){n=0,i=0;do{0|j(i)&&(zt(0|i,0,45),a=0|l|E(),r[(e=t+(n<<3)|0)>>2]=-1,r[e+4>>2]=a,n=n+1|0),i=i+1|0}while(122!=(0|i));return 0|(n=0)}n=0,a=0;do{if(0|j(a)){for(zt(0|a,0,45),i=1,s=-1,o=0|l|E();s&=~(c=0|zt(7,0,3*(15-i|0)|0)),o&=~E(),(0|i)!=(0|e);)i=i+1|0;r[(c=t+(n<<3)|0)>>2]=s,r[c+4>>2]=o,n=n+1|0}a=a+1|0}while(122!=(0|a));return 0|(n=0)}function ze(e,t,n,i){e|=0,i|=0;var s=0,o=0,a=0;s=0|Vt(0|(t|=0),0|(n|=0),52),E(),!(0|t)&!(0|n)|(0|i)>15|(0|(s&=15))>(0|i)?(o=-1,t=-1,n=0,s=0):(t=0|Se(t,n,s+1|0,i),a=-15728641&E(),n=0|zt(0|i,0,52),o=s,t=(t=!(0|Ee(n|=t,a=0|a|E())))?-1:i,s=a),r[(a=e)>>2]=n,r[a+4>>2]=s,r[e+8>>2]=o,r[e+12>>2]=t}function Ge(e,t,n,i){n|=0,i|=0;var s=0,o=0;return s=0|Vt(0|(e|=0),0|(t|=0),52),E(),s&=15,r[(o=i+8|0)>>2]=s,!(0|e)&!(0|t)|(0|n)>15|(0|s)>(0|n)?(r[(n=i)>>2]=0,r[n+4>>2]=0,r[o>>2]=-1,void(r[i+12>>2]=-1)):(e=0|Se(e,t,s+1|0,n),o=-15728641&E(),s=0|zt(0|n,0,52),s|=e,o=0|o|E(),r[(e=i)>>2]=s,r[e+4>>2]=o,e=i+12|0,0|Ee(s,o)?void(r[e>>2]=n):void(r[e>>2]=-1))}function je(e){var t,n=0,i=0,s=0,o=0,a=0,l=0,c=0,A=0;if(!(!(0|(n=0|r[(i=e|=0)>>2]))&!(0|(i=0|r[i+4>>2]))||(s=0|Vt(0|n,0|i,52),E(),n=0|Lt(0|(c=0|zt(1,0,3*(15^(s&=15))|0)),0|E(),0|n,0|i),i=0|E(),r[(c=e)>>2]=n,r[c+4>>2]=i,(0|s)<(0|(l=0|r[(c=e+8|0)>>2]))))){for(t=e+12|0,a=s;;){if((0|a)==(0|l)){s=5;break}if(A=(0|a)==(0|r[t>>2]),s=0|Vt(0|n,0|i,0|(o=3*(15-a|0)|0)),E(),A&1==(0|(s&=7))&!0){s=7;break}if(!(7==(0|s)&!0)){s=10;break}if(n=0|Lt(0|n,0|i,0|(A=0|zt(1,0,0|o)),0|E()),i=0|E(),r[(A=e)>>2]=n,r[A+4>>2]=i,!((0|a)>(0|l))){s=10;break}a=a+-1|0}if(5==(0|s))return r[(A=e)>>2]=0,r[A+4>>2]=0,r[c>>2]=-1,void(r[t>>2]=-1);if(7==(0|s))return l=0|Lt(0|n,0|i,0|(l=0|zt(1,0,0|o)),0|E()),c=0|E(),r[(A=e)>>2]=l,r[A+4>>2]=c,void(r[t>>2]=a+-1)}}function He(e){var t;return t=(e=+e)<0?e+6.283185307179586:e,+(e>=6.283185307179586?t+-6.283185307179586:t)}function We(e,t){switch(e=+e,0|(t|=0)){case 1:e=e<0?e+6.283185307179586:e;break;case 2:e=e>0?e+-6.283185307179586:e}return+e}function qe(e,t){e|=0;var n,i,r,o=0;return i=+s[(t|=0)>>3],n=+s[e>>3],o=(r=+h(.5*(i-n)))*r+(o=+h(.5*(+s[t+8>>3]-+s[e+8>>3])))*(+u(+i)*+u(+n)*o),2*+m(+ +A(+o),+ +A(+(1-o)))*6371.007180918475}function Ke(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(s[t>>3]=+s[20624+(e<<3)>>3],0|(t=0))}function Qe(e,t){t|=0;var n=0;return(e|=0)>>>0>15?0|(t=4):(n=0|kt(0|(n=0|Je(7,0,e,((0|e)<0)<<31>>31)),0|E(),120,0),e=0|E(),r[t>>2]=2|n,r[t+4>>2]=e,0|(t=0))}function Xe(e,t,n,s,o){n|=0,s|=0,o|=0;var a,l=0,c=0,A=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,b=0,_=0,v=0;if(a=I,I=I+16|0,_=a,d=0|Vt(0|(e|=0),0|(t|=0),52),E(),d&=15,g=0|Vt(0|n,0|s,52),E(),(0|d)!=(15&g))return I=a,0|(_=12);if(u=0|Vt(0|e,0|t,45),E(),u&=127,h=0|Vt(0|n,0|s,45),E(),u>>>0>121|(h&=127)>>>0>121)return I=a,0|(_=5);if(g=(0|u)!=(0|h)){if(7==(0|(c=0|X(u,h))))return I=a,0|(_=1);7==(0|(A=0|X(h,u)))?S(27291,27315,164,27325):(b=c,l=A)}else b=0,l=0;f=0|j(u),p=0|j(h),r[_>>2]=0,r[_+4>>2]=0,r[_+8>>2]=0,r[_+12>>2]=0;do{if(b){c=(0|(h=0|r[4272+(28*u|0)+(b<<2)>>2]))>0;e:do{if(p)if(c)for(u=0,A=n,c=s;;){switch(A=0|Le(A,c),c=0|E(),0|l){case 5:case 1:l=3;break;case 3:l=2;break;case 2:l=6;break;case 6:l=4;break;case 4:l=5}if((0|(u=u+1|0))==(0|h)){h=l,u=A,A=c;break e}}else h=l,u=n,A=s;else if(c)for(u=0,A=n,c=s;;){switch(A=0|Ie(A,c),c=0|E(),0|l){case 1:l=3;break;case 3:l=2;break;case 2:l=6;break;case 6:l=4;break;case 4:l=5;break;case 5:l=1}if((0|(u=u+1|0))==(0|h)){h=l,u=A,A=c;break e}}else h=l,u=n,A=s}while(0);if(ke(u,A,_),g||S(27340,27315,194,27325),(c=!!(0|f))&(l=!!(0|p))&&S(27367,27315,195,27325),c){if(7==(0|(l=0|Pe(e,t)))){l=5;break}if(0|i[21968+(7*l|0)+b|0]){l=1;break}g=p=0|r[21136+(28*l|0)+(b<<2)>>2]}else if(l){if(7==(0|(l=0|Pe(u,A)))){l=5;break}if(0|i[21968+(7*l|0)+h|0]){l=1;break}g=0,p=0|r[21136+(28*h|0)+(l<<2)>>2]}else g=0,p=0;if((g|p|0)>=0){if((0|p)>0){s=_+8|0,f=_+12|0,h=0,A=0|r[(n=_+4|0)>>2],c=0|r[s>>2],l=0|r[f>>2];do{(0|(u=(0|(l=(v=(0|(A=l+A-(v=(t=(0|(m=c+A|0))<0)?m:0)-(u=(e=(0|(c=l+c-v|0))<0)?c:0)|0))<0)?0:A))<(0|(u=(0|(c=(e?0:c)-(A=v?A:0)|0))<(0|(A=(t?0:m)-u-A|0))?c:A))?l:u))>0&&(A=A-u|0,c=c-u|0,l=l-u|0),h=h+1|0}while((0|h)!=(0|p));r[n>>2]=A,r[s>>2]=c,r[f>>2]=l}if((b+-1|0)>>>0<6?(l=0|r[22032+(12*b|0)>>2],A=0|r[22032+(12*b|0)+4>>2],l=l-(c=(0|(c=(0|(v=0|r[22032+(12*b|0)+8>>2]))<(0|(c=(0|A)<(0|l)?A:l))?v:c))>0?c:0)|0,A=A-c|0,c=v-c|0):(l=0,A=0,c=0),d)for(;;){if(u=3*l|0,h=3*A|0,n=3*c|0,0|Be(d)?(l=(v=(0|(c=(0|(b=(c=(0|(A=l+n-((e=(0|(t=u+A|0))<0)?t:0)-((m=(0|(v=h+c-(e?t:0)|0))<0)?v:0)|0))<0)?0:A))<(0|(c=(0|(u=(m?0:v)-(c?A:0)|0))<(0|(A=(e?0:t)-(m?v:0)-(c?A:0)|0))?u:A))?b:c))>0)?c:0,u=u-(v?c:0)|0,c=b-(v?c:0)|0):(l=(v=(0|(c=(0|(b=(c=(0|(A=n+A-((t=(0|(m=u+c|0))<0)?m:0)-((l=(0|(v=h+l-(t?m:0)|0))<0)?v:0)|0))<0)?0:A))<(0|(c=(0|(u=(l?0:v)-(c?A:0)|0))<(0|(A=(t?0:m)-(l?v:0)-(c?A:0)|0))?u:A))?b:c))>0)?c:0,u=u-(v?c:0)|0,c=b-(v?c:0)|0),l=A-l|0,!((0|d)>1)){A=u;break}d=d+-1|0,A=u}if((0|g)>0){u=0;do{c=(c=(l=(0|(b=l+c-((e=(0|(t=l+A|0))<0)?t:0)-((m=(0|(v=A+c-(e?t:0)|0))<0)?v:0)|0))<0)?0:b)-((v=(0|(l=(0|c)<(0|(l=(0|(A=(m?0:v)-(l?b:0)|0))<(0|(b=(e?0:t)-(m?v:0)-(l?b:0)|0))?A:b))?c:l))>0)?l:0)|0,A=A-(v?l:0)|0,l=b-(v?l:0)|0,u=u+1|0}while((0|u)!=(0|g))}n=_+4|0,b=0|r[(d=_+8|0)>>2],v=0|r[(s=_+12|0)>>2],u=(0|r[n>>2])+l|0,r[n>>2]=u,A=b+A|0,r[d>>2]=A,l=v+c|0,r[s>>2]=l,c=A-u|0,(0|u)<0?(l=l-u|0,r[d>>2]=c,r[s>>2]=l,r[n>>2]=0,A=0):(c=A,A=u),(0|c)<0&&(A=A-c|0,r[n>>2]=A,l=l-c|0,r[s>>2]=l,r[d>>2]=0,c=0),h=A-l|0,u=c-l|0,(0|l)<0?(r[n>>2]=h,r[d>>2]=u,r[s>>2]=0,A=h,l=0):u=c,(0|(c=(0|l)<(0|(c=(0|u)<(0|A)?u:A))?l:c))>0?(r[n>>2]=A-c,r[d>>2]=u-c,r[s>>2]=l-c,m=77):m=77}else l=5}else if(ke(n,s,_),!!(0|f)&!!(0|p))if((0|h)!=(0|u)&&S(27398,27315,264,27325),7==(0|(c=0|Pe(e,t)))|7==(0|(l=0|Pe(n,s))))l=5;else if(0|i[21968+(7*c|0)+l|0])l=1;else if((0|(n=0|r[21136+(28*c|0)+(l<<2)>>2]))>0){s=_+8|0,f=_+12|0,h=0,A=0|r[(d=_+4|0)>>2],c=0|r[s>>2],l=0|r[f>>2];do{(0|(u=(0|(l=(e=(0|(A=l+A-(e=(m=(0|(b=c+A|0))<0)?b:0)-(u=(t=(0|(c=l+c-e|0))<0)?c:0)|0))<0)?0:A))<(0|(u=(0|(c=(t?0:c)-(A=e?A:0)|0))<(0|(A=(m?0:b)-u-A|0))?c:A))?l:u))>0&&(A=A-u|0,c=c-u|0,l=l-u|0),h=h+1|0}while((0|h)!=(0|n));r[d>>2]=A,r[s>>2]=c,r[f>>2]=l,m=77}else m=77;else m=77}while(0);return 77==(0|m)&&(l=_+4|0,r[o>>2]=r[l>>2],r[o+4>>2]=r[l+4>>2],r[o+8>>2]=r[l+8>>2],l=0),I=a,0|(v=l)}function $e(e,t,n,i){n|=0,i|=0;var s=0,o=0,a=0,l=0,c=0,A=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,b=0,_=0,v=0,y=0,w=0,x=0,T=0,C=0;if(o=0|Vt(0|(e|=0),0|(t|=0),52),E(),o&=15,y=0|Vt(0|e,0|t,45),E(),(y&=127)>>>0>121)return 0|(i=5);if(m=0|j(y),zt(0|o,0,52),l=134225919|E(),r[(a=i)>>2]=-1,r[a+4>>2]=l,a=0|r[n>>2],l=0|r[n+4>>2],n=0|r[n+8>>2],!o){s=(s=(n=(0|(b=n-(b=(t=(0|a)<0)?a:0)+((m=(0|(v=l-b|0))<0)?0-v|0:0)|0))<0)?0:b)-(v=(0|(v=(0|s)<(0|(v=(0|(n=(m?0:v)-(b=n?b:0)|0))<(0|(b=(t?0:a)-(m?v:0)-b|0))?n:b))?s:v))>0?v:0)|0,n=n-v|0;e:do{switch(b-v|0){case 0:switch(0|n){case 0:if(s){s=1==(0|s)?1:7,_=11;break e}s=0;break e;case 1:if(s){s=1==(0|s)?3:7,_=11;break e}s=2;break e;default:return 0|(i=1)}case 1:switch(0|n){case 0:if(s){s=1==(0|s)?5:7,_=11;break e}s=4;break e;case 1:if(!s){s=6;break e}return 0|(s=1);default:return 0|(i=1)}default:return 0|(i=1)}}while(0);return 11==(0|_)&&7==(0|s)||127==(0|(s=0|Q(y,s)))?0|(i=1):(v=0|zt(0|s,0,45),y=0|E(),y=-1040385&r[(_=i)+4>>2]|y,r[i>>2]=r[_>>2]|v,r[i+4>>2]=y,0|(i=0))}for(;;){if(g=o,o=o+-1|0,c=(p=a-n|0)>>>0>715827881|(f=l-n|0)>>>0>715827881,0|Be(g)){if(c){if(h=2147483647-p|0,d=-2147483648-p|0,(u=(0|p)>0)?(0|h)<(0|p):(0|d)>(0|p)){s=1,_=107;break}if(C=p<<1,u?(2147483647-C|0)<(0|p):(-2147483648-C|0)>(0|p)){s=1,_=107;break}if((0|f)>0?(2147483647-f|0)<(0|f):(-2147483648-f|0)>(0|f)){s=1,_=107;break}if(c=3*p|0,A=f<<1,(u?(0|h)<(0|A):(0|d)>(0|A))||((0|p)>-1?(-2147483648|c)>=(0|f):(-2147483648^c)<(0|f))){s=1,_=107;break}}else c=3*p|0,A=f<<1;if(h=0|Et(.14285714285714285*+(c-f|0)),c=(A=(0|(u=0|Et(.14285714285714285*+(A+p|0))))<(0|h))?h:u,(0|(A=A?u:h))<0){if(-2147483648==(0|A)||((0|c)>0?(2147483647-c|0)<(0|A):(-2147483648-c|0)>(0|A))){_=24;break}if((0|c)>-1?(-2147483648|c)>=(0|A):(-2147483648^c)<(0|A)){_=24;break}}d=((d=(0|h)<0)?0:h)-((x=(0|(f=u-(d?h:0)|0))<0)?f:0)-((p=(0|(w=(d?0-h|0:0)-(x?f:0)|0))<0)?w:0)|0,f=(x?0:f)-(p?w:0)|0,d=d-((x=(0|(p=(0|(w=p?0:w))<(0|(p=(0|f)<(0|d)?f:d))?w:p))>0)?p:0)|0,f=f-(x?p:0)|0,c=(C=(0|(u=(0|(T=(u=(0|(h=(3*(p=w-(x?p:0)|0)|0)+d-((w=(0|(x=(3*d|0)+f|0))<0)?x:0)-((c=(0|(C=(3*f|0)+p-(w?x:0)|0))<0)?C:0)|0))<0)?0:h))<(0|(u=(0|(A=(c?0:C)-(u?h:0)|0))<(0|(h=(w?0:x)-(c?C:0)-(u?h:0)|0))?A:h))?T:u))>0)?u:0,A=A-(C?u:0)|0,u=T-(C?u:0)|0}else{if(c){if((A=(0|p)>0)?(2147483647-p|0)<(0|p):(-2147483648-p|0)>(0|p)){s=1,_=107;break}if(c=p<<1,(u=(0|f)>0)?(2147483647-f|0)<(0|f):(-2147483648-f|0)>(0|f)){s=1,_=107;break}if(d=f<<1,u?(2147483647-d|0)<(0|f):(-2147483648-d|0)>(0|f)){s=1,_=107;break}if(A?(2147483647-c|0)<(0|f):(-2147483648-c|0)>(0|f)){s=1,_=107;break}if(A=3*f|0,(0|f)>-1?(-2147483648|A)>=(0|p):(-2147483648^A)<(0|p)){s=1,_=107;break}}else c=p<<1,A=3*f|0;if(h=0|Et(.14285714285714285*+(c+f|0)),c=(A=(0|(u=0|Et(.14285714285714285*+(A-p|0))))<(0|h))?h:u,(0|(A=A?u:h))<0){if(-2147483648==(0|A)||((0|c)>0?(2147483647-c|0)<(0|A):(-2147483648-c|0)>(0|A))){_=36;break}if((0|c)>-1?(-2147483648|c)>=(0|A):(-2147483648^c)<(0|A)){_=36;break}}d=((d=(0|h)<0)?0:h)-((T=(0|(f=u-(d?h:0)|0))<0)?f:0)-((p=(0|(C=(d?0-h|0:0)-(T?f:0)|0))<0)?C:0)|0,f=(T?0:f)-(p?C:0)|0,d=d-((T=(0|(p=(0|(C=p?0:C))<(0|(p=(0|f)<(0|d)?f:d))?C:p))>0)?p:0)|0,f=f-(T?p:0)|0,c=(w=(0|(u=(0|(x=(u=(0|(h=(3*(p=C-(T?p:0)|0)|0)+f-((C=(0|(T=(3*d|0)+p|0))<0)?T:0)-((c=(0|(w=(3*f|0)+d-(C?T:0)|0))<0)?w:0)|0))<0)?0:h))<(0|(u=(0|(A=(c?0:w)-(u?h:0)|0))<(0|(h=(C?0:T)-(c?w:0)-(u?h:0)|0))?A:h))?x:u))>0)?u:0,A=A-(w?u:0)|0,u=x-(w?u:0)|0}u=(a=(0|(w=n-u+((T=(0|(c=a+(c-h)|0))<0)?0-c|0:0)+((h=(0|(A=l-A-(T?c:0)|0))<0)?0-A|0:0)|0))<0)?0:w,C=(h?0:A)-(a?w:0)|0,w=(w=(T?0:c)-(h?A:0)-(a?w:0)|0)-((n=(0|(a=(0|u)<(0|(a=(0|C)<(0|w)?C:w))?u:a))>0)?a:0)|0,h=0|r[(A=i)>>2],A=0|r[A+4>>2],c=h&~(c=0|zt(7,0,0|(l=3*(15-g|0)|0))),A&=~E(),n=(n=(a=(0|(T=u-(n?a:0)-(T=(h=(0|w)<0)?w:0)+((x=(0|(C=C-(n?a:0)-T|0))<0)?0-C|0:0)|0))<0)?0:T)-(C=(0|(C=(0|n)<(0|(C=(0|(a=(x?0:C)-(T=a?T:0)|0))<(0|(T=(h?0:w)-(x?C:0)-T|0))?a:T))?n:C))>0?C:0)|0,a=a-C|0;e:do{switch(T-C|0){case 0:switch(0|a){case 0:n=0|n?1==(0|n)?1:7:0;break e;case 1:n=0|n?1==(0|n)?3:7:2;break e;default:_=45;break e}case 1:switch(0|a){case 0:n=0|n?1==(0|n)?5:7:4;break e;case 1:if(n){_=45;break e}n=6;break e;default:_=45;break e}default:_=45}}while(0);if(45==(0|_)&&(_=0,n=7),x=0|zt(0|n,0,0|l),T=0|E()|A,r[(C=i)>>2]=x|c,r[C+4>>2]=T,(0|g)<=1){_=47;break}a=d,l=f,n=p}if(24==(0|_))S(27634,27425,416,27447);else if(36==(0|_))S(27634,27425,464,27461);else{if(47==(0|_)){if((0|d)>1|(0|f)>1|(0|p)>1)return 0|(C=1);n=(n=(o=(0|(T=p-(T=(w=(0|d)<0)?d:0)+((x=(0|(C=f-T|0))<0)?0-C|0:0)|0))<0)?0:T)-(C=(0|(C=(0|n)<(0|(C=(0|(o=(x?0:C)-(T=o?T:0)|0))<(0|(T=(w?0:d)-(x?C:0)-T|0))?o:T))?n:C))>0?C:0)|0,o=o-C|0;e:do{switch(T-C|0){case 0:switch(0|o){case 0:o=0|n?1==(0|n)?1:7:0;break e;case 1:o=0|n?1==(0|n)?3:7:2;break e;default:_=55;break e}case 1:switch(0|o){case 0:o=0|n?1==(0|n)?5:7:4;break e;case 1:if(n){_=55;break e}o=6;break e;default:_=55;break e}default:_=55}}while(0);55==(0|_)&&(o=7),A=127==(0|(l=0|Q(y,o)))?0:0|j(l);e:do{if(o){if(m){if(7==(0|(n=0|Pe(e,t))))return 0|(C=5);a=0|r[21344+(28*n|0)+(o<<2)>>2];t:do{if((0|a)>0)for(n=o,o=0;;){switch(0|n){case 1:n=5;break;case 5:n=4;break;case 4:n=6;break;case 6:n=2;break;case 2:n=3;break;case 3:n=1}if((0|(o=o+1|0))==(0|a))break t}else n=o}while(0);if(1==(0|n))return 0|(C=9);127==(0|(o=0|Q(y,n)))&&S(27476,27315,415,27506),0|j(o)?S(27521,27315,416,27506):(s=o,v=a,b=n)}else s=l,v=0,b=o;if((0|(c=0|r[4272+(28*y|0)+(b<<2)>>2]))<=-1&&S(27552,27315,423,27506),!A){if((0|v)<0)return 0|(C=5);if(0|v){n=0,o=0|r[(a=i)>>2],a=0|r[a+4>>2];do{o=0|Me(o,a),a=0|E(),r[(C=i)>>2]=o,r[C+4>>2]=a,n=n+1|0}while((0|n)<(0|v))}if((0|c)<=0){_=104;break}for(n=0,o=0|r[(a=i)>>2],a=0|r[a+4>>2];;)if(o=0|Me(o,a),a=0|E(),r[(C=i)>>2]=o,r[C+4>>2]=a,(0|(n=n+1|0))==(0|c)){_=104;break e}}if(7==(0|(l=0|X(s,y)))&&S(27291,27315,432,27506),o=0|r[(n=i)>>2],n=0|r[n+4>>2],(0|c)>0){a=0;do{o=0|Me(o,n),n=0|E(),r[(C=i)>>2]=o,r[C+4>>2]=n,a=a+1|0}while((0|a)!=(0|c))}if(7==(0|(n=0|Pe(o,n)))&&S(27634,27315,444,27506),o=0|H(s),(0|(o=0|r[(o?21760:21552)+(28*l|0)+(n<<2)>>2]))<0&&S(27634,27315,458,27506),o){n=0,a=0|r[(l=i)>>2],l=0|r[l+4>>2];do{a=0|Re(a,l),l=0|E(),r[(C=i)>>2]=a,r[C+4>>2]=l,n=n+1|0}while((0|n)<(0|o));_=104}else _=104}else if(!!(0|m)&!!(0|A)){if(7==(0|(s=0|Pe(e,t)))|7==(0|(n=0|Pe(0|r[(n=i)>>2],0|r[n+4>>2]))))return 0|(C=5);if((0|(n=0|r[21344+(28*s|0)+(n<<2)>>2]))<0)return 0|(C=5);if(n){s=0,o=0|r[(a=i)>>2],a=0|r[a+4>>2];do{o=0|Me(o,a),a=0|E(),r[(C=i)>>2]=o,r[C+4>>2]=a,s=s+1|0}while((0|s)<(0|n));s=l,_=104}else s=l,_=105}else s=l,_=104}while(0);return 104==(0|_)&&A&&(_=105),105==(0|_)&&1==(0|Pe(0|r[(C=i)>>2],0|r[C+4>>2]))?0|(C=9):(w=0|r[(T=i)>>2],T=-1040385&r[T+4>>2],x=0|zt(0|s,0,45),T=0|T|E(),r[(C=i)>>2]=w|x,r[C+4>>2]=T,0|(C=0))}if(107==(0|_))return 0|s}return 0}function Ze(e,t,n,i,s){n|=0,i|=0,s|=0;var o,a,l=0,c=0,A=0;return o=I,I=I+32|0,A=o,0|(l=0|Xe(e|=0,t|=0,e,t,c=o+12|0))?(I=o,0|(A=l)):0|(e=0|Xe(e,t,n,i,A))?(I=o,0|(A=e)):(t=(0|(n=(i=(a=(0|(e=(0|r[c>>2])-(0|r[A>>2])|0))<0)?0-e|0:0)+((0|r[c+4>>2])-(0|r[A+4>>2]))|0))<0,c=(c=(l=(0|(i=(0|r[c+8>>2])-(0|r[A+8>>2])+i+(t?0-n|0:0)|0))<0)?0:i)-(A=(0|(A=(0|c)<(0|(A=(0|(l=(t?0:n)-(i=l?i:0)|0))<(0|(i=(a?0:e)-(t?n:0)-i|0))?l:i))?c:A))>0?A:0)|0,l=l-A|0,c=(0|(A=(0|(A=i-A|0))>-1?A:0-A|0))>(0|(c=(0|(l=(0|l)>-1?l:0-l|0))>(0|(c=(0|c)>-1?c:0-c|0))?l:c))?A:c,r[(A=s)>>2]=c,r[A+4>>2]=((0|c)<0)<<31>>31,I=o,0|(A=0))}function Ye(e,t,n,i,s,o,a,l,A,u,h){e|=0,t|=0,n|=0,i|=0,s|=0,o|=0,a|=0,l|=0,A|=0,u|=0,h|=0;var d,f,p,g,m,b,_,v=0,y=0,w=0,x=0,T=0,C=0,P=0,R=0,M=0,L=0,O=0;if(_=I,I=I+48|0,y=_+12|0,b=_,r[(v=_+24|0)>>2]=0,r[v+4>>2]=0,r[v+8>>2]=0,r[y>>2]=0,r[y+4>>2]=0,r[y+8>>2]=0,0|Xe(e,t,e,t,v)&&S(27634,27315,696,27575),0|Xe(e,t,n,i,y)&&S(27634,27315,701,27575),n=(i=0|r[(T=v+8|0)>>2])-(0|r[v>>2])|0,r[v>>2]=n,i=(0|r[(L=v+4|0)>>2])-i|0,r[L>>2]=i,v=0-(L=i+n|0)|0,r[T>>2]=v,C=(P=0|r[(T=y+8|0)>>2])-(0|r[y>>2])|0,r[y>>2]=C,P=(0|r[(M=y+4|0)>>2])-P|0,r[M>>2]=P,M=P+C|0,r[T>>2]=0-M,g=(R=1/(+(s>>>0)+4294967296*+(0|o)))*+(C-n|0),m=R*+(P-i|0),R*=+(L-M|0),r[b>>2]=n,r[(M=b+4|0)>>2]=i,r[(L=b+8|0)>>2]=v,(0|o)<0)return I=_,0|(u=0);for(p=+(0|n),f=+(0|i),d=+(0|v),C=0,P=0;;){if(O=g*(x=+(C>>>0)+4294967296*+(0|P))+p,w=m*x+f,x=R*x+d,i=~~+Wt(+O),v=~~+Wt(+w),n=~~+Wt(+x),(O=+c(+(+(0|i)-O)))>(w=+c(+(+(0|v)-w)))&O>(x=+c(+(+(0|n)-x)))?i=0-(y=n+v|0)|0:(y=0-i|0,w>x&&(v=y-n|0)),r[M>>2]=v,r[b>>2]=y,r[L>>2]=0,n=i+v|0,(0|i)>0?(r[M>>2]=n,r[L>>2]=i,r[b>>2]=0,y=0):(n=v,i=0),(0|n)<0?(v=y-n|0,r[b>>2]=v,i=i-n|0,r[L>>2]=i,r[M>>2]=0,y=v-i|0,n=0-i|0,(0|i)<0?(r[b>>2]=y,r[M>>2]=n,r[L>>2]=0,T=n,i=0):(T=0,y=v)):T=n,(0|(n=(0|i)<(0|(n=(0|T)<(0|y)?T:y))?i:n))>0&&(r[b>>2]=y-n,r[M>>2]=T-n,r[L>>2]=i-n),n=0|Lt(0|(n=0|kt(0|C,0|P,0|u,0|h)),0|E(),0|l,0|A),E(),0|(n=0|$e(e,t,b,a+(n<<3)|0))){i=20;break}if(T=C,C=0|Lt(0|C,0|P,1,0),y=P,P=0|E(),!((0|y)<(0|o)|(0|y)==(0|o)&T>>>0<s>>>0)){n=0,i=20;break}}return 20==(0|i)?(I=_,0|n):0}function Je(e,t,n,i){e|=0,t|=0;var r=0,s=0,o=0;if(!(0|(n|=0))&!(0|(i|=0)))return s=1,T(0|(r=0)),0|s;s=e,r=t,e=1,t=0;do{e=0|kt(0|((o=!0&!(1&n))?1:s),0|(o?0:r),0|e,0|t),t=0|E(),n=0|Ut(0|n,0|i,1),i=0|E(),s=0|kt(0|s,0|r,0|s,0|r),r=0|E()}while(!(!(0|n)&!(0|i)));return T(0|t),0|e}function et(e,t,n,i){n|=0,i|=0;var o,a=0,l=0,c=0,A=0,h=0,d=0;o=I,I=I+16|0,l=o,c=0|Vt(0|(e|=0),0|(t|=0),52),E(),c&=15;do{if(c){if(!(a=0|De(e,t,l))){h=+s[l>>3],A=1/+u(+h),d=+s[26032+(c<<3)>>3],s[n>>3]=h+d,s[n+8>>3]=h-d,h=+s[l+8>>3],A*=d,s[n+16>>3]=A+h,s[n+24>>3]=h-A;break}return I=o,0|(c=a)}if(a=0|Vt(0|e,0|t,45),E(),(a&=127)>>>0>121)return I=o,0|(c=5);l=22128+(a<<5)|0,r[n>>2]=r[l>>2],r[n+4>>2]=r[l+4>>2],r[n+8>>2]=r[l+8>>2],r[n+12>>2]=r[l+12>>2],r[n+16>>2]=r[l+16>>2],r[n+20>>2]=r[l+20>>2],r[n+24>>2]=r[l+24>>2],r[n+28>>2]=r[l+28>>2];break}while(0);return function(e,t){t=+t;var n,i,r,o,a,l,c,A=0,u=0;A=(o=+s[(r=16+(e|=0)|0)>>3])-(i=+s[(n=e+24|0)>>3]),A=o<i?A+6.283185307179586:A,u=+s[e>>3],A=.5*(A*t-A),u+=t=.5*((c=u-(l=+s[(a=e+8|0)>>3]))*t-c),s[e>>3]=u>1.5707963267948966?1.5707963267948966:u,t=l-t,s[a>>3]=t<-1.5707963267948966?-1.5707963267948966:t,t=(t=o+A)>3.141592653589793?t+-6.283185307179586:t,s[r>>3]=t<-3.141592653589793?t+6.283185307179586:t,t=(t=i-A)>3.141592653589793?t+-6.283185307179586:t,s[n>>3]=t<-3.141592653589793?t+6.283185307179586:t}(n,i?1.4:1.1),(0|r[(i=26160+(c<<3)|0)>>2])==(0|e)&&(0|r[i+4>>2])==(0|t)&&(s[n>>3]=1.5707963267948966),(0|r[(c=26288+(c<<3)|0)>>2])==(0|e)&&(0|r[c+4>>2])==(0|t)&&(s[n+8>>3]=-1.5707963267948966),1.5707963267948966!=+s[n>>3]&&-1.5707963267948966!=+s[n+8>>3]?(I=o,0|(c=0)):(s[n+16>>3]=3.141592653589793,s[n+24>>3]=-3.141592653589793,I=o,0|(c=0))}function tt(e,t,n,s){e|=0,t|=0,n|=0,s|=0;var o,a,l,c=0,A=0,u=0,h=0;l=I,I=I+48|0,o=l+40|0,a=l,we(A=l+32|0,0,0,0),u=0|r[A>>2],A=0|r[A+4>>2];do{if(n>>>0<=15){if(0|(c=0|ot(s))){r[(s=a)>>2]=0,r[s+4>>2]=0,r[a+8>>2]=c,r[a+12>>2]=-1,u=a+29|0,r[(s=a+16|0)>>2]=0,r[s+4>>2]=0,r[s+8>>2]=0,i[s+12|0]=0,i[u|0]=0|i[o|0],i[u+1|0]=0|i[o+1|0],i[u+2|0]=0|i[o+2|0];break}if(c=0|Pt(1+(0|r[t+8>>2])|0,32)){at(t,c),r[(h=a)>>2]=u,r[h+4>>2]=A,r[a+8>>2]=0,r[a+12>>2]=n,r[a+16>>2]=s,r[a+20>>2]=t,r[a+24>>2]=c,i[a+28|0]=0,i[(u=a+29|0)|0]=0|i[o|0],i[u+1|0]=0|i[o+1|0],i[u+2|0]=0|i[o+2|0];break}r[(s=a)>>2]=0,r[s+4>>2]=0,r[a+8>>2]=13,r[a+12>>2]=-1,u=a+29|0,r[(s=a+16|0)>>2]=0,r[s+4>>2]=0,r[s+8>>2]=0,i[s+12|0]=0,i[u|0]=0|i[o|0],i[u+1|0]=0|i[o+1|0],i[u+2|0]=0|i[o+2|0];break}r[(u=a)>>2]=0,r[u+4>>2]=0,r[a+8>>2]=4,r[a+12>>2]=-1,h=a+29|0,r[(u=a+16|0)>>2]=0,r[u+4>>2]=0,r[u+8>>2]=0,i[u+12|0]=0,i[h|0]=0|i[o|0],i[h+1|0]=0|i[o+1|0],i[h+2|0]=0|i[o+2|0]}while(0);nt(a),r[e>>2]=r[a>>2],r[e+4>>2]=r[a+4>>2],r[e+8>>2]=r[a+8>>2],r[e+12>>2]=r[a+12>>2],r[e+16>>2]=r[a+16>>2],r[e+20>>2]=r[a+20>>2],r[e+24>>2]=r[a+24>>2],r[e+28>>2]=r[a+28>>2],I=l}function nt(e){var t,n,s,o,a=0,l=0,c=0,A=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,b=0,_=0,v=0,y=0,w=0;if(o=I,I=I+336|0,t=o+168|0,n=o,!(0|(l=0|r[(c=e|=0)>>2]))&!(0|(c=0|r[c+4>>2])))I=o;else{if(0|i[(a=e+28|0)|0]?(l=0|it(l,c),c=0|E()):i[a|0]=1,!(0|r[r[(s=e+20|0)>>2]>>2]))return 0|(l=0|r[(a=e+24|0)>>2])&&Ct(l),r[(w=e)>>2]=0,r[w+4>>2]=0,r[e+8>>2]=0,r[s>>2]=0,r[e+12>>2]=-1,r[e+16>>2]=0,r[a>>2]=0,void(I=o);A=15&(a=0|r[(w=e+16|0)>>2]);e:do{if(!(0|l)&!(0|c))y=e+24|0;else{_=e+12|0,m=3==(0|A),g=255&a,f=3==(1|A),b=e+24|0,p=(A+-1|0)>>>0<3,h=3==(2|A),d=n+8|0;t:for(;;){if(u=0|Vt(0|l,0|c,52),E(),(0|(u&=15))==(0|r[_>>2])){switch(15&g){case 0:case 2:case 3:if(0|(A=0|De(l,c,t))){v=15;break t}if(0|lt(0|r[s>>2],0|r[b>>2],t)){v=19;break t}}if(f&&(A=0|r[4+(0|r[s>>2])>>2],r[t>>2]=r[A>>2],r[t+4>>2]=r[A+4>>2],r[t+8>>2]=r[A+8>>2],r[t+12>>2]=r[A+12>>2],0|Y(26896,t))){if(0|Ne(0|r[4+(0|r[s>>2])>>2],u,n)){v=25;break}if((0|r[(A=n)>>2])==(0|l)&&(0|r[A+4>>2])==(0|c)){v=29;break}}if(p){if(0|(A=0|Ue(l,c,t))){v=32;break}if(0|et(l,c,n,0)){v=36;break}if(h&&0|ct(0|r[s>>2],0|r[b>>2],t,n)){v=42;break}if(f&&0|ut(0|r[s>>2],0|r[b>>2],t,n)){v=42;break}}if(m){if(a=0|et(l,c,t,1),A=0|r[b>>2],0|a){v=45;break}if(0|J(A,t)){if(te(n,t),0|ee(t,0|r[b>>2])){v=53;break}if(0|lt(0|r[s>>2],0|r[b>>2],d)){v=53;break}if(0|ut(0|r[s>>2],0|r[b>>2],n,t)){v=53;break}}}}do{if((0|u)<(0|r[_>>2])){if(a=0|et(l,c,t,1),A=0|r[b>>2],0|a){v=58;break t}if(!(0|J(A,t))){v=73;break}if(0|ee(0|r[b>>2],t)&&(te(n,t),0|ct(0|r[s>>2],0|r[b>>2],n,t))){v=65;break t}if(0|(l=0|Ce(l,c,u+1|0,n))){v=67;break t}l=0|r[(c=n)>>2],c=0|r[c+4>>2]}else v=73}while(0);if(73==(0|v)&&(v=0,l=0|it(l,c),c=0|E()),!(0|l)&!(0|c)){y=b;break e}}switch(0|v){case 15:0|(a=0|r[b>>2])&&Ct(a),r[(v=e)>>2]=0,r[v+4>>2]=0,r[s>>2]=0,r[_>>2]=-1,r[w>>2]=0,r[b>>2]=0,r[e+8>>2]=A,v=20;break;case 19:r[e>>2]=l,r[e+4>>2]=c,v=20;break;case 25:S(27634,27600,470,27611);break;case 29:case 42:return r[e>>2]=l,r[e+4>>2]=c,void(I=o);case 32:return 0|(a=0|r[b>>2])&&Ct(a),r[(y=e)>>2]=0,r[y+4>>2]=0,r[s>>2]=0,r[_>>2]=-1,r[w>>2]=0,r[b>>2]=0,r[e+8>>2]=A,void(I=o);case 36:S(27634,27600,493,27611);break;case 45:0|A&&Ct(A),r[(v=e)>>2]=0,r[v+4>>2]=0,r[s>>2]=0,r[_>>2]=-1,r[w>>2]=0,r[b>>2]=0,r[e+8>>2]=a,v=55;break;case 53:r[e>>2]=l,r[e+4>>2]=c,v=55;break;case 58:0|A&&Ct(A),r[(v=e)>>2]=0,r[v+4>>2]=0,r[s>>2]=0,r[_>>2]=-1,r[w>>2]=0,r[b>>2]=0,r[e+8>>2]=a,v=71;break;case 65:r[e>>2]=l,r[e+4>>2]=c,v=71;break;case 67:return 0|(a=0|r[b>>2])&&Ct(a),r[(y=e)>>2]=0,r[y+4>>2]=0,r[s>>2]=0,r[_>>2]=-1,r[w>>2]=0,r[b>>2]=0,r[e+8>>2]=l,void(I=o)}if(20==(0|v))return void(I=o);if(55==(0|v))return void(I=o);if(71==(0|v))return void(I=o)}}while(0);0|(a=0|r[y>>2])&&Ct(a),r[(v=e)>>2]=0,r[v+4>>2]=0,r[e+8>>2]=0,r[s>>2]=0,r[e+12>>2]=-1,r[w>>2]=0,r[y>>2]=0,I=o}}function it(e,t){var n,i=0,s=0,o=0,a=0,l=0,c=0,A=0,u=0,h=0;n=I,I=I+16|0,h=n,s=0|Vt(0|(e|=0),0|(t|=0),52),E(),s&=15,i=0|Vt(0|e,0|t,45),E();do{if(s){for(;i=0|zt(s+4095|0,0,52),o=E()|-15728641&t,i=i|e|(l=0|zt(7,0,0|(a=3*(15-s|0)|0))),o|=c=0|E(),A=0|Vt(0|e,0|t,0|a),E(),s=s+-1|0,!((A&=7)>>>0<6);){if(!s){u=4;break}t=o,e=i}if(4==(0|u)){i=0|Vt(0|i,0|o,45),E();break}return h=0|zt(((h=!(0|A)&!!(0|Ee(i,o)))?2:1)+A|0,0,0|a),u=0|E()|t&~c,h|=e&~l,T(0|u),I=n,0|h}}while(0);return(i&=127)>>>0>120?(h=0,T(0|(u=0)),I=n,0|h):(we(h,0,i+1|0,0),u=0|r[h+4>>2],h=0|r[h>>2],T(0|u),I=n,0|h)}function rt(e,t,n){e|=0;var i,o=0,a=0,l=0,c=0,A=0,u=0,h=0,d=0,f=0;if(!(0|Y(t|=0,n|=0)))return 0|(f=0);if(t=0|function(e){return+s[16+(e|=0)>>3]<+s[e+24>>3]|0}(t),o=+s[n>>3],a=t&(a=+s[n+8>>3])<0?a+6.283185307179586:a,(0|(f=0|r[e>>2]))<=0)return 0|(f=0);if(i=0|r[e+4>>2],t){t=0,d=a,n=-1,e=0;e:for(;;){for(h=e;c=+s[i+(h<<4)>>3],a=+s[i+(h<<4)+8>>3],l=+s[i+((e=(n+2|0)%(0|f)|0)<<4)>>3],A=+s[i+(e<<4)+8>>3],c>l?(u=c,c=A):(u=l,l=c,c=a,a=A),(o=o==l|o==u?o+2220446049250313e-31:o)<l|o>u;){if((0|(n=h+1|0))>=(0|f)){n=22;break e}e=h,h=n,n=e}if(((u=(A=c<0?c+6.283185307179586:c)+(o-l)/(u-l)*((c=a<0?a+6.283185307179586:a)-A))<0?u+6.283185307179586:u)>(d=A==d|c==d?d+-2220446049250313e-31:d)&&(t^=1),(0|(e=h+1|0))>=(0|f)){n=22;break}n=h}if(22==(0|n))return 0|t}else{t=0,d=a,n=-1,e=0;e:for(;;){for(h=e;c=+s[i+(h<<4)>>3],a=+s[i+(h<<4)+8>>3],l=+s[i+((e=(n+2|0)%(0|f)|0)<<4)>>3],A=+s[i+(e<<4)+8>>3],c>l?(u=c,c=A):(u=l,l=c,c=a,a=A),(o=o==l|o==u?o+2220446049250313e-31:o)<l|o>u;){if((0|(n=h+1|0))>=(0|f)){n=22;break e}e=h,h=n,n=e}if(c+(o-l)/(u-l)*(a-c)>(d=c==d|a==d?d+-2220446049250313e-31:d)&&(t^=1),(0|(e=h+1|0))>=(0|f)){n=22;break}n=h}if(22==(0|n))return 0|t}return 0}function st(e,t){t|=0;var n,i,o,a,l,A=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,b=0,_=0,v=0,y=0;if(!(i=0|r[(e|=0)>>2]))return r[t>>2]=0,r[t+4>>2]=0,r[t+8>>2]=0,r[t+12>>2]=0,r[t+16>>2]=0,r[t+20>>2]=0,r[t+24>>2]=0,void(r[t+28>>2]=0);if(s[(o=t+8|0)>>3]=17976931348623157e292,s[(a=t+24|0)>>3]=17976931348623157e292,s[t>>3]=-17976931348623157e292,s[(l=t+16|0)>>3]=-17976931348623157e292,!((0|i)<=0)){for(n=0|r[e+4>>2],m=17976931348623157e292,b=-17976931348623157e292,_=0,e=-1,d=17976931348623157e292,f=17976931348623157e292,g=-17976931348623157e292,u=-17976931348623157e292,v=0;A=+s[n+(v<<4)>>3],p=+s[n+(v<<4)+8>>3],h=+s[n+(((0|(e=e+2|0))==(0|i)?0:e)<<4)+8>>3],A<d&&(s[o>>3]=A,d=A),p<f&&(s[a>>3]=p,f=p),A>g?s[t>>3]=A:A=g,p>u&&(s[l>>3]=p,u=p),m=p>0&p<m?p:m,b=p<0&p>b?p:b,_|=+c(+(p-h))>3.141592653589793,(0|(e=v+1|0))!=(0|i);)y=v,g=A,v=e,e=y;_&&(s[l>>3]=b,s[a>>3]=m)}}function ot(e){return 0|((e|=0)>>>0<4?0:15)}function at(e,t){t|=0;var n,i=0,o=0,a=0,l=0,A=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,b=0,_=0,v=0,y=0,w=0,x=0,T=0,E=0,S=0;if(b=0|r[(e|=0)>>2]){if(s[(_=t+8|0)>>3]=17976931348623157e292,s[(v=t+24|0)>>3]=17976931348623157e292,s[t>>3]=-17976931348623157e292,s[(y=t+16|0)>>3]=-17976931348623157e292,(0|b)>0){for(a=0|r[e+4>>2],g=17976931348623157e292,m=-17976931348623157e292,o=0,i=-1,h=17976931348623157e292,d=17976931348623157e292,p=-17976931348623157e292,A=-17976931348623157e292,w=0;l=+s[a+(w<<4)>>3],f=+s[a+(w<<4)+8>>3],u=+s[a+(((0|(E=i+2|0))==(0|b)?0:E)<<4)+8>>3],l<h&&(s[_>>3]=l,h=l),f<d&&(s[v>>3]=f,d=f),l>p?s[t>>3]=l:l=p,f>A&&(s[y>>3]=f,A=f),g=f>0&f<g?f:g,m=f<0&f>m?f:m,o|=+c(+(f-u))>3.141592653589793,(0|(i=w+1|0))!=(0|b);)E=w,p=l,w=i,i=E;o&&(s[y>>3]=m,s[v>>3]=g)}}else r[t>>2]=0,r[t+4>>2]=0,r[t+8>>2]=0,r[t+12>>2]=0,r[t+16>>2]=0,r[t+20>>2]=0,r[t+24>>2]=0,r[t+28>>2]=0;if(!((0|(i=0|r[(E=e+8|0)>>2]))<=0)){n=e+12|0,T=0;do{if(a=0|r[n>>2],o=T,v=t+((T=T+1|0)<<5)|0,y=0|r[a+(o<<3)>>2]){if(s[(w=t+(T<<5)+8|0)>>3]=17976931348623157e292,s[(e=t+(T<<5)+24|0)>>3]=17976931348623157e292,s[v>>3]=-17976931348623157e292,s[(x=t+(T<<5)+16|0)>>3]=-17976931348623157e292,(0|y)>0){for(b=0|r[a+(o<<3)+4>>2],g=17976931348623157e292,m=-17976931348623157e292,a=0,o=-1,_=0,h=17976931348623157e292,d=17976931348623157e292,f=-17976931348623157e292,A=-17976931348623157e292;l=+s[b+(_<<4)>>3],p=+s[b+(_<<4)+8>>3],u=+s[b+(((0|(o=o+2|0))==(0|y)?0:o)<<4)+8>>3],l<h&&(s[w>>3]=l,h=l),p<d&&(s[e>>3]=p,d=p),l>f?s[v>>3]=l:l=f,p>A&&(s[x>>3]=p,A=p),g=p>0&p<g?p:g,m=p<0&p>m?p:m,a|=+c(+(p-u))>3.141592653589793,(0|(o=_+1|0))!=(0|y);)S=_,_=o,f=l,o=S;a&&(s[x>>3]=m,s[e>>3]=g)}}else r[v>>2]=0,r[v+4>>2]=0,r[v+8>>2]=0,r[v+12>>2]=0,r[v+16>>2]=0,r[v+20>>2]=0,r[v+24>>2]=0,r[v+28>>2]=0,i=0|r[E>>2]}while((0|T)<(0|i))}}function lt(e,t,n){var i=0,s=0,o=0;if(!(0|rt(e|=0,t|=0,n|=0)))return 0|(s=0);if((0|r[(s=e+8|0)>>2])<=0)return 0|(s=1);for(i=e+12|0,e=0;;){if(o=e,e=e+1|0,0|rt((0|r[i>>2])+(o<<3)|0,t+(e<<5)|0,n)){e=0,i=6;break}if((0|e)>=(0|r[s>>2])){e=1,i=6;break}}return 6==(0|i)?0|e:0}function ct(e,t,n,i){i|=0;var s,o,a=0,l=0,c=0,A=0,u=0;if(o=I,I=I+16|0,s=o,!(0|rt(e|=0,t|=0,c=(n|=0)+8|0)))return I=o,0|(A=0);A=e+8|0;e:do{if((0|r[A>>2])>0){for(l=e+12|0,a=0;;){if(u=a,a=a+1|0,0|rt((0|r[l>>2])+(u<<3)|0,t+(a<<5)|0,c)){a=0;break}if((0|a)>=(0|r[A>>2]))break e}return I=o,0|a}}while(0);if(0|At(e,t,n,i))return I=o,0|(u=0);r[s>>2]=r[n>>2],r[s+4>>2]=c,a=0|r[A>>2];e:do{if((0|a)>0)for(e=e+12|0,c=0,l=a;;){if(a=0|r[e>>2],(0|r[a+(c<<3)>>2])>0){if(0|rt(s,i,0|r[a+(c<<3)+4>>2])){a=0;break e}if(a=c+1|0,0|At((0|r[e>>2])+(c<<3)|0,t+(a<<5)|0,n,i)){a=0;break e}l=0|r[A>>2]}else a=c+1|0;if(!((0|a)<(0|l))){a=1;break}c=a}else a=1}while(0);return I=o,0|(u=a)}function At(e,t,n,i){e|=0,n|=0;var o,a,l,c,A,u,h=0,d=0,f=0,p=0,g=0,m=0,b=0,_=0,v=0,y=0,w=0,x=0,T=0,E=0,S=0;if(u=I,I=I+176|0,c=u+172|0,h=u+168|0,A=u,!(0|J(t|=0,i|=0)))return I=u,0|(e=0);if(function(e,t,n,i){var o,a,l,c,A;t|=0,n|=0,i|=0,e=(a=+s[16+(e|=0)>>3])<(A=+s[e+24>>3]),o=(c=+s[t+16>>3])<(l=+s[t+24>>3]),t=A-c<l-a,r[n>>2]=e?o|t?1:2:0,r[i>>2]=o?e?1:t?2:1:0}(t,i,c,h),qt(0|A,0|n,168),(0|r[n>>2])>0){t=0;do{w=+We(+s[(E=A+8+(t<<4)+8|0)>>3],0|r[h>>2]),s[E>>3]=w,t=t+1|0}while((0|t)<(0|r[n>>2]))}a=+s[i>>3],l=+s[i+8>>3],w=+We(+s[i+16>>3],0|r[h>>2]),o=+We(+s[i+24>>3],0|r[h>>2]);e:do{if((0|r[e>>2])>0){if(i=e+4|0,(0|(h=0|r[A>>2]))<=0)for(t=0;;)if((0|(t=t+1|0))>=(0|r[e>>2])){t=0;break e}for(n=0;;){if(t=0|r[i>>2],v=+s[t+(n<<4)>>3],y=+We(+s[t+(n<<4)+8>>3],0|r[c>>2]),t=0|r[i>>2],E=(0|(n=n+1|0))%(0|r[e>>2])|0,d=+s[t+(E<<4)>>3],f=+We(+s[t+(E<<4)+8>>3],0|r[c>>2]),!(v>=a)|!(d>=a)&&!(v<=l)|!(d<=l)&&!(y<=o)|!(f<=o)&&!(y>=w)|!(f>=w)){_=d-v,m=f-y,t=0;do{if(S=t,E=(0|(t=t+1|0))==(0|h)?0:t,d=+s[A+8+(S<<4)+8>>3],f=+s[A+8+(E<<4)+8>>3]-d,p=+s[A+8+(S<<4)>>3],!(0==(b=_*f-m*(g=+s[A+8+(E<<4)>>3]-p))||(x=y-d,T=v-p,g=(x*g-f*T)/b,g<0|g>1))&&(b=(_*x-m*T)/b)>=0&b<=1){t=1;break e}}while((0|t)<(0|h))}if((0|n)>=(0|r[e>>2])){t=0;break}}}else t=0}while(0);return I=u,0|(S=t)}function ut(e,t,n,i){var s=0,o=0,a=0;if(0|At(e|=0,t|=0,n|=0,i|=0))return 0|(o=1);if((0|r[(o=e+8|0)>>2])<=0)return 0|(o=0);for(s=e+12|0,e=0;;){if(a=e,e=e+1|0,0|At((0|r[s>>2])+(a<<3)|0,t+(e<<5)|0,n,i)){e=1,s=6;break}if((0|e)>=(0|r[o>>2])){e=0,s=6;break}}return 6==(0|s)?0|e:0}function ht(e,t,n,i,r){t|=0,n|=0,i|=0,r|=0;var o,a,l,c,A,u,h,d=0;c=+s[(e|=0)>>3],l=+s[t>>3]-c,a=+s[e+8>>3],o=+s[t+8>>3]-a,u=+s[n>>3],d=((d=+s[i>>3]-u)*(a-(h=+s[n+8>>3]))-(c-u)*(A=+s[i+8>>3]-h))/(l*A-o*d),s[r>>3]=c+l*d,s[r+8>>3]=a+o*d}function dt(e,t){return t|=0,+c(+(+s[(e|=0)>>3]-+s[t>>3]))<1.1920928955078125e-7?0|(t=+c(+(+s[e+8>>3]-+s[t+8>>3]))<1.1920928955078125e-7):0|(t=0)}function ft(e,t,n){n|=0;var i,s,o,a,l=0,c=0,A=0,u=0;if(a=I,I=I+32|0,u=a,0|(l=0|Fe(e|=0,t|=0,s=a+16|0)))return I=a,0|(n=l);i=0|ve(e,t),o=0|Pe(e,t),function(e,t){e=7696+(28*(e|=0)|0)|0,r[(t|=0)>>2]=r[e>>2],r[t+4>>2]=r[e+4>>2],r[t+8>>2]=r[e+8>>2],r[t+12>>2]=r[e+12>>2]}(i,u),l=0|function(e,t){e|=0;var n=0,i=0;if((t|=0)>>>0>20)return-1;do{if((0|r[11120+(216*t|0)>>2])!=(0|e))if((0|r[11120+(216*t|0)+8>>2])!=(0|e))if((0|r[11120+(216*t|0)+16>>2])!=(0|e))if((0|r[11120+(216*t|0)+24>>2])!=(0|e))if((0|r[11120+(216*t|0)+32>>2])!=(0|e))if((0|r[11120+(216*t|0)+40>>2])!=(0|e))if((0|r[11120+(216*t|0)+48>>2])!=(0|e))if((0|r[11120+(216*t|0)+56>>2])!=(0|e))if((0|r[11120+(216*t|0)+64>>2])!=(0|e))if((0|r[11120+(216*t|0)+72>>2])!=(0|e))if((0|r[11120+(216*t|0)+80>>2])!=(0|e))if((0|r[11120+(216*t|0)+88>>2])!=(0|e))if((0|r[11120+(216*t|0)+96>>2])!=(0|e))if((0|r[11120+(216*t|0)+104>>2])!=(0|e))if((0|r[11120+(216*t|0)+112>>2])!=(0|e))if((0|r[11120+(216*t|0)+120>>2])!=(0|e))if((0|r[11120+(216*t|0)+128>>2])!=(0|e)){if((0|r[11120+(216*t|0)+136>>2])!=(0|e)){if((0|r[11120+(216*t|0)+144>>2])==(0|e)){e=0,n=2,i=0;break}if((0|r[11120+(216*t|0)+152>>2])==(0|e)){e=0,n=2,i=1;break}if((0|r[11120+(216*t|0)+160>>2])==(0|e)){e=0,n=2,i=2;break}if((0|r[11120+(216*t|0)+168>>2])==(0|e)){e=1,n=2,i=0;break}if((0|r[11120+(216*t|0)+176>>2])==(0|e)){e=1,n=2,i=1;break}if((0|r[11120+(216*t|0)+184>>2])==(0|e)){e=1,n=2,i=2;break}if((0|r[11120+(216*t|0)+192>>2])==(0|e)){e=2,n=2,i=0;break}if((0|r[11120+(216*t|0)+200>>2])==(0|e)){e=2,n=2,i=1;break}if((0|r[11120+(216*t|0)+208>>2])==(0|e)){e=2,n=2,i=2;break}return-1}e=2,n=1,i=2}else e=2,n=1,i=1;else e=2,n=1,i=0;else e=1,n=1,i=2;else e=1,n=1,i=1;else e=1,n=1,i=0;else e=0,n=1,i=2;else e=0,n=1,i=1;else e=0,n=1,i=0;else e=2,n=0,i=2;else e=2,n=0,i=1;else e=2,n=0,i=0;else e=1,n=0,i=2;else e=1,n=0,i=1;else e=1,n=0,i=0;else e=0,n=0,i=2;else e=0,n=0,i=1;else e=0,n=0,i=0}while(0);return 0|r[11120+(216*t|0)+(72*n|0)+(24*e|0)+(i<<3)+4>>2]}(i,0|r[s>>2]);do{if(0|j(i)){switch(0|i){case 4:c=0;break;case 14:c=1;break;case 24:c=2;break;case 38:c=3;break;case 49:c=4;break;case 58:c=5;break;case 63:c=6;break;case 72:c=7;break;case 83:c=8;break;case 97:c=9;break;case 107:c=10;break;case 117:c=11;break;default:S(27634,27636,75,27645)}if(A=0|r[26480+(24*c|0)+8>>2],t=0|r[26480+(24*c|0)+16>>2],(0|(e=0|r[s>>2]))!=(0|r[u>>2])&&(u=0|H(i))|(0|(e=0|r[s>>2]))==(0|t)&&(l=(l+1|0)%6|0),3==(0|o)&(0|e)==(0|t)){l=(l+5|0)%6|0;break}5==(0|o)&(0|e)==(0|A)&&(l=(l+1|0)%6|0)}}while(0);return r[n>>2]=l,I=a,0|(n=0)}function pt(e,t,n,i){n|=0,i|=0;var s,o,a,l,c,A=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,b=0,_=0,v=0;if(c=I,I=I+32|0,v=c+24|0,l=c+20|0,a=c+8|0,o=c+16|0,s=c,f=(f=!(0|Ee(e|=0,t|=0)))?6:5,g=0|Vt(0|e,0|t,52),E(),f>>>0<=n>>>0)return I=c,0|(i=2);!(m=!(0|(g&=15)))&&!((b=0|zt(7,0,3*(15^g)|0))&e|0)&!((0|E())&t)?A=n:u=4;e:do{if(4==(0|u)){if((0|((A=!!(0|Ee(e,t)))?4:5))<(0|n))return I=c,0|(i=1);if(0|ft(e,t,v))return I=c,0|(i=1);if(u=(0|r[v>>2])+n|0,7==(0|(b=0|r[(A=A?26768+((0|u)%5<<2)|0:26800+((0|u)%6<<2)|0)>>2])))return I=c,0|(i=1);r[l>>2]=0,A=0|F(e,t,b,l,a);do{if(!A){if(p=0|r[(d=a)>>2],u=(h=(d=0|r[d+4>>2])>>>0<t>>>0|(0|d)==(0|t)&p>>>0<e>>>0)?p:e,h=h?d:t,!m&&!(p&(m=0|zt(7,0,3*(15^g)|0))|0)&!(d&(0|E())))A=n;else{if(d=(n+-1+f|0)%(0|f)|0,A=0|Ee(e,t),(0|d)<0&&S(27634,27636,248,27661),(0|((f=!!(0|A))?4:5))<(0|d)&&S(27634,27636,248,27661),0|ft(e,t,v)&&S(27634,27636,248,27661),A=(0|r[v>>2])+d|0,7==(0|(d=0|r[(A=f?26768+((0|A)%5<<2)|0:26800+((0|A)%6<<2)|0)>>2]))&&S(27634,27636,248,27661),r[o>>2]=0,0|(A=0|F(e,t,d,o,s)))break;f=0|r[(p=s)>>2],p=0|r[p+4>>2];do{if(p>>>0<h>>>0|(0|p)==(0|h)&f>>>0<u>>>0){if(u=0|Ee(f,p)?0|V(f,p,e,t):0|r[26864+(((0|r[o>>2])+(0|r[26832+(d<<2)>>2])|0)%6<<2)>>2],A=0|Ee(f,p),(u+-1|0)>>>0>5){A=-1,u=f,h=p;break}if(1==(0|u)&(A=!!(0|A))){A=-1,u=f,h=p;break}do{if(!(0|ft(f,p,v))){if(A){A=(5+(0|r[26416+(u<<2)>>2])-(0|r[v>>2])|0)%5|0;break}A=(6+(0|r[26448+(u<<2)>>2])-(0|r[v>>2])|0)%6|0;break}A=-1}while(0);u=f,h=p}else A=n}while(0);p=0|r[(d=a)>>2],d=0|r[d+4>>2]}if((0|u)==(0|p)&(0|h)==(0|d)){if(e=(f=!!(0|Ee(p,d)))?0|V(p,d,e,t):0|r[26864+(((0|r[l>>2])+(0|r[26832+(b<<2)>>2])|0)%6<<2)>>2],A=0|Ee(p,d),(e+-1|0)>>>0<=5&&!(1==(0|e)&(_=!!(0|A))))do{if(!(0|ft(p,d,v))){if(_){A=(5+(0|r[26416+(e<<2)>>2])-(0|r[v>>2])|0)%5|0;break}A=(6+(0|r[26448+(e<<2)>>2])-(0|r[v>>2])|0)%6|0;break}A=-1}while(0);else A=-1;A=6==(0|(A=A+1|0))|f&5==(0|A)?0:A}t=h,e=u;break e}}while(0);return I=c,0|(i=A)}}while(0);return _=0|zt(0|A,0,56),v=E()|-2130706433&t|536870912,r[i>>2]=_|e,r[i+4>>2]=v,I=c,0|(i=0)}function gt(e,t){e|=0;var n,i,s=0,o=0;return i=I,I=I+16|0,n=i,!0&536870912==(2013265920&(t|=0))&&0|ye(e,s=-2130706433&t|134217728)?(o=0|Vt(0|e,0|t,56),E(),s=(o=!(0|pt(e,s,7&o,n)))&((0|r[(s=n)>>2])==(0|e)?(0|r[s+4>>2])==(0|t):0)&1,I=i,0|s):(I=i,0|(s=0))}function mt(e,t,n,i){e|=0,i|=0;var s,o,a,l=0,c=0,A=0,u=0,h=0,d=0;a=I,I=I+208|0,s=a,o=a+192|0,A=0|_(n|=0,t|=0),r[(u=o)>>2]=1,r[u+4>>2]=0;e:do{if(0|A){for(u=0-n|0,r[s+4>>2]=n,r[s>>2]=n,l=2,t=n,c=n;t=t+n+c|0,r[s+(l<<2)>>2]=t,t>>>0<A>>>0;)d=c,l=l+1|0,c=t,t=d;if((c=e+A+u|0)>>>0>e>>>0){A=c,l=1,t=1;do{do{if(3&~t){if((0|r[s+((t=l+-1|0)<<2)>>2])>>>0<(A-e|0)>>>0?bt(e,n,i,l,s):vt(e,n,i,o,l,0,s),1==(0|l)){yt(o,1),l=0;break}yt(o,t),l=1;break}bt(e,n,i,l,s),_t(o,2),l=l+2|0}while(0);t=1|r[o>>2],r[o>>2]=t,e=e+n|0}while(e>>>0<c>>>0)}else l=1,t=1;for(vt(e,n,i,o,l,0,s),c=o+4|0;;){if(1==(0|l)&1==(0|t)){if(!(0|r[c>>2]))break e;h=19}else(0|l)<2?h=19:(yt(o,2),d=l+-2|0,r[o>>2]=7^r[o>>2],_t(o,1),vt(e+(0-(0|r[s+(d<<2)>>2]))+u|0,n,i,o,l+-1|0,1,s),yt(o,1),t=1|r[o>>2],r[o>>2]=t,vt(e=e+u|0,n,i,o,d,1,s),l=d);19==(0|h)&&(h=0,_t(o,t=0|wt(o)),e=e+u|0,l=t+l|0,t=0|r[o>>2])}}}while(0);I=a}function bt(e,t,n,i,s){e|=0,t|=0,n|=0,i|=0,s|=0;var o,a,l=0,c=0,A=0,u=0,h=0;a=I,I=I+240|0,r[(o=a)>>2]=e;e:do{if((0|i)>1)for(h=0-t|0,A=e,l=i,i=1,c=e;;){if(e=(A=A+h|0)+(0-(0|r[s+((u=l+-2|0)<<2)>>2]))|0,(0|Zt[3&n](c,e))>-1&&(0|Zt[3&n](c,A))>-1)break e;if(c=o+(i<<2)|0,(0|Zt[3&n](e,A))>-1?(r[c>>2]=e,l=l+-1|0):(r[c>>2]=A,e=A,l=u),i=i+1|0,(0|l)<=1)break e;A=e,c=0|r[o>>2]}else i=1}while(0);Tt(t,o,i),I=a}function _t(e,t){var n,i=0,s=0;n=(e|=0)+4|0,(t|=0)>>>0>31?(s=0|r[n>>2],r[e>>2]=s,r[n>>2]=0,t=t+-32|0,i=0):(i=0|r[n>>2],s=0|r[e>>2]),r[e>>2]=i<<32-t|s>>>t,r[n>>2]=i>>>t}function vt(e,t,n,i,s,o,a){e|=0,t|=0,n|=0,s|=0,o|=0,a|=0;var l,c,A,u,h=0,d=0,f=0,p=0;u=I,I=I+240|0,c=u+232|0,A=u,p=0|r[(i|=0)>>2],r[c>>2]=p,d=0|r[i+4>>2],r[(l=c+4|0)>>2]=d,r[A>>2]=e;e:do{if(1!=(0|p)|!!(0|d)&&(f=0-t|0,h=e+(0-(0|r[a+(s<<2)>>2]))|0,(0|Zt[3&n](h,e))>=1))for(i=1,o=!(0|o),d=h;;){if(o&(0|s)>1){if(o=e+f|0,h=0|r[a+(s+-2<<2)>>2],(0|Zt[3&n](o,d))>-1){h=10;break e}if((0|Zt[3&n](o+(0-h)|0,d))>-1){h=10;break e}}if(o=i+1|0,r[A+(i<<2)>>2]=d,_t(c,p=0|wt(c)),s=p+s|0,!(1!=(0|r[c>>2])|!!(0|r[l>>2]))){i=o,e=d,h=10;break e}if(e=d+(0-(0|r[a+(s<<2)>>2]))|0,(0|Zt[3&n](e,0|r[A>>2]))<1){e=d,i=o,o=0,h=9;break}p=d,i=o,o=1,d=e,e=p}else i=1,h=9}while(0);9!=(0|h)||0|o||(h=10),10==(0|h)&&(Tt(t,A,i),bt(e,t,n,s,a)),I=u}function yt(e,t){var n,i=0,s=0;n=(e|=0)+4|0,(t|=0)>>>0>31?(s=0|r[e>>2],r[n>>2]=s,r[e>>2]=0,t=t+-32|0,i=0):(i=0|r[e>>2],s=0|r[n>>2]),r[n>>2]=i>>>(32-t|0)|s<<t,r[e>>2]=i<<t}function wt(e){var t=0;return(t=0|xt((0|r[(e|=0)>>2])-1|0))?0|t:0|(0|(t=0|xt(0|r[e+4>>2]))?t+32:0)}function xt(e){var t=0;if(e|=0)if(1&e)e=0;else for(t=e,e=0;e=e+1|0,!(2&t);)t>>>=1;else e=32;return 0|e}function Tt(e,t,n){e|=0,t|=0,n|=0;var i,s=0,o=0,a=0,l=0;i=I,I=I+256|0,s=i;e:do{if((0|n)>=2&&(r[(a=t+(n<<2)|0)>>2]=s,0|e))for(;;){o=e>>>0<256?e:256,qt(0|s,0|r[t>>2],0|o),s=0;do{l=t+(s<<2)|0,s=s+1|0,qt(0|r[l>>2],0|r[t+(s<<2)>>2],0|o),r[l>>2]=(0|r[l>>2])+o}while((0|s)!=(0|n));if(!(e=e-o|0))break e;s=0|r[a>>2]}}while(0);I=i}function Et(e){return 0|+Xt(+(e=+e))}function St(e){e|=0;var t,n=0,i=0,s=0,o=0,a=0,l=0,c=0,A=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,b=0,_=0,v=0,y=0,w=0;t=I,I=I+16|0,f=t;do{if(e>>>0<245){if(e=(u=e>>>0<11?16:e+11&-8)>>>3,3&(i=(d=0|r[6921])>>>e))return s=0|r[(i=(e=27724+((n=(1&i^1)+e|0)<<1<<2)|0)+8|0)>>2],(0|(a=0|r[(o=s+8|0)>>2]))==(0|e)?r[6921]=d&~(1<<n):(r[a+12>>2]=e,r[i>>2]=a),w=n<<3,r[s+4>>2]=3|w,r[(w=s+w+4|0)>>2]=1|r[w>>2],I=t,0|(w=o);if(u>>>0>(h=0|r[6923])>>>0){if(0|i)return n=((n=i<<e&((n=2<<e)|0-n))&0-n)-1|0,a=0|r[(e=(n=27724+((s=((i=(n>>>=c=n>>>12&16)>>>5&8)|c|(a=(n>>>=i)>>>2&4)|(e=(n>>>=a)>>>1&2)|(s=(n>>>=e)>>>1&1))+(n>>>s)|0)<<1<<2)|0)+8|0)>>2],(0|(i=0|r[(c=a+8|0)>>2]))==(0|n)?(e=d&~(1<<s),r[6921]=e):(r[i+12>>2]=n,r[e>>2]=i,e=d),l=(w=s<<3)-u|0,r[a+4>>2]=3|u,r[(o=a+u|0)+4>>2]=1|l,r[a+w>>2]=l,0|h&&(s=0|r[6926],i=27724+((n=h>>>3)<<1<<2)|0,e&(n=1<<n)?n=0|r[(e=i+8|0)>>2]:(r[6921]=e|n,n=i,e=i+8|0),r[e>>2]=s,r[n+12>>2]=s,r[s+8>>2]=n,r[s+12>>2]=i),r[6923]=l,r[6926]=o,I=t,0|(w=c);if(a=0|r[6922]){for(i=(a&0-a)-1|0,i=A=0|r[27988+(((s=(i>>>=o=i>>>12&16)>>>5&8)|o|(l=(i>>>=s)>>>2&4)|(c=(i>>>=l)>>>1&2)|(A=(i>>>=c)>>>1&1))+(i>>>A)<<2)>>2],c=A,A=(-8&r[A+4>>2])-u|0;(e=0|r[i+16>>2])||(e=0|r[i+20>>2]);)i=e,c=(o=(l=(-8&r[e+4>>2])-u|0)>>>0<A>>>0)?e:c,A=o?l:A;if((l=c+u|0)>>>0>c>>>0){o=0|r[c+24>>2],n=0|r[c+12>>2];do{if((0|n)==(0|c)){if(!(n=0|r[(e=c+20|0)>>2])&&!(n=0|r[(e=c+16|0)>>2])){i=0;break}for(;;)if(i=0|r[(s=n+20|0)>>2])n=i,e=s;else{if(!(i=0|r[(s=n+16|0)>>2]))break;n=i,e=s}r[e>>2]=0,i=n}else i=0|r[c+8>>2],r[i+12>>2]=n,r[n+8>>2]=i,i=n}while(0);do{if(0|o){if(n=0|r[c+28>>2],(0|c)==(0|r[(e=27988+(n<<2)|0)>>2])){if(r[e>>2]=i,!i){r[6922]=a&~(1<<n);break}}else if(r[((0|r[(w=o+16|0)>>2])==(0|c)?w:o+20)>>2]=i,!i)break;r[i+24>>2]=o,0|(n=0|r[c+16>>2])&&(r[i+16>>2]=n,r[n+24>>2]=i),0|(n=0|r[c+20>>2])&&(r[i+20>>2]=n,r[n+24>>2]=i)}}while(0);return A>>>0<16?(w=A+u|0,r[c+4>>2]=3|w,r[(w=c+w+4|0)>>2]=1|r[w>>2]):(r[c+4>>2]=3|u,r[l+4>>2]=1|A,r[l+A>>2]=A,0|h&&(s=0|r[6926],i=27724+((n=h>>>3)<<1<<2)|0,(n=1<<n)&d?n=0|r[(e=i+8|0)>>2]:(r[6921]=n|d,n=i,e=i+8|0),r[e>>2]=s,r[n+12>>2]=s,r[s+8>>2]=n,r[s+12>>2]=i),r[6923]=A,r[6926]=l),I=t,0|(w=c+8|0)}d=u}else d=u}else d=u}else if(e>>>0<=4294967231)if(u=-8&(e=e+11|0),s=0|r[6922]){o=0-u|0,A=(e>>>=8)?u>>>0>16777215?31:u>>>((A=14-((c=((m=e<<(d=(e+1048320|0)>>>16&8))+520192|0)>>>16&4)|d|(A=((m<<=c)+245760|0)>>>16&2))+(m<<A>>>15)|0)+7|0)&1|A<<1:0,i=0|r[27988+(A<<2)>>2];e:do{if(i)for(e=0,c=u<<(31==(0|A)?0:25-(A>>>1)|0),a=0;;){if((l=(-8&r[i+4>>2])-u|0)>>>0<o>>>0){if(!l){e=i,o=0,m=65;break e}e=i,o=l}if(a=!(0|(m=0|r[i+20>>2]))|(0|m)==(0|(i=0|r[i+16+(c>>>31<<2)>>2]))?a:m,!i){i=a,m=61;break}c<<=1}else i=0,e=0,m=61}while(0);if(61==(0|m)){if(!(0|i)&!(0|e)){if(!(e=((e=2<<A)|0-e)&s)){d=u;break}d=(e&0-e)-1|0,e=0,i=0|r[27988+(((a=(d>>>=l=d>>>12&16)>>>5&8)|l|(c=(d>>>=a)>>>2&4)|(A=(d>>>=c)>>>1&2)|(i=(d>>>=A)>>>1&1))+(d>>>i)<<2)>>2]}i?m=65:(c=e,l=o)}if(65==(0|m))for(a=i;;){if(o=(i=(d=(-8&r[a+4>>2])-u|0)>>>0<o>>>0)?d:o,e=i?a:e,(i=0|r[a+16>>2])||(i=0|r[a+20>>2]),!i){c=e,l=o;break}a=i}if(0|c&&l>>>0<((0|r[6923])-u|0)>>>0&&(h=c+u|0)>>>0>c>>>0){a=0|r[c+24>>2],n=0|r[c+12>>2];do{if((0|n)==(0|c)){if(!(n=0|r[(e=c+20|0)>>2])&&!(n=0|r[(e=c+16|0)>>2])){n=0;break}for(;;)if(i=0|r[(o=n+20|0)>>2])n=i,e=o;else{if(!(i=0|r[(o=n+16|0)>>2]))break;n=i,e=o}r[e>>2]=0}else w=0|r[c+8>>2],r[w+12>>2]=n,r[n+8>>2]=w}while(0);do{if(a){if(e=0|r[c+28>>2],(0|c)==(0|r[(i=27988+(e<<2)|0)>>2])){if(r[i>>2]=n,!n){s&=~(1<<e),r[6922]=s;break}}else if(r[((0|r[(w=a+16|0)>>2])==(0|c)?w:a+20)>>2]=n,!n)break;r[n+24>>2]=a,0|(e=0|r[c+16>>2])&&(r[n+16>>2]=e,r[e+24>>2]=n),(e=0|r[c+20>>2])&&(r[n+20>>2]=e,r[e+24>>2]=n)}}while(0);e:do{if(l>>>0<16)w=l+u|0,r[c+4>>2]=3|w,r[(w=c+w+4|0)>>2]=1|r[w>>2];else{if(r[c+4>>2]=3|u,r[h+4>>2]=1|l,r[h+l>>2]=l,n=l>>>3,l>>>0<256){i=27724+(n<<1<<2)|0,(e=0|r[6921])&(n=1<<n)?n=0|r[(e=i+8|0)>>2]:(r[6921]=e|n,n=i,e=i+8|0),r[e>>2]=h,r[n+12>>2]=h,r[h+8>>2]=n,r[h+12>>2]=i;break}if(n=27988+((i=(n=l>>>8)?l>>>0>16777215?31:l>>>((i=14-((v=((w=n<<(y=(n+1048320|0)>>>16&8))+520192|0)>>>16&4)|y|(i=((w<<=v)+245760|0)>>>16&2))+(w<<i>>>15)|0)+7|0)&1|i<<1:0)<<2)|0,r[h+28>>2]=i,r[(e=h+16|0)+4>>2]=0,r[e>>2]=0,!(s&(e=1<<i))){r[6922]=s|e,r[n>>2]=h,r[h+24>>2]=n,r[h+12>>2]=h,r[h+8>>2]=h;break}n=0|r[n>>2];t:do{if((-8&r[n+4>>2])!=(0|l)){for(s=l<<(31==(0|i)?0:25-(i>>>1)|0);e=0|r[(i=n+16+(s>>>31<<2)|0)>>2];){if((-8&r[e+4>>2])==(0|l)){n=e;break t}s<<=1,n=e}r[i>>2]=h,r[h+24>>2]=n,r[h+12>>2]=h,r[h+8>>2]=h;break e}}while(0);w=0|r[(y=n+8|0)>>2],r[w+12>>2]=h,r[y>>2]=h,r[h+8>>2]=w,r[h+12>>2]=n,r[h+24>>2]=0}}while(0);return I=t,0|(w=c+8|0)}d=u}else d=u;else d=-1}while(0);if((i=0|r[6923])>>>0>=d>>>0)return n=i-d|0,e=0|r[6926],n>>>0>15?(w=e+d|0,r[6926]=w,r[6923]=n,r[w+4>>2]=1|n,r[e+i>>2]=n,r[e+4>>2]=3|d):(r[6923]=0,r[6926]=0,r[e+4>>2]=3|i,r[(w=e+i+4|0)>>2]=1|r[w>>2]),I=t,0|(w=e+8|0);if((l=0|r[6924])>>>0>d>>>0)return v=l-d|0,r[6924]=v,y=(w=0|r[6927])+d|0,r[6927]=y,r[y+4>>2]=1|v,r[w+4>>2]=3|d,I=t,0|(w=w+8|0);if(0|r[7039]?e=0|r[7041]:(r[7041]=4096,r[7040]=4096,r[7042]=-1,r[7043]=-1,r[7044]=0,r[7032]=0,r[7039]=-16&f^1431655768,e=4096),c=d+48|0,(u=(a=e+(A=d+47|0)|0)&(o=0-e|0))>>>0<=d>>>0)return I=t,0|(w=0);if(0|(e=0|r[7031])&&(f=(h=0|r[7029])+u|0)>>>0<=h>>>0|f>>>0>e>>>0)return I=t,0|(w=0);e:do{if(4&r[7032])n=0,m=143;else{i=0|r[6927];t:do{if(i){for(s=28132;!((f=0|r[s>>2])>>>0<=i>>>0&&(f+(0|r[s+4>>2])|0)>>>0>i>>>0);){if(!(e=0|r[s+8>>2])){m=128;break t}s=e}if((n=a-l&o)>>>0<2147483647)if((0|(e=0|$t(0|n)))==((0|r[s>>2])+(0|r[s+4>>2])|0)){if(-1!=(0|e)){l=n,a=e,m=145;break e}}else s=e,m=136;else n=0}else m=128}while(0);do{if(128==(0|m))if(-1!=(0|(i=0|$t(0)))&&(n=i,g=(n=((g=(p=0|r[7040])+-1|0)&n|0?(g+n&0-p)-n|0:0)+u|0)+(p=0|r[7029])|0,n>>>0>d>>>0&n>>>0<2147483647)){if(0|(f=0|r[7031])&&g>>>0<=p>>>0|g>>>0>f>>>0){n=0;break}if((0|(e=0|$t(0|n)))==(0|i)){l=n,a=i,m=145;break e}s=e,m=136}else n=0}while(0);do{if(136==(0|m)){if(i=0-n|0,!(c>>>0>n>>>0&n>>>0<2147483647&-1!=(0|s))){if(-1==(0|s)){n=0;break}l=n,a=s,m=145;break e}if((e=A-n+(e=0|r[7041])&0-e)>>>0>=2147483647){l=n,a=s,m=145;break e}if(-1==(0|$t(0|e))){$t(0|i),n=0;break}l=e+n|0,a=s,m=145;break e}}while(0);r[7032]=4|r[7032],m=143}}while(0);if(143==(0|m)&&u>>>0<2147483647&&!(-1==(0|(v=0|$t(0|u)))|1^(_=(b=(g=0|$t(0))-v|0)>>>0>(d+40|0)>>>0)|v>>>0<g>>>0&-1!=(0|v)&-1!=(0|g)^1)&&(l=_?b:n,a=v,m=145),145==(0|m)){n=(0|r[7029])+l|0,r[7029]=n,n>>>0>(0|r[7030])>>>0&&(r[7030]=n),A=0|r[6927];e:do{if(A){for(n=28132;;){if((0|a)==((e=0|r[n>>2])+(i=0|r[n+4>>2])|0)){m=154;break}if(!(s=0|r[n+8>>2]))break;n=s}if(!(154!=(0|m)||(y=n+4|0,8&r[n+12>>2]))&&a>>>0>A>>>0&e>>>0<=A>>>0){r[y>>2]=i+l,y=A+(v=7&(v=A+8|0)?0-v&7:0)|0,v=(w=(0|r[6924])+l|0)-v|0,r[6927]=y,r[6924]=v,r[y+4>>2]=1|v,r[A+w+4>>2]=40,r[6928]=r[7043];break}for(a>>>0<(0|r[6925])>>>0&&(r[6925]=a),i=a+l|0,n=28132;;){if((0|r[n>>2])==(0|i)){m=162;break}if(!(e=0|r[n+8>>2]))break;n=e}if(162==(0|m)&&!(8&r[n+12>>2])){r[n>>2]=a,r[(h=n+4|0)>>2]=(0|r[h>>2])+l,u=(h=a+(7&(h=a+8|0)?0-h&7:0)|0)+d|0,c=(n=i+(7&(n=i+8|0)?0-n&7:0)|0)-h-d|0,r[h+4>>2]=3|d;t:do{if((0|A)==(0|n))w=(0|r[6924])+c|0,r[6924]=w,r[6927]=u,r[u+4>>2]=1|w;else{if((0|r[6926])==(0|n)){w=(0|r[6923])+c|0,r[6923]=w,r[6926]=u,r[u+4>>2]=1|w,r[u+w>>2]=w;break}if(1==(3&(e=0|r[n+4>>2]))){l=-8&e,s=e>>>3;n:do{if(e>>>0<256){if(e=0|r[n+8>>2],(0|(i=0|r[n+12>>2]))==(0|e)){r[6921]=r[6921]&~(1<<s);break}r[e+12>>2]=i,r[i+8>>2]=e;break}a=0|r[n+24>>2],e=0|r[n+12>>2];do{if((0|e)==(0|n)){if(e=0|r[(s=(i=n+16|0)+4|0)>>2])i=s;else if(!(e=0|r[i>>2])){e=0;break}for(;;)if(s=0|r[(o=e+20|0)>>2])e=s,i=o;else{if(!(s=0|r[(o=e+16|0)>>2]))break;e=s,i=o}r[i>>2]=0}else w=0|r[n+8>>2],r[w+12>>2]=e,r[e+8>>2]=w}while(0);if(!a)break;s=27988+((i=0|r[n+28>>2])<<2)|0;do{if((0|r[s>>2])==(0|n)){if(r[s>>2]=e,0|e)break;r[6922]=r[6922]&~(1<<i);break n}if(r[((0|r[(w=a+16|0)>>2])==(0|n)?w:a+20)>>2]=e,!e)break n}while(0);if(r[e+24>>2]=a,0|(s=0|r[(i=n+16|0)>>2])&&(r[e+16>>2]=s,r[s+24>>2]=e),!(i=0|r[i+4>>2]))break;r[e+20>>2]=i,r[i+24>>2]=e}while(0);n=n+l|0,o=l+c|0}else o=c;if(r[(n=n+4|0)>>2]=-2&r[n>>2],r[u+4>>2]=1|o,r[u+o>>2]=o,n=o>>>3,o>>>0<256){i=27724+(n<<1<<2)|0,(e=0|r[6921])&(n=1<<n)?n=0|r[(e=i+8|0)>>2]:(r[6921]=e|n,n=i,e=i+8|0),r[e>>2]=u,r[n+12>>2]=u,r[u+8>>2]=n,r[u+12>>2]=i;break}n=o>>>8;do{if(n){if(o>>>0>16777215){s=31;break}s=o>>>((s=14-((v=((w=n<<(y=(n+1048320|0)>>>16&8))+520192|0)>>>16&4)|y|(s=((w<<=v)+245760|0)>>>16&2))+(w<<s>>>15)|0)+7|0)&1|s<<1}else s=0}while(0);if(n=27988+(s<<2)|0,r[u+28>>2]=s,r[(e=u+16|0)+4>>2]=0,r[e>>2]=0,!((e=0|r[6922])&(i=1<<s))){r[6922]=e|i,r[n>>2]=u,r[u+24>>2]=n,r[u+12>>2]=u,r[u+8>>2]=u;break}n=0|r[n>>2];n:do{if((-8&r[n+4>>2])!=(0|o)){for(s=o<<(31==(0|s)?0:25-(s>>>1)|0);e=0|r[(i=n+16+(s>>>31<<2)|0)>>2];){if((-8&r[e+4>>2])==(0|o)){n=e;break n}s<<=1,n=e}r[i>>2]=u,r[u+24>>2]=n,r[u+12>>2]=u,r[u+8>>2]=u;break t}}while(0);w=0|r[(y=n+8|0)>>2],r[w+12>>2]=u,r[y>>2]=u,r[u+8>>2]=w,r[u+12>>2]=n,r[u+24>>2]=0}}while(0);return I=t,0|(w=h+8|0)}for(n=28132;!((e=0|r[n>>2])>>>0<=A>>>0&&(w=e+(0|r[n+4>>2])|0)>>>0>A>>>0);)n=0|r[n+8>>2];n=(e=(e=(o=w+-47|0)+(7&(e=o+8|0)?0-e&7:0)|0)>>>0<(o=A+16|0)>>>0?A:e)+8|0,y=a+(v=7&(v=a+8|0)?0-v&7:0)|0,v=(i=l+-40|0)-v|0,r[6927]=y,r[6924]=v,r[y+4>>2]=1|v,r[a+i+4>>2]=40,r[6928]=r[7043],r[(i=e+4|0)>>2]=27,r[n>>2]=r[7033],r[n+4>>2]=r[7034],r[n+8>>2]=r[7035],r[n+12>>2]=r[7036],r[7033]=a,r[7034]=l,r[7036]=0,r[7035]=n,n=e+24|0;do{y=n,r[(n=n+4|0)>>2]=7}while((y+8|0)>>>0<w>>>0);if((0|e)!=(0|A)){if(a=e-A|0,r[i>>2]=-2&r[i>>2],r[A+4>>2]=1|a,r[e>>2]=a,n=a>>>3,a>>>0<256){i=27724+(n<<1<<2)|0,(e=0|r[6921])&(n=1<<n)?n=0|r[(e=i+8|0)>>2]:(r[6921]=e|n,n=i,e=i+8|0),r[e>>2]=A,r[n+12>>2]=A,r[A+8>>2]=n,r[A+12>>2]=i;break}if(i=27988+((s=(n=a>>>8)?a>>>0>16777215?31:a>>>((s=14-((v=((w=n<<(y=(n+1048320|0)>>>16&8))+520192|0)>>>16&4)|y|(s=((w<<=v)+245760|0)>>>16&2))+(w<<s>>>15)|0)+7|0)&1|s<<1:0)<<2)|0,r[A+28>>2]=s,r[A+20>>2]=0,r[o>>2]=0,!((n=0|r[6922])&(e=1<<s))){r[6922]=n|e,r[i>>2]=A,r[A+24>>2]=i,r[A+12>>2]=A,r[A+8>>2]=A;break}n=0|r[i>>2];t:do{if((-8&r[n+4>>2])!=(0|a)){for(s=a<<(31==(0|s)?0:25-(s>>>1)|0);e=0|r[(i=n+16+(s>>>31<<2)|0)>>2];){if((-8&r[e+4>>2])==(0|a)){n=e;break t}s<<=1,n=e}r[i>>2]=A,r[A+24>>2]=n,r[A+12>>2]=A,r[A+8>>2]=A;break e}}while(0);w=0|r[(y=n+8|0)>>2],r[w+12>>2]=A,r[y>>2]=A,r[A+8>>2]=w,r[A+12>>2]=n,r[A+24>>2]=0}}else!(0|(w=0|r[6925]))|a>>>0<w>>>0&&(r[6925]=a),r[7033]=a,r[7034]=l,r[7036]=0,r[6930]=r[7039],r[6929]=-1,r[6934]=27724,r[6933]=27724,r[6936]=27732,r[6935]=27732,r[6938]=27740,r[6937]=27740,r[6940]=27748,r[6939]=27748,r[6942]=27756,r[6941]=27756,r[6944]=27764,r[6943]=27764,r[6946]=27772,r[6945]=27772,r[6948]=27780,r[6947]=27780,r[6950]=27788,r[6949]=27788,r[6952]=27796,r[6951]=27796,r[6954]=27804,r[6953]=27804,r[6956]=27812,r[6955]=27812,r[6958]=27820,r[6957]=27820,r[6960]=27828,r[6959]=27828,r[6962]=27836,r[6961]=27836,r[6964]=27844,r[6963]=27844,r[6966]=27852,r[6965]=27852,r[6968]=27860,r[6967]=27860,r[6970]=27868,r[6969]=27868,r[6972]=27876,r[6971]=27876,r[6974]=27884,r[6973]=27884,r[6976]=27892,r[6975]=27892,r[6978]=27900,r[6977]=27900,r[6980]=27908,r[6979]=27908,r[6982]=27916,r[6981]=27916,r[6984]=27924,r[6983]=27924,r[6986]=27932,r[6985]=27932,r[6988]=27940,r[6987]=27940,r[6990]=27948,r[6989]=27948,r[6992]=27956,r[6991]=27956,r[6994]=27964,r[6993]=27964,r[6996]=27972,r[6995]=27972,y=a+(v=7&(v=a+8|0)?0-v&7:0)|0,v=(w=l+-40|0)-v|0,r[6927]=y,r[6924]=v,r[y+4>>2]=1|v,r[a+w+4>>2]=40,r[6928]=r[7043]}while(0);if((n=0|r[6924])>>>0>d>>>0)return v=n-d|0,r[6924]=v,y=(w=0|r[6927])+d|0,r[6927]=y,r[y+4>>2]=1|v,r[w+4>>2]=3|d,I=t,0|(w=w+8|0)}return r[(w=27680)>>2]=12,I=t,0|(w=0)}function Ct(e){var t=0,n=0,i=0,s=0,o=0,a=0,l=0,c=0;if(e|=0){n=e+-8|0,s=0|r[6925],c=n+(t=-8&(e=0|r[e+-4>>2]))|0;do{if(1&e)l=n,a=n;else{if(i=0|r[n>>2],!(3&e))return;if(o=i+t|0,(a=n+(0-i)|0)>>>0<s>>>0)return;if((0|r[6926])==(0|a)){if(3&~(t=0|r[(e=c+4|0)>>2])){l=a,t=o;break}return r[6923]=o,r[e>>2]=-2&t,r[a+4>>2]=1|o,void(r[a+o>>2]=o)}if(n=i>>>3,i>>>0<256){if(e=0|r[a+8>>2],(0|(t=0|r[a+12>>2]))==(0|e)){r[6921]=r[6921]&~(1<<n),l=a,t=o;break}r[e+12>>2]=t,r[t+8>>2]=e,l=a,t=o;break}s=0|r[a+24>>2],e=0|r[a+12>>2];do{if((0|e)==(0|a)){if(e=0|r[(n=(t=a+16|0)+4|0)>>2])t=n;else if(!(e=0|r[t>>2])){e=0;break}for(;;)if(n=0|r[(i=e+20|0)>>2])e=n,t=i;else{if(!(n=0|r[(i=e+16|0)>>2]))break;e=n,t=i}r[t>>2]=0}else l=0|r[a+8>>2],r[l+12>>2]=e,r[e+8>>2]=l}while(0);if(s){if(t=0|r[a+28>>2],(0|r[(n=27988+(t<<2)|0)>>2])==(0|a)){if(r[n>>2]=e,!e){r[6922]=r[6922]&~(1<<t),l=a,t=o;break}}else if(r[((0|r[(l=s+16|0)>>2])==(0|a)?l:s+20)>>2]=e,!e){l=a,t=o;break}r[e+24>>2]=s,0|(n=0|r[(t=a+16|0)>>2])&&(r[e+16>>2]=n,r[n+24>>2]=e),(t=0|r[t+4>>2])?(r[e+20>>2]=t,r[t+24>>2]=e,l=a,t=o):(l=a,t=o)}else l=a,t=o}}while(0);if(!(a>>>0>=c>>>0)&&1&(i=0|r[(e=c+4|0)>>2])){if(2&i)r[e>>2]=-2&i,r[l+4>>2]=1|t,r[a+t>>2]=t,s=t;else{if((0|r[6927])==(0|c)){if(c=(0|r[6924])+t|0,r[6924]=c,r[6927]=l,r[l+4>>2]=1|c,(0|l)!=(0|r[6926]))return;return r[6926]=0,void(r[6923]=0)}if((0|r[6926])==(0|c))return c=(0|r[6923])+t|0,r[6923]=c,r[6926]=a,r[l+4>>2]=1|c,void(r[a+c>>2]=c);s=(-8&i)+t|0,n=i>>>3;do{if(i>>>0<256){if(t=0|r[c+8>>2],(0|(e=0|r[c+12>>2]))==(0|t)){r[6921]=r[6921]&~(1<<n);break}r[t+12>>2]=e,r[e+8>>2]=t;break}o=0|r[c+24>>2],e=0|r[c+12>>2];do{if((0|e)==(0|c)){if(e=0|r[(n=(t=c+16|0)+4|0)>>2])t=n;else if(!(e=0|r[t>>2])){n=0;break}for(;;)if(n=0|r[(i=e+20|0)>>2])e=n,t=i;else{if(!(n=0|r[(i=e+16|0)>>2]))break;e=n,t=i}r[t>>2]=0,n=e}else n=0|r[c+8>>2],r[n+12>>2]=e,r[e+8>>2]=n,n=e}while(0);if(0|o){if(e=0|r[c+28>>2],(0|r[(t=27988+(e<<2)|0)>>2])==(0|c)){if(r[t>>2]=n,!n){r[6922]=r[6922]&~(1<<e);break}}else if(r[((0|r[(i=o+16|0)>>2])==(0|c)?i:o+20)>>2]=n,!n)break;r[n+24>>2]=o,0|(t=0|r[(e=c+16|0)>>2])&&(r[n+16>>2]=t,r[t+24>>2]=n),0|(e=0|r[e+4>>2])&&(r[n+20>>2]=e,r[e+24>>2]=n)}}while(0);if(r[l+4>>2]=1|s,r[a+s>>2]=s,(0|l)==(0|r[6926]))return void(r[6923]=s)}if(e=s>>>3,s>>>0<256)return n=27724+(e<<1<<2)|0,(t=0|r[6921])&(e=1<<e)?e=0|r[(t=n+8|0)>>2]:(r[6921]=t|e,e=n,t=n+8|0),r[t>>2]=l,r[e+12>>2]=l,r[l+8>>2]=e,void(r[l+12>>2]=n);e=27988+((i=(e=s>>>8)?s>>>0>16777215?31:s>>>((i=14-((o=((c=e<<(a=(e+1048320|0)>>>16&8))+520192|0)>>>16&4)|a|(i=((c<<=o)+245760|0)>>>16&2))+(c<<i>>>15)|0)+7|0)&1|i<<1:0)<<2)|0,r[l+28>>2]=i,r[l+20>>2]=0,r[l+16>>2]=0,t=0|r[6922],n=1<<i;e:do{if(t&n){e=0|r[e>>2];t:do{if((-8&r[e+4>>2])!=(0|s)){for(i=s<<(31==(0|i)?0:25-(i>>>1)|0);t=0|r[(n=e+16+(i>>>31<<2)|0)>>2];){if((-8&r[t+4>>2])==(0|s)){e=t;break t}i<<=1,e=t}r[n>>2]=l,r[l+24>>2]=e,r[l+12>>2]=l,r[l+8>>2]=l;break e}}while(0);c=0|r[(a=e+8|0)>>2],r[c+12>>2]=l,r[a>>2]=l,r[l+8>>2]=c,r[l+12>>2]=e,r[l+24>>2]=0}else r[6922]=t|n,r[e>>2]=l,r[l+24>>2]=e,r[l+12>>2]=l,r[l+8>>2]=l}while(0);if(c=(0|r[6929])-1|0,r[6929]=c,!(0|c)){for(e=28140;e=0|r[e>>2];)e=e+8|0;r[6929]=-1}}}}function Pt(e,t){t|=0;var n=0;return(e|=0)?(n=0|_(t,e),(t|e)>>>0>65535&&(n=((n>>>0)/(e>>>0)|0)==(0|t)?n:-1)):n=0,(e=0|St(n))&&3&r[e+-4>>2]?(Qt(0|e,0,0|n),0|e):0|e}function Rt(e,t){t|=0;var n=0,i=0;return(e|=0)?t>>>0>4294967231?(r[(t=27680)>>2]=12,0|(t=0)):(n=0|function(e,t){e|=0,t|=0;var n=0,i=0,s=0,o=0,a=0,l=0,c=0,A=0,u=0,h=0;if(u=e+4|0,h=0|r[u>>2],n=-8&h,l=e+n|0,!(3&h))return t>>>0<256?0|(e=0):n>>>0>=(t+4|0)>>>0&&(n-t|0)>>>0<=r[7041]<<1>>>0?0|e:0|(e=0);if(n>>>0>=t>>>0)return(n=n-t|0)>>>0<=15||(A=e+t|0,r[u>>2]=1&h|t|2,r[A+4>>2]=3|n,r[(h=l+4|0)>>2]=1|r[h>>2],Mt(A,n)),0|e;if((0|r[6927])==(0|l))return n=(A=(0|r[6924])+n|0)-t|0,i=e+t|0,A>>>0<=t>>>0?0|(e=0):(r[u>>2]=1&h|t|2,r[i+4>>2]=1|n,r[6927]=i,r[6924]=n,0|e);if((0|r[6926])==(0|l))return(i=(0|r[6923])+n|0)>>>0<t>>>0?0|(e=0):((n=i-t|0)>>>0>15?(A=e+t|0,i=e+i|0,r[u>>2]=1&h|t|2,r[A+4>>2]=1|n,r[i>>2]=n,r[(i=i+4|0)>>2]=-2&r[i>>2],i=A):(r[u>>2]=1&h|i|2,r[(i=e+i+4|0)>>2]=1|r[i>>2],i=0,n=0),r[6923]=n,r[6926]=i,0|e);if(i=0|r[l+4>>2],2&i)return 0|(e=0);if(c=(-8&i)+n|0,c>>>0<t>>>0)return 0|(e=0);A=c-t|0,s=i>>>3;do{if(i>>>0<256){if(i=0|r[l+8>>2],(0|(n=0|r[l+12>>2]))==(0|i)){r[6921]=r[6921]&~(1<<s);break}r[i+12>>2]=n,r[n+8>>2]=i;break}a=0|r[l+24>>2],n=0|r[l+12>>2];do{if((0|n)==(0|l)){if(n=0|r[(s=(i=l+16|0)+4|0)>>2])i=s;else if(!(n=0|r[i>>2])){s=0;break}for(;;)if(s=0|r[(o=n+20|0)>>2])n=s,i=o;else{if(!(s=0|r[(o=n+16|0)>>2]))break;n=s,i=o}r[i>>2]=0,s=n}else s=0|r[l+8>>2],r[s+12>>2]=n,r[n+8>>2]=s,s=n}while(0);if(0|a){if(n=0|r[l+28>>2],(0|r[(i=27988+(n<<2)|0)>>2])==(0|l)){if(r[i>>2]=s,!s){r[6922]=r[6922]&~(1<<n);break}}else if(r[((0|r[(o=a+16|0)>>2])==(0|l)?o:a+20)>>2]=s,!s)break;r[s+24>>2]=a,0|(i=0|r[(n=l+16|0)>>2])&&(r[s+16>>2]=i,r[i+24>>2]=s),0|(n=0|r[n+4>>2])&&(r[s+20>>2]=n,r[n+24>>2]=s)}}while(0);return A>>>0<16?(r[u>>2]=1&h|c|2,r[(h=e+c+4|0)>>2]=1|r[h>>2],0|e):(l=e+t|0,r[u>>2]=1&h|t|2,r[l+4>>2]=3|A,r[(h=e+c+4|0)>>2]=1|r[h>>2],Mt(l,A),0|e)}(e+-8|0,t>>>0<11?16:t+11&-8),0|n?0|(t=n+8|0):(n=0|St(t))?(qt(0|n,0|e,0|((i=(-8&(i=0|r[e+-4>>2]))-(3&i?4:8)|0)>>>0<t>>>0?i:t)),Ct(e),0|(t=n)):0|(t=0)):0|(t=0|St(t))}function Mt(e,t){var n=0,i=0,s=0,o=0,a=0,l=0;l=(e|=0)+(t|=0)|0,n=0|r[e+4>>2];do{if(1&n)a=e;else{if(s=0|r[e>>2],!(3&n))return;if(a=e+(0-s)|0,t=s+t|0,(0|r[6926])==(0|a)){if(3&~(n=0|r[(e=l+4|0)>>2]))break;return r[6923]=t,r[e>>2]=-2&n,r[a+4>>2]=1|t,void(r[l>>2]=t)}if(i=s>>>3,s>>>0<256){if(e=0|r[a+8>>2],(0|(n=0|r[a+12>>2]))==(0|e)){r[6921]=r[6921]&~(1<<i);break}r[e+12>>2]=n,r[n+8>>2]=e;break}o=0|r[a+24>>2],e=0|r[a+12>>2];do{if((0|e)==(0|a)){if(e=0|r[(i=(n=a+16|0)+4|0)>>2])n=i;else if(!(e=0|r[n>>2])){e=0;break}for(;;)if(i=0|r[(s=e+20|0)>>2])e=i,n=s;else{if(!(i=0|r[(s=e+16|0)>>2]))break;e=i,n=s}r[n>>2]=0}else s=0|r[a+8>>2],r[s+12>>2]=e,r[e+8>>2]=s}while(0);if(o){if(n=0|r[a+28>>2],(0|r[(i=27988+(n<<2)|0)>>2])==(0|a)){if(r[i>>2]=e,!e){r[6922]=r[6922]&~(1<<n);break}}else if(r[((0|r[(s=o+16|0)>>2])==(0|a)?s:o+20)>>2]=e,!e)break;r[e+24>>2]=o,0|(i=0|r[(n=a+16|0)>>2])&&(r[e+16>>2]=i,r[i+24>>2]=e),(n=0|r[n+4>>2])&&(r[e+20>>2]=n,r[n+24>>2]=e)}}}while(0);if(2&(i=0|r[(e=l+4|0)>>2]))r[e>>2]=-2&i,r[a+4>>2]=1|t,r[a+t>>2]=t,s=t;else{if((0|r[6927])==(0|l)){if(l=(0|r[6924])+t|0,r[6924]=l,r[6927]=a,r[a+4>>2]=1|l,(0|a)!=(0|r[6926]))return;return r[6926]=0,void(r[6923]=0)}if((0|r[6926])==(0|l))return l=(0|r[6923])+t|0,r[6923]=l,r[6926]=a,r[a+4>>2]=1|l,void(r[a+l>>2]=l);s=(-8&i)+t|0,n=i>>>3;do{if(i>>>0<256){if(e=0|r[l+8>>2],(0|(t=0|r[l+12>>2]))==(0|e)){r[6921]=r[6921]&~(1<<n);break}r[e+12>>2]=t,r[t+8>>2]=e;break}o=0|r[l+24>>2],t=0|r[l+12>>2];do{if((0|t)==(0|l)){if(t=0|r[(n=(e=l+16|0)+4|0)>>2])e=n;else if(!(t=0|r[e>>2])){n=0;break}for(;;)if(n=0|r[(i=t+20|0)>>2])t=n,e=i;else{if(!(n=0|r[(i=t+16|0)>>2]))break;t=n,e=i}r[e>>2]=0,n=t}else n=0|r[l+8>>2],r[n+12>>2]=t,r[t+8>>2]=n,n=t}while(0);if(0|o){if(t=0|r[l+28>>2],(0|r[(e=27988+(t<<2)|0)>>2])==(0|l)){if(r[e>>2]=n,!n){r[6922]=r[6922]&~(1<<t);break}}else if(r[((0|r[(i=o+16|0)>>2])==(0|l)?i:o+20)>>2]=n,!n)break;r[n+24>>2]=o,0|(e=0|r[(t=l+16|0)>>2])&&(r[n+16>>2]=e,r[e+24>>2]=n),0|(t=0|r[t+4>>2])&&(r[n+20>>2]=t,r[t+24>>2]=n)}}while(0);if(r[a+4>>2]=1|s,r[a+s>>2]=s,(0|a)==(0|r[6926]))return void(r[6923]=s)}if(t=s>>>3,s>>>0<256)return n=27724+(t<<1<<2)|0,(e=0|r[6921])&(t=1<<t)?t=0|r[(e=n+8|0)>>2]:(r[6921]=e|t,t=n,e=n+8|0),r[e>>2]=a,r[t+12>>2]=a,r[a+8>>2]=t,void(r[a+12>>2]=n);if(t=27988+((i=(t=s>>>8)?s>>>0>16777215?31:s>>>((i=14-((n=((l=t<<(o=(t+1048320|0)>>>16&8))+520192|0)>>>16&4)|o|(i=((l<<=n)+245760|0)>>>16&2))+(l<<i>>>15)|0)+7|0)&1|i<<1:0)<<2)|0,r[a+28>>2]=i,r[a+20>>2]=0,r[a+16>>2]=0,!((e=0|r[6922])&(n=1<<i)))return r[6922]=e|n,r[t>>2]=a,r[a+24>>2]=t,r[a+12>>2]=a,void(r[a+8>>2]=a);t=0|r[t>>2];e:do{if((-8&r[t+4>>2])!=(0|s)){for(i=s<<(31==(0|i)?0:25-(i>>>1)|0);e=0|r[(n=t+16+(i>>>31<<2)|0)>>2];){if((-8&r[e+4>>2])==(0|s)){t=e;break e}i<<=1,t=e}return r[n>>2]=a,r[a+24>>2]=t,r[a+12>>2]=a,void(r[a+8>>2]=a)}}while(0);l=0|r[(o=t+8|0)>>2],r[l+12>>2]=a,r[o>>2]=a,r[a+8>>2]=l,r[a+12>>2]=t,r[a+24>>2]=0}function Lt(e,t,n,i){return 0|(T((t|=0)+(i|=0)+((n=(e|=0)+(n|=0)>>>0)>>>0<e>>>0|0)>>>0|0),n)}function It(e,t,n,i){return 0|(T(0|(i=(t|=0)-(i|=0)-((n|=0)>>>0>(e|=0)>>>0|0)>>>0)),e-n>>>0)}function Ot(e){return 0|((e|=0)?31-(0|w(e^e-1)):32)}function Bt(e,t,n,i,s){s|=0;var o=0,a=0,l=0,c=0,A=0,u=0,h=0,d=0,f=0,p=0;if(u=e|=0,a=n|=0,l=d=i|=0,!(A=c=t|=0))return o=!!(0|s),l?o?(r[s>>2]=0|e,r[s+4>>2]=0&t,s=0,0|(T(0|(d=0)),s)):(s=0,0|(T(0|(d=0)),s)):(o&&(r[s>>2]=(u>>>0)%(a>>>0),r[s+4>>2]=0),s=(u>>>0)/(a>>>0)>>>0,0|(T(0|(d=0)),s));o=!(0|l);do{if(a){if(!o){if((o=(0|w(0|l))-(0|w(0|A))|0)>>>0<=31){a=h=o+1|0,e=u>>>(h>>>0)&(t=o-31>>31)|A<<(l=31-o|0),t&=A>>>(h>>>0),o=0,l=u<<l;break}return s?(r[s>>2]=0|e,r[s+4>>2]=c|0&t,s=0,0|(T(0|(d=0)),s)):(s=0,0|(T(0|(d=0)),s))}if((o=a-1|0)&a|0){a=l=33+(0|w(0|a))-(0|w(0|A))|0,e=(h=32-l|0)-1>>31&A>>>((f=l-32|0)>>>0)|(A<<h|u>>>(l>>>0))&(t=f>>31),t&=A>>>(l>>>0),o=u<<(p=64-l|0)&(c=h>>31),l=(A<<p|u>>>(f>>>0))&c|u<<h&l-33>>31;break}return 0|s&&(r[s>>2]=o&u,r[s+4>>2]=0),1==(0|a)?(p=0|e,0|(T(0|(f=c|0&t)),p)):(f=A>>>((p=0|Ot(0|a))>>>0)|0,p=A<<32-p|u>>>(p>>>0),0|(T(0|f),p))}if(o)return 0|s&&(r[s>>2]=(A>>>0)%(a>>>0),r[s+4>>2]=0),p=(A>>>0)/(a>>>0)>>>0,0|(T(0|(f=0)),p);if(!u)return 0|s&&(r[s>>2]=0,r[s+4>>2]=(A>>>0)%(l>>>0)),p=(A>>>0)/(l>>>0)>>>0,0|(T(0|(f=0)),p);if(!((o=l-1|0)&l))return 0|s&&(r[s>>2]=0|e,r[s+4>>2]=o&A|0&t),f=0,p=A>>>((0|Ot(0|l))>>>0),0|(T(0|f),p);if((o=(0|w(0|l))-(0|w(0|A))|0)>>>0<=30){a=t=o+1|0,e=A<<(l=31-o|0)|u>>>(t>>>0),t=A>>>(t>>>0),o=0,l=u<<l;break}return s?(r[s>>2]=0|e,r[s+4>>2]=c|0&t,p=0,0|(T(0|(f=0)),p)):(p=0,0|(T(0|(f=0)),p))}while(0);if(a){A=0|Lt(0|(h=0|n),0|(u=d|0&i),-1,-1),n=0|E(),c=l,l=0;do{i=c,c=o>>>31|c<<1,o=l|o<<1,It(0|A,0|n,0|(i=e<<1|i>>>31),0|(d=e>>>31|t<<1)),l=1&(f=(p=0|E())>>31|((0|p)<0?-1:0)<<1),e=0|It(0|i,0|d,f&h|0,(((0|p)<0?-1:0)>>31|((0|p)<0?-1:0)<<1)&u),t=0|E(),a=a-1|0}while(0|a);A=c,c=0}else A=l,c=0,l=0;return a=0,0|s&&(r[s>>2]=e,r[s+4>>2]=t),p=o<<1&-2|l,0|(T(0|(f=(0|o)>>>31|(A|a)<<1|c)),p)}function Nt(e,t,n,i){n|=0;var r,s,o,a,l;return s=(i|=0)>>31|((0|i)<0?-1:0)<<1,r=((0|i)<0?-1:0)>>31|((0|i)<0?-1:0)<<1,o=0|It((l=(t|=0)>>31|((0|t)<0?-1:0)<<1)^(e|=0)|0,(a=((0|t)<0?-1:0)>>31|((0|t)<0?-1:0)<<1)^t|0,0|l,0|a),e=s^l,t=r^a,0|It((0|Bt(o,0|E(),0|It(s^n|0,r^i|0,0|s,0|r),0|E(),0))^e,(0|E())^t,0|e,0|t)}function kt(e,t,n,i){t|=0,i|=0;var r,s;return n=0|function(e,t){var n,i,r,s=0;return e=((n=0|_(s=65535&(t|=0),r=65535&(e|=0)))>>>16)+(0|_(s,i=e>>>16))|0,t=0|_(s=t>>>16,r),0|(T((e>>>16)+(0|_(s,i))+(((65535&e)+t|0)>>>16)|0),e+t<<16|65535&n)}(r=e|=0,s=n|=0),e=0|E(),0|(T((0|_(t,s))+(0|_(i,r))+e|0&e),n)}function Ft(e,t,n,i){n|=0;var s,o,a,l,c,A;return s=I,I=I+16|0,l=0|s,A=(i|=0)>>31|((0|i)<0?-1:0)<<1,c=((0|i)<0?-1:0)>>31|((0|i)<0?-1:0)<<1,Bt(e=0|It((a=(t|=0)>>31|((0|t)<0?-1:0)<<1)^(e|=0)|0,(o=((0|t)<0?-1:0)>>31|((0|t)<0?-1:0)<<1)^t|0,0|a,0|o),t=0|E(),0|It(A^n|0,c^i|0,0|A,0|c),0|E(),l),i=0|It(r[l>>2]^a|0,r[l+4>>2]^o|0,0|a,0|o),n=0|E(),I=s,0|(T(0|n),i)}function Dt(e,t,n,i){var s,o;return o=I,I=I+16|0,Bt(e|=0,t|=0,n|=0,i|=0,s=0|o),I=o,0|(T(0|r[s+4>>2]),r[s>>2])}function Ut(e,t,n){return e|=0,t|=0,(0|(n|=0))<32?(T(t>>n|0),e>>>n|(t&(1<<n)-1)<<32-n):(T(0|((0|t)<0?-1:0)),t>>n-32)}function Vt(e,t,n){return e|=0,t|=0,(0|(n|=0))<32?(T(t>>>n|0),e>>>n|(t&(1<<n)-1)<<32-n):(T(0),t>>>n-32|0)}function zt(e,t,n){return e|=0,t|=0,(0|(n|=0))<32?(T(t<<n|(e&(1<<n)-1<<32-n)>>>32-n),e<<n):(T(e<<n-32),0)}function Gt(e,t,n){return e|=0,32==(0|(t=0|w(t|=0)))&&(t=t+(0|w(e))|0),T(0),0|t}function jt(e,t){return t=+t,(e=+e)!=e?+t:t!=t?+e:+y(+e,+t)}function Ht(e,t){return t=+t,(e=+e)!=e?+t:t!=t?+e:+v(+e,+t)}function Wt(e){return(e=+e)>=0?+l(e+.5):+b(e-.5)}function qt(e,t,n){e|=0,t|=0;var s,o,a=0;if((0|(n|=0))>=8192)return R(0|e,0|t,0|n),0|e;if(o=0|e,s=e+n|0,(3&e)==(3&t)){for(;3&e;){if(!n)return 0|o;i[e|0]=0|i[t|0],e=e+1|0,t=t+1|0,n=n-1|0}for(a=(n=-4&s)-64|0;(0|e)<=(0|a);)r[e>>2]=r[t>>2],r[e+4>>2]=r[t+4>>2],r[e+8>>2]=r[t+8>>2],r[e+12>>2]=r[t+12>>2],r[e+16>>2]=r[t+16>>2],r[e+20>>2]=r[t+20>>2],r[e+24>>2]=r[t+24>>2],r[e+28>>2]=r[t+28>>2],r[e+32>>2]=r[t+32>>2],r[e+36>>2]=r[t+36>>2],r[e+40>>2]=r[t+40>>2],r[e+44>>2]=r[t+44>>2],r[e+48>>2]=r[t+48>>2],r[e+52>>2]=r[t+52>>2],r[e+56>>2]=r[t+56>>2],r[e+60>>2]=r[t+60>>2],e=e+64|0,t=t+64|0;for(;(0|e)<(0|n);)r[e>>2]=r[t>>2],e=e+4|0,t=t+4|0}else for(n=s-4|0;(0|e)<(0|n);)i[e|0]=0|i[t|0],i[e+1|0]=0|i[t+1|0],i[e+2|0]=0|i[t+2|0],i[e+3|0]=0|i[t+3|0],e=e+4|0,t=t+4|0;for(;(0|e)<(0|s);)i[e|0]=0|i[t|0],e=e+1|0,t=t+1|0;return 0|o}function Kt(e,t,n){var r=0;if((0|(t|=0))<(0|(e|=0))&(0|e)<(t+(n|=0)|0)){for(r=e,t=t+n|0,e=e+n|0;(0|n)>0;)t=t-1|0,n=n-1|0,i[(e=e-1|0)|0]=0|i[t|0];e=r}else qt(e,t,n);return 0|e}function Qt(e,t,n){t|=0;var s,o=0,a=0,l=0;if(s=(e|=0)+(n|=0)|0,t&=255,(0|n)>=67){for(;3&e;)i[e|0]=t,e=e+1|0;for(l=t|t<<8|t<<16|t<<24,a=(o=-4&s)-64|0;(0|e)<=(0|a);)r[e>>2]=l,r[e+4>>2]=l,r[e+8>>2]=l,r[e+12>>2]=l,r[e+16>>2]=l,r[e+20>>2]=l,r[e+24>>2]=l,r[e+28>>2]=l,r[e+32>>2]=l,r[e+36>>2]=l,r[e+40>>2]=l,r[e+44>>2]=l,r[e+48>>2]=l,r[e+52>>2]=l,r[e+56>>2]=l,r[e+60>>2]=l,e=e+64|0;for(;(0|e)<(0|o);)r[e>>2]=l,e=e+4|0}for(;(0|e)<(0|s);)i[e|0]=t,e=e+1|0;return s-n|0}function Xt(e){return(e=+e)>=0?+l(e+.5):+b(e-.5)}function $t(e){e|=0;var t,n,i;return i=0|P(),(0|e)>0&(0|(t=(n=0|r[a>>2])+e|0))<(0|n)|(0|t)<0?(L(0|t),C(12),-1):(0|t)>(0|i)&&!(0|M(0|t))?(C(12),-1):(r[a>>2]=t,0|n)}var Zt=[function(e,t){return x(0),0},function(e,t){t|=0;var n=0,i=0;return e=0|r[(i=e|=0)>>2],i=0|r[i+4>>2],t=0|r[(n=t)>>2],0|(i>>>0<(n=0|r[n+4>>2])>>>0|(0|i)==(0|n)&e>>>0<t>>>0?-1:1&(i>>>0>n>>>0|(0|i)==(0|n)&e>>>0>t>>>0))},function(e,t){t|=0;var n,i,o,a,l=0,c=0;return a=0|r[(c=e|=0)>>2],c=0|r[c+4>>2],o=0|r[(l=t)>>2],c>>>0<(l=0|r[l+4>>2])>>>0|(0|c)==(0|l)&a>>>0<o>>>0?0|(t=-1):c>>>0>l>>>0|(0|c)==(0|l)&a>>>0>o>>>0?0|(t=1):(i=+s[e+8>>3])<(n=+s[t+8>>3])?0|(t=-1):0|(t=i>n&1)},function(e,t){var n,i;return t|=0,0|((i=+s[(e|=0)>>3])>(n=+s[t>>3])?-1:i<n&1)}];return{___divdi3:Nt,___muldi3:kt,___remdi3:Ft,___uremdi3:Dt,_areNeighborCells:function(e,t,n,i,s){s|=0;var o,a,l,c=0,A=0,u=0,h=0;if(l=I,I=I+64|0,a=l,o=l+56|0,!(!0&134217728==(2013265920&(t|=0))&!0&134217728==(2013265920&(i|=0))))return I=l,0|(s=5);if((0|(e|=0))==(0|(n|=0))&(0|t)==(0|i))return r[s>>2]=0,I=l,0|(s=0);if(A=0|Vt(0|e,0|t,52),E(),A&=15,h=0|Vt(0|n,0|i,52),E(),(0|A)!=(15&h))return I=l,0|(s=12);if(c=A+-1|0,A>>>0>1){xe(e,t,c,a),xe(n,i,c,o),u=0|r[(h=a)>>2],h=0|r[h+4>>2];e:do{if((0|u)==(0|r[o>>2])&&(0|h)==(0|r[o+4>>2])){c=0|Vt(0|e,0|t,0|(A=3*(15^A)|0)),E(),c&=7,A=0|Vt(0|n,0|i,0|A),E(),A&=7;do{if(!(0|c)|!(0|A))r[s>>2]=1,c=0;else if(7==(0|c))c=5;else{if(1==(0|c)|1==(0|A)&&0|Ee(u,h)){c=5;break}if((0|r[15824+(c<<2)>>2])!=(0|A)&&(0|r[15856+(c<<2)>>2])!=(0|A))break e;r[s>>2]=1,c=0}}while(0);return I=l,0|(s=c)}}while(0)}A=(c=a)+56|0;do{r[c>>2]=0,c=c+4|0}while((0|c)<(0|A));return O(e,t,1,a),c=(0|r[(t=a)>>2])==(0|n)&&(0|r[t+4>>2])==(0|i)||(0|r[(t=a+8|0)>>2])==(0|n)&&(0|r[t+4>>2])==(0|i)||(0|r[(t=a+16|0)>>2])==(0|n)&&(0|r[t+4>>2])==(0|i)||(0|r[(t=a+24|0)>>2])==(0|n)&&(0|r[t+4>>2])==(0|i)||(0|r[(t=a+32|0)>>2])==(0|n)&&(0|r[t+4>>2])==(0|i)||(0|r[(t=a+40|0)>>2])==(0|n)&&(0|r[t+4>>2])==(0|i)?1:1&((0|r[(c=a+48|0)>>2])==(0|n)?(0|r[c+4>>2])==(0|i):0),r[s>>2]=c,I=l,0|(s=0)},_bitshift64Ashr:Ut,_bitshift64Lshr:Vt,_bitshift64Shl:zt,_calloc:Pt,_cellAreaKm2:function(e,t,n){n|=0;var i,o,a,l=0;return a=I,I=I+192|0,i=a+176|0,l=a+168|0,(e=0|Ue(e|=0,t|=0,o=a))?(I=a,0|(l=e)):(r[l>>2]=r[o>>2],r[l+4>>2]=o+8,r[i>>2]=r[l>>2],r[i+4>>2]=r[l+4>>2],G(i,n),s[n>>3]=40589732.49931477*+s[n>>3],I=a,0|(l=0))},_cellAreaM2:function(e,t,n){n|=0;var i,o,a,l=0;return a=I,I=I+192|0,i=a+176|0,l=a+168|0,(e=0|Ue(e|=0,t|=0,o=a))?(I=a,0|(l=e)):(r[l>>2]=r[o>>2],r[l+4>>2]=o+8,r[i>>2]=r[l>>2],r[i+4>>2]=r[l+4>>2],G(i,n),s[n>>3]=40589732.49931477*+s[n>>3]*1e6,I=a,0|(l=0))},_cellAreaRads2:function(e,t,n){n|=0;var i,s,o,a=0;return o=I,I=I+192|0,i=o+176|0,a=o+168|0,0|(e=0|Ue(e|=0,t|=0,s=o))?(I=o,0|(a=e)):(r[a>>2]=r[s>>2],r[a+4>>2]=s+8,r[i>>2]=r[a>>2],r[i+4>>2]=r[a+4>>2],G(i,n),I=o,0|(a=0))},_cellToBoundary:Ue,_cellToCenterChild:Ce,_cellToChildPos:function(e,t,n,i){n|=0,i|=0;var s,o=0,a=0,l=0,c=0,A=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,b=0,_=0;if(s=I,I=I+16|0,b=s,_=0|Vt(0|(e|=0),0|(t|=0),52),E(),_&=15,n>>>0>15)return I=s,0|(_=4);if((0|_)<(0|n))return I=s,0|(_=12);if((0|_)!=(0|n))if(a=0|zt(0|n,0,52),a|=e,c=E()|-15728641&t,(0|_)>(0|n)){A=n;do{m=0|zt(7,0,3*(14-A|0)|0),A=A+1|0,a|=m,c=0|E()|c}while((0|A)<(0|_));m=a}else m=a;else m=e,c=t;g=0|Vt(0|m,0|c,45),E();e:do{if(0|j(127&g)){if(A=0|Vt(0|m,0|c,52),E(),0|(A&=15))for(a=1;;){if(!(!((g=0|zt(7,0,3*(15-a|0)|0))&m|0)&!((0|E())&c))){u=33;break e}if(!(a>>>0<A>>>0))break;a=a+1|0}if(r[(g=i)>>2]=0,r[g+4>>2]=0,(0|_)>(0|n)){for(g=-15728641&t,p=_;;){if(f=p,(p=p+-1|0)>>>0>15|(0|_)<(0|p)){u=19;break}if((0|_)!=(0|p))if(a=0|zt(0|p,0,52),a|=e,A=0|E()|g,(0|_)<(0|f))d=a;else{u=p;do{d=0|zt(7,0,3*(14-u|0)|0),u=u+1|0,a|=d,A=0|E()|A}while((0|u)<(0|_));d=a}else d=e,A=t;if(h=0|Vt(0|d,0|A,45),E(),0|j(127&h)){h=0|Vt(0|d,0|A,52),E(),h&=15;t:do{if(h)for(u=1;;){if(a=0|Vt(0|d,0|A,3*(15-u|0)|0),E(),0|(a&=7))break t;if(!(u>>>0<h>>>0)){a=0;break}u=u+1|0}else a=0}while(0);a=1&!(0|a)}else a=0;if(A=0|Vt(0|e,0|t,3*(15-f|0)|0),E(),7==(0|(A&=7))){o=5,u=42;break}if(1==(0|A)&(a=!!(0|a))){o=5,u=42;break}if(0|(d=A+((!!(0|A)&a)<<31>>31)|0)&&(u=0|Je(7,0,u=_-f|0,((0|u)<0)<<31>>31),h=0|E(),a?(a=0|Lt(0|(a=0|kt(0|u,0|h,5,0)),0|E(),-5,-1),a=0|Lt(0|(a=0|Nt(0|a,0|E(),6,0)),0|E(),1,0),A=0|E()):(a=u,A=h),f=0|Lt(0|a,0|A,0|(f=0|kt(0|u,0|h,0|(f=d+-1|0),((0|f)<0)<<31>>31)),0|E()),h=0|Lt(0|f,0|(d=0|E()),0|r[(h=i)>>2],0|r[h+4>>2]),d=0|E(),r[(f=i)>>2]=h,r[f+4>>2]=d),(0|p)<=(0|n)){u=37;break}}if(19==(0|u))S(27634,27225,1407,27259);else{if(37==(0|u)){o=0|r[(l=i)+4>>2],l=0|r[l>>2];break}if(42==(0|u))return I=s,0|o}}else o=0,l=0}else u=33}while(0);e:do{if(33==(0|u)){if(r[(g=i)>>2]=0,r[g+4>>2]=0,(0|_)>(0|n)){for(a=_;;){if(o=0|Vt(0|e,0|t,3*(15-a|0)|0),E(),7==(0|(o&=7))){o=5;break}if(o=0|kt(0|(l=0|Je(7,0,l=_-a|0,((0|l)<0)<<31>>31)),0|E(),0|o,0),l=0|E(),l=0|Lt(0|r[(g=i)>>2],0|r[g+4>>2],0|o,0|l),o=0|E(),r[(g=i)>>2]=l,r[g+4>>2]=o,(0|(a=a+-1|0))<=(0|n))break e}return I=s,0|o}o=0,l=0}}while(0);return 0|Te(m,c,_,b)&&S(27634,27225,1367,27274),((0|o)>-1|-1==(0|o)&l>>>0>4294967295)&((0|(b=0|r[(_=b)+4>>2]))>(0|o)|((0|b)==(0|o)?(0|r[_>>2])>>>0>l>>>0:0))?(I=s,0|(_=0)):(S(27634,27225,1447,27259),0)},_cellToChildren:function(e,t,n,i){i|=0;var s,o,a=0,l=0;if(o=I,I=I+16|0,ze(s=o,e|=0,t|=0,n|=0),!(0|(e=0|r[(t=s)>>2]))&!(0|(t=0|r[t+4>>2])))return I=o,0;a=0,n=0;do{r[(l=i+(a<<3)|0)>>2]=e,r[l+4>>2]=t,a=0|Lt(0|a,0|n,1,0),n=0|E(),je(s),e=0|r[(l=s)>>2],t=0|r[l+4>>2]}while(!(!(0|e)&!(0|t)));return I=o,0},_cellToChildrenSize:Te,_cellToLatLng:De,_cellToLocalIj:function(e,t,n,i,s,o){o|=0;var a,l=0;return a=I,I=I+16|0,l=a,0|(s|=0)?(I=a,0|(l=15)):((e=0|Xe(e|=0,t|=0,n|=0,i|=0,l))||(s=0|r[l+4>>2],e=0|r[l+8>>2],r[o>>2]=(0|r[l>>2])-e,r[o+4>>2]=s-e,e=0),I=a,0|(l=e))},_cellToParent:xe,_cellToVertex:pt,_cellToVertexes:function(e,t,n){n|=0;var i,s=0,o=0;return o=!(0|Ee(e|=0,t|=0)),i=!(0|(s=0|pt(e,t,0,n))),o?i?0|(s=0|pt(e,t,1,n+8|0))||0|(s=0|pt(e,t,2,n+16|0))||0|(s=0|pt(e,t,3,n+24|0))||(s=0|pt(e,t,4,n+32|0))?0|(o=s):0|pt(e,t,5,n+40|0):0|(o=s):i?0|(s=0|pt(e,t,1,n+8|0))||0|(s=0|pt(e,t,2,n+16|0))||0|(s=0|pt(e,t,3,n+24|0))||0|(s=0|pt(e,t,4,n+32|0))?0|(o=s):(r[(o=n+40|0)>>2]=0,r[o+4>>2]=0,0|(o=0)):0|(o=s)},_cellsToDirectedEdge:function(e,t,n,i,s){return s|=0,7==(0|(n=0|V(e|=0,t|=0,n|=0,i|=0)))?0|(s=11):(i=0|zt(0|n,0,56),t=-2130706433&t|E()|268435456,r[s>>2]=e|i,r[s+4>>2]=t,0|(s=0))},_cellsToLinkedMultiPolygon:function(e,t,n){n|=0;var i,s,o=0,a=0,l=0,c=0,A=0;if(s=I,I=I+16|0,0|(e=0|re(e|=0,t|=0,((0|t)<0)<<31>>31,l=s)))return I=s,0|(l=e);if(i=0|function(e,t){e|=0,t|=0;var n=0,i=0,s=0,o=0,a=0,l=0,c=0,A=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,b=0;if(r[t>>2]=0,m=t+4|0,r[m>>2]=0,b=t+8|0,r[b>>2]=0,g=0|r[e>>2],(0|g)<=0)return 0|(t=0);p=e+4|0,e=t,f=0;e:for(;;){if(f){if(!(n=0|Pt(1,12))){n=5;break}r[e+8>>2]=n,e=n}if(c=0|r[p>>2],!(A=0|Pt(1,12))){e=13,n=37;break}if(i=0|r[(d=e+4|0)>>2],r[(0|i?i+8:e)>>2]=A,r[d>>2]=A,(0|(i=0|r[c+(f<<4)>>2]))<3){e=1,n=37;break}s=c+(f<<4)+4|0,o=A+4|0,n=0,a=0;do{if(l=a,!(a=0|St(24))){e=13,n=37;break e}Kt(0|a,(0|r[s>>2])+(n<<4)|0,16),r[a+16>>2]=0,l?r[l+16>>2]=a:r[A>>2]=a,r[o>>2]=a,n=n+1|0}while((0|n)<(0|i));if((0|(h=0|r[c+(f<<4)+8>>2]))>0){u=c+(f<<4)+12|0,c=0;do{if(i=0|r[u>>2],n=A,!(A=0|Pt(1,12))){e=13,n=37;break e}if(r[n+8>>2]=A,r[d>>2]=A,(0|(l=0|r[i+(c<<3)>>2]))<3){e=1,n=37;break e}i=i+(c<<3)+4|0,s=A+4|0,n=0,o=0;do{if(a=o,!(o=0|St(24))){e=13,n=37;break e}Kt(0|o,(0|r[i>>2])+(n<<4)|0,16),r[o+16>>2]=0,a?r[a+16>>2]=o:r[A>>2]=o,r[s>>2]=o,n=n+1|0}while((0|n)<(0|l));c=c+1|0}while((0|c)<(0|h))}if((0|(f=f+1|0))>=(0|g)){e=0,n=50;break}}if(5==(0|n)){if(!t)return 0|(t=13);for(i=1,s=t;;){if(0|(e=0|r[s>>2]))do{if(0|(n=0|r[e>>2]))do{g=n,n=0|r[n+16>>2],Ct(g)}while(0|n);g=e,e=0|r[e+8>>2],Ct(g)}while(0|e);if(e=s,s=0|r[s+8>>2],i?(r[t>>2]=0,r[m>>2]=0,r[b>>2]=0):Ct(e),!s){e=13;break}i=0}return 0|e}if(37==(0|n)){if(!t)return 0|(t=e);for(s=1,o=t;;){if(0|(n=0|r[o>>2]))do{if(0|(i=0|r[n>>2]))do{g=i,i=0|r[i+16>>2],Ct(g)}while(0|i);g=n,n=0|r[n+8>>2],Ct(g)}while(0|n);if(n=o,o=0|r[o+8>>2],s?(r[t>>2]=0,r[m>>2]=0,r[b>>2]=0):Ct(n),!o)break;s=0}return 0|e}if(50==(0|n))return 0|e;return 0}(l,n),n=l+4|0,(0|r[l>>2])>0){t=0;do{if(a=0|r[n>>2],Ct(0|r[(o=a+(t<<4)+4|0)>>2]),r[o>>2]=0,r[a+(t<<4)>>2]=0,o=a+(t<<4)+8|0,a=a+(t<<4)+12|0,(0|r[o>>2])>0){e=0;do{c=0|r[a>>2],Ct(0|r[(A=c+(e<<3)+4|0)>>2]),r[A>>2]=0,r[c+(e<<3)>>2]=0,e=e+1|0}while((0|e)<(0|r[o>>2]))}Ct(0|r[a>>2]),r[a>>2]=0,r[o>>2]=0,t=t+1|0}while((0|t)<(0|r[l>>2]))}return Ct(0|r[n>>2]),r[n>>2]=0,r[l>>2]=0,I=s,0|(A=i)},_childPosToCell:function(e,t,n,i,s,o){e|=0,t|=0,o|=0;var a,l=0,c=0,A=0,u=0,h=0,d=0,f=0,p=0,g=0;if(a=I,I=I+16|0,l=a,(s|=0)>>>0>15)return I=a,0|(o=4);if(c=0|Vt(0|(n|=0),0|(i|=0),52),E(),(0|(c&=15))>(0|s))return I=a,0|(o=12);if(0|Te(n,i,s,l)&&S(27634,27225,1367,27274),!(((0|t)>-1|-1==(0|t)&e>>>0>4294967295)&((0|(u=0|r[(h=l)+4>>2]))>(0|t)|((0|u)==(0|t)?(0|r[h>>2])>>>0>e>>>0:0))))return I=a,0|(o=2);h=s-c|0,s=0|zt(0|s,0,52),A=E()|-15728641&i,r[(u=o)>>2]=s|n,r[u+4>>2]=A,u=0|Vt(0|n,0|i,45),E();e:do{if(0|j(127&u)){if(0|c)for(l=1;;){if(!(!((u=0|zt(7,0,3*(15-l|0)|0))&n|0)&!((0|E())&i)))break e;if(!(l>>>0<c>>>0))break;l=l+1|0}if((0|h)<1)return I=a,0|(o=0);for(u=15^c,i=-1,A=1,l=1;;){c=0|Je(7,0,c=h-A|0,((0|c)<0)<<31>>31),n=0|E();do{if(l){if(l=0|Nt(0|(l=0|Lt(0|(l=0|kt(0|c,0|n,5,0)),0|E(),-5,-1)),0|E(),6,0),(0|t)>(0|(s=0|E()))|(0|t)==(0|s)&e>>>0>l>>>0){t=0|It(0|(t=0|Lt(0|e,0|t,-1,-1)),0|E(),0|l,0|s),l=0|E(),p=0|r[(d=o)>>2],d=0|r[d+4>>2],f=0|zt(7,0,0|(g=3*(u+i|0)|0)),d&=~E(),g=0|zt(0|(s=0|Lt(0|(i=0|Nt(0|t,0|l,0|c,0|n)),0|(e=0|E()),2,0)),0|E(),0|g),d=0|E()|d,r[(s=o)>>2]=g|p&~f,r[s+4>>2]=d,e=0|It(0|t,0|l,0|(e=0|kt(0|i,0|e,0|c,0|n)),0|E()),l=0,t=0|E();break}f=0|r[(g=o)>>2],g=0|r[g+4>>2],p=0|zt(7,0,3*(u+i|0)|0),g&=~E(),r[(l=o)>>2]=f&~p,r[l+4>>2]=g,l=1;break}s=0|r[(f=o)>>2],f=0|r[f+4>>2],d=0|zt(7,0,0|(i=3*(u+i|0)|0)),f&=~E(),i=0|zt(0|(g=0|Nt(0|e,0|t,0|c,0|n)),0|(l=0|E()),0|i),f=0|E()|f,r[(p=o)>>2]=i|s&~d,r[p+4>>2]=f,e=0|It(0|e,0|t,0|(l=0|kt(0|g,0|l,0|c,0|n)),0|E()),l=0,t=0|E()}while(0);if(!((0|h)>(0|A))){t=0;break}i=~A,A=A+1|0}return I=a,0|t}}while(0);if((0|h)<1)return I=a,0|(g=0);for(s=15^c,l=1;;){if(p=0|Je(7,0,p=h-l|0,((0|p)<0)<<31>>31),g=0|E(),n=0|r[(A=o)>>2],A=0|r[A+4>>2],i=0|zt(7,0,0|(c=3*(s-l|0)|0)),A&=~E(),c=0|zt(0|(d=0|Nt(0|e,0|t,0|p,0|g)),0|(f=0|E()),0|c),A=0|E()|A,r[(u=o)>>2]=c|n&~i,r[u+4>>2]=A,e=0|It(0|e,0|t,0|(g=0|kt(0|d,0|f,0|p,0|g)),0|E()),t=0|E(),(0|h)<=(0|l)){t=0;break}l=l+1|0}return I=a,0|t},_compactCells:function(e,t,n,i){t|=0;var s,o=0,a=0,l=0,c=0,A=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,b=0,_=0,v=0,y=0,w=0,x=0,T=0,C=0,P=0,R=0,M=0,L=0,I=0;if(!(0|(n|=0))&!(0|(i|=0)))return 0|(I=0);if(a=0|r[(o=e|=0)>>2],!0&!(15728640&(o=0|r[o+4>>2]))){if(!((0|i)>0|!(0|i)&n>>>0>0))return 0|(I=0);if(r[(I=t)>>2]=a,r[I+4>>2]=o,1==(0|n)&!(0|i))return 0|(I=0);o=1,a=0;do{L=0|r[(M=e+(o<<3)|0)+4>>2],r[(I=t+(o<<3)|0)>>2]=r[M>>2],r[I+4>>2]=L,o=0|Lt(0|o,0|a,1,0),a=0|E()}while((0|a)<(0|i)|(0|a)==(0|i)&o>>>0<n>>>0);return 0|(o=0)}if(!(L=0|St(s=n<<3)))return 0|(I=13);if(qt(0|L,0|e,0|s),!(M=0|Pt(n,8)))return Ct(L),0|(I=13);e:for(;;){P=0|Vt(0|(u=0|r[(o=L)>>2]),0|(o=0|r[o+4>>2]),52),E(),R=(P&=15)+-1|0,C=!!(0|P),T=(0|i)>0|!(0|i)&n>>>0>0;t:do{if(C&T){if(v=0|zt(0|R,0,52),y=0|E(),R>>>0>15){if(!(!(0|u)&!(0|o))){I=16;break e}for(a=0,e=0;;){if(a=0|Lt(0|a,0|e,1,0),!((0|(e=0|E()))<(0|i)|(0|e)==(0|i)&a>>>0<n>>>0))break t;if(!(!(0|(x=0|r[(l=L+(a<<3)|0)>>2]))&!(0|(l=0|r[l+4>>2])))){o=l,I=16;break e}}}for(c=u,e=o,a=0,l=0;;){if(!(!(0|c)&!(0|e))){if(!(!0&!(117440512&e))){I=21;break e}if(h=0|Vt(0|c,0|e,52),E(),(0|(h&=15))<(0|R)){o=12,I=27;break e}if((0|h)!=(0|R)&&(c|=v,e=-15728641&e|y,h>>>0>=P>>>0)){A=R;do{x=0|zt(7,0,3*(14-A|0)|0),A=A+1|0,c|=x,e=0|E()|e}while(A>>>0<h>>>0)}if(f=0|Dt(0|c,0|e,0|n,0|i),p=0|E(),!(!(0|(d=0|r[(h=A=M+(f<<3)|0)>>2]))&!(0|(h=0|r[h+4>>2])))){b=0,_=0;do{if((0|b)>(0|i)|(0|b)==(0|i)&_>>>0>n>>>0){I=31;break e}if((0|d)==(0|c)&(-117440513&h)==(0|e)){g=0|Vt(0|d,0|h,56),E(),m=(g&=7)+1|0,x=0|Vt(0|d,0|h,45),E();n:do{if(0|j(127&x)){if(d=0|Vt(0|d,0|h,52),E(),!(d&=15)){h=6;break}for(h=1;;){if(!(!((x=0|zt(7,0,3*(15-h|0)|0))&c|0)&!((0|E())&e))){h=7;break n}if(!(h>>>0<d>>>0)){h=6;break}h=h+1|0}}else h=7}while(0);if((g+2|0)>>>0>h>>>0){I=41;break e}x=0|zt(0|m,0,56),e=E()|-117440513&e,r[(w=A)>>2]=0,r[w+4>>2]=0,c|=x}else f=0|Ft(0|(f=0|Lt(0|f,0|p,1,0)),0|E(),0|n,0|i),p=0|E();_=0|Lt(0|_,0|b,1,0),b=0|E(),d=0|r[(h=A=M+(f<<3)|0)>>2],h=0|r[h+4>>2]}while(!(!(0|d)&!(0|h)))}r[(x=A)>>2]=c,r[x+4>>2]=e}if(a=0|Lt(0|a,0|l,1,0),!((0|(l=0|E()))<(0|i)|(0|l)==(0|i)&a>>>0<n>>>0))break t;c=0|r[(e=L+(a<<3)|0)>>2],e=0|r[e+4>>2]}}}while(0);if(x=0|Lt(0|n,0|i,5,0),(w=0|E())>>>0<0|!(0|w)&x>>>0<11){I=85;break}if(x=0|Nt(0|n,0|i,6,0),E(),!(x=0|Pt(x,8))){I=48;break}do{if(T){for(m=0,e=0,g=0,b=0;;){if(!(0|(a=0|r[(l=h=M+(m<<3)|0)>>2]))&!(0|(l=0|r[l+4>>2])))w=g;else{d=0|Vt(0|a,0|l,56),E(),c=(d&=7)+1|0,f=-117440513&l,w=0|Vt(0|a,0|l,45),E();t:do{if(0|j(127&w)){if(p=0|Vt(0|a,0|l,52),E(),0|(p&=15))for(A=1;;){if(!(!(a&(w=0|zt(7,0,3*(15-A|0)|0))|0)&!(f&(0|E()))))break t;if(!(A>>>0<p>>>0))break;A=A+1|0}a|=l=0|zt(0|c,0,56),l=0|E()|f,r[(c=h)>>2]=a,r[c+4>>2]=l,c=d+2|0}}while(0);7==(0|c)?(r[(w=x+(e<<3)|0)>>2]=a,r[w+4>>2]=-117440513&l,e=0|Lt(0|e,0|g,1,0),w=0|E()):w=g}if(m=0|Lt(0|m,0|b,1,0),!((0|(b=0|E()))<(0|i)|(0|b)==(0|i)&m>>>0<n>>>0))break;g=w}if(T){if(_=R>>>0>15,v=0|zt(0|R,0,52),y=0|E(),!C){for(a=0,A=0,c=0,l=0;!(0|u)&!(0|o)||(r[(R=t+(a<<3)|0)>>2]=u,r[R+4>>2]=o,a=0|Lt(0|a,0|A,1,0),A=0|E()),c=0|Lt(0|c,0|l,1,0),(0|(l=0|E()))<(0|i)|(0|l)==(0|i)&c>>>0<n>>>0;)u=0|r[(o=L+(c<<3)|0)>>2],o=0|r[o+4>>2];o=w;break}for(a=0,A=0,l=0,c=0;;){do{if(!(!(0|u)&!(0|o))){if(p=0|Vt(0|u,0|o,52),E(),_|(0|(p&=15))<(0|R)){I=80;break e}if((0|p)!=(0|R)){if(h=u|v,d=-15728641&o|y,p>>>0>=P>>>0){f=R;do{C=0|zt(7,0,3*(14-f|0)|0),f=f+1|0,h|=C,d=0|E()|d}while(f>>>0<p>>>0)}}else h=u,d=o;g=0|Dt(0|h,0|d,0|n,0|i),f=0,p=0,b=0|E();do{if((0|f)>(0|i)|(0|f)==(0|i)&p>>>0>n>>>0){I=81;break e}if((-117440513&(m=0|r[(C=M+(g<<3)|0)+4>>2]))==(0|d)&&(0|r[C>>2])==(0|h)){I=65;break}g=0|Ft(0|(C=0|Lt(0|g,0|b,1,0)),0|E(),0|n,0|i),b=0|E(),p=0|Lt(0|p,0|f,1,0),f=0|E(),C=M+(g<<3)|0}while((0|r[C>>2])!=(0|h)||(0|r[C+4>>2])!=(0|d));if(65==(0|I)&&(I=0,!0&100663296==(117440512&m)))break;r[(C=t+(a<<3)|0)>>2]=u,r[C+4>>2]=o,a=0|Lt(0|a,0|A,1,0),A=0|E()}}while(0);if(l=0|Lt(0|l,0|c,1,0),!((0|(c=0|E()))<(0|i)|(0|c)==(0|i)&l>>>0<n>>>0))break;u=0|r[(o=L+(l<<3)|0)>>2],o=0|r[o+4>>2]}o=w}else a=0,o=w}else a=0,e=0,o=0}while(0);if(Qt(0|M,0,0|s),qt(0|L,0|x,e<<3),Ct(x),!(0|e)&!(0|o)){I=89;break}t=t+(a<<3)|0,i=o,n=e}if(16==(0|I))!0&!(117440512&o)?(o=4,I=27):I=21;else if(31==(0|I))S(27634,27225,620,27235);else{if(41==(0|I))return Ct(L),Ct(M),0|(I=10);if(48==(0|I))return Ct(L),Ct(M),0|(I=13);80==(0|I)?S(27634,27225,711,27235):81==(0|I)?S(27634,27225,723,27235):85==(0|I)&&(qt(0|t,0|L,n<<3),I=89)}return 21==(0|I)?(Ct(L),Ct(M),0|(I=5)):27==(0|I)?(Ct(L),Ct(M),0|(I=o)):89==(0|I)?(Ct(L),Ct(M),0|(I=0)):0},_constructCell:function(e,t,n,s){n|=0,s|=0;var o=0,a=0,l=0,c=0,A=0,u=0;if((e|=0)>>>0>15)return 0|(s=4);if((t|=0)>>>0>121)return 0|(s=17);l=0|zt(0|e,0,52),o=0|E(),c=0|zt(0|t,0,45),o=0|o|E()|134225919;e:do{if((0|e)>=1){for(c=1,l=!!(0|i[20496+t|0]),a=-1;;){if((t=0|r[n+(c+-1<<2)>>2])>>>0>6){o=18,t=10;break}if(!(!(0|t)|1^l)){if(1==(0|t)){o=19,t=10;break}l=0}if(A=0|zt(7,0,0|(u=3*(15-c|0)|0)),o&=~E(),a=(t=0|zt(0|t,((0|t)<0)<<31>>31,0|u))|a&~A,o=0|E()|o,!((0|c)<(0|e)))break e;c=c+1|0}if(10==(0|t))return 0|o}else a=-1}while(0);return r[(u=s)>>2]=a,r[u+4>>2]=o,0|(u=0)},_destroyLinkedMultiPolygon:function(e){var t,n,i=0,s=0,o=0,a=0,l=0;if(e|=0)for(t=e+4|0,n=e+8|0,o=1,a=e;;){if(0|(i=0|r[a>>2]))do{if(0|(s=0|r[i>>2]))do{l=s,s=0|r[s+16>>2],Ct(l)}while(0|s);l=i,i=0|r[i+8>>2],Ct(l)}while(0|i);if(i=a,a=0|r[a+8>>2],o?(r[e>>2]=0,r[t>>2]=0,r[n>>2]=0):Ct(i),!a)break;o=0}},_directedEdgeToBoundary:le,_directedEdgeToCells:function(e,t,n){e|=0;var i,s,o,a=0;return i=I,I=I+16|0,a=i,!0&268435456==(2013265920&(t|=0))?(s=-2130706433&t|134217728,r[(o=n|=0)>>2]=e,r[o+4>>2]=s,r[a>>2]=0,t=0|Vt(0|e,0|t,56),E(),a=0|F(e,s,7&t,a,n+8|0),I=i,0|a):(I=i,0|(a=6))},_edgeLengthKm:function(e,t,n){n|=0;var i,o=0,a=0,l=0,c=0,d=0,f=0,p=0;if(i=I,I=I+176|0,0|(e=0|le(e|=0,t|=0,c=i)))return c=e,l=+s[n>>3],l*=6371.007180918475,s[n>>3]=l,I=i,0|c;if(s[n>>3]=0,(0|(e=0|r[c>>2]))<=1)return c=0,l=0,l*=6371.007180918475,s[n>>3]=l,I=i,0|c;t=e+-1|0,e=0,o=+s[c+8>>3],a=+s[c+16>>3],l=0;do{f=o,o=+s[c+8+((e=e+1|0)<<4)>>3],p=+h(.5*(o-f)),d=a,a=+s[c+8+(e<<4)+8>>3],d=p*p+(d=+h(.5*(a-d)))*(+u(+f)*+u(+o)*d),l+=2*+m(+ +A(+d),+ +A(+(1-d)))}while((0|e)!=(0|t));return s[n>>3]=l,c=0,p=l,p*=6371.007180918475,s[n>>3]=p,I=i,0|c},_edgeLengthM:function(e,t,n){n|=0;var i,o=0,a=0,l=0,c=0,d=0,f=0,p=0;if(i=I,I=I+176|0,0|(e=0|le(e|=0,t|=0,c=i)))return c=e,l=+s[n>>3],l*=6371.007180918475,l*=1e3,s[n>>3]=l,I=i,0|c;if(s[n>>3]=0,(0|(e=0|r[c>>2]))<=1)return c=0,l=0,l*=6371.007180918475,l*=1e3,s[n>>3]=l,I=i,0|c;t=e+-1|0,e=0,o=+s[c+8>>3],a=+s[c+16>>3],l=0;do{f=o,o=+s[c+8+((e=e+1|0)<<4)>>3],p=+h(.5*(o-f)),d=a,a=+s[c+8+(e<<4)+8>>3],d=p*p+(d=+h(.5*(a-d)))*(+u(+f)*+u(+o)*d),l+=2*+m(+ +A(+d),+ +A(+(1-d)))}while((0|e)!=(0|t));return s[n>>3]=l,c=0,p=l,p*=6371.007180918475,p*=1e3,s[n>>3]=p,I=i,0|c},_edgeLengthRads:function(e,t,n){n|=0;var i,o=0,a=0,l=0,c=0,d=0,f=0,p=0;if(i=I,I=I+176|0,0|(e=0|le(e|=0,t|=0,c=i)))return I=i,0|(c=e);if(s[n>>3]=0,(0|(e=0|r[c>>2]))<=1)return I=i,0|(c=0);t=e+-1|0,e=0,o=+s[c+8>>3],a=+s[c+16>>3],l=0;do{f=o,o=+s[c+8+((e=e+1|0)<<4)>>3],p=+h(.5*(o-f)),d=a,a=+s[c+8+(e<<4)+8>>3],d=p*p+(d=+h(.5*(a-d)))*(+u(+o)*+u(+f)*d),l+=2*+m(+ +A(+d),+ +A(+(1-d)))}while((0|e)<(0|t));return s[n>>3]=l,I=i,0|(c=0)},_emscripten_replace_memory:function(e){return i=new Int8Array(e),new Uint8Array(e),r=new Int32Array(e),new Float32Array(e),s=new Float64Array(e),n=e,!0},_free:Ct,_getBaseCellNumber:ve,_getDirectedEdgeDestination:function(e,t,n){e|=0,t|=0,n|=0;var i,s,o=0;return i=I,I=I+16|0,r[(o=i)>>2]=0,!0&268435456==(2013265920&t)?(s=0|Vt(0|e,0|t,56),E(),o=0|F(e,-2130706433&t|134217728,7&s,o,n),I=i,0|o):(I=i,0|(o=6))},_getDirectedEdgeOrigin:function(e,t,n){return e|=0,n|=0,!0&268435456==(2013265920&(t|=0))?(r[n>>2]=e,r[n+4>>2]=-2130706433&t|134217728,0|(n=0)):0|(n=6)},_getHexagonAreaAvgKm2:Ke,_getHexagonAreaAvgM2:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(s[t>>3]=+s[20752+(e<<3)>>3],0|(t=0))},_getHexagonEdgeLengthAvgKm:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(s[t>>3]=+s[20880+(e<<3)>>3],0|(t=0))},_getHexagonEdgeLengthAvgM:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(s[t>>3]=+s[21008+(e<<3)>>3],0|(t=0))},_getIcosahedronFaces:function e(t,n,i){i|=0;var s,o=0,a=0,l=0,c=0,A=0,u=0,h=0,d=0;s=I,I=I+128|0,h=s+112|0,l=s+96|0,d=s,a=0|Vt(0|(t|=0),0|(n|=0),52),E(),A=15&a,r[h>>2]=A,c=0|Vt(0|t,0|n,45),E(),c&=127;e:do{if(0|j(c)){if(0|A)for(o=1;;){if(!(!((u=0|zt(7,0,3*(15-o|0)|0))&t|0)&!((0|E())&n))){a=0;break e}if(!(o>>>0<A>>>0))break;o=o+1|0}if(!(1&a))return u=0|zt(A+1|0,0,52),d=E()|-15728641&n,d=0|e((u|t)&~(h=0|zt(7,0,3*(14-A|0)|0)),d&~E(),i),I=s,0|d;a=1}else a=0}while(0);if(!(o=0|Fe(t,n,l))){a?(fe(l,h,d),u=5):(be(l,h,d),u=6);e:do{if(0|j(c))if(A)for(o=1;;){if(!(!((c=0|zt(7,0,3*(15-o|0)|0))&t|0)&!((0|E())&n))){t=2;break e}if(!(o>>>0<A>>>0)){t=5;break}o=o+1|0}else t=5;else t=2}while(0);Qt(0|i,-1,t<<2);e:do{if(a)for(l=0;;){if(ge(c=d+(l<<4)|0,0|r[h>>2]),c=0|r[c>>2],-1==(0|(A=0|r[i>>2]))|(0|A)==(0|c))o=i;else{a=0;do{if((a=a+1|0)>>>0>=t>>>0){o=1;break e}A=0|r[(o=i+(a<<2)|0)>>2]}while(!(-1==(0|A)|(0|A)==(0|c)))}if(r[o>>2]=c,(l=l+1|0)>>>0>=u>>>0){o=0;break}}else for(l=0;;){if(pe(c=d+(l<<4)|0,0|r[h>>2],0,1),c=0|r[c>>2],-1==(0|(A=0|r[i>>2]))|(0|A)==(0|c))o=i;else{a=0;do{if((a=a+1|0)>>>0>=t>>>0){o=1;break e}A=0|r[(o=i+(a<<2)|0)>>2]}while(!(-1==(0|A)|(0|A)==(0|c)))}if(r[o>>2]=c,(l=l+1|0)>>>0>=u>>>0){o=0;break}}}while(0)}return I=s,0|(d=o)},_getIndexDigit:function(e,t,n,i){return i|=0,((n|=0)+-1|0)>>>0>14?0|(i=4):(n=0|Vt(0|(e|=0),0|(t|=0),3*(15-n|0)|0),E(),r[i>>2]=7&n,0|(i=0))},_getNumCells:Qe,_getPentagons:Ve,_getRes0Cells:function(e){e|=0;var t=0,n=0,i=0;t=0;do{zt(0|t,0,45),i=134225919|E(),r[(n=e+(t<<3)|0)>>2]=-1,r[n+4>>2]=i,t=t+1|0}while(122!=(0|t));return 0},_getResolution:_e,_greatCircleDistanceKm:qe,_greatCircleDistanceM:function(e,t){e|=0;var n,i,r,o=0;return i=+s[(t|=0)>>3],n=+s[e>>3],o=(r=+h(.5*(i-n)))*r+(o=+h(.5*(+s[t+8>>3]-+s[e+8>>3])))*(+u(+i)*+u(+n)*o),2*+m(+ +A(+o),+ +A(+(1-o)))*6371.007180918475*1e3},_greatCircleDistanceRads:function(e,t){e|=0;var n,i,r,o=0;return i=+s[(t|=0)>>3],n=+s[e>>3],o=(r=+h(.5*(i-n)))*r+(o=+h(.5*(+s[t+8>>3]-+s[e+8>>3])))*(+u(+i)*+u(+n)*o),2*+m(+ +A(+o),+ +A(+(1-o)))},_gridDisk:O,_gridDiskDistances:B,_gridDistance:Ze,_gridPathCells:function(e,t,n,i,s){s|=0;var o,a,l=0,c=0;return a=I,I=I+16|0,0|(c=0|Ze(e|=0,t|=0,n|=0,i|=0,l=a))?(I=a,0|(s=c)):!(0|(l=0|r[(c=l)>>2]))&!(0|(c=0|r[c+4>>2]))?(r[s>>2]=e,r[s+4>>2]=t,I=a,0|(s=0)):(o=0|Ye(e,t,n,i,l,c,s,0,0,1,0))?(s=!(0|Ye(n,i,e,t,l,c,s,l,c,-1,-1)),I=a,0|(s=s?0:o)):(I=a,0|(s=0))},_gridPathCellsSize:function(e,t,n,i,s){s|=0;var o,a=0;return o=I,I=I+16|0,0|(e=0|Ze(e|=0,t|=0,n|=0,i|=0,a=o))?(I=o,0|(a=e)):(n=0|Lt(0|r[(n=a)>>2],0|r[n+4>>2],1,0),i=0|E(),r[(a=s)>>2]=n,r[a+4>>2]=i,I=o,0|(a=0))},_gridRing:function(e,t,n,i){return 0|D(e|=0,t|=0,n|=0,i|=0)?(Qt(0|i,0,48*n|0),0|(i=0|U(e,t,n,i))):0|(i=0)},_gridRingUnsafe:D,_i64Add:Lt,_i64Subtract:It,_isPentagon:Ee,_isResClassIII:function(e,t){return t=0|Vt(0|(e|=0),0|(t|=0),52),E(),1&t},_isValidCell:ye,_isValidDirectedEdge:oe,_isValidIndex:function(e,t){e|=0;var n=0,r=0,s=0,o=0;if(!0&134217728==(-16777216&(t|=0))&&(r=0|Vt(0|e,0|t,52),E(),r&=15,n=0|Vt(0|e,0|t,45),E(),(n&=127)>>>0<=121)&&!(613566756&(o=0|zt(0|(s=0|Vt(0|e,0|t,0|(o=3*(15^r)|0))),0|E(),0|o))&(0|It(-1227133514,-1171,0|o,0|(s=0|E()))))&!(4681&s&E())&&15==(0|r)|!(0|(o=0|Vt(0|(0|zt(0|~e,0|~t,0|(o=19+(3*r|0)|0))),0|E(),0|o)))&!(0|E())){if(!(0|i[20496+n|0]))return 0|(o=1);if(!(0|e)&!(0|(n=8191&t)))return 0|(o=1);if(o=0|Gt(0|e,0|n,0),E(),(63-o|0)%3|0)return 0|(o=1)}return 0|oe(e,t)?0|(o=1):0|(o=1&!!(0|gt(e,t)))},_isValidVertex:gt,_latLngToCell:Ne,_llvm_ctlz_i64:Gt,_llvm_maxnum_f64:jt,_llvm_minnum_f64:Ht,_llvm_round_f64:Wt,_localIjToCell:function(e,t,n,i,s){e|=0,t|=0,s|=0;var o,a,l,c=0,A=0,u=0,h=0;return l=I,I=I+16|0,h=l,0|(i|=0)?(I=l,0|(h=15)):(u=0|r[(n|=0)>>2],A=0|r[n+4>>2],r[h>>2]=u,r[(o=h+4|0)>>2]=A,r[(a=h+8|0)>>2]=0,i=(n=(0|A)<(0|u))?u:A,(0|(n=n?A:u))<0&&(-2147483648==(0|n)||((0|i)>0?(2147483647-i|0)<(0|n):(-2147483648-i|0)>(0|n))||((0|i)>-1?(-2147483648|i)>=(0|n):(-2147483648^i)<(0|n)))?i=1:c=5,5==(0|c)&&(i=A-u|0,c=0-u|0,(0|u)<0?(r[o>>2]=i,r[a>>2]=c,r[h>>2]=0,u=0):(i=A,c=0),A=u-i|0,n=c-i|0,(0|i)<0?(r[h>>2]=A,r[a>>2]=n,r[o>>2]=0,u=A,i=0):n=c,A=u-n|0,c=i-n|0,(0|n)<0?(r[h>>2]=A,r[o>>2]=c,r[a>>2]=0,n=0):(c=i,A=u),(0|(i=(0|n)<(0|(i=(0|c)<(0|A)?c:A))?n:i))>0&&(r[h>>2]=A-i,r[o>>2]=c-i,r[a>>2]=n-i),i=0|$e(e,t,h,s)),I=l,0|(h=i))},_malloc:St,_maxFaceCount:function(e,t,n){n|=0;var i=0,s=0;if(s=0|Vt(0|(e|=0),0|(t|=0),45),E(),!(0|j(127&s)))return s=2,r[n>>2]=s,0;if(s=0|Vt(0|e,0|t,52),E(),!(s&=15))return s=5,r[n>>2]=s,0;for(i=1;;){if(!(!((0|zt(7,0,3*(15-i|0)|0))&e|0)&!((0|E())&t))){i=2,e=6;break}if(!(i>>>0<s>>>0)){i=5,e=6;break}i=i+1|0}return 6==(0|e)?(r[n>>2]=i,0):0},_maxGridDiskSize:function(e,t){t|=0;var n=0,i=0,s=0;return(0|(e|=0))<0?0|(t=2):(0|e)>13780509?0|(t=0|Qe(15,t)):(s=0|kt(0|e,0|(n=((0|e)<0)<<31>>31),3,0),i=0|E(),n=0|Lt(0|e,0|n,1,0),n=0|Lt(0|(n=0|kt(0|s,0|i,0|n,0|E())),0|E(),1,0),e=0|E(),r[t>>2]=n,r[t+4>>2]=e,0|(t=0))},_maxPolygonToCellsSize:function(e,t,n,i){e|=0,t|=0,i|=0;var s,o=0,a=0,l=0,c=0,A=0;if(s=I,I=I+48|0,o=s+16|0,a=s+8|0,l=s,0|(n=0|ot(n|=0)))return I=s,0|(l=n);if(c=0|r[(A=e)+4>>2],r[(n=a)>>2]=r[A>>2],r[n+4>>2]=c,st(a,o),!(n=0|ne(o,t,l))){if(t=0|r[a>>2],(0|(a=0|r[e+8>>2]))>0){o=0|r[e+12>>2],n=0;do{t=(0|r[o+(n<<3)>>2])+t|0,n=n+1|0}while((0|n)<(0|a))}o=0|r[(n=l)>>2],(0|(n=0|r[n+4>>2]))<(0|(a=((0|t)<0)<<31>>31))|(0|n)==(0|a)&o>>>0<t>>>0?(r[(n=l)>>2]=t,r[n+4>>2]=a,n=a):t=o,c=0|Lt(0|t,0|n,12,0),A=0|E(),r[(n=l)>>2]=c,r[n+4>>2]=A,r[(n=i)>>2]=c,r[n+4>>2]=A,n=0}return I=s,0|(A=n)},_maxPolygonToCellsSizeExperimental:function(e,t,n,o){t|=0,n|=0,o|=0;var a,l,A=0,h=0,d=0,f=0,p=0,g=0,m=0,b=0;if(l=I,I=I+48|0,p=l+32|0,f=l+40|0,a=l,!(0|r[(e|=0)>>2]))return r[(g=o)>>2]=0,r[g+4>>2]=0,I=l,0|(g=0);we(p,0,0,0),A=0|r[(d=p)>>2],d=0|r[d+4>>2];do{if(t>>>0>15)r[(g=a)>>2]=0,r[g+4>>2]=0,r[a+8>>2]=4,r[a+12>>2]=-1,n=a+29|0,r[(g=a+16|0)>>2]=0,r[g+4>>2]=0,r[g+8>>2]=0,i[g+12|0]=0,i[n|0]=0|i[f|0],i[n+1|0]=0|i[f+1|0],i[n+2|0]=0|i[f+2|0],n=4,g=9;else{if(0|(n=0|ot(n))){r[(p=a)>>2]=0,r[p+4>>2]=0,r[a+8>>2]=n,r[a+12>>2]=-1,g=a+29|0,r[(p=a+16|0)>>2]=0,r[p+4>>2]=0,r[p+8>>2]=0,i[p+12|0]=0,i[g|0]=0|i[f|0],i[g+1|0]=0|i[f+1|0],i[g+2|0]=0|i[f+2|0],g=9;break}if(!(n=0|Pt(1+(0|r[e+8>>2])|0,32))){r[(g=a)>>2]=0,r[g+4>>2]=0,r[a+8>>2]=13,r[a+12>>2]=-1,n=a+29|0,r[(g=a+16|0)>>2]=0,r[g+4>>2]=0,r[g+8>>2]=0,i[g+12|0]=0,i[n|0]=0|i[f|0],i[n+1|0]=0|i[f+1|0],i[n+2|0]=0|i[f+2|0],n=13,g=9;break}at(e,n),r[(b=a)>>2]=A,r[b+4>>2]=d,r[(d=a+8|0)>>2]=0,r[a+12>>2]=t,r[a+20>>2]=e,r[a+24>>2]=n,i[a+28|0]=0,i[(A=a+29|0)|0]=0|i[f|0],i[A+1|0]=0|i[f+1|0],i[A+2|0]=0|i[f+2|0],r[a+16>>2]=3,m=+Z(n),m*=+$(n),h=+c(+ +s[n>>3]),h=m/+u(+ +Ht(+h,+ +c(+ +s[n+8>>3])))*6371.007180918475*6371.007180918475,n=0|r[(A=a+12|0)>>2];e:do{if((0|n)>0)do{if(Ke(n+-1|0,p),!(h/+s[p>>3]>10))break e;n=(b=0|r[A>>2])+-1|0,r[A>>2]=n}while((0|b)>1)}while(0);if(nt(a),r[(A=o)>>2]=0,r[A+4>>2]=0,!(!(0|(n=0|r[(A=a)>>2]))&!(0|(A=0|r[A+4>>2]))))do{Te(n,A,t,p),f=p,f=0|Lt(0|r[(e=o)>>2],0|r[e+4>>2],0|r[f>>2],0|r[f+4>>2]),e=0|E(),r[(b=o)>>2]=f,r[b+4>>2]=e,nt(a),n=0|r[(b=a)>>2],A=0|r[b+4>>2]}while(!(!(0|n)&!(0|A)));n=0|r[d>>2]}}while(0);return I=l,0|(b=n)},_memcpy:qt,_memmove:Kt,_memset:Qt,_originToDirectedEdges:ae,_pentagonCount:function(){return 12},_polygonToCells:function(e,t,n,i){e|=0,t|=0,i|=0;var s,o,a,l,c=0,A=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,b=0,_=0,v=0,y=0,w=0,x=0,T=0,S=0,C=0,P=0,R=0,M=0,L=0,O=0,B=0,F=0,D=0,U=0;if(l=I,I=I+112|0,s=l+80|0,d=l+72|0,o=l,a=l+56|0,0|(c=0|ot(n|=0)))return I=l,0|(U=c);if(!(U=0|St(32+(r[(f=e+8|0)>>2]<<5)|0)))return I=l,0|(U=13);if(at(e,U),!(c=0|ot(n))){if(D=0|r[(F=e)+4>>2],r[(c=d)>>2]=r[F>>2],r[c+4>>2]=D,st(d,s),c=0|ne(s,t,o))F=0,D=0;else{if(c=0|r[d>>2],(0|(A=0|r[f>>2]))>0){u=0|r[e+12>>2],n=0;do{c=(0|r[u+(n<<3)>>2])+c|0,n=n+1|0}while((0|n)!=(0|A));n=c}else n=c;A=0|r[(c=o)>>2],(0|(c=0|r[c+4>>2]))<(0|(u=((0|n)<0)<<31>>31))|(0|c)==(0|u)&A>>>0<n>>>0?(r[(c=o)>>2]=n,r[c+4>>2]=u,c=u):n=A,F=0|Lt(0|n,0|c,12,0),D=0|E(),r[(c=o)>>2]=F,r[c+4>>2]=D,c=0}if(!c){if(!(n=0|Pt(F,8)))return Ct(U),I=l,0|(U=13);if(!(h=0|Pt(F,8)))return Ct(U),Ct(n),I=l,0|(U=13);r[(O=s)>>2]=0,r[O+4>>2]=0,B=0|r[(O=e)+4>>2],r[(c=d)>>2]=r[O>>2],r[c+4>>2]=B,c=0|z(d,F,D,t,s,n,h);e:do{if(c)Ct(n),Ct(h),Ct(U);else{t:do{if((0|r[f>>2])>0){for(u=e+12|0,A=0;c=0|z((0|r[u>>2])+(A<<3)|0,F,D,t,s,n,h),A=A+1|0,!(0|c);)if((0|A)>=(0|r[f>>2]))break t;Ct(n),Ct(h),Ct(U);break e}}while(0);(0|D)>0|!(0|D)&F>>>0>0&&Qt(0|h,0,F<<3),O=0|r[(B=s)+4>>2];t:do{if((0|O)>0|!(0|O)&(0|r[B>>2])>>>0>0){R=n,M=h,L=n,O=h,B=n,c=n,S=n,C=h,P=h,n=h;n:for(;;){for(y=0,w=0,x=0,T=0,A=0,u=0;;){d=(h=o)+56|0;do{r[h>>2]=0,h=h+4|0}while((0|h)<(0|d));if(0|N(f=0|r[(t=R+(y<<3)|0)>>2],t=0|r[t+4>>2],1,o,0)){d=(h=o)+56|0;do{r[h>>2]=0,h=h+4|0}while((0|h)<(0|d));0|(h=0|Pt(7,4))&&(k(f,t,1,o,h,7,0,0),Ct(h))}for(v=0;;){b=0|r[(_=o+(v<<3)|0)>>2],_=0|r[_+4>>2];i:do{if(!(0|b)&!(0|_))h=A,d=u;else{if(p=0|Dt(0|b,0|_,0|F,0|D),f=0|E(),!(!(0|(d=0|r[(t=h=i+(p<<3)|0)>>2]))&!(0|(t=0|r[t+4>>2])))){g=0,m=0;do{if((0|g)>(0|D)|(0|g)==(0|D)&m>>>0>F>>>0)break n;if((0|d)==(0|b)&(0|t)==(0|_)){h=A,d=u;break i}p=0|Ft(0|(h=0|Lt(0|p,0|f,1,0)),0|E(),0|F,0|D),f=0|E(),m=0|Lt(0|m,0|g,1,0),g=0|E(),d=0|r[(t=h=i+(p<<3)|0)>>2],t=0|r[t+4>>2]}while(!(!(0|d)&!(0|t)))}if(!(0|b)&!(0|_)){h=A,d=u;break}De(b,_,a),0|lt(e,U,a)&&(m=0|Lt(0|A,0|u,1,0),u=0|E(),r[(g=h)>>2]=b,r[g+4>>2]=_,r[(A=M+(A<<3)|0)>>2]=b,r[A+4>>2]=_,A=m),h=A,d=u}}while(0);if((v=v+1|0)>>>0>=7)break;A=h,u=d}if(y=0|Lt(0|y,0|w,1,0),w=0|E(),x=0|Lt(0|x,0|T,1,0),T=0|E(),A=0|r[(u=s)>>2],!((0|T)<(0|(u=0|r[u+4>>2]))|(0|T)==(0|u)&x>>>0<A>>>0))break;A=h,u=d}if((0|u)>0|!(0|u)&A>>>0>0){A=0,u=0;do{r[(T=R+(A<<3)|0)>>2]=0,r[T+4>>2]=0,A=0|Lt(0|A,0|u,1,0),u=0|E(),x=0|r[(T=s)+4>>2]}while((0|u)<(0|x)|((0|u)==(0|x)?A>>>0<(0|r[T>>2])>>>0:0))}if(r[(T=s)>>2]=h,r[T+4>>2]=d,!((0|d)>0|!(0|d)&h>>>0>0))break t;v=n,y=P,w=B,x=C,T=M,n=S,P=c,C=L,S=v,c=y,B=O,O=w,L=x,M=R,R=T}Ct(L),Ct(O),Ct(U),c=1;break e}c=h}while(0);Ct(U),Ct(n),Ct(c),c=0}}while(0);return I=l,0|(U=c)}}return Ct(U),I=l,0|(U=c)},_polygonToCellsExperimental:function(e,t,n,i,s,o){i|=0,s|=0,o|=0;var a,l,c,A=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0;c=I,I=I+160|0,u=c+64|0,f=c+112|0,m=c,tt(d=c+80|0,e|=0,t|=0,n|=0),ze(u,0|r[(h=d)>>2],0|r[h+4>>2],t),a=0|r[(h=u)>>2],h=0|r[h+4>>2],A=0|r[d+8>>2],r[(p=f+4|0)>>2]=r[d>>2],r[p+4>>2]=r[d+4>>2],r[p+8>>2]=r[d+8>>2],r[p+12>>2]=r[d+12>>2],r[p+16>>2]=r[d+16>>2],r[p+20>>2]=r[d+20>>2],r[p+24>>2]=r[d+24>>2],r[p+28>>2]=r[d+28>>2],r[(p=m)>>2]=a,r[p+4>>2]=h,r[(p=m+8|0)>>2]=A,t=f,n=(e=m+12|0)+36|0;do{r[e>>2]=r[t>>2],e=e+4|0,t=t+4|0}while((0|e)<(0|n));if(r[(f=m+48|0)>>2]=r[u>>2],r[f+4>>2]=r[u+4>>2],r[f+8>>2]=r[u+8>>2],r[f+12>>2]=r[u+12>>2],!(0|a)&!(0|h))return I=c,0|(m=A);n=m+16|0,l=m+24|0,d=m+28|0,A=0,u=0,t=a,e=h;do{if(!((0|A)<(0|s)|(0|A)==(0|s)&u>>>0<i>>>0)){g=4;break}if(h=u,u=0|Lt(0|u,0|A,1,0),A=0|E(),r[(h=o+(h<<3)|0)>>2]=t,r[h+4>>2]=e,je(f),!(0|(t=0|r[(e=f)>>2]))&!(0|(e=0|r[e+4>>2]))){if(nt(n),!(0|(e=0|r[(t=n)>>2]))&!(0|(t=0|r[t+4>>2]))){g=10;break}Ge(e,t,0|r[d>>2],f),t=0|r[(e=f)>>2],e=0|r[e+4>>2]}r[(h=m)>>2]=t,r[h+4>>2]=e}while(!(!(0|t)&!(0|e)));return 4==(0|g)?(0|(t=0|r[(e=m+40|0)>>2])&&Ct(t),r[(g=m+16|0)>>2]=0,r[g+4>>2]=0,r[l>>2]=0,r[m+36>>2]=0,r[d>>2]=-1,r[m+32>>2]=0,r[e>>2]=0,Ge(0,0,0,f),r[m>>2]=0,r[m+4>>2]=0,r[p>>2]=0,I=c,0|(m=14)):(10==(0|g)&&(r[m>>2]=0,r[m+4>>2]=0,r[p>>2]=r[l>>2]),m=0|r[p>>2],I=c,0|m)},_readInt64AsDoubleFromPointer:function(e){return+(+((0|r[(e|=0)>>2])>>>0)+4294967296*+(0|r[e+4>>2]))},_res0CellCount:function(){return 122},_reverseDirectedEdge:ce,_round:Xt,_sbrk:$t,_sizeOfCellBoundary:function(){return 168},_sizeOfCoordIJ:function(){return 8},_sizeOfGeoLoop:function(){return 8},_sizeOfGeoPolygon:function(){return 16},_sizeOfH3Index:function(){return 8},_sizeOfLatLng:function(){return 16},_sizeOfLinkedGeoPolygon:function(){return 12},_uncompactCells:function(e,t,n,i,s,o,a){e|=0,i|=0,s|=0,o|=0;var l,c=0,A=0,u=0,h=0,d=0,f=0,p=0,g=0;if(l=I,I=I+16|0,g=l,!((0|(n|=0))>0|!(0|n)&(t|=0)>>>0>0))return I=l,0|(g=0);if((0|(a|=0))>=16)return I=l,0|(g=12);f=0,p=0,d=0,c=0;e:for(;;){if(h=0|Vt(0|(A=0|r[(u=e+(f<<3)|0)>>2]),0|(u=0|r[u+4>>2]),52),E(),(15&h)>(0|a)){c=12,A=11;break}if(ze(g,A,u,a),!(0|(u=0|r[(h=g)>>2]))&!(0|(h=0|r[h+4>>2])))A=d;else{A=d;do{if(!((0|c)<(0|o)|(0|c)==(0|o)&A>>>0<s>>>0)){A=10;break e}r[(d=i+(A<<3)|0)>>2]=u,r[d+4>>2]=h,A=0|Lt(0|A,0|c,1,0),c=0|E(),je(g),u=0|r[(d=g)>>2],h=0|r[d+4>>2]}while(!(!(0|u)&!(0|h)))}if(f=0|Lt(0|f,0|p,1,0),!((0|(p=0|E()))<(0|n)|(0|p)==(0|n)&f>>>0<t>>>0)){c=0,A=11;break}d=A}return 10==(0|A)?(I=l,0|(g=14)):11==(0|A)?(I=l,0|c):0},_uncompactCellsSize:function(e,t,n,i,s){e|=0,t|=0,n|=0,i|=0,s|=0;var o,a,l=0,c=0,A=0,u=0,h=0,d=0;a=I,I=I+16|0,o=a;e:do{if((0|n)>0|!(0|n)&t>>>0>0){for(h=0,c=0,l=0,d=0;;){if(!(!(0|(A=0|r[(u=e+(h<<3)|0)>>2]))&!(0|(u=0|r[u+4>>2]))||(u=!(0|Te(A,u,i,o)),c=0|Lt(0|r[(A=o)>>2],0|r[A+4>>2],0|c,0|l),l=0|E(),u))){l=12;break}if(h=0|Lt(0|h,0|d,1,0),!((0|(d=0|E()))<(0|n)|(0|d)==(0|n)&h>>>0<t>>>0))break e}return I=a,0|l}c=0,l=0}while(0);return r[s>>2]=c,r[s+4>>2]=l,I=a,0|(s=0)},_vertexToLatLng:function(e,t,n){n|=0;var i,s,o,a,l=0,c=0;return a=I,I=I+192|0,s=a,o=a+168|0,l=0|Vt(0|(e|=0),0|(t|=0),56),E(),l&=7,0|(i=0|Fe(e,c=-2130706433&t|134217728,o))?(I=a,0|(c=i)):(t=0|Vt(0|e,0|t,52),E(),t&=15,0|Ee(e,c)?de(o,t,l,1,s):me(o,t,l,1,s),c=s+8|0,r[n>>2]=r[c>>2],r[n+4>>2]=r[c+4>>2],r[n+8>>2]=r[c+8>>2],r[n+12>>2]=r[c+12>>2],I=a,0|(c=0))},dynCall_iii:function(e,t,n){return t|=0,n|=0,0|Zt[3&(e|=0)](0|t,0|n)},establishStackSpace:function(e,t){I=e|=0},stackAlloc:function(e){var t;return t=I,I=(I=I+(e|=0)|0)+15&-16,0|t},stackRestore:function(e){I=e|=0},stackSave:function(){return 0|I}}}({Math,Int8Array,Int32Array,Uint8Array,Float32Array,Float64Array},J,p),te=(n.___divdi3=ee.___divdi3,n.___muldi3=ee.___muldi3,n.___remdi3=ee.___remdi3,n.___uremdi3=ee.___uremdi3,n._areNeighborCells=ee._areNeighborCells,n._bitshift64Ashr=ee._bitshift64Ashr,n._bitshift64Lshr=ee._bitshift64Lshr,n._bitshift64Shl=ee._bitshift64Shl,n._calloc=ee._calloc,n._cellAreaKm2=ee._cellAreaKm2,n._cellAreaM2=ee._cellAreaM2,n._cellAreaRads2=ee._cellAreaRads2,n._cellToBoundary=ee._cellToBoundary,n._cellToCenterChild=ee._cellToCenterChild,n._cellToChildPos=ee._cellToChildPos,n._cellToChildren=ee._cellToChildren,n._cellToChildrenSize=ee._cellToChildrenSize,n._cellToLatLng=ee._cellToLatLng,n._cellToLocalIj=ee._cellToLocalIj,n._cellToParent=ee._cellToParent,n._cellToVertex=ee._cellToVertex,n._cellToVertexes=ee._cellToVertexes,n._cellsToDirectedEdge=ee._cellsToDirectedEdge,n._cellsToLinkedMultiPolygon=ee._cellsToLinkedMultiPolygon,n._childPosToCell=ee._childPosToCell,n._compactCells=ee._compactCells,n._constructCell=ee._constructCell,n._destroyLinkedMultiPolygon=ee._destroyLinkedMultiPolygon,n._directedEdgeToBoundary=ee._directedEdgeToBoundary,n._directedEdgeToCells=ee._directedEdgeToCells,n._edgeLengthKm=ee._edgeLengthKm,n._edgeLengthM=ee._edgeLengthM,n._edgeLengthRads=ee._edgeLengthRads,n._emscripten_replace_memory=ee._emscripten_replace_memory),ne=(n._free=ee._free,n._getBaseCellNumber=ee._getBaseCellNumber,n._getDirectedEdgeDestination=ee._getDirectedEdgeDestination,n._getDirectedEdgeOrigin=ee._getDirectedEdgeOrigin,n._getHexagonAreaAvgKm2=ee._getHexagonAreaAvgKm2,n._getHexagonAreaAvgM2=ee._getHexagonAreaAvgM2,n._getHexagonEdgeLengthAvgKm=ee._getHexagonEdgeLengthAvgKm,n._getHexagonEdgeLengthAvgM=ee._getHexagonEdgeLengthAvgM,n._getIcosahedronFaces=ee._getIcosahedronFaces,n._getIndexDigit=ee._getIndexDigit,n._getNumCells=ee._getNumCells,n._getPentagons=ee._getPentagons,n._getRes0Cells=ee._getRes0Cells,n._getResolution=ee._getResolution,n._greatCircleDistanceKm=ee._greatCircleDistanceKm,n._greatCircleDistanceM=ee._greatCircleDistanceM,n._greatCircleDistanceRads=ee._greatCircleDistanceRads,n._gridDisk=ee._gridDisk,n._gridDiskDistances=ee._gridDiskDistances,n._gridDistance=ee._gridDistance,n._gridPathCells=ee._gridPathCells,n._gridPathCellsSize=ee._gridPathCellsSize,n._gridRing=ee._gridRing,n._gridRingUnsafe=ee._gridRingUnsafe,n._i64Add=ee._i64Add,n._i64Subtract=ee._i64Subtract,n._isPentagon=ee._isPentagon,n._isResClassIII=ee._isResClassIII,n._isValidCell=ee._isValidCell,n._isValidDirectedEdge=ee._isValidDirectedEdge,n._isValidIndex=ee._isValidIndex,n._isValidVertex=ee._isValidVertex,n._latLngToCell=ee._latLngToCell,n._llvm_ctlz_i64=ee._llvm_ctlz_i64,n._llvm_maxnum_f64=ee._llvm_maxnum_f64,n._llvm_minnum_f64=ee._llvm_minnum_f64,n._llvm_round_f64=ee._llvm_round_f64,n._localIjToCell=ee._localIjToCell,n._malloc=ee._malloc,n._maxFaceCount=ee._maxFaceCount,n._maxGridDiskSize=ee._maxGridDiskSize,n._maxPolygonToCellsSize=ee._maxPolygonToCellsSize,n._maxPolygonToCellsSizeExperimental=ee._maxPolygonToCellsSizeExperimental,n._memcpy=ee._memcpy,n._memmove=ee._memmove,n._memset=ee._memset,n._originToDirectedEdges=ee._originToDirectedEdges,n._pentagonCount=ee._pentagonCount,n._polygonToCells=ee._polygonToCells,n._polygonToCellsExperimental=ee._polygonToCellsExperimental,n._readInt64AsDoubleFromPointer=ee._readInt64AsDoubleFromPointer,n._res0CellCount=ee._res0CellCount,n._reverseDirectedEdge=ee._reverseDirectedEdge,n._round=ee._round,n._sbrk=ee._sbrk,n._sizeOfCellBoundary=ee._sizeOfCellBoundary,n._sizeOfCoordIJ=ee._sizeOfCoordIJ,n._sizeOfGeoLoop=ee._sizeOfGeoLoop,n._sizeOfGeoPolygon=ee._sizeOfGeoPolygon,n._sizeOfH3Index=ee._sizeOfH3Index,n._sizeOfLatLng=ee._sizeOfLatLng,n._sizeOfLinkedGeoPolygon=ee._sizeOfLinkedGeoPolygon,n._uncompactCells=ee._uncompactCells,n._uncompactCellsSize=ee._uncompactCellsSize,n._vertexToLatLng=ee._vertexToLatLng,n.establishStackSpace=ee.establishStackSpace,n.stackAlloc=ee.stackAlloc),ie=n.stackRestore=ee.stackRestore,re=n.stackSave=ee.stackSave;n.dynCall_iii=ee.dynCall_iii;if(n.asm=ee,n.cwrap=function(e,t,n,i){var r=(n=n||[]).every(function(e){return"number"===e});return"string"!==t&&r&&!i?u(e):function(){return h(e,t,n,arguments)}},n.setValue=function(e,t,n,i){switch("*"===(n=n||"i8").charAt(n.length-1)&&(n="i32"),n){case"i1":case"i8":g[e|0]=t;break;case"i16":b[e>>1]=t;break;case"i32":_[e>>2]=t;break;case"i64":V=[t>>>0,(U=t,+I(U)>=1?U>0?(0|N(+B(U/4294967296),4294967295))>>>0:~~+O((U-+(~~U>>>0))/4294967296)>>>0:0)],_[e>>2]=V[0],_[e+4>>2]=V[1];break;case"float":v[e>>2]=t;break;case"double":y[e>>3]=t;break;default:Ae("invalid type for setValue: "+n)}},n.getValue=function(e,t,n){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return g[e|0];case"i16":return b[e>>1];case"i32":case"i64":return _[e>>2];case"float":return v[e>>2];case"double":return y[e>>3];default:Ae("invalid type for getValue: "+t)}return null},z){j(z)||(Z=z,z=n.locateFile?n.locateFile(Z,o):o+Z),k++,n.monitorRunDependencies&&n.monitorRunDependencies(k);var se=function(e){e.byteLength&&(e=new Uint8Array(e)),m.set(e,8),n.memoryInitializerRequest&&delete n.memoryInitializerRequest.response,function(){if(k--,n.monitorRunDependencies&&n.monitorRunDependencies(k),0==k&&(null!==F&&(clearInterval(F),F=null),D)){var e=D;D=null,e()}}()},oe=function(){r(z,se,function(){throw"could not load memory initializer "+z})},ae=$(z);if(ae)se(ae.buffer);else if(n.memoryInitializerRequest){var le=function(){var e=n.memoryInitializerRequest,t=e.response;if(200!==e.status&&0!==e.status){var i=$(n.memoryInitializerRequestURL);if(!i)return console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+e.status+", retrying "+z),void oe();t=i.buffer}se(t)};n.memoryInitializerRequest.response?setTimeout(le,0):n.memoryInitializerRequest.addEventListener("load",le)}else oe()}function ce(e){function t(){Y||(Y=!0,A||(E(C),E(P),n.onRuntimeInitialized&&n.onRuntimeInitialized(),function(){if(n.postRun)for("function"==typeof n.postRun&&(n.postRun=[n.postRun]);n.postRun.length;)L(n.postRun.shift());E(R)}()))}e=e||s,k>0||(!function(){if(n.preRun)for("function"==typeof n.preRun&&(n.preRun=[n.preRun]);n.preRun.length;)M(n.preRun.shift());E(S)}(),k>0||(n.setStatus?(n.setStatus("Running..."),setTimeout(function(){setTimeout(function(){n.setStatus("")},1),t()},1)):t()))}function Ae(e){throw n.onAbort&&n.onAbort(e),a(e+=""),l(e),A=!0,"abort("+e+"). Build with -s ASSERTIONS=1 for more info."}if(D=function e(){Y||ce(),Y||(D=e)},n.run=ce,n.abort=Ae,n.preInit)for("function"==typeof n.preInit&&(n.preInit=[n.preInit]);n.preInit.length>0;)n.preInit.pop()();return ce(),e}("object"==typeof Dg?Dg:{}),Ug="number",Vg={0:"Success",1:"The operation failed but a more specific error is not available",2:"Argument was outside of acceptable range",3:"Latitude or longitude arguments were outside of acceptable range",4:"Resolution argument was outside of acceptable range",5:"Cell argument was not valid",6:"Directed edge argument was not valid",7:"Undirected edge argument was not valid",8:"Vertex argument was not valid",9:"Pentagon distortion was encountered",10:"Duplicate input",11:"Cell arguments were not neighbors",12:"Cell arguments had incompatible resolutions",13:"Memory allocation failed",14:"Bounds of provided memory were insufficient",15:"Mode or flags argument was not valid",16:"Index argument was not valid",17:"Base cell number was outside of acceptable range",18:"Child indexing digits invalid",19:"Child indexing digits refer to a deleted subsequence"},zg=1e3,Gg={1e3:"Unknown unit",1001:"Array length out of bounds",1002:"Got unexpected null value for H3 index"};function jg(e,t,n){var i=n&&"value"in n,r=new Error((e[t]||"Unknown error")+" (code: "+t+(i?", value: "+n.value:"")+")");return r.code=t,r}function Hg(e,t){return jg(Vg,e,2===arguments.length?{value:t}:{})}function Wg(e,t){return jg(Gg,e,2===arguments.length?{value:t}:{})}function qg(e){if(0!==e)throw Hg(e)}var Kg={};[["sizeOfH3Index",Ug],["sizeOfLatLng",Ug],["sizeOfCellBoundary",Ug],["sizeOfGeoLoop",Ug],["sizeOfGeoPolygon",Ug],["sizeOfLinkedGeoPolygon",Ug],["sizeOfCoordIJ",Ug],["readInt64AsDoubleFromPointer",Ug],["isValidCell",Ug,[Ug,Ug]],["isValidIndex",Ug,[Ug,Ug]],["latLngToCell",Ug,[Ug,Ug,Ug,Ug]],["cellToLatLng",Ug,[Ug,Ug,Ug]],["cellToBoundary",Ug,[Ug,Ug,Ug]],["maxGridDiskSize",Ug,[Ug,Ug]],["gridDisk",Ug,[Ug,Ug,Ug,Ug]],["gridDiskDistances",Ug,[Ug,Ug,Ug,Ug,Ug]],["gridRing",Ug,[Ug,Ug,Ug,Ug]],["gridRingUnsafe",Ug,[Ug,Ug,Ug,Ug]],["maxPolygonToCellsSize",Ug,[Ug,Ug,Ug,Ug]],["polygonToCells",Ug,[Ug,Ug,Ug,Ug]],["maxPolygonToCellsSizeExperimental",Ug,[Ug,Ug,Ug,Ug]],["polygonToCellsExperimental",Ug,[Ug,Ug,Ug,Ug,Ug,Ug]],["cellsToLinkedMultiPolygon",Ug,[Ug,Ug,Ug]],["destroyLinkedMultiPolygon",null,[Ug]],["compactCells",Ug,[Ug,Ug,Ug,Ug]],["uncompactCells",Ug,[Ug,Ug,Ug,Ug,Ug,Ug]],["uncompactCellsSize",Ug,[Ug,Ug,Ug,Ug,Ug]],["isPentagon",Ug,[Ug,Ug]],["isResClassIII",Ug,[Ug,Ug]],["getBaseCellNumber",Ug,[Ug,Ug]],["getResolution",Ug,[Ug,Ug]],["getIndexDigit",Ug,[Ug,Ug,Ug]],["constructCell",Ug,[Ug,Ug,Ug,Ug]],["maxFaceCount",Ug,[Ug,Ug,Ug]],["getIcosahedronFaces",Ug,[Ug,Ug,Ug]],["cellToParent",Ug,[Ug,Ug,Ug,Ug]],["cellToChildren",Ug,[Ug,Ug,Ug,Ug]],["cellToCenterChild",Ug,[Ug,Ug,Ug,Ug]],["cellToChildrenSize",Ug,[Ug,Ug,Ug,Ug]],["cellToChildPos",Ug,[Ug,Ug,Ug,Ug]],["childPosToCell",Ug,[Ug,Ug,Ug,Ug,Ug,Ug]],["areNeighborCells",Ug,[Ug,Ug,Ug,Ug,Ug]],["cellsToDirectedEdge",Ug,[Ug,Ug,Ug,Ug,Ug]],["getDirectedEdgeOrigin",Ug,[Ug,Ug,Ug]],["getDirectedEdgeDestination",Ug,[Ug,Ug,Ug]],["isValidDirectedEdge",Ug,[Ug,Ug]],["directedEdgeToCells",Ug,[Ug,Ug,Ug]],["originToDirectedEdges",Ug,[Ug,Ug,Ug]],["directedEdgeToBoundary",Ug,[Ug,Ug,Ug]],["reverseDirectedEdge",Ug,[Ug,Ug,Ug]],["gridDistance",Ug,[Ug,Ug,Ug,Ug,Ug]],["gridPathCells",Ug,[Ug,Ug,Ug,Ug,Ug]],["gridPathCellsSize",Ug,[Ug,Ug,Ug,Ug,Ug]],["cellToLocalIj",Ug,[Ug,Ug,Ug,Ug,Ug,Ug]],["localIjToCell",Ug,[Ug,Ug,Ug,Ug,Ug]],["getHexagonAreaAvgM2",Ug,[Ug,Ug]],["getHexagonAreaAvgKm2",Ug,[Ug,Ug]],["getHexagonEdgeLengthAvgM",Ug,[Ug,Ug]],["getHexagonEdgeLengthAvgKm",Ug,[Ug,Ug]],["greatCircleDistanceM",Ug,[Ug,Ug]],["greatCircleDistanceKm",Ug,[Ug,Ug]],["greatCircleDistanceRads",Ug,[Ug,Ug]],["cellAreaM2",Ug,[Ug,Ug,Ug]],["cellAreaKm2",Ug,[Ug,Ug,Ug]],["cellAreaRads2",Ug,[Ug,Ug,Ug]],["edgeLengthM",Ug,[Ug,Ug,Ug]],["edgeLengthKm",Ug,[Ug,Ug,Ug]],["edgeLengthRads",Ug,[Ug,Ug,Ug]],["getNumCells",Ug,[Ug,Ug]],["getRes0Cells",Ug,[Ug]],["res0CellCount",Ug],["getPentagons",Ug,[Ug,Ug]],["pentagonCount",Ug],["cellToVertex",Ug,[Ug,Ug,Ug,Ug]],["cellToVertexes",Ug,[Ug,Ug,Ug]],["vertexToLatLng",Ug,[Ug,Ug,Ug]],["isValidVertex",Ug,[Ug,Ug]]].forEach(function(e){Kg[e[0]]=Dg.cwrap.apply(Dg,e)});var Qg=16,Xg=Kg.sizeOfH3Index(),$g=Kg.sizeOfLatLng(),Zg=Kg.sizeOfCellBoundary(),Yg=(Kg.sizeOfGeoPolygon(),Kg.sizeOfGeoLoop(),Kg.sizeOfLinkedGeoPolygon()),Jg=(Kg.sizeOfCoordIJ(),"m"),em="km";function tm(e){if("number"!=typeof e||e<0||e>15||Math.floor(e)!==e)throw Hg(4,e);return e}function nm(e){if(!e)throw Wg(1002);return e}Math.pow(2,32),Math.pow(2,31);var im=/[^0-9a-fA-F]/;function rm(e){if(Array.isArray(e)&&2===e.length&&Number.isInteger(e[0])&&Number.isInteger(e[1]))return e;if("string"!=typeof e||im.test(e))return[0,0];var t=parseInt(e.substring(0,e.length-8),Qg);return[parseInt(e.substring(e.length-8),Qg),t]}function sm(e){if(e>=0)return e.toString(Qg);var t=om(8,(e&=2147483647).toString(Qg));return t=(parseInt(t[0],Qg)+8).toString(Qg)+t.substring(1)}function om(e,t){for(var n=e-t.length,i="",r=0;r<n;r++)i+="0";return i+=t}Math.pow(2,32);function am(e,t){void 0===t&&(t=0);var n=Dg.getValue(e+Xg*t,"i32"),i=Dg.getValue(e+Xg*t+4,"i32");return i?function(e,t){return sm(t)+om(8,sm(e))}(n,i):null}function lm(e,t){return void 0===t&&(t=0),Dg.getValue(e+8*t,"double")}function cm(e){return Kg.readInt64AsDoubleFromPointer(e)}function Am(e,t,n){Dg.HEAPU32.set(rm(e),t/4+2*n)}function um(e,t){for(var n=t.length,i=0;i<n;i++)Am(t[i],e,i)}function hm(e){return 180*Dg.getValue(e,"double")/Math.PI}function dm(e){return[hm(e),hm(e+8)]}function fm(e){return[hm(e+8),hm(e)]}function pm(e,t,n){for(var i=Dg.getValue(e,"i32"),r=e+8,s=[],o=t?fm:dm,a=0;a<2*i;a+=2)s.push(o(r+8*a));return n&&s.push(s[0]),s}function gm(e){var t=rm(e),n=t[0],i=t[1];return Boolean(Kg.isPentagon(n,i))}function mm(e){var t=rm(e),n=t[0],i=t[1];return Kg.isValidCell(n,i)?Kg.getResolution(n,i):-1}function bm(e){var t=Dg._malloc($g),n=rm(e),i=n[0],r=n[1];try{return qg(Kg.cellToLatLng(i,r,t)),dm(t)}finally{Dg._free(t)}}function _m(e,t){if(!e||!e.length)return[];var n=e.length,i=Dg._calloc(n,Xg);um(i,e);var r=Dg._calloc(Yg);try{return qg(Kg.cellsToLinkedMultiPolygon(i,n,r)),function(e,t){for(var n,i,r,s,o=[],a=t?fm:dm;e;){for(o.push(n=[]),i=Dg.getValue(e,"i8*");i;){for(n.push(r=[]),s=Dg.getValue(i,"i8*");s;)r.push(a(s)),s=Dg.getValue(s+16,"i8*");t&&r.push(r[0]),i=Dg.getValue(i+8,"i8*")}e=Dg.getValue(e+8,"i8*")}return o}(r,t)}finally{Kg.destroyLinkedMultiPolygon(r),Dg._free(r),Dg._free(i)}}function vm(e,t){tm(e);var n=Dg._malloc(8);try{switch(t){case Jg:qg(Kg.getHexagonEdgeLengthAvgM(e,n));break;case em:qg(Kg.getHexagonEdgeLengthAvgKm(e,n));break;default:throw Wg(zg,t)}return lm(n)}finally{Dg._free(n)}}function ym(e){return e*Math.PI/180}function wm(e,t){t=void 0===t?e[0][0]:t;for(const n of e){const e=n[0]-t;e>180?n[0]-=360:e<-180&&(n[0]+=360)}}function xm(e,t,n){const i=e(t,n),[r,s]=bm(i);return[s,r]}function Tm(e,t=1){const n=function(e,t){var n=Dg._malloc(Zg),i=rm(e),r=i[0],s=i[1];try{return qg(Kg.cellToBoundary(r,s,n)),pm(n,t,t)}finally{Dg._free(n)}}(e,!0);return 1!==t?function(e,t,n){const[i,r]=bm(e),s=t.length;wm(t,r);const o=t[0]===t[s-1]?s-1:s;for(let e=0;e<o;e++)t[e][0]=(0,xn.Cc)(r,t[e][0],n),t[e][1]=(0,xn.Cc)(i,t[e][1],n)}(e,n,t):wm(n),n}function Em(e){const t=new Float64Array(2*e.length);let n=0;for(const i of e)t[n++]=i[0],t[n++]=i[1];return t}class A5Layer extends bu{indexToBounds(){const{data:e,getPentagon:t}=this.props;return{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(e,n)=>{const i=t(e,n);return Em(Ng("string"==typeof i?BigInt(`0x${i}`):i,{closedRing:!0,segments:"auto"}))}}}}A5Layer.layerName="A5Layer",A5Layer.defaultProps={getPentagon:{type:"accessor",value:e=>e.pentagon}};const Sm=A5Layer;class GreatCircleLayer extends Mo{}GreatCircleLayer.layerName="GreatCircleLayer",GreatCircleLayer.defaultProps={getHeight:{type:"accessor",value:0},greatCircle:!0};const Cm=GreatCircleLayer;var Pm=n(81456);const Rm=180/Math.PI;function Mm(e,t,n){const i=1<<t;return[(e[0]+n[0])/i,(e[1]+n[1])/i]}function Lm(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function Im(e){return[Lm(e[0]),Lm(e[1])]}function Om(e,[t,n]){switch(e){case 0:return[1,t,n];case 1:return[-t,1,n];case 2:return[-t,-n,1];case 3:return[-1,-n,-t];case 4:return[n,-1,-t];case 5:return[n,t,-1];default:throw new Error("Invalid face")}}function Bm([e,t,n]){const i=Math.atan2(n,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*Rm,i*Rm]}function Nm(e,t,n,i){if(0===i){1===n&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);const i=t[0];t[0]=t[1],t[1]=i}}function km(e){if("string"==typeof e){if(e.indexOf("/")>0)return e;e=function(e){const t=e.padEnd(16,"0");return Pm.fromString(t,16)}(e)}return function(e){let t=Pm.fromString(e,!0,10).toString(2);for(;t.length<64;)t="0"+t;const n=t.lastIndexOf("1"),i=t.substring(0,3),r=t.substring(3,n),s=r.length/2,o=Pm.fromString(i,!0,2).toString(10);let a=Pm.fromString(r,!0,2).toString(4);for(;a.length<s;)a="0"+a;return`${o}/${a}`}(e.toString())}function Fm(e){return function({face:e,ij:t,level:n}){const i=[[0,0],[0,1],[1,1],[1,0],[0,0]],r=Math.max(1,Math.ceil(100*Math.pow(2,-n))),s=new Float64Array(4*r*2+2);let o=0,a=0;for(let l=0;l<4;l++){const c=i[l].slice(0),A=i[l+1],u=(A[0]-c[0])/r,h=(A[1]-c[1])/r;for(let i=0;i<r;i++){c[0]+=u,c[1]+=h;const i=Bm(Om(e,Im(Mm(t,n,c))));Math.abs(i[1])>89.999&&(i[0]=a);const r=i[0]-a;i[0]+=r>180?-360:r<-180?360:0,s[o++]=i[0],s[o++]=i[1],a=i[0]}}return s[o++]=s[0],s[o++]=s[1],s}(function(e){const t=e.split("/"),n=parseInt(t[0],10),i=t[1],r=i.length,s=[0,0];let o;for(let e=r-1;e>=0;e--){o=r-e;const t=i[e];let n=0,a=0;"1"===t?a=1:"2"===t?(n=1,a=1):"3"===t&&(n=1);const l=Math.pow(2,o-1);Nm(l,s,n,a),s[0]+=l*n,s[1]+=l*a}if(n%2==1){const e=s[0];s[0]=s[1],s[1]=e}return{face:n,ij:s,level:o}}(km(e)))}class S2Layer extends bu{indexToBounds(){const{data:e,getS2Token:t}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(e,n)=>Fm(t(e,n))}}}S2Layer.layerName="S2Layer",S2Layer.defaultProps={getS2Token:{type:"accessor",value:e=>e.token}};const Dm=S2Layer;function Um(e,t=1){const[n,i]=function(e,t){let n=0,i=0,r=1<<e.length;const s=r/512;for(let t=0;t<e.length;t++){r>>=1;const s=parseInt(e[t]);s%2&&(n|=r),s>1&&(i|=r)}return[[n/s,512-i/s],[(n+t)/s,512-(i+t)/s]]}(e,t),[r,s]=(0,Ln.iV)(n),[o,a]=(0,Ln.iV)(i);return[o,s,o,a,r,a,r,s,o,s]}class QuadkeyLayer extends bu{indexToBounds(){const{data:e,extruded:t,getQuadkey:n}=this.props,i=t?.99:1;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(e,t)=>Um(n(e,t),i),updateTriggers:{getPolygon:i}}}}QuadkeyLayer.layerName="QuadkeyLayer",QuadkeyLayer.defaultProps={getQuadkey:{type:"accessor",value:e=>e.quadkey}};const Vm=QuadkeyLayer;const zm={...yl.defaultProps,highPrecision:"auto",coverage:{type:"number",min:0,max:1,value:1},centerHexagon:null,getHexagon:{type:"accessor",value:e=>e.hexagon},extruded:!0};class H3HexagonLayer extends Ss{initializeState(){H3HexagonLayer._checkH3Lib(),this.state={edgeLengthKM:0,resolution:-1}}shouldUpdateState({changeFlags:e}){return this._shouldUseHighPrecision()?e.propsOrDataChanged:e.somethingChanged}updateState({props:e,changeFlags:t}){if(!0!==e.highPrecision&&(t.dataChanged||t.updateTriggersChanged&&t.updateTriggersChanged.getHexagon)){const e=this._calculateH3DataProps();this.setState(e)}this._updateVertices(this.context.viewport)}_calculateH3DataProps(){let e=-1,t=!1,n=!1;const{iterable:i,objectInfo:r}=br(this.props.data);for(const s of i){r.index++;const i=this.props.getHexagon(s,r),o=mm(i);if(e<0){if(e=o,!this.props.highPrecision)break}else if(e!==o){n=!0;break}if(gm(i)){t=!0;break}}return{resolution:e,edgeLengthKM:e>=0?vm(e,"km"):0,hasMultipleRes:n,hasPentagon:t}}_shouldUseHighPrecision(){if("auto"===this.props.highPrecision){const{resolution:e,hasPentagon:t,hasMultipleRes:n}=this.state,{viewport:i}=this.context;return Boolean(i?.resolution)||n||t||e>=0&&e<=5}return this.props.highPrecision}_updateVertices(e){if(this._shouldUseHighPrecision())return;const{resolution:t,edgeLengthKM:n,centerHex:i}=this.state;if(t<0)return;const r=this.props.centerHexagon||function(e,t,n){var i=Dg._malloc($g);Dg.HEAPF64.set([e,t].map(ym),i/8);var r=Dg._malloc(Xg);try{return qg(Kg.latLngToCell(i,n,r)),nm(am(r))}finally{Dg._free(r),Dg._free(i)}}(e.latitude,e.longitude,t);if(i===r)return;if(i)try{if(function(e,t){var n=rm(e),i=n[0],r=n[1],s=rm(t),o=s[0],a=s[1],l=Dg._malloc(8);try{return qg(Kg.gridDistance(i,r,o,a,l)),cm(l)}finally{Dg._free(l)}}(i,r)*n<10)return}catch{}const{unitsPerMeter:s}=e.distanceScales;let o=Tm(r);const[a,l]=bm(r),[c,A]=e.projectFlat([l,a]);o=o.map(t=>{const n=e.projectFlat(t);return[(n[0]-c)/s[0],(n[1]-A)/s[1]]}),this.setState({centerHex:r,vertices:o})}renderLayers(){return this._shouldUseHighPrecision()?this._renderPolygonLayer():this._renderColumnLayer()}_getForwardProps(){const{elevationScale:e,material:t,coverage:n,extruded:i,wireframe:r,stroked:s,filled:o,lineWidthUnits:a,lineWidthScale:l,lineWidthMinPixels:c,lineWidthMaxPixels:A,getFillColor:u,getElevation:h,getLineColor:d,getLineWidth:f,transitions:p,updateTriggers:g}=this.props;return{elevationScale:e,extruded:i,coverage:n,wireframe:r,stroked:s,filled:o,lineWidthUnits:a,lineWidthScale:l,lineWidthMinPixels:c,lineWidthMaxPixels:A,material:t,getElevation:h,getFillColor:u,getLineColor:d,getLineWidth:f,transitions:p,updateTriggers:{getFillColor:g.getFillColor,getElevation:g.getElevation,getLineColor:g.getLineColor,getLineWidth:g.getLineWidth}}}_renderPolygonLayer(){const{data:e,getHexagon:t,updateTriggers:n,coverage:i}=this.props,r=this.getSubLayerClass("hexagon-cell-hifi",yl),s=this._getForwardProps();return s.updateTriggers.getPolygon=function(e,t){let n;return n=null==e?t:"object"==typeof e?{...e,coverage:t}:{getHexagon:e,coverage:t},n}(n.getHexagon,i),new r(s,this.getSubLayerProps({id:"hexagon-cell-hifi",updateTriggers:s.updateTriggers}),{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(e,n)=>Em(Tm(t(e,n),i))})}_renderColumnLayer(){const{data:e,getHexagon:t,updateTriggers:n}=this.props,i=this.getSubLayerClass("hexagon-cell",Sa),r=this._getForwardProps();return r.updateTriggers.getPosition=n.getHexagon,new i(r,this.getSubLayerProps({id:"hexagon-cell",flatShading:!0,updateTriggers:r.updateTriggers}),{data:e,diskResolution:6,radius:1,vertices:this.state.vertices,getPosition:xm.bind(null,t)})}}H3HexagonLayer.defaultProps=zm,H3HexagonLayer.layerName="H3HexagonLayer",H3HexagonLayer._checkH3Lib=()=>{};const Gm=H3HexagonLayer;class H3ClusterLayer extends bu{initializeState(){Gm._checkH3Lib()}updateState({props:e,changeFlags:t}){if(t.dataChanged||t.updateTriggersChanged&&t.updateTriggersChanged.getHexagons){const{data:t,getHexagons:n}=e,i=[],{iterable:r,objectInfo:s}=br(t);for(const e of r){s.index++;const t=_m(n(e,s),!0);for(const n of t){for(const e of n)wm(e);i.push(this.getSubLayerRow({polygon:n},e,s.index))}}this.setState({polygons:i})}}indexToBounds(){const{getElevation:e,getFillColor:t,getLineColor:n,getLineWidth:i}=this.props;return{data:this.state.polygons,getPolygon:e=>e.polygon,getElevation:this.getSubLayerAccessor(e),getFillColor:this.getSubLayerAccessor(t),getLineColor:this.getSubLayerAccessor(n),getLineWidth:this.getSubLayerAccessor(i)}}}H3ClusterLayer.layerName="H3ClusterLayer",H3ClusterLayer.defaultProps={getHexagons:{type:"accessor",value:e=>e.hexagons}};const jm=H3ClusterLayer,Hm={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={...Hm,...e},this.stats=new lt.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--,this._issueNewRequests())};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)}}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,requestScheduler:t,onLoad:n,onError:i}){const{index:r,id:s,bbox:o,userData:a,zoom:l}=this,c=this._loaderId;this._abortController=new AbortController;const{signal:A}=this._abortController,u=await t.scheduleRequest(this,e=>e.isSelected?1:-1);if(!u)return void(this._isCancelled=!0);if(this._isCancelled)return void u.done();let h,d=null;try{d=await e({index:r,id:s,bbox:o,userData:a,zoom:l,signal:A})}catch(e){h=e||!0}finally{u.done()}c===this._loaderId&&(this._loader=void 0,this.content=d,!this._isCancelled||d?(this._isLoaded=!0,this._isCancelled=!1,h?i(h,this):n(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())}}const Wm=-1,qm=0,Km=1,Qm=new oi.P,Xm=new oi.P;class AxisAlignedBoundingBox{constructor(e=[0,0,0],t=[0,0,0],n){n=n||Qm.copy(e).add(t).scale(.5),this.center=new oi.P(n),this.halfDiagonal=new oi.P(t).subtract(this.center),this.minimum=new oi.P(e),this.maximum=new oi.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=Xm.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?Km:r+i<0?Wm:qm}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=Qm.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 $m=n(90218);const Zm=new oi.P,Ym=new oi.P;class BoundingSphere{constructor(e=[0,0,0],t=0){this.radius=-0,this.center=new oi.P,this.fromCenterRadius(e,t)}fromCenterRadius(e,t){return this.center.from(e),this.radius=t,this}fromCornerPoints(e,t){return t=Zm.from(t),this.center=(new oi.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=Zm.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 Ym.copy(s).scale((-n+a)/o).add(t),this.center.copy(Ym),this.radius=a,this}expand(e){const t=Zm.from(e).subtract(this.center).magnitude();return t>this.radius&&(this.radius=t),this}transform(e){this.center.transform(e);const t=$m.IL(Zm,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=Zm.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?Wm:i<n?qm:Km}}var Jm=n(46022),eb=n(73731),tb=n(68225),nb=n(50741);function ib(e,t,n){const i=t[0],r=t[1],s=t[2],o=t[3],a=t[4],l=t[5],c=t[6],A=t[7],u=t[8],h=n[0],d=n[1],f=n[2],p=n[3],g=n[4],m=n[5],b=n[6],_=n[7],v=n[8];return e[0]=h*i+d*o+f*c,e[1]=h*r+d*a+f*A,e[2]=h*s+d*l+f*u,e[3]=p*i+g*o+m*c,e[4]=p*r+g*a+m*A,e[5]=p*s+g*l+m*u,e[6]=b*i+_*o+v*c,e[7]=b*r+_*a+v*A,e[8]=b*s+_*l+v*u,e}function rb(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 sb,ob=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"}(sb||(sb={}));const ab=Object.freeze([1,0,0,0,1,0,0,0,1]);class Matrix3 extends Jm.u{static get IDENTITY(){return function(){cb||(cb=new Matrix3,Object.freeze(cb));return cb}()}static get ZERO(){return function(){lb||(lb=new Matrix3([0,0,0,0,0,0,0,0,0]),Object.freeze(lb));return lb}()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return sb}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(ab)}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,l=r+r,c=n*o,A=i*o,u=i*a,h=r*o,d=r*a,f=r*l,p=s*o,g=s*a,m=s*l;e[0]=1-u-f,e[3]=A-m,e[6]=h+g,e[1]=A+m,e[4]=1-c-f,e[7]=d-p,e[2]=h-g,e[5]=d+p,e[8]=1-c-u}(this,e),this.check()}set(e,t,n,i,r,s,o,a,l){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]=l,this.check()}setRowMajor(e,t,n,i,r,s,o,a,l){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]=l,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],l=e[7],c=e[8];return t*(c*s-o*l)+n*(-c*r+o*a)+i*(l*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],l=t[6],c=t[7],A=t[8],u=A*o-a*c,h=-A*s+a*l,d=c*s-o*l;let f=n*u+i*h+r*d;f&&(f=1/f,e[0]=u*f,e[1]=(-A*i+r*c)*f,e[2]=(a*i-r*o)*f,e[3]=h*f,e[4]=(A*n-r*l)*f,e[5]=(-a*n+r*s)*f,e[6]=d*f,e[7]=(-c*n+i*l)*f,e[8]=(o*n-i*s)*f)}(this,this),this.check()}multiplyLeft(e){return ib(this,e,this),this.check()}multiplyRight(e){return ib(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],l=t[5],c=t[6],A=t[7],u=t[8],h=Math.sin(n),d=Math.cos(n);e[0]=d*i+h*o,e[1]=d*r+h*a,e[2]=d*s+h*l,e[3]=d*o-h*i,e[4]=d*a-h*r,e[5]=d*l-h*s,e[6]=c,e[7]=A,e[8]=u}(this,this,e),this.check()}scale(e){return Array.isArray(e)?rb(this,this,e):rb(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],l=t[5],c=t[6],A=t[7],u=t[8],h=n[0],d=n[1];e[0]=i,e[1]=r,e[2]=s,e[3]=o,e[4]=a,e[5]=l,e[6]=h*i+d*o+c,e[7]=h*r+d*a+A,e[8]=h*s+d*l+u}(this,this,e),this.check()}transform(e,t){let n;switch(e.length){case 2:n=(0,ob.ei)(t||[-0,-0],e,this);break;case 3:n=(0,In.ei)(t||[-0,-0,-0],e,this);break;case 4:n=(0,tb.vE)(t||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return(0,eb.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 lb,cb=null;var Ab=n(58073),ub=n(54272);let hb;class Vector4 extends ub.M{static get ZERO(){return hb||(hb=new Vector4(0,0,0,0),Object.freeze(hb)),hb}constructor(e=0,t=0,n=0,i=0){super(-0,-0,-0,-0),(0,xn.cy)(e)&&1===arguments.length?this.copy(e):(xn.$W.debug&&((0,eb.ws)(e),(0,eb.ws)(t),(0,eb.ws)(n),(0,eb.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 xn.$W.debug&&((0,eb.ws)(e.x),(0,eb.ws)(e.y),(0,eb.ws)(e.z),(0,eb.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,eb.ws)(e)}get w(){return this[3]}set w(e){this[3]=(0,eb.ws)(e)}transform(e){return(0,In.Z0)(this,this,e),this.check()}transformByMatrix3(e){return(0,tb.vE)(this,this,e),this.check()}transformByMatrix2(e){return(0,tb.Cg)(this,this,e),this.check()}transformByQuaternion(e){return(0,In.gL)(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}}function db(){const e=new nb.tb(4);return nb.tb!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function fb(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 pb(e,t,n){const i=t[0],r=t[1],s=t[2],o=t[3],a=n[0],l=n[1],c=n[2],A=n[3];return e[0]=i*A+o*a+r*c-s*l,e[1]=r*A+o*l+s*a-i*c,e[2]=s*A+o*c+i*l-r*a,e[3]=o*A-i*a-r*l-s*c,e}function gb(e,t,n,i){const r=t[0],s=t[1],o=t[2],a=t[3];let l,c,A,u,h,d=n[0],f=n[1],p=n[2],g=n[3];return l=r*d+s*f+o*p+a*g,l<0&&(l=-l,d=-d,f=-f,p=-p,g=-g),1-l>nb.p8?(c=Math.acos(l),h=Math.sin(c),A=Math.sin((1-i)*c)/h,u=Math.sin(i*c)/h):(A=1-i,u=i),e[0]=A*r+u*d,e[1]=A*s+u*f,e[2]=A*o+u*p,e[3]=A*a+u*g,e}function mb(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}On.o8,On.fA,On.C,On.hZ;const bb=On.WQ,_b=On.hs,vb=On.Om,yb=On.Cc,wb=On.Bw,xb=On.m3,Tb=On.S8;On.t2;const Eb=function(){const e=In.vt(),t=In.fA(1,0,0),n=In.fA(0,1,0);return function(i,r,s){const o=In.Om(r,s);return o<-.999999?(In.$A(e,t,r),In.Il(e)<1e-6&&In.$A(e,n,r),In.S8(e,e),fb(i,e,Math.PI),i):o>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(In.$A(e,r,s),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=1+o,Tb(i,i))}}(),Sb=(function(){const e=db(),t=db()}(),function(){const e=function(){const e=new nb.tb(9);return nb.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 Ab.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 mb(this,e),this.check()}fromAxisRotation(e,t){return fb(this,e,t),this.check()}identity(){return function(e){e[0]=0,e[1]=0,e[2]=0,e[3]=1}(this),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,eb.ws)(e)}get y(){return this[1]}set y(e){this[1]=(0,eb.ws)(e)}get z(){return this[2]}set z(e){this[2]=(0,eb.ws)(e)}get w(){return this[3]}set w(e){this[3]=(0,eb.ws)(e)}len(){return wb(this)}lengthSquared(){return xb(this)}dot(e){return vb(this,e)}rotationTo(e,t){return Eb(this,e,t),this.check()}add(e){return bb(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(){return function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3]}(this,this),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):(yb(this,e,t,n),this.check())}multiplyRight(e){return pb(this,this,e),this.check()}multiplyLeft(e){return pb(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),l=Math.cos(n);e[0]=i*l+o*a,e[1]=r*l+s*a,e[2]=s*l-r*a,e[3]=o*l-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),l=Math.cos(n);e[0]=i*l-s*a,e[1]=r*l+o*a,e[2]=s*l+i*a,e[3]=o*l-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),l=Math.cos(n);e[0]=i*l+r*a,e[1]=r*l-i*a,e[2]=s*l+o*a,e[3]=o*l-s*a}(this,this,e),this.check()}scale(e){return _b(this,this,e),this.check()}slerp(e,t,n){let i,r,s;switch(arguments.length){case 1:({start:i=Sb,target:r,ratio:s}=e);break;case 2:i=this,r=e,s=t;break;default:i=e,r=t,s=n}return gb(this,i,r,s),this.check()}transformVector4(e,t=new Vector4){return(0,On.gL)(t,e,this),(0,eb.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 Cb=new oi.P,Pb=new oi.P,Rb=new oi.P,Mb=new oi.P,Lb=new oi.P,Ib=new oi.P,Ob=new oi.P,Bb=0,Nb=1,kb=2,Fb=3,Db=4,Ub=5,Vb=6,zb=7,Gb=8;class OrientedBoundingBox{constructor(e=[0,0,0],t=[0,0,0,0,0,0,0,0,0]){this.center=(new oi.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 oi.P(e).len(),new oi.P(t).len(),new oi.P(n).len()]}get quaternion(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2),i=new oi.P(e).normalize(),r=new oi.P(t).normalize(),s=new oi.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 oi.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,Rb),i=t.getColumn(1,Mb),r=t.getColumn(2,Lb),s=Cb.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[Bb]+s*i[Nb]+o*i[kb])+Math.abs(r*i[Fb]+s*i[Db]+o*i[Ub])+Math.abs(r*i[Vb]+s*i[zb]+o*i[Gb]),l=n.dot(t)+e.distance;return l<=-a?Wm:l>=a?Km:qm}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=Pb.from(e).subtract(this.center),n=this.halfAxes,i=n.getColumn(0,Rb),r=n.getColumn(1,Mb),s=n.getColumn(2,Lb),o=i.magnitude(),a=r.magnitude(),l=s.magnitude();i.normalize(),r.normalize(),s.normalize();let c,A=0;return c=Math.abs(t.dot(i))-o,c>0&&(A+=c*c),c=Math.abs(t.dot(r))-a,c>0&&(A+=c*c),c=Math.abs(t.dot(s))-l,c>0&&(A+=c*c),A}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,Rb),l=o.getColumn(1,Mb),c=o.getColumn(2,Lb),A=Ib.copy(a).add(l).add(c).add(s),u=Ob.copy(A).subtract(e);let h=t.dot(u);return i=Math.min(h,i),r=Math.max(h,r),A.copy(s).add(a).add(l).subtract(c),u.copy(A).subtract(e),h=t.dot(u),i=Math.min(h,i),r=Math.max(h,r),A.copy(s).add(a).subtract(l).add(c),u.copy(A).subtract(e),h=t.dot(u),i=Math.min(h,i),r=Math.max(h,r),A.copy(s).add(a).subtract(l).subtract(c),u.copy(A).subtract(e),h=t.dot(u),i=Math.min(h,i),r=Math.max(h,r),s.copy(A).subtract(a).add(l).add(c),u.copy(A).subtract(e),h=t.dot(u),i=Math.min(h,i),r=Math.max(h,r),s.copy(A).subtract(a).add(l).subtract(c),u.copy(A).subtract(e),h=t.dot(u),i=Math.min(h,i),r=Math.max(h,r),s.copy(A).subtract(a).subtract(l).add(c),u.copy(A).subtract(e),h=t.dot(u),i=Math.min(h,i),r=Math.max(h,r),s.copy(A).subtract(a).subtract(l).subtract(c),u.copy(A).subtract(e),h=t.dot(u),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,Rb);t.transformAsPoint(e);const n=this.halfAxes.getColumn(1,Mb);n.transformAsPoint(e);const i=this.halfAxes.getColumn(2,Lb);return i.transformAsPoint(e),this.halfAxes=new Matrix3([...t,...n,...i]),this}getTransform(){throw new Error("not implemented")}}var jb=n(4990);const Hb=new oi.P,Wb=new oi.P;class Plane{constructor(e=[0,0,1],t=0){this.normal=new oi.P,this.distance=-0,this.fromNormalDistance(e,t)}fromNormalDistance(e,t){return(0,jb.v)(Number.isFinite(t)),this.normal.from(e).normalize(),this.distance=t,this}fromPointNormal(e,t){e=Hb.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,jb.v)((0,xn.aI)(this.normal.len(),1)),this.distance=i,this}clone(){return new Plane(this.normal,this.distance)}equals(e){return(0,xn.aI)(this.distance,e.distance)&&(0,xn.aI)(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){const t=Wb.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=Hb.from(e),i=this.getPointDistance(n),r=Wb.copy(this.normal).scale(i);return n.subtract(r).to(t)}}const qb=[new oi.P([1,0,0]),new oi.P([0,1,0]),new oi.P([0,0,1])],Kb=new oi.P,Qb=new oi.P;class CullingVolume{constructor(e=[]){this.planes=e}fromBoundingSphere(e){this.planes.length=2*qb.length;const t=e.center,n=e.radius;let i=0;for(const e of qb){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=Kb.copy(e).scale(-n).add(t);r.fromPointNormal(o,e);const a=Kb.copy(e).scale(n).add(t),l=Qb.copy(e).negate();s.fromPointNormal(a,l),i+=2}return this}computeVisibility(e){let t=Km;for(const n of this.planes){switch(e.intersectPlane(n)){case Wm:return Wm;case qm:t=qm}}return t}computeVisibilityWithPlaneMask(e,t){if((0,jb.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===Wm)return CullingVolume.MASK_OUTSIDE;a===qm&&(n|=s)}return n}}CullingVolume.MASK_OUTSIDE=4294967295,CullingVolume.MASK_INSIDE=0,CullingVolume.MASK_INDETERMINATE=2147483647;new oi.P,new oi.P,new oi.P,new oi.P,new oi.P;new oi.P,new oi.P,new oi.P,new oi.P,new oi.P,new oi.P,new oi.P,new oi.P,new oi.P,new oi.P,new oi.P,new oi.P;const Xb=new Matrix3,$b=new Matrix3,Zb=new Matrix3,Yb=new Matrix3,Jb=new Matrix3;function e_(e,t={}){let n=0,i=0;const r=$b,s=Zb;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&&i_(s)>o;)r_(s,Yb),Jb.copy(Yb).transpose(),s.multiplyRight(Yb),s.multiplyLeft(Jb),r.multiplyRight(Yb),++n>2&&(++i,n=0);return t.unitary=r.toTarget(t.unitary),t.diagonal=s.toTarget(t.diagonal),t}const t_=[1,0,0],n_=[2,2,1];function i_(e){let t=0;for(let n=0;n<3;++n){const i=e[Xb.getElementIndex(n_[n],t_[n])];t+=2*i*i}return Math.sqrt(t)}function r_(e,t){let n=0,i=1;for(let t=0;t<3;++t){const r=Math.abs(e[Xb.getElementIndex(n_[t],t_[t])]);r>n&&(i=t,n=r)}const r=t_[i],s=n_[i];let o=1,a=0;if(Math.abs(e[Xb.getElementIndex(s,r)])>1e-15){const t=(e[Xb.getElementIndex(s,s)]-e[Xb.getElementIndex(r,r)])/2/e[Xb.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[Xb.getElementIndex(r,r)]=t[Xb.getElementIndex(s,s)]=o,t[Xb.getElementIndex(s,r)]=a,t[Xb.getElementIndex(r,s)]=-a,t}const s_=new oi.P,o_=new oi.P,a_=new oi.P,l_=new oi.P,c_=new oi.P,A_=new Matrix3,u_={diagonal:new Matrix3,unitary:new Matrix3};function h_(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 oi.P,t;const n=e.length,i=new oi.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,l=0,c=0,A=0;for(const t of e){const e=s_.copy(t).subtract(i);s+=e.x*e.x,o+=e.x*e.y,a+=e.x*e.z,l+=e.y*e.y,c+=e.y*e.z,A+=e.z*e.z}s*=r,o*=r,a*=r,l*=r,c*=r,A*=r;const u=A_;u[0]=s,u[1]=o,u[2]=a,u[3]=o,u[4]=l,u[5]=c,u[6]=a,u[7]=c,u[8]=A;const{unitary:h}=e_(u,u_),d=t.halfAxes.copy(h);let f=d.getColumn(0,a_),p=d.getColumn(1,l_),g=d.getColumn(2,c_),m=-Number.MAX_VALUE,b=-Number.MAX_VALUE,_=-Number.MAX_VALUE,v=Number.MAX_VALUE,y=Number.MAX_VALUE,w=Number.MAX_VALUE;for(const t of e)s_.copy(t),m=Math.max(s_.dot(f),m),b=Math.max(s_.dot(p),b),_=Math.max(s_.dot(g),_),v=Math.min(s_.dot(f),v),y=Math.min(s_.dot(p),y),w=Math.min(s_.dot(g),w);f=f.multiplyByScalar(.5*(v+m)),p=p.multiplyByScalar(.5*(y+b)),g=g.multiplyByScalar(.5*(w+_)),t.center.copy(f).add(p).add(g);const x=o_.set(m-v,b-y,_-w).multiplyByScalar(.5),T=new Matrix3([x[0],0,0,0,x[1],0,0,0,x[2]]);return t.halfAxes.multiplyRight(T),t}const d_=512,f_=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],p_=f_.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),g_=p_.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:l}=e,c=this.getBoundingVolume(i,a,l);if(o&&!this.insideBounds(o))return!1;if(n.computeVisibility(c)<0)return!1;if(!this.childVisible){let{z:e}=this;if(e<s&&e>=r){const n=c.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}insideBounds([e,t,n,i]){const r=Math.pow(2,this.z),s=d_/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?g_:this.z<2?p_:f_,i=[];for(const r of t){const t=E_(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 h_(i)}const i=Math.pow(2,this.z),r=d_/i,s=this.x*r+t*d_,o=d_-(this.y+1)*r;return new AxisAlignedBoundingBox([s,o,e[0]],[s+r,o+r,e[1]])}}const m_=512,b_=[-1/0,-1/0,1/0,1/0],__={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 v_(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 y_(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 w_({viewport:e,z:t,cullRect:n}){return(e.subViewports||[e]).map(e=>x_(e,t||0,n))}function x_(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},l=e.unproject([i,r],a),c=e.unproject([i+s,r],a),A=e.unproject([i,r+o],a),u=e.unproject([i+s,r+o],a);return[Math.min(l[0],c[0],A[0],u[0]),Math.min(l[1],c[1],A[1],u[1]),Math.max(l[0],c[0],A[0],u[0]),Math.max(l[1],c[1],A[1],u[1])]}const i=x_(e,t[0],n),r=x_(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 T_(e,t){return Math.pow(2,e)*m_/t}function E_(e,t,n){const i=T_(n,m_),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 S_(e,t,n,i){const r=T_(n,i);return[e/r*m_,t/r*m_]}function C_(e,t,n,i,r=512){if(e.isGeospatial){const[e,r]=E_(t,n,i),[s,o]=E_(t+1,n+1,i);return{west:e,north:r,east:s,south:o}}const[s,o]=S_(t,n,i,r),[a,l]=S_(t+1,n+1,i,r);return{left:s,top:o,right:a,bottom:l}}function P_(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=T_(t,n),[a,l,c,A]=function(e,t,n){if(n)return v_(e,n).map(e=>e*t/m_);return e.map(e=>e*t/m_)}(s,o,r),u=[];for(let e=Math.floor(a);e<c;e++)for(let n=Math.floor(l);n<A;n++)u.push({x:e,y:n,z:t});return u}function R_({viewport:e,maxZoom:t,minZoom:n,zRange:i,extent:r,tileSize:s=512,modelMatrix:o,modelMatrixInverse:a,zoomOffset:l=0,visibleMinZoom:c,visibleMaxZoom:A}){let u=e.isGeospatial?Math.round(e.zoom+Math.log2(m_/s)+l):Math.ceil(e.zoom+l);if("number"==typeof n&&Number.isFinite(n)&&u<n){if(!r)return[];u=n}if("number"==typeof t&&Number.isFinite(t)&&u>t&&(u=t),null!=c&&e.zoom<c)return[];if(null!=A&&e.zoom>A)return[];let h=r;return o&&a&&r&&!e.isGeospatial&&(h=v_(r,o)),e.isGeospatial?function(e,t,n,i){const r=e instanceof Un&&e.resolution?e.projectPosition:null,s=Object.values(e.getFrustumPlanes()).map(({normal:e,distance:t})=>new Plane(e.clone().negate(),t)),o=new CullingVolume(s),a=e.distanceScales.unitsPerMeter[2],l=n&&n[0]*a||0,c=n&&n[1]*a||0,A=e instanceof wn.A&&e.pitch<=60?t:0;if(i){const[e,t,n,r]=i,s=(0,Ln.Gw)([e,r]),o=(0,Ln.Gw)([n,t]);i=[s[0],d_-s[1],o[0],d_-o[1]]}const u=new OSMNode(0,0,0),h={viewport:e,project:r,cullingVolume:o,elevationBounds:[l,c],minZ:A,maxZ:t,bounds:i,offset:0};if(u.update(h),e instanceof wn.A&&e.subViewports&&e.subViewports.length>1){for(h.offset=-1;u.update(h)&&!(--h.offset<-3););for(h.offset=1;u.update(h)&&!(++h.offset>3););}return u.getSelected()}(e,u,i,r):P_(e,u,s,h||b_,a)}function M_(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",I_="no-overlap",O_="best-available",B_={[O_]:function(e){for(const t of e)t.state=0;for(const t of e)t.isSelected&&!k_(t)&&F_(t);for(const t of e)t.isVisible=Boolean(2&t.state)},[I_]:function(e){for(const t of e)t.state=0;for(const t of e)t.isSelected&&k_(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&&F_(e)},[L_]:()=>{}},N_={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(!M_(i[r],n[r])){t=e(i),n=i;break}return t}}(w_),this.opts={...N_,...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 Rn.k,this._modelMatrixInverse=new Rn.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 Rn.k(n):new Rn.k,r=!i.equals(this._modelMatrix);if(this._viewport&&e.equals(this._viewport)&&(0,xn.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 s=this.updateTileStates();return this._pruneRequests(),this._dirty&&this._resizeCache(),s&&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,s,o]of i){let i;if("west"in r)i=r.west<s&&r.east>e&&r.south<o&&r.north>t;else{if(n&&!Rn.k.IDENTITY.equals(n)){const[e,t,i,s]=v_([r.left,r.top,r.right,r.bottom],n);r={left:e,top:t,right:i,bottom:s}}const a=Math.min(r.top,r.bottom),l=Math.max(r.top,r.bottom);i=r.left<s&&r.right>e&&a<o&&l>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:a,zoomOffset:l,visibleMinZoom:c,visibleMaxZoom:A}=this.opts;return R_({viewport:e,maxZoom:t,minZoom:n,zRange:i,tileSize:o,extent:a,modelMatrix:r,modelMatrixInverse:s,zoomOffset:l,visibleMinZoom:c,visibleMaxZoom:A})}getTileId(e){return`${e.x}-${e.y}-${e.z}`}getTileZoom(e){return e.z}getTileMetadata(e){const{tileSize:t}=this.opts;return{bbox:C_(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||O_,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:B_[e])(Array.from(this._cache.values())),n=0;for(const e of this._cache.values())if(t[n++]!==e.isVisible)return!0;return!1}_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,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 k_(e){let t=e;for(;t;){if(t.isLoaded||t.content)return t.state|=2,!0;t=t.parent}return!1}function F_(e){for(const t of e.children)t.isLoaded||t.content?t.state|=2:F_(t)}const D_={TilesetClass:Tileset2D,data:{type:"data",value:[]},dataComparator:__.equal,renderSubLayers:{type:"function",value:e=>new lc(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_,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,visibleMinZoom:null,visibleMaxZoom:null};class TileLayer extends Ss{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:l,zoomOffset:c,visibleMinZoom:A,visibleMaxZoom:u}=this.props;return{maxCacheSize:t,maxCacheByteSize:n,maxZoom:s,minZoom:o,tileSize:e,refinementStrategy:i,extent:r,maxRequests:a,debounceTime:l,zoomOffset:c,visibleMinZoom:A,visibleMaxZoom:u,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)?y_(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,r=this.context.viewport.zoom;if(null!=e&&r<e||null!=t&&r>t||null!=n&&!i&&r<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=st(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 Rn.k(i):null)}}TileLayer.defaultProps=D_,TileLayer.layerName="TileLayer";const U_=TileLayer,V_="layout(std140) uniform tripsUniforms {\n bool fadeTrail;\n float trailLength;\n float currentTime;\n} trips;\n",z_={name:"trips",vs:V_,fs:V_,uniformTypes:{fadeTrail:"f32",trailLength:"f32",currentTime:"f32"}};class TripsLayer extends Za{getShaders(){const e=super.getShaders();return e.inject={"vs:#decl":"in float instanceTimestamps;\nin float instanceNextTimestamps;\nout float vTime;\n","vs:#main-end":"vTime = instanceTimestamps + (instanceNextTimestamps - instanceTimestamps) * vPathPosition.y / vPathLength;\n","fs:#decl":"in float vTime;\n","fs:#main-start":"if(vTime > trips.currentTime || (trips.fadeTrail && (vTime < trips.currentTime - trips.trailLength))) {\n discard;\n}\n","fs:DECKGL_FILTER_COLOR":"if(trips.fadeTrail) {\n color.a *= 1.0 - (trips.currentTime - vTime) / trips.trailLength;\n}\n"},e.modules=[...e.modules,z_],e}initializeState(){super.initializeState();this.getAttributeManager().addInstanced({timestamps:{size:1,accessor:"getTimestamps",shaderAttributes:{instanceTimestamps:{vertexOffset:0},instanceNextTimestamps:{vertexOffset:1}}}})}draw(e){const{fadeTrail:t,trailLength:n,currentTime:i}=this.props,r={fadeTrail:t,trailLength:n,currentTime:i};this.state.model.shaderInputs.setProps({trips:r}),super.draw(e)}}TripsLayer.layerName="TripsLayer",TripsLayer.defaultProps={fadeTrail:!0,trailLength:{type:"number",value:120,min:0},currentTime:{type:"number",value:0,min:0},getTimestamps:{type:"accessor",value:e=>e.timestamps}};const G_=TripsLayer,j_="#ifdef USE_IBL\nuniform samplerCube pbr_diffuseEnvSampler;\nuniform samplerCube pbr_specularEnvSampler;\nuniform sampler2D pbr_brdfLUT;\n#endif\n",H_="layout(std140) uniform pbrProjectionUniforms {\n mat4 modelViewProjectionMatrix;\n mat4 modelMatrix;\n mat4 normalMatrix;\n vec3 camera;\n} pbrProjection;\n",W_={props:{},uniforms:{},defaultUniforms:{unlit:!1,baseColorMapEnabled:!1,baseColorFactor:[1,1,1,1],normalMapEnabled:!1,normalScale:1,emissiveMapEnabled:!1,emissiveFactor:[0,0,0],metallicRoughnessValues:[1,1],metallicRoughnessMapEnabled:!1,occlusionMapEnabled:!1,occlusionStrength:1,alphaCutoffEnabled:!1,alphaCutoff:.5,IBLenabled:!1,scaleIBLAmbient:[1,1],scaleDiffBaseMR:[0,0,0,0],scaleFGDSpec:[0,0,0,0],specularColorFactor:[1,1,1],specularIntensityFactor:1,specularColorMapEnabled:!1,specularIntensityMapEnabled:!1,ior:1.5,transmissionFactor:0,transmissionMapEnabled:!1,thicknessFactor:0,attenuationDistance:1e9,attenuationColor:[1,1,1],clearcoatFactor:0,clearcoatRoughnessFactor:0,clearcoatMapEnabled:!1,clearcoatRoughnessMapEnabled:!1,sheenColorFactor:[0,0,0],sheenRoughnessFactor:0,sheenColorMapEnabled:!1,sheenRoughnessMapEnabled:!1,iridescenceFactor:0,iridescenceIor:1.3,iridescenceThicknessRange:[100,400],iridescenceMapEnabled:!1,anisotropyStrength:0,anisotropyRotation:0,anisotropyDirection:[1,0],anisotropyMapEnabled:!1,emissiveStrength:1,baseColorUVSet:0,baseColorUVTransform:[1,0,0,0,1,0,0,0,1],metallicRoughnessUVSet:0,metallicRoughnessUVTransform:[1,0,0,0,1,0,0,0,1],normalUVSet:0,normalUVTransform:[1,0,0,0,1,0,0,0,1],occlusionUVSet:0,occlusionUVTransform:[1,0,0,0,1,0,0,0,1],emissiveUVSet:0,emissiveUVTransform:[1,0,0,0,1,0,0,0,1],specularColorUVSet:0,specularColorUVTransform:[1,0,0,0,1,0,0,0,1],specularIntensityUVSet:0,specularIntensityUVTransform:[1,0,0,0,1,0,0,0,1],transmissionUVSet:0,transmissionUVTransform:[1,0,0,0,1,0,0,0,1],thicknessUVSet:0,thicknessUVTransform:[1,0,0,0,1,0,0,0,1],clearcoatUVSet:0,clearcoatUVTransform:[1,0,0,0,1,0,0,0,1],clearcoatRoughnessUVSet:0,clearcoatRoughnessUVTransform:[1,0,0,0,1,0,0,0,1],clearcoatNormalUVSet:0,clearcoatNormalUVTransform:[1,0,0,0,1,0,0,0,1],sheenColorUVSet:0,sheenColorUVTransform:[1,0,0,0,1,0,0,0,1],sheenRoughnessUVSet:0,sheenRoughnessUVTransform:[1,0,0,0,1,0,0,0,1],iridescenceUVSet:0,iridescenceUVTransform:[1,0,0,0,1,0,0,0,1],iridescenceThicknessUVSet:0,iridescenceThicknessUVTransform:[1,0,0,0,1,0,0,0,1],anisotropyUVSet:0,anisotropyUVTransform:[1,0,0,0,1,0,0,0,1]},name:"pbrMaterial",firstBindingSlot:0,bindingLayout:[{name:"pbrMaterial",group:3},{name:"pbr_baseColorSampler",group:3},{name:"pbr_normalSampler",group:3},{name:"pbr_emissiveSampler",group:3},{name:"pbr_metallicRoughnessSampler",group:3},{name:"pbr_occlusionSampler",group:3},{name:"pbr_specularColorSampler",group:3},{name:"pbr_specularIntensitySampler",group:3},{name:"pbr_transmissionSampler",group:3},{name:"pbr_thicknessSampler",group:3},{name:"pbr_clearcoatSampler",group:3},{name:"pbr_clearcoatRoughnessSampler",group:3},{name:"pbr_clearcoatNormalSampler",group:3},{name:"pbr_sheenColorSampler",group:3},{name:"pbr_sheenRoughnessSampler",group:3},{name:"pbr_iridescenceSampler",group:3},{name:"pbr_iridescenceThicknessSampler",group:3},{name:"pbr_anisotropySampler",group:3}],dependencies:[Js,{name:"ibl",firstBindingSlot:32,bindingLayout:[{name:"pbr_diffuseEnvSampler",group:2},{name:"pbr_specularEnvSampler",group:2},{name:"pbr_brdfLUT",group:2}],source:"#ifdef USE_IBL\n@group(2) @binding(auto) var pbr_diffuseEnvSampler: texture_cube<f32>;\n@group(2) @binding(auto) var pbr_diffuseEnvSamplerSampler: sampler;\n@group(2) @binding(auto) var pbr_specularEnvSampler: texture_cube<f32>;\n@group(2) @binding(auto) var pbr_specularEnvSamplerSampler: sampler;\n@group(2) @binding(auto) var pbr_brdfLUT: texture_2d<f32>;\n@group(2) @binding(auto) var pbr_brdfLUTSampler: sampler;\n#endif\n",vs:j_,fs:j_},{name:"pbrProjection",bindingLayout:[{name:"pbrProjection",group:0}],source:"struct pbrProjectionUniforms {\n modelViewProjectionMatrix: mat4x4<f32>,\n modelMatrix: mat4x4<f32>,\n normalMatrix: mat4x4<f32>,\n camera: vec3<f32>\n};\n\n@group(0) @binding(auto) var<uniform> pbrProjection: pbrProjectionUniforms;\n",vs:H_,fs:H_,getUniforms:e=>e,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<f32>"}}],source:"struct PBRFragmentInputs {\n pbr_vPosition: vec3f,\n pbr_vUV0: vec2f,\n pbr_vUV1: vec2f,\n pbr_vTBN: mat3x3f,\n pbr_vNormal: vec3f\n};\n\nvar<private> fragmentInputs: PBRFragmentInputs;\n\nfn pbr_setPositionNormalTangentUV(\n position: vec4f,\n normal: vec4f,\n tangent: vec4f,\n uv0: vec2f,\n uv1: vec2f\n)\n{\n var pos: vec4f = pbrProjection.modelMatrix * position;\n fragmentInputs.pbr_vPosition = pos.xyz / pos.w;\n fragmentInputs.pbr_vNormal = vec3f(0.0, 0.0, 1.0);\n fragmentInputs.pbr_vTBN = mat3x3f(\n vec3f(1.0, 0.0, 0.0),\n vec3f(0.0, 1.0, 0.0),\n vec3f(0.0, 0.0, 1.0)\n );\n fragmentInputs.pbr_vUV0 = vec2f(0.0, 0.0);\n fragmentInputs.pbr_vUV1 = uv1;\n\n#ifdef HAS_NORMALS\n let normalW: vec3f = normalize((pbrProjection.normalMatrix * vec4f(normal.xyz, 0.0)).xyz);\n fragmentInputs.pbr_vNormal = normalW;\n#ifdef HAS_TANGENTS\n let tangentW: vec3f = normalize((pbrProjection.modelMatrix * vec4f(tangent.xyz, 0.0)).xyz);\n let bitangentW: vec3f = cross(normalW, tangentW) * tangent.w;\n fragmentInputs.pbr_vTBN = mat3x3f(tangentW, bitangentW, normalW);\n#endif\n#endif\n\n#ifdef HAS_UV\n fragmentInputs.pbr_vUV0 = uv0;\n#endif\n}\n\nstruct pbrMaterialUniforms {\n // Material is unlit\n unlit: u32,\n\n // Base color map\n baseColorMapEnabled: u32,\n baseColorFactor: vec4f,\n\n normalMapEnabled : u32,\n normalScale: f32, // #ifdef HAS_NORMALMAP\n\n emissiveMapEnabled: u32,\n emissiveFactor: vec3f, // #ifdef HAS_EMISSIVEMAP\n\n metallicRoughnessValues: vec2f,\n metallicRoughnessMapEnabled: u32,\n\n occlusionMapEnabled: i32,\n occlusionStrength: f32, // #ifdef HAS_OCCLUSIONMAP\n \n alphaCutoffEnabled: i32,\n alphaCutoff: f32, // #ifdef ALPHA_CUTOFF\n\n specularColorFactor: vec3f,\n specularIntensityFactor: f32,\n specularColorMapEnabled: i32,\n specularIntensityMapEnabled: i32,\n\n ior: f32,\n\n transmissionFactor: f32,\n transmissionMapEnabled: i32,\n\n thicknessFactor: f32,\n attenuationDistance: f32,\n attenuationColor: vec3f,\n\n clearcoatFactor: f32,\n clearcoatRoughnessFactor: f32,\n clearcoatMapEnabled: i32,\n clearcoatRoughnessMapEnabled: i32,\n\n sheenColorFactor: vec3f,\n sheenRoughnessFactor: f32,\n sheenColorMapEnabled: i32,\n sheenRoughnessMapEnabled: i32,\n\n iridescenceFactor: f32,\n iridescenceIor: f32,\n iridescenceThicknessRange: vec2f,\n iridescenceMapEnabled: i32,\n\n anisotropyStrength: f32,\n anisotropyRotation: f32,\n anisotropyDirection: vec2f,\n anisotropyMapEnabled: i32,\n\n emissiveStrength: f32,\n \n // IBL\n IBLenabled: i32,\n scaleIBLAmbient: vec2f, // #ifdef USE_IBL\n \n // debugging flags used for shader output of intermediate PBR variables\n // #ifdef PBR_DEBUG\n scaleDiffBaseMR: vec4f,\n scaleFGDSpec: vec4f,\n // #endif\n\n baseColorUVSet: i32,\n baseColorUVTransform: mat3x3f,\n metallicRoughnessUVSet: i32,\n metallicRoughnessUVTransform: mat3x3f,\n normalUVSet: i32,\n normalUVTransform: mat3x3f,\n occlusionUVSet: i32,\n occlusionUVTransform: mat3x3f,\n emissiveUVSet: i32,\n emissiveUVTransform: mat3x3f,\n specularColorUVSet: i32,\n specularColorUVTransform: mat3x3f,\n specularIntensityUVSet: i32,\n specularIntensityUVTransform: mat3x3f,\n transmissionUVSet: i32,\n transmissionUVTransform: mat3x3f,\n thicknessUVSet: i32,\n thicknessUVTransform: mat3x3f,\n clearcoatUVSet: i32,\n clearcoatUVTransform: mat3x3f,\n clearcoatRoughnessUVSet: i32,\n clearcoatRoughnessUVTransform: mat3x3f,\n clearcoatNormalUVSet: i32,\n clearcoatNormalUVTransform: mat3x3f,\n sheenColorUVSet: i32,\n sheenColorUVTransform: mat3x3f,\n sheenRoughnessUVSet: i32,\n sheenRoughnessUVTransform: mat3x3f,\n iridescenceUVSet: i32,\n iridescenceUVTransform: mat3x3f,\n iridescenceThicknessUVSet: i32,\n iridescenceThicknessUVTransform: mat3x3f,\n anisotropyUVSet: i32,\n anisotropyUVTransform: mat3x3f,\n}\n\n@group(3) @binding(auto) var<uniform> pbrMaterial : pbrMaterialUniforms;\n\n// Samplers\n#ifdef HAS_BASECOLORMAP\n@group(3) @binding(auto) var pbr_baseColorSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_baseColorSamplerSampler: sampler;\n#endif\n#ifdef HAS_NORMALMAP\n@group(3) @binding(auto) var pbr_normalSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_normalSamplerSampler: sampler;\n#endif\n#ifdef HAS_EMISSIVEMAP\n@group(3) @binding(auto) var pbr_emissiveSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_emissiveSamplerSampler: sampler;\n#endif\n#ifdef HAS_METALROUGHNESSMAP\n@group(3) @binding(auto) var pbr_metallicRoughnessSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_metallicRoughnessSamplerSampler: sampler;\n#endif\n#ifdef HAS_OCCLUSIONMAP\n@group(3) @binding(auto) var pbr_occlusionSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_occlusionSamplerSampler: sampler;\n#endif\n#ifdef HAS_SPECULARCOLORMAP\n@group(3) @binding(auto) var pbr_specularColorSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_specularColorSamplerSampler: sampler;\n#endif\n#ifdef HAS_SPECULARINTENSITYMAP\n@group(3) @binding(auto) var pbr_specularIntensitySampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_specularIntensitySamplerSampler: sampler;\n#endif\n#ifdef HAS_TRANSMISSIONMAP\n@group(3) @binding(auto) var pbr_transmissionSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_transmissionSamplerSampler: sampler;\n#endif\n#ifdef HAS_THICKNESSMAP\n@group(3) @binding(auto) var pbr_thicknessSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_thicknessSamplerSampler: sampler;\n#endif\n#ifdef HAS_CLEARCOATMAP\n@group(3) @binding(auto) var pbr_clearcoatSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_clearcoatSamplerSampler: sampler;\n#endif\n#ifdef HAS_CLEARCOATROUGHNESSMAP\n@group(3) @binding(auto) var pbr_clearcoatRoughnessSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_clearcoatRoughnessSamplerSampler: sampler;\n#endif\n#ifdef HAS_CLEARCOATNORMALMAP\n@group(3) @binding(auto) var pbr_clearcoatNormalSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_clearcoatNormalSamplerSampler: sampler;\n#endif\n#ifdef HAS_SHEENCOLORMAP\n@group(3) @binding(auto) var pbr_sheenColorSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_sheenColorSamplerSampler: sampler;\n#endif\n#ifdef HAS_SHEENROUGHNESSMAP\n@group(3) @binding(auto) var pbr_sheenRoughnessSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_sheenRoughnessSamplerSampler: sampler;\n#endif\n#ifdef HAS_IRIDESCENCEMAP\n@group(3) @binding(auto) var pbr_iridescenceSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_iridescenceSamplerSampler: sampler;\n#endif\n#ifdef HAS_IRIDESCENCETHICKNESSMAP\n@group(3) @binding(auto) var pbr_iridescenceThicknessSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_iridescenceThicknessSamplerSampler: sampler;\n#endif\n#ifdef HAS_ANISOTROPYMAP\n@group(3) @binding(auto) var pbr_anisotropySampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_anisotropySamplerSampler: sampler;\n#endif\n// Encapsulate the various inputs used by the various functions in the shading equation\n// We store values in this struct to simplify the integration of alternative implementations\n// of the shading terms, outlined in the Readme.MD Appendix.\nstruct PBRInfo {\n NdotL: f32, // cos angle between normal and light direction\n NdotV: f32, // cos angle between normal and view direction\n NdotH: f32, // cos angle between normal and half vector\n LdotH: f32, // cos angle between light direction and half vector\n VdotH: f32, // cos angle between view direction and half vector\n perceptualRoughness: f32, // roughness value, as authored by the model creator (input to shader)\n metalness: f32, // metallic value at the surface\n reflectance0: vec3f, // full reflectance color (normal incidence angle)\n reflectance90: vec3f, // reflectance color at grazing angle\n alphaRoughness: f32, // roughness mapped to a more linear change in the roughness (proposed by [2])\n diffuseColor: vec3f, // color contribution from diffuse lighting\n specularColor: vec3f, // color contribution from specular lighting\n n: vec3f, // normal at surface point\n v: vec3f, // vector from surface point to camera\n};\n\nconst M_PI = 3.141592653589793;\nconst c_MinRoughness = 0.04;\n\nfn SRGBtoLINEAR(srgbIn: vec4f ) -> vec4f\n{\n var linOut: vec3f = srgbIn.xyz;\n#ifdef MANUAL_SRGB\n let bLess: vec3f = step(vec3f(0.04045), srgbIn.xyz);\n linOut = mix(\n srgbIn.xyz / vec3f(12.92),\n pow((srgbIn.xyz + vec3f(0.055)) / vec3f(1.055), vec3f(2.4)),\n bLess\n );\n#ifdef SRGB_FAST_APPROXIMATION\n linOut = pow(srgbIn.xyz, vec3f(2.2));\n#endif\n#endif\n return vec4f(linOut, srgbIn.w);\n}\n\nfn getMaterialUV(uvSet: i32, uvTransform: mat3x3f) -> vec2f\n{\n var baseUV = fragmentInputs.pbr_vUV0;\n if (uvSet == 1) {\n baseUV = fragmentInputs.pbr_vUV1;\n }\n return (uvTransform * vec3f(baseUV, 1.0)).xy;\n}\n\n// Build the tangent basis from interpolated attributes or screen-space derivatives.\nfn getTBN(uv: vec2f) -> mat3x3f\n{\n let pos_dx: vec3f = dpdx(fragmentInputs.pbr_vPosition);\n let pos_dy: vec3f = dpdy(fragmentInputs.pbr_vPosition);\n let tex_dx: vec3f = dpdx(vec3f(uv, 0.0));\n let tex_dy: vec3f = dpdy(vec3f(uv, 0.0));\n var t: vec3f = (tex_dy.y * pos_dx - tex_dx.y * pos_dy) / (tex_dx.x * tex_dy.y - tex_dy.x * tex_dx.y);\n\n var ng: vec3f = cross(pos_dx, pos_dy);\n#ifdef HAS_NORMALS\n ng = normalize(fragmentInputs.pbr_vNormal);\n#endif\n t = normalize(t - ng * dot(ng, t));\n var b: vec3f = normalize(cross(ng, t));\n var tbn: mat3x3f = mat3x3f(t, b, ng);\n#ifdef HAS_TANGENTS\n tbn = fragmentInputs.pbr_vTBN;\n#endif\n\n return tbn;\n}\n\n// Find the normal for this fragment, pulling either from a predefined normal map\n// or from the interpolated mesh normal and tangent attributes.\nfn getMappedNormal(\n normalSampler: texture_2d<f32>,\n normalSamplerBinding: sampler,\n tbn: mat3x3f,\n normalScale: f32,\n uv: vec2f\n) -> vec3f\n{\n let n = textureSample(normalSampler, normalSamplerBinding, uv).rgb;\n return normalize(tbn * ((2.0 * n - 1.0) * vec3f(normalScale, normalScale, 1.0)));\n}\n\nfn getNormal(tbn: mat3x3f, uv: vec2f) -> vec3f\n{\n // The tbn matrix is linearly interpolated, so we need to re-normalize\n var n: vec3f = normalize(tbn[2].xyz);\n#ifdef HAS_NORMALMAP\n n = getMappedNormal(\n pbr_normalSampler,\n pbr_normalSamplerSampler,\n tbn,\n pbrMaterial.normalScale,\n uv\n );\n#endif\n\n return n;\n}\n\nfn getClearcoatNormal(tbn: mat3x3f, baseNormal: vec3f, uv: vec2f) -> vec3f\n{\n#ifdef HAS_CLEARCOATNORMALMAP\n return getMappedNormal(\n pbr_clearcoatNormalSampler,\n pbr_clearcoatNormalSamplerSampler,\n tbn,\n 1.0,\n uv\n );\n#else\n return baseNormal;\n#endif\n}\n\n// Calculation of the lighting contribution from an optional Image Based Light source.\n// Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].\n// See our README.md on Environment Maps [3] for additional discussion.\n#ifdef USE_IBL\nfn getIBLContribution(pbrInfo: PBRInfo, n: vec3f, reflection: vec3f) -> vec3f\n{\n let mipCount: f32 = 9.0; // resolution of 512x512\n let lod: f32 = pbrInfo.perceptualRoughness * mipCount;\n // retrieve a scale and bias to F0. See [1], Figure 3\n let brdf = SRGBtoLINEAR(\n textureSampleLevel(\n pbr_brdfLUT,\n pbr_brdfLUTSampler,\n vec2f(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness),\n 0.0\n )\n ).rgb;\n let diffuseLight =\n SRGBtoLINEAR(\n textureSampleLevel(pbr_diffuseEnvSampler, pbr_diffuseEnvSamplerSampler, n, 0.0)\n ).rgb;\n var specularLight = SRGBtoLINEAR(\n textureSampleLevel(\n pbr_specularEnvSampler,\n pbr_specularEnvSamplerSampler,\n reflection,\n 0.0\n )\n ).rgb;\n#ifdef USE_TEX_LOD\n specularLight = SRGBtoLINEAR(\n textureSampleLevel(\n pbr_specularEnvSampler,\n pbr_specularEnvSamplerSampler,\n reflection,\n lod\n )\n ).rgb;\n#endif\n\n let diffuse = diffuseLight * pbrInfo.diffuseColor * pbrMaterial.scaleIBLAmbient.x;\n let specular =\n specularLight * (pbrInfo.specularColor * brdf.x + brdf.y) * pbrMaterial.scaleIBLAmbient.y;\n\n return diffuse + specular;\n}\n#endif\n\n// Basic Lambertian diffuse\n// Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog\n// See also [1], Equation 1\nfn diffuse(pbrInfo: PBRInfo) -> vec3<f32> {\n return pbrInfo.diffuseColor / M_PI;\n}\n\n// The following equation models the Fresnel reflectance term of the spec equation (aka F())\n// Implementation of fresnel from [4], Equation 15\nfn specularReflection(pbrInfo: PBRInfo) -> vec3<f32> {\n return pbrInfo.reflectance0 +\n (pbrInfo.reflectance90 - pbrInfo.reflectance0) *\n pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);\n}\n\n// This calculates the specular geometric attenuation (aka G()),\n// where rougher material will reflect less light back to the viewer.\n// This implementation is based on [1] Equation 4, and we adopt their modifications to\n// alphaRoughness as input as originally proposed in [2].\nfn geometricOcclusion(pbrInfo: PBRInfo) -> f32 {\n let NdotL: f32 = pbrInfo.NdotL;\n let NdotV: f32 = pbrInfo.NdotV;\n let r: f32 = pbrInfo.alphaRoughness;\n\n let attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));\n let attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));\n return attenuationL * attenuationV;\n}\n\n// The following equation(s) model the distribution of microfacet normals across\n// the area being drawn (aka D())\n// Implementation from \"Average Irregularity Representation of a Roughened Surface\n// for Ray Reflection\" by T. S. Trowbridge, and K. P. Reitz\n// Follows the distribution function recommended in the SIGGRAPH 2013 course notes\n// from EPIC Games [1], Equation 3.\nfn microfacetDistribution(pbrInfo: PBRInfo) -> f32 {\n let roughnessSq = pbrInfo.alphaRoughness * pbrInfo.alphaRoughness;\n let f = (pbrInfo.NdotH * roughnessSq - pbrInfo.NdotH) * pbrInfo.NdotH + 1.0;\n return roughnessSq / (M_PI * f * f);\n}\n\nfn maxComponent(value: vec3f) -> f32 {\n return max(max(value.r, value.g), value.b);\n}\n\nfn getDielectricF0(ior: f32) -> f32 {\n let clampedIor = max(ior, 1.0);\n let ratio = (clampedIor - 1.0) / (clampedIor + 1.0);\n return ratio * ratio;\n}\n\nfn normalizeDirection(direction: vec2f) -> vec2f {\n let directionLength = length(direction);\n if (directionLength > 0.0001) {\n return direction / directionLength;\n }\n\n return vec2f(1.0, 0.0);\n}\n\nfn rotateDirection(direction: vec2f, rotation: f32) -> vec2f {\n let s = sin(rotation);\n let c = cos(rotation);\n return vec2f(direction.x * c - direction.y * s, direction.x * s + direction.y * c);\n}\n\nfn getIridescenceTint(iridescence: f32, thickness: f32, NdotV: f32) -> vec3f {\n if (iridescence <= 0.0) {\n return vec3f(1.0);\n }\n\n let phase = 0.015 * thickness * pbrMaterial.iridescenceIor + (1.0 - NdotV) * 6.0;\n let thinFilmTint =\n 0.5 +\n 0.5 *\n cos(vec3f(phase, phase + 2.0943951, phase + 4.1887902));\n return mix(vec3f(1.0), thinFilmTint, iridescence);\n}\n\nfn getVolumeAttenuation(thickness: f32) -> vec3f {\n if (thickness <= 0.0) {\n return vec3f(1.0);\n }\n\n let attenuationCoefficient =\n -log(max(pbrMaterial.attenuationColor, vec3f(0.0001))) /\n max(pbrMaterial.attenuationDistance, 0.0001);\n return exp(-attenuationCoefficient * thickness);\n}\n\nfn createClearcoatPBRInfo(\n basePBRInfo: PBRInfo,\n clearcoatNormal: vec3f,\n clearcoatRoughness: f32\n) -> PBRInfo {\n let perceptualRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);\n let alphaRoughness = perceptualRoughness * perceptualRoughness;\n let NdotV = clamp(abs(dot(clearcoatNormal, basePBRInfo.v)), 0.001, 1.0);\n\n return PBRInfo(\n basePBRInfo.NdotL,\n NdotV,\n basePBRInfo.NdotH,\n basePBRInfo.LdotH,\n basePBRInfo.VdotH,\n perceptualRoughness,\n 0.0,\n vec3f(0.04),\n vec3f(1.0),\n alphaRoughness,\n vec3f(0.0),\n vec3f(0.04),\n clearcoatNormal,\n basePBRInfo.v\n );\n}\n\nfn calculateClearcoatContribution(\n pbrInfo: PBRInfo,\n lightColor: vec3f,\n clearcoatNormal: vec3f,\n clearcoatFactor: f32,\n clearcoatRoughness: f32\n) -> vec3f {\n if (clearcoatFactor <= 0.0) {\n return vec3f(0.0);\n }\n\n let clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness);\n return calculateFinalColor(clearcoatPBRInfo, lightColor) * clearcoatFactor;\n}\n\n#ifdef USE_IBL\nfn calculateClearcoatIBLContribution(\n pbrInfo: PBRInfo,\n clearcoatNormal: vec3f,\n reflection: vec3f,\n clearcoatFactor: f32,\n clearcoatRoughness: f32\n) -> vec3f {\n if (clearcoatFactor <= 0.0) {\n return vec3f(0.0);\n }\n\n let clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness);\n return getIBLContribution(clearcoatPBRInfo, clearcoatNormal, reflection) * clearcoatFactor;\n}\n#endif\n\nfn calculateSheenContribution(\n pbrInfo: PBRInfo,\n lightColor: vec3f,\n sheenColor: vec3f,\n sheenRoughness: f32\n) -> vec3f {\n if (maxComponent(sheenColor) <= 0.0) {\n return vec3f(0.0);\n }\n\n let sheenFresnel = pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);\n let sheenVisibility = mix(1.0, pbrInfo.NdotL * pbrInfo.NdotV, sheenRoughness);\n return pbrInfo.NdotL *\n lightColor *\n sheenColor *\n (0.25 + 0.75 * sheenFresnel) *\n sheenVisibility *\n (1.0 - pbrInfo.metalness);\n}\n\nfn calculateAnisotropyBoost(\n pbrInfo: PBRInfo,\n anisotropyTangent: vec3f,\n anisotropyStrength: f32\n) -> f32 {\n if (anisotropyStrength <= 0.0) {\n return 1.0;\n }\n\n let anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));\n let bitangentViewAlignment = abs(dot(pbrInfo.v, anisotropyBitangent));\n return mix(1.0, 0.65 + 0.7 * bitangentViewAlignment, anisotropyStrength);\n}\n\nfn calculateMaterialLightColor(\n pbrInfo: PBRInfo,\n lightColor: vec3f,\n clearcoatNormal: vec3f,\n clearcoatFactor: f32,\n clearcoatRoughness: f32,\n sheenColor: vec3f,\n sheenRoughness: f32,\n anisotropyTangent: vec3f,\n anisotropyStrength: f32\n) -> vec3f {\n let anisotropyBoost = calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength);\n var color = calculateFinalColor(pbrInfo, lightColor) * anisotropyBoost;\n color += calculateClearcoatContribution(\n pbrInfo,\n lightColor,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness\n );\n color += calculateSheenContribution(pbrInfo, lightColor, sheenColor, sheenRoughness);\n return color;\n}\n\nfn PBRInfo_setAmbientLight(pbrInfo: ptr<function, PBRInfo>) {\n (*pbrInfo).NdotL = 1.0;\n (*pbrInfo).NdotH = 0.0;\n (*pbrInfo).LdotH = 0.0;\n (*pbrInfo).VdotH = 1.0;\n}\n\nfn PBRInfo_setDirectionalLight(pbrInfo: ptr<function, PBRInfo>, lightDirection: vec3<f32>) {\n let n = (*pbrInfo).n;\n let v = (*pbrInfo).v;\n let l = normalize(lightDirection); // Vector from surface point to light\n let h = normalize(l + v); // Half vector between both l and v\n\n (*pbrInfo).NdotL = clamp(dot(n, l), 0.001, 1.0);\n (*pbrInfo).NdotH = clamp(dot(n, h), 0.0, 1.0);\n (*pbrInfo).LdotH = clamp(dot(l, h), 0.0, 1.0);\n (*pbrInfo).VdotH = clamp(dot(v, h), 0.0, 1.0);\n}\n\nfn PBRInfo_setPointLight(pbrInfo: ptr<function, PBRInfo>, pointLight: PointLight) {\n let light_direction = normalize(pointLight.position - fragmentInputs.pbr_vPosition);\n PBRInfo_setDirectionalLight(pbrInfo, light_direction);\n}\n\nfn PBRInfo_setSpotLight(pbrInfo: ptr<function, PBRInfo>, spotLight: SpotLight) {\n let light_direction = normalize(spotLight.position - fragmentInputs.pbr_vPosition);\n PBRInfo_setDirectionalLight(pbrInfo, light_direction);\n}\n\nfn calculateFinalColor(pbrInfo: PBRInfo, lightColor: vec3<f32>) -> vec3<f32> {\n // Calculate the shading terms for the microfacet specular shading model\n let F = specularReflection(pbrInfo);\n let G = geometricOcclusion(pbrInfo);\n let D = microfacetDistribution(pbrInfo);\n\n // Calculation of analytical lighting contribution\n let diffuseContrib = (1.0 - F) * diffuse(pbrInfo);\n let specContrib = F * G * D / (4.0 * pbrInfo.NdotL * pbrInfo.NdotV);\n // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)\n return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib);\n}\n\nfn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {\n let baseColorUV = getMaterialUV(pbrMaterial.baseColorUVSet, pbrMaterial.baseColorUVTransform);\n let metallicRoughnessUV = getMaterialUV(\n pbrMaterial.metallicRoughnessUVSet,\n pbrMaterial.metallicRoughnessUVTransform\n );\n let normalUV = getMaterialUV(pbrMaterial.normalUVSet, pbrMaterial.normalUVTransform);\n let occlusionUV = getMaterialUV(pbrMaterial.occlusionUVSet, pbrMaterial.occlusionUVTransform);\n let emissiveUV = getMaterialUV(pbrMaterial.emissiveUVSet, pbrMaterial.emissiveUVTransform);\n let specularColorUV = getMaterialUV(\n pbrMaterial.specularColorUVSet,\n pbrMaterial.specularColorUVTransform\n );\n let specularIntensityUV = getMaterialUV(\n pbrMaterial.specularIntensityUVSet,\n pbrMaterial.specularIntensityUVTransform\n );\n let transmissionUV = getMaterialUV(\n pbrMaterial.transmissionUVSet,\n pbrMaterial.transmissionUVTransform\n );\n let thicknessUV = getMaterialUV(pbrMaterial.thicknessUVSet, pbrMaterial.thicknessUVTransform);\n let clearcoatUV = getMaterialUV(pbrMaterial.clearcoatUVSet, pbrMaterial.clearcoatUVTransform);\n let clearcoatRoughnessUV = getMaterialUV(\n pbrMaterial.clearcoatRoughnessUVSet,\n pbrMaterial.clearcoatRoughnessUVTransform\n );\n let clearcoatNormalUV = getMaterialUV(\n pbrMaterial.clearcoatNormalUVSet,\n pbrMaterial.clearcoatNormalUVTransform\n );\n let sheenColorUV = getMaterialUV(\n pbrMaterial.sheenColorUVSet,\n pbrMaterial.sheenColorUVTransform\n );\n let sheenRoughnessUV = getMaterialUV(\n pbrMaterial.sheenRoughnessUVSet,\n pbrMaterial.sheenRoughnessUVTransform\n );\n let iridescenceUV = getMaterialUV(\n pbrMaterial.iridescenceUVSet,\n pbrMaterial.iridescenceUVTransform\n );\n let iridescenceThicknessUV = getMaterialUV(\n pbrMaterial.iridescenceThicknessUVSet,\n pbrMaterial.iridescenceThicknessUVTransform\n );\n let anisotropyUV = getMaterialUV(\n pbrMaterial.anisotropyUVSet,\n pbrMaterial.anisotropyUVTransform\n );\n\n // The albedo may be defined from a base texture or a flat color\n var baseColor: vec4<f32> = pbrMaterial.baseColorFactor;\n #ifdef HAS_BASECOLORMAP\n baseColor = SRGBtoLINEAR(\n textureSample(pbr_baseColorSampler, pbr_baseColorSamplerSampler, baseColorUV)\n ) * pbrMaterial.baseColorFactor;\n #endif\n\n #ifdef ALPHA_CUTOFF\n if (baseColor.a < pbrMaterial.alphaCutoff) {\n discard;\n }\n #endif\n\n var color = vec3<f32>(0.0, 0.0, 0.0);\n var transmission = 0.0;\n\n if (pbrMaterial.unlit != 0u) {\n color = baseColor.rgb;\n } else {\n // Metallic and Roughness material properties are packed together\n // In glTF, these factors can be specified by fixed scalar values\n // or from a metallic-roughness map\n var perceptualRoughness = pbrMaterial.metallicRoughnessValues.y;\n var metallic = pbrMaterial.metallicRoughnessValues.x;\n #ifdef HAS_METALROUGHNESSMAP\n // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.\n // This layout intentionally reserves the 'r' channel for (optional) occlusion map data\n let mrSample = textureSample(\n pbr_metallicRoughnessSampler,\n pbr_metallicRoughnessSamplerSampler,\n metallicRoughnessUV\n );\n perceptualRoughness = mrSample.g * perceptualRoughness;\n metallic = mrSample.b * metallic;\n #endif\n perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);\n metallic = clamp(metallic, 0.0, 1.0);\n let tbn = getTBN(normalUV);\n let n = getNormal(tbn, normalUV); // normal at surface point\n let v = normalize(pbrProjection.camera - fragmentInputs.pbr_vPosition); // Vector from surface point to camera\n let NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);\n var useExtendedPBR = false;\n #ifdef USE_MATERIAL_EXTENSIONS\n useExtendedPBR =\n pbrMaterial.specularColorMapEnabled != 0 ||\n pbrMaterial.specularIntensityMapEnabled != 0 ||\n abs(pbrMaterial.specularIntensityFactor - 1.0) > 0.0001 ||\n maxComponent(abs(pbrMaterial.specularColorFactor - vec3f(1.0))) > 0.0001 ||\n abs(pbrMaterial.ior - 1.5) > 0.0001 ||\n pbrMaterial.transmissionMapEnabled != 0 ||\n pbrMaterial.transmissionFactor > 0.0001 ||\n pbrMaterial.clearcoatMapEnabled != 0 ||\n pbrMaterial.clearcoatRoughnessMapEnabled != 0 ||\n pbrMaterial.clearcoatFactor > 0.0001 ||\n pbrMaterial.clearcoatRoughnessFactor > 0.0001 ||\n pbrMaterial.sheenColorMapEnabled != 0 ||\n pbrMaterial.sheenRoughnessMapEnabled != 0 ||\n maxComponent(pbrMaterial.sheenColorFactor) > 0.0001 ||\n pbrMaterial.sheenRoughnessFactor > 0.0001 ||\n pbrMaterial.iridescenceMapEnabled != 0 ||\n pbrMaterial.iridescenceFactor > 0.0001 ||\n abs(pbrMaterial.iridescenceIor - 1.3) > 0.0001 ||\n abs(pbrMaterial.iridescenceThicknessRange.x - 100.0) > 0.0001 ||\n abs(pbrMaterial.iridescenceThicknessRange.y - 400.0) > 0.0001 ||\n pbrMaterial.anisotropyMapEnabled != 0 ||\n pbrMaterial.anisotropyStrength > 0.0001 ||\n abs(pbrMaterial.anisotropyRotation) > 0.0001 ||\n length(pbrMaterial.anisotropyDirection - vec2f(1.0, 0.0)) > 0.0001;\n #endif\n\n if (!useExtendedPBR) {\n let alphaRoughness = perceptualRoughness * perceptualRoughness;\n\n let f0 = vec3<f32>(0.04);\n var diffuseColor = baseColor.rgb * (vec3<f32>(1.0) - f0);\n diffuseColor *= 1.0 - metallic;\n let specularColor = mix(f0, baseColor.rgb, metallic);\n\n let reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\n let reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\n let specularEnvironmentR0 = specularColor;\n let specularEnvironmentR90 = vec3<f32>(1.0, 1.0, 1.0) * reflectance90;\n let reflection = -normalize(reflect(v, n));\n\n var pbrInfo = PBRInfo(\n 0.0, // NdotL\n NdotV,\n 0.0, // NdotH\n 0.0, // LdotH\n 0.0, // VdotH\n perceptualRoughness,\n metallic,\n specularEnvironmentR0,\n specularEnvironmentR90,\n alphaRoughness,\n diffuseColor,\n specularColor,\n n,\n v\n );\n\n #ifdef USE_LIGHTS\n PBRInfo_setAmbientLight(&pbrInfo);\n color += calculateFinalColor(pbrInfo, lighting.ambientColor);\n\n for (var i = 0; i < lighting.directionalLightCount; i++) {\n if (i < lighting.directionalLightCount) {\n PBRInfo_setDirectionalLight(&pbrInfo, lighting_getDirectionalLight(i).direction);\n color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);\n }\n }\n\n for (var i = 0; i < lighting.pointLightCount; i++) {\n if (i < lighting.pointLightCount) {\n PBRInfo_setPointLight(&pbrInfo, lighting_getPointLight(i));\n let attenuation = getPointLightAttenuation(\n lighting_getPointLight(i),\n distance(lighting_getPointLight(i).position, fragmentInputs.pbr_vPosition)\n );\n color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);\n }\n }\n\n for (var i = 0; i < lighting.spotLightCount; i++) {\n if (i < lighting.spotLightCount) {\n PBRInfo_setSpotLight(&pbrInfo, lighting_getSpotLight(i));\n let attenuation = getSpotLightAttenuation(\n lighting_getSpotLight(i),\n fragmentInputs.pbr_vPosition\n );\n color += calculateFinalColor(pbrInfo, lighting_getSpotLight(i).color / attenuation);\n }\n }\n #endif\n\n #ifdef USE_IBL\n if (pbrMaterial.IBLenabled != 0) {\n color += getIBLContribution(pbrInfo, n, reflection);\n }\n #endif\n\n #ifdef HAS_OCCLUSIONMAP\n if (pbrMaterial.occlusionMapEnabled != 0) {\n let ao = textureSample(pbr_occlusionSampler, pbr_occlusionSamplerSampler, occlusionUV).r;\n color = mix(color, color * ao, pbrMaterial.occlusionStrength);\n }\n #endif\n\n var emissive = pbrMaterial.emissiveFactor;\n #ifdef HAS_EMISSIVEMAP\n if (pbrMaterial.emissiveMapEnabled != 0u) {\n emissive *= SRGBtoLINEAR(\n textureSample(pbr_emissiveSampler, pbr_emissiveSamplerSampler, emissiveUV)\n ).rgb;\n }\n #endif\n color += emissive * pbrMaterial.emissiveStrength;\n\n #ifdef PBR_DEBUG\n color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);\n color = mix(color, vec3<f32>(metallic), pbrMaterial.scaleDiffBaseMR.z);\n color = mix(color, vec3<f32>(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);\n #endif\n\n return vec4<f32>(pow(color, vec3<f32>(1.0 / 2.2)), baseColor.a);\n }\n\n var specularIntensity = pbrMaterial.specularIntensityFactor;\n #ifdef HAS_SPECULARINTENSITYMAP\n if (pbrMaterial.specularIntensityMapEnabled != 0) {\n specularIntensity *= textureSample(\n pbr_specularIntensitySampler,\n pbr_specularIntensitySamplerSampler,\n specularIntensityUV\n ).a;\n }\n #endif\n\n var specularFactor = pbrMaterial.specularColorFactor;\n #ifdef HAS_SPECULARCOLORMAP\n if (pbrMaterial.specularColorMapEnabled != 0) {\n specularFactor *= SRGBtoLINEAR(\n textureSample(\n pbr_specularColorSampler,\n pbr_specularColorSamplerSampler,\n specularColorUV\n )\n ).rgb;\n }\n #endif\n\n transmission = pbrMaterial.transmissionFactor;\n #ifdef HAS_TRANSMISSIONMAP\n if (pbrMaterial.transmissionMapEnabled != 0) {\n transmission *= textureSample(\n pbr_transmissionSampler,\n pbr_transmissionSamplerSampler,\n transmissionUV\n ).r;\n }\n #endif\n transmission = clamp(transmission * (1.0 - metallic), 0.0, 1.0);\n var thickness = max(pbrMaterial.thicknessFactor, 0.0);\n #ifdef HAS_THICKNESSMAP\n thickness *= textureSample(\n pbr_thicknessSampler,\n pbr_thicknessSamplerSampler,\n thicknessUV\n ).g;\n #endif\n\n var clearcoatFactor = pbrMaterial.clearcoatFactor;\n var clearcoatRoughness = pbrMaterial.clearcoatRoughnessFactor;\n #ifdef HAS_CLEARCOATMAP\n if (pbrMaterial.clearcoatMapEnabled != 0) {\n clearcoatFactor *= textureSample(\n pbr_clearcoatSampler,\n pbr_clearcoatSamplerSampler,\n clearcoatUV\n ).r;\n }\n #endif\n #ifdef HAS_CLEARCOATROUGHNESSMAP\n if (pbrMaterial.clearcoatRoughnessMapEnabled != 0) {\n clearcoatRoughness *= textureSample(\n pbr_clearcoatRoughnessSampler,\n pbr_clearcoatRoughnessSamplerSampler,\n clearcoatRoughnessUV\n ).g;\n }\n #endif\n clearcoatFactor = clamp(clearcoatFactor, 0.0, 1.0);\n clearcoatRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);\n let clearcoatNormal = getClearcoatNormal(getTBN(clearcoatNormalUV), n, clearcoatNormalUV);\n\n var sheenColor = pbrMaterial.sheenColorFactor;\n var sheenRoughness = pbrMaterial.sheenRoughnessFactor;\n #ifdef HAS_SHEENCOLORMAP\n if (pbrMaterial.sheenColorMapEnabled != 0) {\n sheenColor *= SRGBtoLINEAR(\n textureSample(\n pbr_sheenColorSampler,\n pbr_sheenColorSamplerSampler,\n sheenColorUV\n )\n ).rgb;\n }\n #endif\n #ifdef HAS_SHEENROUGHNESSMAP\n if (pbrMaterial.sheenRoughnessMapEnabled != 0) {\n sheenRoughness *= textureSample(\n pbr_sheenRoughnessSampler,\n pbr_sheenRoughnessSamplerSampler,\n sheenRoughnessUV\n ).a;\n }\n #endif\n sheenRoughness = clamp(sheenRoughness, c_MinRoughness, 1.0);\n\n var iridescence = pbrMaterial.iridescenceFactor;\n #ifdef HAS_IRIDESCENCEMAP\n if (pbrMaterial.iridescenceMapEnabled != 0) {\n iridescence *= textureSample(\n pbr_iridescenceSampler,\n pbr_iridescenceSamplerSampler,\n iridescenceUV\n ).r;\n }\n #endif\n iridescence = clamp(iridescence, 0.0, 1.0);\n var iridescenceThickness = mix(\n pbrMaterial.iridescenceThicknessRange.x,\n pbrMaterial.iridescenceThicknessRange.y,\n 0.5\n );\n #ifdef HAS_IRIDESCENCETHICKNESSMAP\n iridescenceThickness = mix(\n pbrMaterial.iridescenceThicknessRange.x,\n pbrMaterial.iridescenceThicknessRange.y,\n textureSample(\n pbr_iridescenceThicknessSampler,\n pbr_iridescenceThicknessSamplerSampler,\n iridescenceThicknessUV\n ).g\n );\n #endif\n\n var anisotropyStrength = clamp(pbrMaterial.anisotropyStrength, 0.0, 1.0);\n var anisotropyDirection = normalizeDirection(pbrMaterial.anisotropyDirection);\n #ifdef HAS_ANISOTROPYMAP\n if (pbrMaterial.anisotropyMapEnabled != 0) {\n let anisotropySample = textureSample(\n pbr_anisotropySampler,\n pbr_anisotropySamplerSampler,\n anisotropyUV\n ).rgb;\n anisotropyStrength *= anisotropySample.b;\n let mappedDirection = anisotropySample.rg * 2.0 - 1.0;\n if (length(mappedDirection) > 0.0001) {\n anisotropyDirection = normalize(mappedDirection);\n }\n }\n #endif\n anisotropyDirection = rotateDirection(anisotropyDirection, pbrMaterial.anisotropyRotation);\n var anisotropyTangent =\n normalize(tbn[0] * anisotropyDirection.x + tbn[1] * anisotropyDirection.y);\n if (length(anisotropyTangent) < 0.0001) {\n anisotropyTangent = normalize(tbn[0]);\n }\n let anisotropyViewAlignment = abs(dot(v, anisotropyTangent));\n perceptualRoughness = mix(\n perceptualRoughness,\n clamp(perceptualRoughness * (1.0 - 0.6 * anisotropyViewAlignment), c_MinRoughness, 1.0),\n anisotropyStrength\n );\n\n // Roughness is authored as perceptual roughness; as is convention,\n // convert to material roughness by squaring the perceptual roughness [2].\n let alphaRoughness = perceptualRoughness * perceptualRoughness;\n\n let dielectricF0 = getDielectricF0(pbrMaterial.ior);\n var dielectricSpecularF0 = min(\n vec3f(dielectricF0) * specularFactor * specularIntensity,\n vec3f(1.0)\n );\n let iridescenceTint = getIridescenceTint(iridescence, iridescenceThickness, NdotV);\n dielectricSpecularF0 = mix(\n dielectricSpecularF0,\n dielectricSpecularF0 * iridescenceTint,\n iridescence\n );\n var diffuseColor = baseColor.rgb * (vec3f(1.0) - dielectricSpecularF0);\n diffuseColor *= (1.0 - metallic) * (1.0 - transmission);\n var specularColor = mix(dielectricSpecularF0, baseColor.rgb, metallic);\n\n let baseLayerEnergy = 1.0 - clearcoatFactor * 0.25;\n diffuseColor *= baseLayerEnergy;\n specularColor *= baseLayerEnergy;\n\n // Compute reflectance.\n let reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\n\n // For typical incident reflectance range (between 4% to 100%) set the grazing\n // reflectance to 100% for typical fresnel effect.\n // For very low reflectance range on highly diffuse objects (below 4%),\n // incrementally reduce grazing reflectance to 0%.\n let reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\n let specularEnvironmentR0 = specularColor;\n let specularEnvironmentR90 = vec3<f32>(1.0, 1.0, 1.0) * reflectance90;\n let reflection = -normalize(reflect(v, n));\n\n var pbrInfo = PBRInfo(\n 0.0, // NdotL\n NdotV,\n 0.0, // NdotH\n 0.0, // LdotH\n 0.0, // VdotH\n perceptualRoughness,\n metallic,\n specularEnvironmentR0,\n specularEnvironmentR90,\n alphaRoughness,\n diffuseColor,\n specularColor,\n n,\n v\n );\n\n #ifdef USE_LIGHTS\n // Apply ambient light\n PBRInfo_setAmbientLight(&pbrInfo);\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting.ambientColor,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n\n // Apply directional light\n for (var i = 0; i < lighting.directionalLightCount; i++) {\n if (i < lighting.directionalLightCount) {\n PBRInfo_setDirectionalLight(&pbrInfo, lighting_getDirectionalLight(i).direction);\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting_getDirectionalLight(i).color,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n }\n }\n\n // Apply point light\n for (var i = 0; i < lighting.pointLightCount; i++) {\n if (i < lighting.pointLightCount) {\n PBRInfo_setPointLight(&pbrInfo, lighting_getPointLight(i));\n let attenuation = getPointLightAttenuation(\n lighting_getPointLight(i),\n distance(lighting_getPointLight(i).position, fragmentInputs.pbr_vPosition)\n );\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting_getPointLight(i).color / attenuation,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n }\n }\n\n for (var i = 0; i < lighting.spotLightCount; i++) {\n if (i < lighting.spotLightCount) {\n PBRInfo_setSpotLight(&pbrInfo, lighting_getSpotLight(i));\n let attenuation = getSpotLightAttenuation(lighting_getSpotLight(i), fragmentInputs.pbr_vPosition);\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting_getSpotLight(i).color / attenuation,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n }\n }\n #endif\n\n // Calculate lighting contribution from image based lighting source (IBL)\n #ifdef USE_IBL\n if (pbrMaterial.IBLenabled != 0) {\n color += getIBLContribution(pbrInfo, n, reflection) *\n calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength);\n color += calculateClearcoatIBLContribution(\n pbrInfo,\n clearcoatNormal,\n -normalize(reflect(v, clearcoatNormal)),\n clearcoatFactor,\n clearcoatRoughness\n );\n color += sheenColor * pbrMaterial.scaleIBLAmbient.x * (1.0 - sheenRoughness) * 0.25;\n }\n #endif\n\n // Apply optional PBR terms for additional (optional) shading\n #ifdef HAS_OCCLUSIONMAP\n if (pbrMaterial.occlusionMapEnabled != 0) {\n let ao = textureSample(pbr_occlusionSampler, pbr_occlusionSamplerSampler, occlusionUV).r;\n color = mix(color, color * ao, pbrMaterial.occlusionStrength);\n }\n #endif\n\n var emissive = pbrMaterial.emissiveFactor;\n #ifdef HAS_EMISSIVEMAP\n if (pbrMaterial.emissiveMapEnabled != 0u) {\n emissive *= SRGBtoLINEAR(\n textureSample(pbr_emissiveSampler, pbr_emissiveSamplerSampler, emissiveUV)\n ).rgb;\n }\n #endif\n color += emissive * pbrMaterial.emissiveStrength;\n\n if (transmission > 0.0) {\n color = mix(color, color * getVolumeAttenuation(thickness), transmission);\n }\n\n // This section uses mix to override final color for reference app visualization\n // of various parameters in the lighting equation.\n #ifdef PBR_DEBUG\n // TODO: Figure out how to debug multiple lights\n\n // color = mix(color, F, pbr_scaleFGDSpec.x);\n // color = mix(color, vec3(G), pbr_scaleFGDSpec.y);\n // color = mix(color, vec3(D), pbr_scaleFGDSpec.z);\n // color = mix(color, specContrib, pbr_scaleFGDSpec.w);\n\n // color = mix(color, diffuseContrib, pbr_scaleDiffBaseMR.x);\n color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);\n color = mix(color, vec3<f32>(metallic), pbrMaterial.scaleDiffBaseMR.z);\n color = mix(color, vec3<f32>(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);\n #endif\n }\n\n let alpha = clamp(baseColor.a * (1.0 - transmission), 0.0, 1.0);\n return vec4<f32>(pow(color, vec3<f32>(1.0 / 2.2)), alpha);\n}\n",vs:"out vec3 pbr_vPosition;\nout vec2 pbr_vUV0;\nout vec2 pbr_vUV1;\n\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nout mat3 pbr_vTBN;\n# else\nout vec3 pbr_vNormal;\n# endif\n#endif\n\nvoid pbr_setPositionNormalTangentUV(\n vec4 position,\n vec4 normal,\n vec4 tangent,\n vec2 uv0,\n vec2 uv1\n)\n{\n vec4 pos = pbrProjection.modelMatrix * position;\n pbr_vPosition = vec3(pos.xyz) / pos.w;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\n vec3 normalW = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0)));\n vec3 tangentW = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0)));\n vec3 bitangentW = cross(normalW, tangentW) * tangent.w;\n pbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else // HAS_TANGENTS != 1\n pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n\n#ifdef HAS_UV\n pbr_vUV0 = uv0;\n#else\n pbr_vUV0 = vec2(0.,0.);\n#endif\n\n pbr_vUV1 = uv1;\n}\n",fs:"precision highp float;\n\nlayout(std140) uniform pbrMaterialUniforms {\n // Material is unlit\n bool unlit;\n\n // Base color map\n bool baseColorMapEnabled;\n vec4 baseColorFactor;\n\n bool normalMapEnabled; \n float normalScale; // #ifdef HAS_NORMALMAP\n\n bool emissiveMapEnabled;\n vec3 emissiveFactor; // #ifdef HAS_EMISSIVEMAP\n\n vec2 metallicRoughnessValues;\n bool metallicRoughnessMapEnabled;\n\n bool occlusionMapEnabled;\n float occlusionStrength; // #ifdef HAS_OCCLUSIONMAP\n \n bool alphaCutoffEnabled;\n float alphaCutoff; // #ifdef ALPHA_CUTOFF\n\n vec3 specularColorFactor;\n float specularIntensityFactor;\n bool specularColorMapEnabled;\n bool specularIntensityMapEnabled;\n\n float ior;\n\n float transmissionFactor;\n bool transmissionMapEnabled;\n\n float thicknessFactor;\n float attenuationDistance;\n vec3 attenuationColor;\n\n float clearcoatFactor;\n float clearcoatRoughnessFactor;\n bool clearcoatMapEnabled;\n bool clearcoatRoughnessMapEnabled;\n\n vec3 sheenColorFactor;\n float sheenRoughnessFactor;\n bool sheenColorMapEnabled;\n bool sheenRoughnessMapEnabled;\n\n float iridescenceFactor;\n float iridescenceIor;\n vec2 iridescenceThicknessRange;\n bool iridescenceMapEnabled;\n\n float anisotropyStrength;\n float anisotropyRotation;\n vec2 anisotropyDirection;\n bool anisotropyMapEnabled;\n\n float emissiveStrength;\n \n // IBL\n bool IBLenabled;\n vec2 scaleIBLAmbient; // #ifdef USE_IBL\n \n // debugging flags used for shader output of intermediate PBR variables\n // #ifdef PBR_DEBUG\n vec4 scaleDiffBaseMR;\n vec4 scaleFGDSpec;\n // #endif\n\n int baseColorUVSet;\n mat3 baseColorUVTransform;\n int metallicRoughnessUVSet;\n mat3 metallicRoughnessUVTransform;\n int normalUVSet;\n mat3 normalUVTransform;\n int occlusionUVSet;\n mat3 occlusionUVTransform;\n int emissiveUVSet;\n mat3 emissiveUVTransform;\n int specularColorUVSet;\n mat3 specularColorUVTransform;\n int specularIntensityUVSet;\n mat3 specularIntensityUVTransform;\n int transmissionUVSet;\n mat3 transmissionUVTransform;\n int thicknessUVSet;\n mat3 thicknessUVTransform;\n int clearcoatUVSet;\n mat3 clearcoatUVTransform;\n int clearcoatRoughnessUVSet;\n mat3 clearcoatRoughnessUVTransform;\n int clearcoatNormalUVSet;\n mat3 clearcoatNormalUVTransform;\n int sheenColorUVSet;\n mat3 sheenColorUVTransform;\n int sheenRoughnessUVSet;\n mat3 sheenRoughnessUVTransform;\n int iridescenceUVSet;\n mat3 iridescenceUVTransform;\n int iridescenceThicknessUVSet;\n mat3 iridescenceThicknessUVTransform;\n int anisotropyUVSet;\n mat3 anisotropyUVTransform;\n} pbrMaterial;\n\n// Samplers\n#ifdef HAS_BASECOLORMAP\nuniform sampler2D pbr_baseColorSampler;\n#endif\n#ifdef HAS_NORMALMAP\nuniform sampler2D pbr_normalSampler;\n#endif\n#ifdef HAS_EMISSIVEMAP\nuniform sampler2D pbr_emissiveSampler;\n#endif\n#ifdef HAS_METALROUGHNESSMAP\nuniform sampler2D pbr_metallicRoughnessSampler;\n#endif\n#ifdef HAS_OCCLUSIONMAP\nuniform sampler2D pbr_occlusionSampler;\n#endif\n#ifdef HAS_SPECULARCOLORMAP\nuniform sampler2D pbr_specularColorSampler;\n#endif\n#ifdef HAS_SPECULARINTENSITYMAP\nuniform sampler2D pbr_specularIntensitySampler;\n#endif\n#ifdef HAS_TRANSMISSIONMAP\nuniform sampler2D pbr_transmissionSampler;\n#endif\n#ifdef HAS_THICKNESSMAP\nuniform sampler2D pbr_thicknessSampler;\n#endif\n#ifdef HAS_CLEARCOATMAP\nuniform sampler2D pbr_clearcoatSampler;\n#endif\n#ifdef HAS_CLEARCOATROUGHNESSMAP\nuniform sampler2D pbr_clearcoatRoughnessSampler;\n#endif\n#ifdef HAS_CLEARCOATNORMALMAP\nuniform sampler2D pbr_clearcoatNormalSampler;\n#endif\n#ifdef HAS_SHEENCOLORMAP\nuniform sampler2D pbr_sheenColorSampler;\n#endif\n#ifdef HAS_SHEENROUGHNESSMAP\nuniform sampler2D pbr_sheenRoughnessSampler;\n#endif\n#ifdef HAS_IRIDESCENCEMAP\nuniform sampler2D pbr_iridescenceSampler;\n#endif\n#ifdef HAS_IRIDESCENCETHICKNESSMAP\nuniform sampler2D pbr_iridescenceThicknessSampler;\n#endif\n#ifdef HAS_ANISOTROPYMAP\nuniform sampler2D pbr_anisotropySampler;\n#endif\n// Inputs from vertex shader\n\nin vec3 pbr_vPosition;\nin vec2 pbr_vUV0;\nin vec2 pbr_vUV1;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nin mat3 pbr_vTBN;\n#else\nin vec3 pbr_vNormal;\n#endif\n#endif\n\n// Encapsulate the various inputs used by the various functions in the shading equation\n// We store values in this struct to simplify the integration of alternative implementations\n// of the shading terms, outlined in the Readme.MD Appendix.\nstruct PBRInfo {\n float NdotL; // cos angle between normal and light direction\n float NdotV; // cos angle between normal and view direction\n float NdotH; // cos angle between normal and half vector\n float LdotH; // cos angle between light direction and half vector\n float VdotH; // cos angle between view direction and half vector\n float perceptualRoughness; // roughness value, as authored by the model creator (input to shader)\n float metalness; // metallic value at the surface\n vec3 reflectance0; // full reflectance color (normal incidence angle)\n vec3 reflectance90; // reflectance color at grazing angle\n float alphaRoughness; // roughness mapped to a more linear change in the roughness (proposed by [2])\n vec3 diffuseColor; // color contribution from diffuse lighting\n vec3 specularColor; // color contribution from specular lighting\n vec3 n; // normal at surface point\n vec3 v; // vector from surface point to camera\n};\n\nconst float M_PI = 3.141592653589793;\nconst float c_MinRoughness = 0.04;\n\nvec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor);\n\nvec4 SRGBtoLINEAR(vec4 srgbIn)\n{\n#ifdef MANUAL_SRGB\n#ifdef SRGB_FAST_APPROXIMATION\n vec3 linOut = pow(srgbIn.xyz,vec3(2.2));\n#else // SRGB_FAST_APPROXIMATION\n vec3 bLess = step(vec3(0.04045),srgbIn.xyz);\n vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );\n#endif //SRGB_FAST_APPROXIMATION\n return vec4(linOut,srgbIn.w);;\n#else //MANUAL_SRGB\n return srgbIn;\n#endif //MANUAL_SRGB\n}\n\nvec2 getMaterialUV(int uvSet, mat3 uvTransform)\n{\n vec2 baseUV = uvSet == 1 ? pbr_vUV1 : pbr_vUV0;\n return (uvTransform * vec3(baseUV, 1.0)).xy;\n}\n\n// Build the tangent basis from interpolated attributes or screen-space derivatives.\nmat3 getTBN(vec2 uv)\n{\n#ifndef HAS_TANGENTS\n vec3 pos_dx = dFdx(pbr_vPosition);\n vec3 pos_dy = dFdy(pbr_vPosition);\n vec3 tex_dx = dFdx(vec3(uv, 0.0));\n vec3 tex_dy = dFdy(vec3(uv, 0.0));\n vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);\n\n#ifdef HAS_NORMALS\n vec3 ng = normalize(pbr_vNormal);\n#else\n vec3 ng = cross(pos_dx, pos_dy);\n#endif\n\n t = normalize(t - ng * dot(ng, t));\n vec3 b = normalize(cross(ng, t));\n mat3 tbn = mat3(t, b, ng);\n#else // HAS_TANGENTS\n mat3 tbn = pbr_vTBN;\n#endif\n\n return tbn;\n}\n\n// Find the normal for this fragment, pulling either from a predefined normal map\n// or from the interpolated mesh normal and tangent attributes.\nvec3 getMappedNormal(sampler2D normalSampler, mat3 tbn, float normalScale, vec2 uv)\n{\n vec3 n = texture(normalSampler, uv).rgb;\n return normalize(tbn * ((2.0 * n - 1.0) * vec3(normalScale, normalScale, 1.0)));\n}\n\nvec3 getNormal(mat3 tbn, vec2 uv)\n{\n#ifdef HAS_NORMALMAP\n vec3 n = getMappedNormal(pbr_normalSampler, tbn, pbrMaterial.normalScale, uv);\n#else\n // The tbn matrix is linearly interpolated, so we need to re-normalize\n vec3 n = normalize(tbn[2].xyz);\n#endif\n\n return n;\n}\n\nvec3 getClearcoatNormal(mat3 tbn, vec3 baseNormal, vec2 uv)\n{\n#ifdef HAS_CLEARCOATNORMALMAP\n return getMappedNormal(pbr_clearcoatNormalSampler, tbn, 1.0, uv);\n#else\n return baseNormal;\n#endif\n}\n\n// Calculation of the lighting contribution from an optional Image Based Light source.\n// Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].\n// See our README.md on Environment Maps [3] for additional discussion.\n#ifdef USE_IBL\nvec3 getIBLContribution(PBRInfo pbrInfo, vec3 n, vec3 reflection)\n{\n float mipCount = 9.0; // resolution of 512x512\n float lod = (pbrInfo.perceptualRoughness * mipCount);\n // retrieve a scale and bias to F0. See [1], Figure 3\n vec3 brdf = SRGBtoLINEAR(texture(pbr_brdfLUT,\n vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness))).rgb;\n vec3 diffuseLight = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, n)).rgb;\n\n#ifdef USE_TEX_LOD\n vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection, lod)).rgb;\n#else\n vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection)).rgb;\n#endif\n\n vec3 diffuse = diffuseLight * pbrInfo.diffuseColor;\n vec3 specular = specularLight * (pbrInfo.specularColor * brdf.x + brdf.y);\n\n // For presentation, this allows us to disable IBL terms\n diffuse *= pbrMaterial.scaleIBLAmbient.x;\n specular *= pbrMaterial.scaleIBLAmbient.y;\n\n return diffuse + specular;\n}\n#endif\n\n// Basic Lambertian diffuse\n// Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog\n// See also [1], Equation 1\nvec3 diffuse(PBRInfo pbrInfo)\n{\n return pbrInfo.diffuseColor / M_PI;\n}\n\n// The following equation models the Fresnel reflectance term of the spec equation (aka F())\n// Implementation of fresnel from [4], Equation 15\nvec3 specularReflection(PBRInfo pbrInfo)\n{\n return pbrInfo.reflectance0 +\n (pbrInfo.reflectance90 - pbrInfo.reflectance0) *\n pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);\n}\n\n// This calculates the specular geometric attenuation (aka G()),\n// where rougher material will reflect less light back to the viewer.\n// This implementation is based on [1] Equation 4, and we adopt their modifications to\n// alphaRoughness as input as originally proposed in [2].\nfloat geometricOcclusion(PBRInfo pbrInfo)\n{\n float NdotL = pbrInfo.NdotL;\n float NdotV = pbrInfo.NdotV;\n float r = pbrInfo.alphaRoughness;\n\n float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));\n float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));\n return attenuationL * attenuationV;\n}\n\n// The following equation(s) model the distribution of microfacet normals across\n// the area being drawn (aka D())\n// Implementation from \"Average Irregularity Representation of a Roughened Surface\n// for Ray Reflection\" by T. S. Trowbridge, and K. P. Reitz\n// Follows the distribution function recommended in the SIGGRAPH 2013 course notes\n// from EPIC Games [1], Equation 3.\nfloat microfacetDistribution(PBRInfo pbrInfo)\n{\n float roughnessSq = pbrInfo.alphaRoughness * pbrInfo.alphaRoughness;\n float f = (pbrInfo.NdotH * roughnessSq - pbrInfo.NdotH) * pbrInfo.NdotH + 1.0;\n return roughnessSq / (M_PI * f * f);\n}\n\nfloat maxComponent(vec3 value)\n{\n return max(max(value.r, value.g), value.b);\n}\n\nfloat getDielectricF0(float ior)\n{\n float clampedIor = max(ior, 1.0);\n float ratio = (clampedIor - 1.0) / (clampedIor + 1.0);\n return ratio * ratio;\n}\n\nvec2 normalizeDirection(vec2 direction)\n{\n float directionLength = length(direction);\n return directionLength > 0.0001 ? direction / directionLength : vec2(1.0, 0.0);\n}\n\nvec2 rotateDirection(vec2 direction, float rotation)\n{\n float s = sin(rotation);\n float c = cos(rotation);\n return vec2(direction.x * c - direction.y * s, direction.x * s + direction.y * c);\n}\n\nvec3 getIridescenceTint(float iridescence, float thickness, float NdotV)\n{\n if (iridescence <= 0.0) {\n return vec3(1.0);\n }\n\n float phase = 0.015 * thickness * pbrMaterial.iridescenceIor + (1.0 - NdotV) * 6.0;\n vec3 thinFilmTint =\n 0.5 + 0.5 * cos(vec3(phase, phase + 2.0943951, phase + 4.1887902));\n return mix(vec3(1.0), thinFilmTint, iridescence);\n}\n\nvec3 getVolumeAttenuation(float thickness)\n{\n if (thickness <= 0.0) {\n return vec3(1.0);\n }\n\n vec3 attenuationCoefficient =\n -log(max(pbrMaterial.attenuationColor, vec3(0.0001))) /\n max(pbrMaterial.attenuationDistance, 0.0001);\n return exp(-attenuationCoefficient * thickness);\n}\n\nPBRInfo createClearcoatPBRInfo(PBRInfo basePBRInfo, vec3 clearcoatNormal, float clearcoatRoughness)\n{\n float perceptualRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);\n float alphaRoughness = perceptualRoughness * perceptualRoughness;\n float NdotV = clamp(abs(dot(clearcoatNormal, basePBRInfo.v)), 0.001, 1.0);\n\n return PBRInfo(\n basePBRInfo.NdotL,\n NdotV,\n basePBRInfo.NdotH,\n basePBRInfo.LdotH,\n basePBRInfo.VdotH,\n perceptualRoughness,\n 0.0,\n vec3(0.04),\n vec3(1.0),\n alphaRoughness,\n vec3(0.0),\n vec3(0.04),\n clearcoatNormal,\n basePBRInfo.v\n );\n}\n\nvec3 calculateClearcoatContribution(\n PBRInfo pbrInfo,\n vec3 lightColor,\n vec3 clearcoatNormal,\n float clearcoatFactor,\n float clearcoatRoughness\n) {\n if (clearcoatFactor <= 0.0) {\n return vec3(0.0);\n }\n\n PBRInfo clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness);\n return calculateFinalColor(clearcoatPBRInfo, lightColor) * clearcoatFactor;\n}\n\n#ifdef USE_IBL\nvec3 calculateClearcoatIBLContribution(\n PBRInfo pbrInfo,\n vec3 clearcoatNormal,\n vec3 reflection,\n float clearcoatFactor,\n float clearcoatRoughness\n) {\n if (clearcoatFactor <= 0.0) {\n return vec3(0.0);\n }\n\n PBRInfo clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness);\n return getIBLContribution(clearcoatPBRInfo, clearcoatNormal, reflection) * clearcoatFactor;\n}\n#endif\n\nvec3 calculateSheenContribution(\n PBRInfo pbrInfo,\n vec3 lightColor,\n vec3 sheenColor,\n float sheenRoughness\n) {\n if (maxComponent(sheenColor) <= 0.0) {\n return vec3(0.0);\n }\n\n float sheenFresnel = pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);\n float sheenVisibility = mix(1.0, pbrInfo.NdotL * pbrInfo.NdotV, sheenRoughness);\n return pbrInfo.NdotL *\n lightColor *\n sheenColor *\n (0.25 + 0.75 * sheenFresnel) *\n sheenVisibility *\n (1.0 - pbrInfo.metalness);\n}\n\nfloat calculateAnisotropyBoost(\n PBRInfo pbrInfo,\n vec3 anisotropyTangent,\n float anisotropyStrength\n) {\n if (anisotropyStrength <= 0.0) {\n return 1.0;\n }\n\n vec3 anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));\n float bitangentViewAlignment = abs(dot(pbrInfo.v, anisotropyBitangent));\n return mix(1.0, 0.65 + 0.7 * bitangentViewAlignment, anisotropyStrength);\n}\n\nvec3 calculateMaterialLightColor(\n PBRInfo pbrInfo,\n vec3 lightColor,\n vec3 clearcoatNormal,\n float clearcoatFactor,\n float clearcoatRoughness,\n vec3 sheenColor,\n float sheenRoughness,\n vec3 anisotropyTangent,\n float anisotropyStrength\n) {\n float anisotropyBoost = calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength);\n vec3 color = calculateFinalColor(pbrInfo, lightColor) * anisotropyBoost;\n color += calculateClearcoatContribution(\n pbrInfo,\n lightColor,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness\n );\n color += calculateSheenContribution(pbrInfo, lightColor, sheenColor, sheenRoughness);\n return color;\n}\n\nvoid PBRInfo_setAmbientLight(inout PBRInfo pbrInfo) {\n pbrInfo.NdotL = 1.0;\n pbrInfo.NdotH = 0.0;\n pbrInfo.LdotH = 0.0;\n pbrInfo.VdotH = 1.0;\n}\n\nvoid PBRInfo_setDirectionalLight(inout PBRInfo pbrInfo, vec3 lightDirection) {\n vec3 n = pbrInfo.n;\n vec3 v = pbrInfo.v;\n vec3 l = normalize(lightDirection); // Vector from surface point to light\n vec3 h = normalize(l+v); // Half vector between both l and v\n\n pbrInfo.NdotL = clamp(dot(n, l), 0.001, 1.0);\n pbrInfo.NdotH = clamp(dot(n, h), 0.0, 1.0);\n pbrInfo.LdotH = clamp(dot(l, h), 0.0, 1.0);\n pbrInfo.VdotH = clamp(dot(v, h), 0.0, 1.0);\n}\n\nvoid PBRInfo_setPointLight(inout PBRInfo pbrInfo, PointLight pointLight) {\n vec3 light_direction = normalize(pointLight.position - pbr_vPosition);\n PBRInfo_setDirectionalLight(pbrInfo, light_direction);\n}\n\nvoid PBRInfo_setSpotLight(inout PBRInfo pbrInfo, SpotLight spotLight) {\n vec3 light_direction = normalize(spotLight.position - pbr_vPosition);\n PBRInfo_setDirectionalLight(pbrInfo, light_direction);\n}\n\nvec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor) {\n // Calculate the shading terms for the microfacet specular shading model\n vec3 F = specularReflection(pbrInfo);\n float G = geometricOcclusion(pbrInfo);\n float D = microfacetDistribution(pbrInfo);\n\n // Calculation of analytical lighting contribution\n vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInfo);\n vec3 specContrib = F * G * D / (4.0 * pbrInfo.NdotL * pbrInfo.NdotV);\n // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)\n return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib);\n}\n\nvec4 pbr_filterColor(vec4 colorUnused)\n{\n vec2 baseColorUV = getMaterialUV(pbrMaterial.baseColorUVSet, pbrMaterial.baseColorUVTransform);\n vec2 metallicRoughnessUV = getMaterialUV(\n pbrMaterial.metallicRoughnessUVSet,\n pbrMaterial.metallicRoughnessUVTransform\n );\n vec2 normalUV = getMaterialUV(pbrMaterial.normalUVSet, pbrMaterial.normalUVTransform);\n vec2 occlusionUV = getMaterialUV(pbrMaterial.occlusionUVSet, pbrMaterial.occlusionUVTransform);\n vec2 emissiveUV = getMaterialUV(pbrMaterial.emissiveUVSet, pbrMaterial.emissiveUVTransform);\n vec2 specularColorUV = getMaterialUV(\n pbrMaterial.specularColorUVSet,\n pbrMaterial.specularColorUVTransform\n );\n vec2 specularIntensityUV = getMaterialUV(\n pbrMaterial.specularIntensityUVSet,\n pbrMaterial.specularIntensityUVTransform\n );\n vec2 transmissionUV = getMaterialUV(\n pbrMaterial.transmissionUVSet,\n pbrMaterial.transmissionUVTransform\n );\n vec2 thicknessUV = getMaterialUV(pbrMaterial.thicknessUVSet, pbrMaterial.thicknessUVTransform);\n vec2 clearcoatUV = getMaterialUV(pbrMaterial.clearcoatUVSet, pbrMaterial.clearcoatUVTransform);\n vec2 clearcoatRoughnessUV = getMaterialUV(\n pbrMaterial.clearcoatRoughnessUVSet,\n pbrMaterial.clearcoatRoughnessUVTransform\n );\n vec2 clearcoatNormalUV = getMaterialUV(\n pbrMaterial.clearcoatNormalUVSet,\n pbrMaterial.clearcoatNormalUVTransform\n );\n vec2 sheenColorUV = getMaterialUV(\n pbrMaterial.sheenColorUVSet,\n pbrMaterial.sheenColorUVTransform\n );\n vec2 sheenRoughnessUV = getMaterialUV(\n pbrMaterial.sheenRoughnessUVSet,\n pbrMaterial.sheenRoughnessUVTransform\n );\n vec2 iridescenceUV = getMaterialUV(\n pbrMaterial.iridescenceUVSet,\n pbrMaterial.iridescenceUVTransform\n );\n vec2 iridescenceThicknessUV = getMaterialUV(\n pbrMaterial.iridescenceThicknessUVSet,\n pbrMaterial.iridescenceThicknessUVTransform\n );\n vec2 anisotropyUV = getMaterialUV(\n pbrMaterial.anisotropyUVSet,\n pbrMaterial.anisotropyUVTransform\n );\n\n // The albedo may be defined from a base texture or a flat color\n#ifdef HAS_BASECOLORMAP\n vec4 baseColor =\n SRGBtoLINEAR(texture(pbr_baseColorSampler, baseColorUV)) * pbrMaterial.baseColorFactor;\n#else\n vec4 baseColor = pbrMaterial.baseColorFactor;\n#endif\n\n#ifdef ALPHA_CUTOFF\n if (baseColor.a < pbrMaterial.alphaCutoff) {\n discard;\n }\n#endif\n\n vec3 color = vec3(0, 0, 0);\n\n float transmission = 0.0;\n\n if(pbrMaterial.unlit){\n color.rgb = baseColor.rgb;\n }\n else{\n // Metallic and Roughness material properties are packed together\n // In glTF, these factors can be specified by fixed scalar values\n // or from a metallic-roughness map\n float perceptualRoughness = pbrMaterial.metallicRoughnessValues.y;\n float metallic = pbrMaterial.metallicRoughnessValues.x;\n#ifdef HAS_METALROUGHNESSMAP\n // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.\n // This layout intentionally reserves the 'r' channel for (optional) occlusion map data\n vec4 mrSample = texture(pbr_metallicRoughnessSampler, metallicRoughnessUV);\n perceptualRoughness = mrSample.g * perceptualRoughness;\n metallic = mrSample.b * metallic;\n#endif\n perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);\n metallic = clamp(metallic, 0.0, 1.0);\n mat3 tbn = getTBN(normalUV);\n vec3 n = getNormal(tbn, normalUV); // normal at surface point\n vec3 v = normalize(pbrProjection.camera - pbr_vPosition); // Vector from surface point to camera\n float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);\n#ifdef USE_MATERIAL_EXTENSIONS\n bool useExtendedPBR =\n pbrMaterial.specularColorMapEnabled ||\n pbrMaterial.specularIntensityMapEnabled ||\n abs(pbrMaterial.specularIntensityFactor - 1.0) > 0.0001 ||\n maxComponent(abs(pbrMaterial.specularColorFactor - vec3(1.0))) > 0.0001 ||\n abs(pbrMaterial.ior - 1.5) > 0.0001 ||\n pbrMaterial.transmissionMapEnabled ||\n pbrMaterial.transmissionFactor > 0.0001 ||\n pbrMaterial.clearcoatMapEnabled ||\n pbrMaterial.clearcoatRoughnessMapEnabled ||\n pbrMaterial.clearcoatFactor > 0.0001 ||\n pbrMaterial.clearcoatRoughnessFactor > 0.0001 ||\n pbrMaterial.sheenColorMapEnabled ||\n pbrMaterial.sheenRoughnessMapEnabled ||\n maxComponent(pbrMaterial.sheenColorFactor) > 0.0001 ||\n pbrMaterial.sheenRoughnessFactor > 0.0001 ||\n pbrMaterial.iridescenceMapEnabled ||\n pbrMaterial.iridescenceFactor > 0.0001 ||\n abs(pbrMaterial.iridescenceIor - 1.3) > 0.0001 ||\n abs(pbrMaterial.iridescenceThicknessRange.x - 100.0) > 0.0001 ||\n abs(pbrMaterial.iridescenceThicknessRange.y - 400.0) > 0.0001 ||\n pbrMaterial.anisotropyMapEnabled ||\n pbrMaterial.anisotropyStrength > 0.0001 ||\n abs(pbrMaterial.anisotropyRotation) > 0.0001 ||\n length(pbrMaterial.anisotropyDirection - vec2(1.0, 0.0)) > 0.0001;\n#else\n bool useExtendedPBR = false;\n#endif\n\n if (!useExtendedPBR) {\n // Keep the baseline metallic-roughness implementation byte-for-byte equivalent in behavior.\n float alphaRoughness = perceptualRoughness * perceptualRoughness;\n\n vec3 f0 = vec3(0.04);\n vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);\n diffuseColor *= 1.0 - metallic;\n vec3 specularColor = mix(f0, baseColor.rgb, metallic);\n\n float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\n float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\n vec3 specularEnvironmentR0 = specularColor.rgb;\n vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;\n vec3 reflection = -normalize(reflect(v, n));\n\n PBRInfo pbrInfo = PBRInfo(\n 0.0, // NdotL\n NdotV,\n 0.0, // NdotH\n 0.0, // LdotH\n 0.0, // VdotH\n perceptualRoughness,\n metallic,\n specularEnvironmentR0,\n specularEnvironmentR90,\n alphaRoughness,\n diffuseColor,\n specularColor,\n n,\n v\n );\n\n#ifdef USE_LIGHTS\n PBRInfo_setAmbientLight(pbrInfo);\n color += calculateFinalColor(pbrInfo, lighting.ambientColor);\n\n for(int i = 0; i < lighting.directionalLightCount; i++) {\n if (i < lighting.directionalLightCount) {\n PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);\n color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);\n }\n }\n\n for(int i = 0; i < lighting.pointLightCount; i++) {\n if (i < lighting.pointLightCount) {\n PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i));\n float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));\n color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);\n }\n }\n\n for(int i = 0; i < lighting.spotLightCount; i++) {\n if (i < lighting.spotLightCount) {\n PBRInfo_setSpotLight(pbrInfo, lighting_getSpotLight(i));\n float attenuation = getSpotLightAttenuation(lighting_getSpotLight(i), pbr_vPosition);\n color += calculateFinalColor(pbrInfo, lighting_getSpotLight(i).color / attenuation);\n }\n }\n#endif\n\n#ifdef USE_IBL\n if (pbrMaterial.IBLenabled) {\n color += getIBLContribution(pbrInfo, n, reflection);\n }\n#endif\n\n#ifdef HAS_OCCLUSIONMAP\n if (pbrMaterial.occlusionMapEnabled) {\n float ao = texture(pbr_occlusionSampler, occlusionUV).r;\n color = mix(color, color * ao, pbrMaterial.occlusionStrength);\n }\n#endif\n\n vec3 emissive = pbrMaterial.emissiveFactor;\n#ifdef HAS_EMISSIVEMAP\n if (pbrMaterial.emissiveMapEnabled) {\n emissive *= SRGBtoLINEAR(texture(pbr_emissiveSampler, emissiveUV)).rgb;\n }\n#endif\n color += emissive * pbrMaterial.emissiveStrength;\n\n#ifdef PBR_DEBUG\n color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);\n color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z);\n color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);\n#endif\n\n return vec4(pow(color, vec3(1.0 / 2.2)), baseColor.a);\n }\n\n float specularIntensity = pbrMaterial.specularIntensityFactor;\n#ifdef HAS_SPECULARINTENSITYMAP\n if (pbrMaterial.specularIntensityMapEnabled) {\n specularIntensity *= texture(pbr_specularIntensitySampler, specularIntensityUV).a;\n }\n#endif\n\n vec3 specularFactor = pbrMaterial.specularColorFactor;\n#ifdef HAS_SPECULARCOLORMAP\n if (pbrMaterial.specularColorMapEnabled) {\n specularFactor *= SRGBtoLINEAR(texture(pbr_specularColorSampler, specularColorUV)).rgb;\n }\n#endif\n\n transmission = pbrMaterial.transmissionFactor;\n#ifdef HAS_TRANSMISSIONMAP\n if (pbrMaterial.transmissionMapEnabled) {\n transmission *= texture(pbr_transmissionSampler, transmissionUV).r;\n }\n#endif\n transmission = clamp(transmission * (1.0 - metallic), 0.0, 1.0);\n float thickness = max(pbrMaterial.thicknessFactor, 0.0);\n#ifdef HAS_THICKNESSMAP\n thickness *= texture(pbr_thicknessSampler, thicknessUV).g;\n#endif\n\n float clearcoatFactor = pbrMaterial.clearcoatFactor;\n float clearcoatRoughness = pbrMaterial.clearcoatRoughnessFactor;\n#ifdef HAS_CLEARCOATMAP\n if (pbrMaterial.clearcoatMapEnabled) {\n clearcoatFactor *= texture(pbr_clearcoatSampler, clearcoatUV).r;\n }\n#endif\n#ifdef HAS_CLEARCOATROUGHNESSMAP\n if (pbrMaterial.clearcoatRoughnessMapEnabled) {\n clearcoatRoughness *= texture(pbr_clearcoatRoughnessSampler, clearcoatRoughnessUV).g;\n }\n#endif\n clearcoatFactor = clamp(clearcoatFactor, 0.0, 1.0);\n clearcoatRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);\n vec3 clearcoatNormal = getClearcoatNormal(getTBN(clearcoatNormalUV), n, clearcoatNormalUV);\n\n vec3 sheenColor = pbrMaterial.sheenColorFactor;\n float sheenRoughness = pbrMaterial.sheenRoughnessFactor;\n#ifdef HAS_SHEENCOLORMAP\n if (pbrMaterial.sheenColorMapEnabled) {\n sheenColor *= SRGBtoLINEAR(texture(pbr_sheenColorSampler, sheenColorUV)).rgb;\n }\n#endif\n#ifdef HAS_SHEENROUGHNESSMAP\n if (pbrMaterial.sheenRoughnessMapEnabled) {\n sheenRoughness *= texture(pbr_sheenRoughnessSampler, sheenRoughnessUV).a;\n }\n#endif\n sheenRoughness = clamp(sheenRoughness, c_MinRoughness, 1.0);\n\n float iridescence = pbrMaterial.iridescenceFactor;\n#ifdef HAS_IRIDESCENCEMAP\n if (pbrMaterial.iridescenceMapEnabled) {\n iridescence *= texture(pbr_iridescenceSampler, iridescenceUV).r;\n }\n#endif\n iridescence = clamp(iridescence, 0.0, 1.0);\n float iridescenceThickness = mix(\n pbrMaterial.iridescenceThicknessRange.x,\n pbrMaterial.iridescenceThicknessRange.y,\n 0.5\n );\n#ifdef HAS_IRIDESCENCETHICKNESSMAP\n iridescenceThickness = mix(\n pbrMaterial.iridescenceThicknessRange.x,\n pbrMaterial.iridescenceThicknessRange.y,\n texture(pbr_iridescenceThicknessSampler, iridescenceThicknessUV).g\n );\n#endif\n\n float anisotropyStrength = clamp(pbrMaterial.anisotropyStrength, 0.0, 1.0);\n vec2 anisotropyDirection = normalizeDirection(pbrMaterial.anisotropyDirection);\n#ifdef HAS_ANISOTROPYMAP\n if (pbrMaterial.anisotropyMapEnabled) {\n vec3 anisotropySample = texture(pbr_anisotropySampler, anisotropyUV).rgb;\n anisotropyStrength *= anisotropySample.b;\n vec2 mappedDirection = anisotropySample.rg * 2.0 - 1.0;\n if (length(mappedDirection) > 0.0001) {\n anisotropyDirection = normalize(mappedDirection);\n }\n }\n#endif\n anisotropyDirection = rotateDirection(anisotropyDirection, pbrMaterial.anisotropyRotation);\n vec3 anisotropyTangent = normalize(tbn[0] * anisotropyDirection.x + tbn[1] * anisotropyDirection.y);\n if (length(anisotropyTangent) < 0.0001) {\n anisotropyTangent = normalize(tbn[0]);\n }\n float anisotropyViewAlignment = abs(dot(v, anisotropyTangent));\n perceptualRoughness = mix(\n perceptualRoughness,\n clamp(perceptualRoughness * (1.0 - 0.6 * anisotropyViewAlignment), c_MinRoughness, 1.0),\n anisotropyStrength\n );\n\n // Roughness is authored as perceptual roughness; as is convention,\n // convert to material roughness by squaring the perceptual roughness [2].\n float alphaRoughness = perceptualRoughness * perceptualRoughness;\n\n float dielectricF0 = getDielectricF0(pbrMaterial.ior);\n vec3 dielectricSpecularF0 = min(\n vec3(dielectricF0) * specularFactor * specularIntensity,\n vec3(1.0)\n );\n vec3 iridescenceTint = getIridescenceTint(iridescence, iridescenceThickness, NdotV);\n dielectricSpecularF0 = mix(\n dielectricSpecularF0,\n dielectricSpecularF0 * iridescenceTint,\n iridescence\n );\n vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - dielectricSpecularF0);\n diffuseColor *= (1.0 - metallic) * (1.0 - transmission);\n vec3 specularColor = mix(dielectricSpecularF0, baseColor.rgb, metallic);\n\n float baseLayerEnergy = 1.0 - clearcoatFactor * 0.25;\n diffuseColor *= baseLayerEnergy;\n specularColor *= baseLayerEnergy;\n\n // Compute reflectance.\n float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\n\n // For typical incident reflectance range (between 4% to 100%) set the grazing\n // reflectance to 100% for typical fresnel effect.\n // For very low reflectance range on highly diffuse objects (below 4%),\n // incrementally reduce grazing reflecance to 0%.\n float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\n vec3 specularEnvironmentR0 = specularColor.rgb;\n vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;\n vec3 reflection = -normalize(reflect(v, n));\n\n PBRInfo pbrInfo = PBRInfo(\n 0.0, // NdotL\n NdotV,\n 0.0, // NdotH\n 0.0, // LdotH\n 0.0, // VdotH\n perceptualRoughness,\n metallic,\n specularEnvironmentR0,\n specularEnvironmentR90,\n alphaRoughness,\n diffuseColor,\n specularColor,\n n,\n v\n );\n\n\n#ifdef USE_LIGHTS\n // Apply ambient light\n PBRInfo_setAmbientLight(pbrInfo);\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting.ambientColor,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n\n // Apply directional light\n for(int i = 0; i < lighting.directionalLightCount; i++) {\n if (i < lighting.directionalLightCount) {\n PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting_getDirectionalLight(i).color,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n }\n }\n\n // Apply point light\n for(int i = 0; i < lighting.pointLightCount; i++) {\n if (i < lighting.pointLightCount) {\n PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i));\n float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting_getPointLight(i).color / attenuation,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n }\n }\n\n for(int i = 0; i < lighting.spotLightCount; i++) {\n if (i < lighting.spotLightCount) {\n PBRInfo_setSpotLight(pbrInfo, lighting_getSpotLight(i));\n float attenuation = getSpotLightAttenuation(lighting_getSpotLight(i), pbr_vPosition);\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting_getSpotLight(i).color / attenuation,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n }\n }\n#endif\n\n // Calculate lighting contribution from image based lighting source (IBL)\n#ifdef USE_IBL\n if (pbrMaterial.IBLenabled) {\n color += getIBLContribution(pbrInfo, n, reflection) *\n calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength);\n color += calculateClearcoatIBLContribution(\n pbrInfo,\n clearcoatNormal,\n -normalize(reflect(v, clearcoatNormal)),\n clearcoatFactor,\n clearcoatRoughness\n );\n color += sheenColor * pbrMaterial.scaleIBLAmbient.x * (1.0 - sheenRoughness) * 0.25;\n }\n#endif\n\n // Apply optional PBR terms for additional (optional) shading\n#ifdef HAS_OCCLUSIONMAP\n if (pbrMaterial.occlusionMapEnabled) {\n float ao = texture(pbr_occlusionSampler, occlusionUV).r;\n color = mix(color, color * ao, pbrMaterial.occlusionStrength);\n }\n#endif\n\n vec3 emissive = pbrMaterial.emissiveFactor;\n#ifdef HAS_EMISSIVEMAP\n if (pbrMaterial.emissiveMapEnabled) {\n emissive *= SRGBtoLINEAR(texture(pbr_emissiveSampler, emissiveUV)).rgb;\n }\n#endif\n color += emissive * pbrMaterial.emissiveStrength;\n\n if (transmission > 0.0) {\n color = mix(color, color * getVolumeAttenuation(thickness), transmission);\n }\n\n // This section uses mix to override final color for reference app visualization\n // of various parameters in the lighting equation.\n#ifdef PBR_DEBUG\n // TODO: Figure out how to debug multiple lights\n\n // color = mix(color, F, pbr_scaleFGDSpec.x);\n // color = mix(color, vec3(G), pbr_scaleFGDSpec.y);\n // color = mix(color, vec3(D), pbr_scaleFGDSpec.z);\n // color = mix(color, specContrib, pbr_scaleFGDSpec.w);\n\n // color = mix(color, diffuseContrib, pbr_scaleDiffBaseMR.x);\n color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);\n color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z);\n color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);\n#endif\n\n }\n\n float alpha = clamp(baseColor.a * (1.0 - transmission), 0.0, 1.0);\n return vec4(pow(color,vec3(1.0/2.2)), alpha);\n}\n",defines:{LIGHTING_FRAGMENT:!0,HAS_NORMALMAP:!1,HAS_EMISSIVEMAP:!1,HAS_OCCLUSIONMAP:!1,HAS_BASECOLORMAP:!1,HAS_METALROUGHNESSMAP:!1,HAS_SPECULARCOLORMAP:!1,HAS_SPECULARINTENSITYMAP:!1,HAS_TRANSMISSIONMAP:!1,HAS_THICKNESSMAP:!1,HAS_CLEARCOATMAP:!1,HAS_CLEARCOATROUGHNESSMAP:!1,HAS_CLEARCOATNORMALMAP:!1,HAS_SHEENCOLORMAP:!1,HAS_SHEENROUGHNESSMAP:!1,HAS_IRIDESCENCEMAP:!1,HAS_IRIDESCENCETHICKNESSMAP:!1,HAS_ANISOTROPYMAP:!1,USE_MATERIAL_EXTENSIONS:!1,ALPHA_CUTOFF:!1,USE_IBL:!1,PBR_DEBUG:!1},getUniforms:e=>e,uniformTypes:{unlit:"i32",baseColorMapEnabled:"i32",baseColorFactor:"vec4<f32>",normalMapEnabled:"i32",normalScale:"f32",emissiveMapEnabled:"i32",emissiveFactor:"vec3<f32>",metallicRoughnessValues:"vec2<f32>",metallicRoughnessMapEnabled:"i32",occlusionMapEnabled:"i32",occlusionStrength:"f32",alphaCutoffEnabled:"i32",alphaCutoff:"f32",specularColorFactor:"vec3<f32>",specularIntensityFactor:"f32",specularColorMapEnabled:"i32",specularIntensityMapEnabled:"i32",ior:"f32",transmissionFactor:"f32",transmissionMapEnabled:"i32",thicknessFactor:"f32",attenuationDistance:"f32",attenuationColor:"vec3<f32>",clearcoatFactor:"f32",clearcoatRoughnessFactor:"f32",clearcoatMapEnabled:"i32",clearcoatRoughnessMapEnabled:"i32",sheenColorFactor:"vec3<f32>",sheenRoughnessFactor:"f32",sheenColorMapEnabled:"i32",sheenRoughnessMapEnabled:"i32",iridescenceFactor:"f32",iridescenceIor:"f32",iridescenceThicknessRange:"vec2<f32>",iridescenceMapEnabled:"i32",anisotropyStrength:"f32",anisotropyRotation:"f32",anisotropyDirection:"vec2<f32>",anisotropyMapEnabled:"i32",emissiveStrength:"f32",IBLenabled:"i32",scaleIBLAmbient:"vec2<f32>",scaleDiffBaseMR:"vec4<f32>",scaleFGDSpec:"vec4<f32>",baseColorUVSet:"i32",baseColorUVTransform:"mat3x3<f32>",metallicRoughnessUVSet:"i32",metallicRoughnessUVTransform:"mat3x3<f32>",normalUVSet:"i32",normalUVTransform:"mat3x3<f32>",occlusionUVSet:"i32",occlusionUVTransform:"mat3x3<f32>",emissiveUVSet:"i32",emissiveUVTransform:"mat3x3<f32>",specularColorUVSet:"i32",specularColorUVTransform:"mat3x3<f32>",specularIntensityUVSet:"i32",specularIntensityUVTransform:"mat3x3<f32>",transmissionUVSet:"i32",transmissionUVTransform:"mat3x3<f32>",thicknessUVSet:"i32",thicknessUVTransform:"mat3x3<f32>",clearcoatUVSet:"i32",clearcoatUVTransform:"mat3x3<f32>",clearcoatRoughnessUVSet:"i32",clearcoatRoughnessUVTransform:"mat3x3<f32>",clearcoatNormalUVSet:"i32",clearcoatNormalUVTransform:"mat3x3<f32>",sheenColorUVSet:"i32",sheenColorUVTransform:"mat3x3<f32>",sheenRoughnessUVSet:"i32",sheenRoughnessUVTransform:"mat3x3<f32>",iridescenceUVSet:"i32",iridescenceUVTransform:"mat3x3<f32>",iridescenceThicknessUVSet:"i32",iridescenceThicknessUVTransform:"mat3x3<f32>",anisotropyUVSet:"i32",anisotropyUVTransform:"mat3x3<f32>"}};function q_(e,t){if(!e)throw new Error(t)}class ScenegraphNode{id;matrix=new Rn.k;display=!0;position=new oi.P;rotation=new oi.P;scale=new oi.P(1,1,1);userData={};props={};constructor(e={}){const{id:t}=e;this.id=t||(0,po.L)(this.constructor.name),this._setScenegraphNodeProps(e)}getBounds(){return null}destroy(){}delete(){this.destroy()}setProps(e){return this._setScenegraphNodeProps(e),this}toString(){return`{type: ScenegraphNode, id: ${this.id})}`}setPosition(e){return q_(3===e.length,"setPosition requires vector argument"),this.position=e,this}setRotation(e){return q_(3===e.length||4===e.length,"setRotation requires vector argument"),this.rotation=e,this}setScale(e){return q_(3===e.length,"setScale requires vector argument"),this.scale=e,this}setMatrix(e,t=!0){t?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){const{position:t,rotation:n,scale:i,update:r=!0}=e;return t&&this.setPosition(t),n&&this.setRotation(n),i&&this.setScale(i),r&&this.updateMatrix(),this}updateMatrix(){if(this.matrix.identity(),this.matrix.translate(this.position),4===this.rotation.length){const e=(new Rn.k).fromQuaternion(this.rotation);this.matrix.multiplyRight(e)}else this.matrix.rotateXYZ(this.rotation);return this.matrix.scale(this.scale),this}update({position:e,rotation:t,scale:n}={}){return e&&this.setPosition(e),t&&this.setRotation(t),n&&this.setScale(n),this.updateMatrix(),this}getCoordinateUniforms(e,t){t=t||this.matrix;const n=new Rn.k(e).multiplyRight(t),i=n.invert(),r=i.transpose();return{viewMatrix:e,modelMatrix:t,objectMatrix:t,worldMatrix:n,worldInverseMatrix:i,worldInverseTransposeMatrix:r}}_setScenegraphNodeProps(e){e?.position&&this.setPosition(e.position),e?.rotation&&this.setRotation(e.rotation),e?.scale&&this.setScale(e.scale),this.updateMatrix(),e?.matrix&&this.setMatrix(e.matrix),Object.assign(this.props,e)}}class GroupNode extends ScenegraphNode{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;const{children:t=[]}=e;Hi.R.assert(t.every(e=>e instanceof ScenegraphNode),"every child must an instance of ScenegraphNode"),super(e),this.children=t}getBounds(){const e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((t,{worldMatrix:n})=>{const i=t.getBounds();if(!i)return;const[r,s]=i,o=new oi.P(r).add(s).divide([2,2,2]);n.transformAsPoint(o,o);const a=new oi.P(s).subtract(r).divide([2,2,2]);n.transformAsVector(a,a);for(let t=0;t<8;t++){const n=new oi.P(1&t?-1:1,2&t?-1:1,4&t?-1:1).multiply(a).add(o);for(let t=0;t<3;t++)e[0][t]=Math.min(e[0][t],n[t]),e[1][t]=Math.max(e[1][t],n[t])}}),Number.isFinite(e[0][0])?e:null}destroy(){this.children.forEach(e=>e.destroy()),this.removeAll(),super.destroy()}add(...e){for(const t of e)Array.isArray(t)?this.add(...t):this.children.push(t);return this}remove(e){const t=this.children,n=t.indexOf(e);return n>-1&&t.splice(n,1),this}removeAll(){return this.children=[],this}traverse(e,{worldMatrix:t=new Rn.k}={}){const n=new Rn.k(t).multiplyRight(this.matrix);for(const t of this.children)t instanceof GroupNode?t.traverse(e,{worldMatrix:n}):e(t,{worldMatrix:n})}preorderTraversal(e,{worldMatrix:t=new Rn.k}={}){const n=new Rn.k(t).multiplyRight(this.matrix);e(this,{worldMatrix:n});for(const t of this.children)t instanceof GroupNode?t.preorderTraversal(e,{worldMatrix:n}):e(t,{worldMatrix:n})}}class ModelNode extends ScenegraphNode{model;bounds=null;managedResources;constructor(e){super(e),this.model=e.model,this.managedResources=e.managedResources||[],this.bounds=e.bounds||null,this.setProps(e)}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(e=>e.destroy()),this.managedResources=[]}getBounds(){return this.bounds}draw(e){return this.model.draw(e)}}var K_=n(99427),Q_=n(24114),X_=n(75638),$_=n(89277),Z_=n(22798),Y_=n(16698);class Material{id;device;factory;shaderInputs;bindings={};_uniformStore;_bindGroupCacheToken={};constructor(e,t={}){this.id=t.id||(0,po.L)("material"),this.device=e,this.factory=t.factory||new MaterialFactory(e,{modules:t.modules||t.shaderInputs?.getModules()||[]});const n=Object.fromEntries((t.shaderInputs?.getModules()||this.factory.modules).map(e=>[e.name,e]));this.shaderInputs=t.shaderInputs||new K_.l(n),this._uniformStore=new Q_.K(this.device,this.shaderInputs.modules);for(const[e,t]of Object.entries(this.shaderInputs.modules))if(this.ownsModule(e)&&(0,Y_.f)(t)){const t=this._uniformStore.getManagedUniformBuffer(e);this.bindings[`${e}Uniforms`]=t}this.updateShaderInputs(),t.bindings&&this._replaceOwnedBindings(t.bindings)}destroy(){this._uniformStore.destroy()}clone(e={}){const t=this.factory.createMaterial({id:e.id,shaderInputs:e.shaderInputs,bindings:{...this.getResourceBindings(),...e.bindings}});return e.shaderInputs||t.setProps(this.shaderInputs.getUniformValues()),e.moduleProps&&t.setProps(e.moduleProps),t}ownsBinding(e){return this.factory.ownsBinding(e)}ownsModule(e){return this.factory.ownsModule(e)}setProps(e){this.shaderInputs.setProps(e),this.updateShaderInputs()}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues());this._setOwnedBindings(this.shaderInputs.getBindingValues())&&(this._bindGroupCacheToken={})}getResourceBindings(){const e={};for(const[t,n]of Object.entries(this.bindings))ev(t)||(e[t]=n);return e}getBindings(){const e={},t=e;for(const[e,n]of Object.entries(this.bindings))n instanceof Z_.R?n.isReady&&(t[e]=n.texture):t[e]=n;return e}getBindingsByGroup(){return this.factory.getBindingsByGroup(this.getBindings())}getBindGroupCacheKey(e){return e===J_?this._bindGroupCacheToken:null}getBindingsUpdateTimestamp(){let e=0;for(const t of Object.values(this.bindings))t instanceof X_.X?e=Math.max(e,t.texture.updateTimestamp):t instanceof Ri.h||t instanceof Pi.g?e=Math.max(e,t.updateTimestamp):t instanceof Z_.R?e=t.texture?Math.max(e,t.texture.updateTimestamp):1/0:t instanceof $_.L||(e=Math.max(e,t.buffer.updateTimestamp));return e}_replaceOwnedBindings(e){this._setOwnedBindings(e)&&(this._bindGroupCacheToken={})}_setOwnedBindings(e){let t=!1;for(const[n,i]of Object.entries(e))void 0!==i&&this.ownsBinding(n)&&this.bindings[n]!==i&&(this.bindings[n]=i,t=!0);return t}}const J_=3;class MaterialFactory{device;modules;_materialBindingNames;_materialModuleNames;constructor(e,t={}){this.device=e,this.modules=t.modules||[];const n=new K_.l(Object.fromEntries(this.modules.map(e=>[e.name,e])));this._materialBindingNames=function(e){const t=new Set;for(const n of Object.values(e.modules))for(const e of n.bindingLayout||[])e.group===J_&&t.add(e.name);return t}(n),this._materialModuleNames=function(e){const t=new Set;for(const n of Object.values(e.modules))n.name&&n.bindingLayout?.some(e=>e.group===J_&&e.name===n.name)&&t.add(n.name);return t}(n)}createMaterial(e={}){return new Material(this.device,{...e,factory:this})}getBindingNames(){return Array.from(this._materialBindingNames)}ownsBinding(e){if(this._materialBindingNames.has(e))return!0;const t=ev(e);return!!t&&this._materialModuleNames.has(t)}ownsModule(e){return this._materialModuleNames.has(e)}getBindingsByGroup(e){return Object.keys(e).length>0?{[J_]:e}:{}}}function ev(e){return e.endsWith("Uniforms")?e.slice(0,-8):null}var tv;!function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ONE=1]="ONE",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST=9728]="NEAREST",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"}(tv||(tv={}));const nv={props:{},uniforms:{},name:"skin",bindingLayout:[{name:"skin",group:0}],dependencies:[],source:"\nstruct skinUniforms {\n jointMatrix: array<mat4x4<f32>, 20>,\n};\n\n@group(0) @binding(auto) var<uniform> skin: skinUniforms;\n\nfn getSkinMatrix(weights: vec4f, joints: vec4u) -> mat4x4<f32> {\n return (weights.x * skin.jointMatrix[joints.x])\n + (weights.y * skin.jointMatrix[joints.y])\n + (weights.z * skin.jointMatrix[joints.z])\n + (weights.w * skin.jointMatrix[joints.w]);\n}\n",vs:"\nlayout(std140) uniform skinUniforms {\n mat4 jointMatrix[SKIN_MAX_JOINTS];\n} skin;\n\nmat4 getSkinMatrix(vec4 weights, uvec4 joints) {\n return (weights.x * skin.jointMatrix[joints.x])\n + (weights.y * skin.jointMatrix[joints.y])\n + (weights.z * skin.jointMatrix[joints.z])\n + (weights.w * skin.jointMatrix[joints.w]);\n}\n\n",fs:"",defines:{SKIN_MAX_JOINTS:20},getUniforms:(e={},t)=>{const{scenegraphsFromGLTF:n}=e;if(!n?.gltf?.skins?.[0])return{jointMatrix:[]};const{inverseBindMatrices:i,joints:r,skeleton:s}=n.gltf.skins[0],o=[],a=i.value.length/16;for(let e=0;e<a;e++){const t=i.value.subarray(16*e,16*e+16);o.push(new Rn.k(Array.from(t)))}const l=n.gltfNodeIndexToNodeMap.get(s),c={};l.preorderTraversal((e,{worldMatrix:t})=>{c[e.id]=t});const A=new Float32Array(320);for(let e=0;e<20;++e){const t=r[e];if(void 0===t)break;const i=c[n.gltfNodeIndexToNodeMap.get(t).id],s=o[e],a=(new Rn.k).copy(i).multiplyRight(s),l=16*e;for(let e=0;e<16;e++)A[l+e]=a[e]}return{jointMatrix:A}},uniformTypes:{jointMatrix:["mat4x4<f32>",20]}};function iv(e,t){const n=t.materialFactory||new MaterialFactory(e,{modules:[W_]}),i={...t.parsedPPBRMaterial.uniforms};delete i.camera;const r=Object.fromEntries(Object.entries({...i,...t.parsedPPBRMaterial.bindings}).filter(([e,t])=>n.ownsBinding(e)&&function(e){return e instanceof Ri.h||e instanceof Z_.R||e instanceof $_.L||e instanceof Pi.g||e instanceof X_.X}(t))),s=n.createMaterial({id:t.id,bindings:r});return s.setProps({pbrMaterial:i}),s}function rv(e,t){const{id:n,geometry:i,parsedPPBRMaterial:r,vertexCount:s,modelOptions:o={}}=t;Hi.R.info(4,"createGLTFModel defines: ",r.defines)();const a={id:n,source:"\nstruct VertexInputs {\n @location(0) positions: vec3f,\n#ifdef HAS_NORMALS\n @location(1) normals: vec3f,\n#endif\n#ifdef HAS_TANGENTS\n @location(2) TANGENT: vec4f,\n#endif\n#ifdef HAS_UV\n @location(3) texCoords: vec2f,\n#endif\n#ifdef HAS_UV_1\n @location(4) texCoords1: vec2f,\n#endif\n#ifdef HAS_SKIN\n @location(5) JOINTS_0: vec4u,\n @location(6) WEIGHTS_0: vec4f,\n#endif\n};\n\nstruct FragmentInputs {\n @builtin(position) position: vec4f,\n @location(0) pbrPosition: vec3f,\n @location(1) pbrUV0: vec2f,\n @location(2) pbrUV1: vec2f,\n @location(3) pbrNormal: vec3f,\n#ifdef HAS_TANGENTS\n @location(4) pbrTangent: vec4f,\n#endif\n};\n\n@vertex\nfn vertexMain(inputs: VertexInputs) -> FragmentInputs {\n var outputs: FragmentInputs;\n var position = vec4f(inputs.positions, 1.0);\n var normal = vec3f(0.0, 0.0, 1.0);\n var tangent = vec4f(1.0, 0.0, 0.0, 1.0);\n var uv0 = vec2f(0.0, 0.0);\n var uv1 = vec2f(0.0, 0.0);\n\n#ifdef HAS_NORMALS\n normal = inputs.normals;\n#endif\n#ifdef HAS_UV\n uv0 = inputs.texCoords;\n#endif\n#ifdef HAS_UV_1\n uv1 = inputs.texCoords1;\n#endif\n#ifdef HAS_TANGENTS\n tangent = inputs.TANGENT;\n#endif\n#ifdef HAS_SKIN\n let skinMatrix = getSkinMatrix(inputs.WEIGHTS_0, inputs.JOINTS_0);\n position = skinMatrix * position;\n normal = normalize((skinMatrix * vec4f(normal, 0.0)).xyz);\n#ifdef HAS_TANGENTS\n tangent = vec4f(normalize((skinMatrix * vec4f(tangent.xyz, 0.0)).xyz), tangent.w);\n#endif\n#endif\n\n let worldPosition = pbrProjection.modelMatrix * position;\n\n#ifdef HAS_NORMALS\n normal = normalize((pbrProjection.normalMatrix * vec4f(normal, 0.0)).xyz);\n#endif\n#ifdef HAS_TANGENTS\n let worldTangent = normalize((pbrProjection.modelMatrix * vec4f(tangent.xyz, 0.0)).xyz);\n outputs.pbrTangent = vec4f(worldTangent, tangent.w);\n#endif\n\n outputs.position = pbrProjection.modelViewProjectionMatrix * position;\n outputs.pbrPosition = worldPosition.xyz / worldPosition.w;\n outputs.pbrUV0 = uv0;\n outputs.pbrUV1 = uv1;\n outputs.pbrNormal = normal;\n return outputs;\n}\n\n@fragment\nfn fragmentMain(inputs: FragmentInputs) -> @location(0) vec4f {\n fragmentInputs.pbr_vPosition = inputs.pbrPosition;\n fragmentInputs.pbr_vUV0 = inputs.pbrUV0;\n fragmentInputs.pbr_vUV1 = inputs.pbrUV1;\n fragmentInputs.pbr_vNormal = inputs.pbrNormal;\n#ifdef HAS_TANGENTS\n let tangent = normalize(inputs.pbrTangent.xyz);\n let bitangent = normalize(cross(inputs.pbrNormal, tangent)) * inputs.pbrTangent.w;\n fragmentInputs.pbr_vTBN = mat3x3f(tangent, bitangent, inputs.pbrNormal);\n#endif\n return pbr_filterColor(vec4f(1.0));\n}\n",vs:"#version 300 es\n\n // in vec4 POSITION;\n in vec4 positions;\n\n #ifdef HAS_NORMALS\n // in vec4 NORMAL;\n in vec4 normals;\n #endif\n\n #ifdef HAS_TANGENTS\n in vec4 TANGENT;\n #endif\n\n #ifdef HAS_UV\n // in vec2 TEXCOORD_0;\n in vec2 texCoords;\n #endif\n\n #ifdef HAS_UV_1\n in vec2 texCoords1;\n #endif\n\n #ifdef HAS_SKIN\n in uvec4 JOINTS_0;\n in vec4 WEIGHTS_0;\n #endif\n\n void main(void) {\n vec4 _NORMAL = vec4(0.);\n vec4 _TANGENT = vec4(0.);\n vec2 _TEXCOORD_0 = vec2(0.);\n vec2 _TEXCOORD_1 = vec2(0.);\n\n #ifdef HAS_NORMALS\n _NORMAL = normals;\n #endif\n\n #ifdef HAS_TANGENTS\n _TANGENT = TANGENT;\n #endif\n\n #ifdef HAS_UV\n _TEXCOORD_0 = texCoords;\n #endif\n\n #ifdef HAS_UV_1\n _TEXCOORD_1 = texCoords1;\n #endif\n\n vec4 pos = positions;\n\n #ifdef HAS_SKIN\n mat4 skinMat = getSkinMatrix(WEIGHTS_0, JOINTS_0);\n pos = skinMat * pos;\n _NORMAL = skinMat * _NORMAL;\n _TANGENT = vec4((skinMat * vec4(_TANGENT.xyz, 0.)).xyz, _TANGENT.w);\n #endif\n\n pbr_setPositionNormalTangentUV(pos, _NORMAL, _TANGENT, _TEXCOORD_0, _TEXCOORD_1);\n gl_Position = pbrProjection.modelViewProjectionMatrix * pos;\n }\n",fs:"#version 300 es\n out vec4 fragmentColor;\n\n void main(void) {\n vec3 pos = pbr_vPosition;\n fragmentColor = pbr_filterColor(vec4(1.0));\n }\n",geometry:i,topology:i.topology,vertexCount:s,modules:[W_,nv],...o,defines:{...r.defines,...o.defines},parameters:{depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back",...r.parameters,...o.parameters}},l=t.material||iv(e,{id:n?`${n}-material`:void 0,parsedPPBRMaterial:r});a.material=l;const c=new Sr.K(e,a),A={...r.uniforms,...o.uniforms,...r.bindings,...o.bindings},u=function(e,t,n){const i=new Map;for(const t of e){for(const e of Object.keys(t.uniformTypes||{}))i.set(e,t.name);for(const e of t.bindingLayout||[])i.set(e.name,t.name)}const r={};for(const[e,s]of Object.entries(n)){if(void 0===s)continue;const n=i.get(e);n&&!t.ownsModule(n)&&(r[n]||={},r[n][e]=s)}return r}(c.shaderInputs.getModules(),l,A);return c.shaderInputs.setProps(u),new ModelNode({managedResources:[],model:c})}var sv=n(42528);function ov(e){return{addressModeU:av(e.wrapS),addressModeV:av(e.wrapT),magFilter:lv(e.magFilter),...cv(e.minFilter)}}function av(e){switch(e){case tv.CLAMP_TO_EDGE:return"clamp-to-edge";case tv.REPEAT:return"repeat";case tv.MIRRORED_REPEAT:return"mirror-repeat";default:return}}function lv(e){switch(e){case tv.NEAREST:return"nearest";case tv.LINEAR:return"linear";default:return}}function cv(e){switch(e){case tv.NEAREST:return{minFilter:"nearest"};case tv.LINEAR:return{minFilter:"linear"};case tv.NEAREST_MIPMAP_NEAREST:return{minFilter:"nearest",mipmapFilter:"nearest"};case tv.LINEAR_MIPMAP_NEAREST:return{minFilter:"linear",mipmapFilter:"nearest"};case tv.NEAREST_MIPMAP_LINEAR:return{minFilter:"nearest",mipmapFilter:"linear"};case tv.LINEAR_MIPMAP_LINEAR:return{minFilter:"linear",mipmapFilter:"linear"};default:return{}}}const Av=[hv("baseColor","pbr_baseColorSampler","baseColorTexture",["pbrMetallicRoughness","baseColorTexture"]),hv("metallicRoughness","pbr_metallicRoughnessSampler","metallicRoughnessTexture",["pbrMetallicRoughness","metallicRoughnessTexture"]),hv("normal","pbr_normalSampler","normalTexture",["normalTexture"]),hv("occlusion","pbr_occlusionSampler","occlusionTexture",["occlusionTexture"]),hv("emissive","pbr_emissiveSampler","emissiveTexture",["emissiveTexture"]),hv("specularColor","pbr_specularColorSampler","KHR_materials_specular.specularColorTexture",["extensions","KHR_materials_specular","specularColorTexture"]),hv("specularIntensity","pbr_specularIntensitySampler","KHR_materials_specular.specularTexture",["extensions","KHR_materials_specular","specularTexture"]),hv("transmission","pbr_transmissionSampler","KHR_materials_transmission.transmissionTexture",["extensions","KHR_materials_transmission","transmissionTexture"]),hv("thickness","pbr_thicknessSampler","KHR_materials_volume.thicknessTexture",["extensions","KHR_materials_volume","thicknessTexture"]),hv("clearcoat","pbr_clearcoatSampler","KHR_materials_clearcoat.clearcoatTexture",["extensions","KHR_materials_clearcoat","clearcoatTexture"]),hv("clearcoatRoughness","pbr_clearcoatRoughnessSampler","KHR_materials_clearcoat.clearcoatRoughnessTexture",["extensions","KHR_materials_clearcoat","clearcoatRoughnessTexture"]),hv("clearcoatNormal","pbr_clearcoatNormalSampler","KHR_materials_clearcoat.clearcoatNormalTexture",["extensions","KHR_materials_clearcoat","clearcoatNormalTexture"]),hv("sheenColor","pbr_sheenColorSampler","KHR_materials_sheen.sheenColorTexture",["extensions","KHR_materials_sheen","sheenColorTexture"]),hv("sheenRoughness","pbr_sheenRoughnessSampler","KHR_materials_sheen.sheenRoughnessTexture",["extensions","KHR_materials_sheen","sheenRoughnessTexture"]),hv("iridescence","pbr_iridescenceSampler","KHR_materials_iridescence.iridescenceTexture",["extensions","KHR_materials_iridescence","iridescenceTexture"]),hv("iridescenceThickness","pbr_iridescenceThicknessSampler","KHR_materials_iridescence.iridescenceThicknessTexture",["extensions","KHR_materials_iridescence","iridescenceThicknessTexture"]),hv("anisotropy","pbr_anisotropySampler","KHR_materials_anisotropy.anisotropyTexture",["extensions","KHR_materials_anisotropy","anisotropyTexture"])],uv=new Map(Av.map(e=>[e.slot,e]));function hv(e,t,n,i){return{slot:e,binding:t,displayName:n,pathSegments:i,uvSetUniform:`${e}UVSet`,uvTransformUniform:`${e}UVTransform`}}function dv(e){const t=uv.get(e);if(!t)throw new Error(`Unknown PBR texture transform slot ${e}`);return t}function fv(e){const t=e?.extensions?.KHR_texture_transform;return{offset:t?.offset?[t.offset[0],t.offset[1]]:[0,0],rotation:t?.rotation??0,scale:t?.scale?[t.scale[0],t.scale[1]]:[1,1]}}function pv(e){const t=e?.extensions?.KHR_texture_transform;return t?.texCoord??e?.texCoord??0}function gv(e){const t=(new Matrix3).set(1,0,0,0,1,0,e.offset[0],e.offset[1],1),n=(new Matrix3).set(Math.cos(e.rotation),Math.sin(e.rotation),0,-Math.sin(e.rotation),Math.cos(e.rotation),0,0,0,1),i=(new Matrix3).set(e.scale[0],0,0,0,e.scale[1],0,0,0,1);return Array.from(t.multiplyRight(n).multiplyRight(i))}function mv(e,t){const n=new Matrix3(gv(e)),i=new Matrix3(gv(t)),r=new Matrix3(n).invert();return Array.from(i.multiplyRight(r))}function bv(e,t,n,i){const r={defines:{MANUAL_SRGB:!0,SRGB_FAST_APPROXIMATION:!0},bindings:{},uniforms:{camera:[0,0,0],metallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};r.defines.USE_TEX_LOD=!0;const{imageBasedLightingEnvironment:s}=i;return s&&(r.bindings.pbr_diffuseEnvSampler=s.diffuseEnvSampler.texture,r.bindings.pbr_specularEnvSampler=s.specularEnvSampler.texture,r.bindings.pbr_brdfLUT=s.brdfLutTexture.texture,r.uniforms.IBLenabled=!0,r.uniforms.scaleIBLAmbient=[1,1]),i?.pbrDebug&&(r.defines.PBR_DEBUG=!0,r.uniforms.scaleDiffBaseMR=[0,0,0,0],r.uniforms.scaleFGDSpec=[0,0,0,0]),n.NORMAL&&(r.defines.HAS_NORMALS=!0),n.TANGENT&&i?.useTangents&&(r.defines.HAS_TANGENTS=!0),n.TEXCOORD_0&&(r.defines.HAS_UV=!0),n.TEXCOORD_1&&(r.defines.HAS_UV_1=!0),n.JOINTS_0&&n.WEIGHTS_0&&(r.defines.HAS_SKIN=!0),n.COLOR_0&&(r.defines.HAS_COLORS=!0),i?.imageBasedLightingEnvironment&&(r.defines.USE_IBL=!0),i?.lights&&(r.defines.USE_LIGHTS=!0),t&&(!1!==i.validateAttributes&&function(e,t){const n=_v(e,0);n.length>0&&!t.TEXCOORD_0&&Hi.R.warn(`glTF material uses ${n.join(", ")} but primitive is missing TEXCOORD_0; textured shading will sample the default UV coordinates`)();const i=_v(e,1);i.length>0&&!t.TEXCOORD_1&&Hi.R.warn(`glTF material uses ${i.join(", ")} with TEXCOORD_1 but primitive is missing TEXCOORD_1; those textures will be skipped`)();const r=Boolean(e.unlit||e.extensions?.KHR_materials_unlit);if(r||t.NORMAL)return;const s=e.normalTexture?"lit PBR shading with normalTexture":"lit PBR shading";Hi.R.warn(`glTF primitive is missing NORMAL while using ${s}; shading will fall back to geometric normals`)()}(t,n),function(e,t,n,i,r){n.uniforms.unlit=Boolean(t.unlit||t.extensions?.KHR_materials_unlit),t.pbrMetallicRoughness&&function(e,t,n,i,r){t.baseColorTexture&&yv(e,t.baseColorTexture,"pbr_baseColorSampler",n,{featureOptions:{define:"HAS_BASECOLORMAP",enabledUniformName:"baseColorMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"baseColor"});n.uniforms.baseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&yv(e,t.metallicRoughnessTexture,"pbr_metallicRoughnessSampler",n,{featureOptions:{define:"HAS_METALROUGHNESSMAP",enabledUniformName:"metallicRoughnessMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"metallicRoughness"});const{metallicFactor:s=1,roughnessFactor:o=1}=t;n.uniforms.metallicRoughnessValues=[s,o]}(e,t.pbrMetallicRoughness,n,i,r);if(t.normalTexture){yv(e,t.normalTexture,"pbr_normalSampler",n,{featureOptions:{define:"HAS_NORMALMAP",enabledUniformName:"normalMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"normal"});const{scale:s=1}=t.normalTexture;n.uniforms.normalScale=s}if(t.occlusionTexture){yv(e,t.occlusionTexture,"pbr_occlusionSampler",n,{featureOptions:{define:"HAS_OCCLUSIONMAP",enabledUniformName:"occlusionMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"occlusion"});const{strength:s=1}=t.occlusionTexture;n.uniforms.occlusionStrength=s}n.uniforms.emissiveFactor=t.emissiveFactor||[0,0,0],t.emissiveTexture&&yv(e,t.emissiveTexture,"pbr_emissiveSampler",n,{featureOptions:{define:"HAS_EMISSIVEMAP",enabledUniformName:"emissiveMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"emissive"});switch(function(e,t,n,i,r={}){if(!t)return;(function(e){return Boolean(e.KHR_materials_specular||e.KHR_materials_ior||e.KHR_materials_transmission||e.KHR_materials_volume||e.KHR_materials_clearcoat||e.KHR_materials_sheen||e.KHR_materials_iridescence||e.KHR_materials_anisotropy)})(t)&&(n.defines.USE_MATERIAL_EXTENSIONS=!0);(function(e,t,n,i,r={}){if(!t)return;t.specularColorFactor&&(n.uniforms.specularColorFactor=t.specularColorFactor);void 0!==t.specularFactor&&(n.uniforms.specularIntensityFactor=t.specularFactor);t.specularColorTexture&&yv(e,t.specularColorTexture,"pbr_specularColorSampler",n,{featureOptions:{define:"HAS_SPECULARCOLORMAP",enabledUniformName:"specularColorMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"specularColor"});t.specularTexture&&yv(e,t.specularTexture,"pbr_specularIntensitySampler",n,{featureOptions:{define:"HAS_SPECULARINTENSITYMAP",enabledUniformName:"specularIntensityMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"specularIntensity"})})(e,t.KHR_materials_specular,n,i,r),function(e,t){void 0!==e?.ior&&(t.uniforms.ior=e.ior)}(t.KHR_materials_ior,n),function(e,t,n,i,r={}){if(!t)return;void 0!==t.transmissionFactor&&(n.uniforms.transmissionFactor=t.transmissionFactor);t.transmissionTexture&&yv(e,t.transmissionTexture,"pbr_transmissionSampler",n,{featureOptions:{define:"HAS_TRANSMISSIONMAP",enabledUniformName:"transmissionMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"transmission"});((t.transmissionFactor??0)>0||t.transmissionTexture)&&(Hi.R.warn("KHR_materials_transmission uses a premultiplied-alpha blending approximation and may require mesh sorting")(),function(e){e.parameters.blend=!0,e.parameters.depthWriteEnabled=!1,e.parameters.blendColorOperation="add",e.parameters.blendColorSrcFactor="one",e.parameters.blendColorDstFactor="one-minus-src-alpha",e.parameters.blendAlphaOperation="add",e.parameters.blendAlphaSrcFactor="one",e.parameters.blendAlphaDstFactor="one-minus-src-alpha",e.glParameters.blend=!0,e.glParameters.depthMask=!1,e.glParameters.blendEquation=tv.FUNC_ADD,e.glParameters.blendFunc=[tv.ONE,tv.ONE_MINUS_SRC_ALPHA,tv.ONE,tv.ONE_MINUS_SRC_ALPHA]}(n))}(e,t.KHR_materials_transmission,n,i,r),function(e,t,n,i,r={}){if(!t)return;void 0!==t.thicknessFactor&&(n.uniforms.thicknessFactor=t.thicknessFactor);t.thicknessTexture&&yv(e,t.thicknessTexture,"pbr_thicknessSampler",n,{featureOptions:{define:"HAS_THICKNESSMAP"},gltf:i,attributes:r,textureTransformSlot:"thickness"});void 0!==t.attenuationDistance&&(n.uniforms.attenuationDistance=t.attenuationDistance);t.attenuationColor&&(n.uniforms.attenuationColor=t.attenuationColor)}(e,t.KHR_materials_volume,n,i,r),function(e,t,n,i,r={}){if(!t)return;void 0!==t.clearcoatFactor&&(n.uniforms.clearcoatFactor=t.clearcoatFactor);void 0!==t.clearcoatRoughnessFactor&&(n.uniforms.clearcoatRoughnessFactor=t.clearcoatRoughnessFactor);t.clearcoatTexture&&yv(e,t.clearcoatTexture,"pbr_clearcoatSampler",n,{featureOptions:{define:"HAS_CLEARCOATMAP",enabledUniformName:"clearcoatMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"clearcoat"});t.clearcoatRoughnessTexture&&yv(e,t.clearcoatRoughnessTexture,"pbr_clearcoatRoughnessSampler",n,{featureOptions:{define:"HAS_CLEARCOATROUGHNESSMAP",enabledUniformName:"clearcoatRoughnessMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"clearcoatRoughness"});t.clearcoatNormalTexture&&yv(e,t.clearcoatNormalTexture,"pbr_clearcoatNormalSampler",n,{featureOptions:{define:"HAS_CLEARCOATNORMALMAP"},gltf:i,attributes:r,textureTransformSlot:"clearcoatNormal"})}(e,t.KHR_materials_clearcoat,n,i,r),function(e,t,n,i,r={}){if(!t)return;t.sheenColorFactor&&(n.uniforms.sheenColorFactor=t.sheenColorFactor);void 0!==t.sheenRoughnessFactor&&(n.uniforms.sheenRoughnessFactor=t.sheenRoughnessFactor);t.sheenColorTexture&&yv(e,t.sheenColorTexture,"pbr_sheenColorSampler",n,{featureOptions:{define:"HAS_SHEENCOLORMAP",enabledUniformName:"sheenColorMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"sheenColor"});t.sheenRoughnessTexture&&yv(e,t.sheenRoughnessTexture,"pbr_sheenRoughnessSampler",n,{featureOptions:{define:"HAS_SHEENROUGHNESSMAP",enabledUniformName:"sheenRoughnessMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"sheenRoughness"})}(e,t.KHR_materials_sheen,n,i,r),function(e,t,n,i,r={}){if(!t)return;void 0!==t.iridescenceFactor&&(n.uniforms.iridescenceFactor=t.iridescenceFactor);void 0!==t.iridescenceIor&&(n.uniforms.iridescenceIor=t.iridescenceIor);void 0===t.iridescenceThicknessMinimum&&void 0===t.iridescenceThicknessMaximum||(n.uniforms.iridescenceThicknessRange=[t.iridescenceThicknessMinimum??100,t.iridescenceThicknessMaximum??400]);t.iridescenceTexture&&yv(e,t.iridescenceTexture,"pbr_iridescenceSampler",n,{featureOptions:{define:"HAS_IRIDESCENCEMAP",enabledUniformName:"iridescenceMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"iridescence"});t.iridescenceThicknessTexture&&yv(e,t.iridescenceThicknessTexture,"pbr_iridescenceThicknessSampler",n,{featureOptions:{define:"HAS_IRIDESCENCETHICKNESSMAP"},gltf:i,attributes:r,textureTransformSlot:"iridescenceThickness"})}(e,t.KHR_materials_iridescence,n,i,r),function(e,t,n,i,r={}){if(!t)return;void 0!==t.anisotropyStrength&&(n.uniforms.anisotropyStrength=t.anisotropyStrength);void 0!==t.anisotropyRotation&&(n.uniforms.anisotropyRotation=t.anisotropyRotation);t.anisotropyTexture&&yv(e,t.anisotropyTexture,"pbr_anisotropySampler",n,{featureOptions:{define:"HAS_ANISOTROPYMAP",enabledUniformName:"anisotropyMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"anisotropy"})}(e,t.KHR_materials_anisotropy,n,i,r),function(e,t){void 0!==e?.emissiveStrength&&(t.uniforms.emissiveStrength=e.emissiveStrength)}(t.KHR_materials_emissive_strength,n)}(e,t.extensions,n,r,i),t.alphaMode||"OPAQUE"){case"OPAQUE":break;case"MASK":{const{alphaCutoff:e=.5}=t;n.defines.ALPHA_CUTOFF=!0,n.uniforms.alphaCutoffEnabled=!0,n.uniforms.alphaCutoff=e;break}case"BLEND":Hi.R.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),function(e){e.parameters.blend=!0,e.parameters.blendColorOperation="add",e.parameters.blendColorSrcFactor="src-alpha",e.parameters.blendColorDstFactor="one-minus-src-alpha",e.parameters.blendAlphaOperation="add",e.parameters.blendAlphaSrcFactor="one",e.parameters.blendAlphaDstFactor="one-minus-src-alpha",e.glParameters.blend=!0,e.glParameters.blendEquation=tv.FUNC_ADD,e.glParameters.blendFunc=[tv.SRC_ALPHA,tv.ONE_MINUS_SRC_ALPHA,tv.ONE,tv.ONE_MINUS_SRC_ALPHA]}(n)}}(e,t,r,n,i.gltf)),r}function _v(e,t){const n=[];for(const i of Av){const r=vv(e,i.pathSegments);r&&(pv(r)===t&&n.push(i.displayName))}return n}function vv(e,t){let n=e;for(const e of t)if(n=n?.[e],!n)return null;return n}function yv(e,t,n,i,r={}){const{featureOptions:s={},gltf:o,attributes:a={},textureTransformSlot:l}=r,{define:c,enabledUniformName:A}=s,u=pv(t);if(u>1)return void Hi.R.warn(`Skipping ${String(n)} because ${u} is not supported; only TEXCOORD_0 and TEXCOORD_1 are currently available`)();if(1===u&&!a.TEXCOORD_1)return void Hi.R.warn(`Skipping ${String(n)} because it requires TEXCOORD_1 but the primitive does not provide TEXCOORD_1`)();const h=function(e,t){if(e.texture||void 0===e.index||!t?.textures)return e;const n=t.textures[e.index];if(!n)return e;if("texture"in n&&n.texture)return{...n,...e,texture:n.texture};if(!("source"in n))return e;return{...e,texture:n}}(t,o),d=h.texture?.source?.image;if(!d)return void Hi.R.warn(`Skipping unresolved glTF texture for ${String(n)}`)();const f={wrapS:10497,wrapT:10497,minFilter:9729,magFilter:9729,...h?.texture?.sampler},p={id:h.uniformName||h.id,sampler:ov(f)};let g;if(d.compressed)g=function(e,t,n){let i;i=Array.isArray(t.data)&&t.data[0]?.data?t.data:"mipmaps"in t&&Array.isArray(t.mipmaps)?t.mipmaps:[];if(0===i.length||!i[0]?.data)return Hi.R.warn("createCompressedTexture: compressed image has no valid mip levels, creating fallback")(),wv(e,n);const r=i[0],s=r.width??t.width??0,o=r.height??t.height??0;if(s<=0||o<=0)return Hi.R.warn("createCompressedTexture: base level has invalid dimensions, creating fallback")(),wv(e,n);const a=xv(r);if(!a)return Hi.R.warn("createCompressedTexture: compressed image has no textureFormat, creating fallback")(),wv(e,n);const l=function(e,t,n){const{blockWidth:i=1,blockHeight:r=1}=sv.vz.getInfo(n);let s=1;for(let n=1;;n++){const o=Math.max(1,e>>n),a=Math.max(1,t>>n);if(o<i||a<r)break;s++}return s}(s,o,a),c=Math.min(i.length,l);let A=1;for(let e=1;e<c;e++){const t=i[e];if(!t.data||t.width<=0||t.height<=0){Hi.R.warn(`createCompressedTexture: mip level ${e} has invalid data/dimensions, truncating`)();break}const n=xv(t);if(n&&n!==a){Hi.R.warn(`createCompressedTexture: mip level ${e} format '${n}' differs from base '${a}', truncating`)();break}const r=Math.max(1,s>>e),l=Math.max(1,o>>e);if(t.width!==r||t.height!==l){Hi.R.warn(`createCompressedTexture: mip level ${e} dimensions ${t.width}x${t.height} don't match expected ${r}x${l}, truncating`)();break}A++}const u=e.createTexture({...n,format:a,usage:Pi.g.TEXTURE|Pi.g.COPY_DST,width:s,height:o,mipLevels:A,data:r.data});for(let e=1;e<A;e++)u.writeData(i[e].data,{width:i[e].width,height:i[e].height,mipLevel:e});return u}(e,d,p);else{const{width:t,height:n}=e.getExternalImageSize(d);g=e.createTexture({...p,width:t,height:n,data:d})}if(i.bindings[n]=g,c&&(i.defines[c]=!0),A&&(i.uniforms[A]=!0),l){const e=dv(l);i.uniforms[e.uvSetUniform]=u,i.uniforms[e.uvTransformUniform]=gv(fv(t))}i.generatedTextures.push(g)}function wv(e,t){return e.createTexture({...t,format:"rgba8unorm",width:1,height:1,mipLevels:1})}function xv(e){return e.textureFormat}const Tv={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:void 0,lights:!0,useTangents:!1,useByteColors:!0};function Ev(e,t,n={}){const i={...Tv,...n},r=new MaterialFactory(e,{modules:[W_]}),s=(t.materials||[]).map((n,s)=>iv(e,{id:Sv(n,s),parsedPPBRMaterial:bv(e,n,{},{...i,gltf:t,validateAttributes:!1}),materialFactory:r})),o=new Map;(t.materials||[]).forEach((e,t)=>{o.set(e.id,s[t])});const a=new Map;t.meshes.forEach((n,r)=>{const s=function(e,t,n,i,r){const s=t.primitives||[],o=s.map((s,o)=>function({device:e,gltfPrimitive:t,primitiveIndex:n,gltfMesh:i,gltf:r,gltfMaterialIdToMaterialMap:s,options:o}){const a=t.name||`${i.name||i.id}-primitive-${n}`,l=function(e){switch(e){case tv.POINTS:return"point-list";case tv.LINES:return"line-list";case tv.LINE_STRIP:return"line-strip";case tv.TRIANGLES:return"triangle-list";case tv.TRIANGLE_STRIP:return"triangle-strip";default:throw new Error(String(e))}}(t.mode??4),c=t.indices?t.indices.count:function(e){let t=1/0;for(const n of Object.values(e))if(n){const{value:e,size:i,components:r}=n,s=i??r;void 0!==e?.length&&s>=1&&(t=Math.min(t,e.length/s))}if(!Number.isFinite(t))throw new Error("Could not determine vertex count from attributes");return t}(t.attributes),A=function(e,t,n){const i={};for(const[e,n]of Object.entries(t.attributes)){const{components:t,size:r,value:s,normalized:o}=n;i[e]={size:r??t,value:s,normalized:o}}return new Geometry({id:e,topology:n,indices:t.indices?.value,attributes:i})}(a,t,l),u=bv(e,t.material,A.attributes,{...o,gltf:r}),h=rv(e,{id:a,geometry:A,material:t.material&&s.get(t.material.id)||null,parsedPPBRMaterial:u,modelOptions:o.modelOptions,vertexCount:c});return h.bounds=[t.attributes.POSITION.min,t.attributes.POSITION.max],h}({device:e,gltfPrimitive:s,primitiveIndex:o,gltfMesh:t,gltf:n,gltfMaterialIdToMaterialMap:i,options:r})),a=new GroupNode({id:t.name||t.id,children:o});return a}(e,n,t,o,i);a.set(n.id,s)});const l=new Map,c=new Map;t.nodes.forEach((e,t)=>{const n=function(e,t){return new GroupNode({id:t.name||t.id,children:[],matrix:t.matrix,position:t.translation,rotation:t.rotation,scale:t.scale})}(0,e);l.set(t,n),c.set(e.id,n)}),t.nodes.forEach((e,t)=>{if(l.get(t).add((e.children??[]).map(({id:e})=>{const n=c.get(e);if(!n)throw new Error(`Cannot find child ${e} of node ${t}`);return n})),e.mesh){const n=a.get(e.mesh.id);if(!n)throw new Error(`Cannot find mesh child ${e.mesh.id} of node ${t}`);l.get(t).add(n)}});return{scenes:t.scenes.map(e=>{const t=(e.nodes||[]).map(({id:t})=>{const n=c.get(t);if(!n)throw new Error(`Cannot find child ${t} of scene ${e.name||e.id}`);return n});return new GroupNode({id:e.name||e.id,children:t})}),materials:s,gltfMeshIdToNodeMap:a,gltfNodeIdToNodeMap:c,gltfNodeIndexToNodeMap:l}}function Sv(e,t){return e.name||e.id||`material-${t}`}function Cv(e,t={}){const n=e.lights||e.extensions?.KHR_lights_punctual?.lights;if(!n||!Array.isArray(n)||0===n.length)return[];const i=[],r=function(e){const t=new Map;for(const n of e)for(const e of n.children||[])t.set(e.id,n);return t}(e.nodes||[]),s=new Map;for(const o of e.nodes||[]){const e=o.light??o.extensions?.KHR_lights_punctual?.light;if("number"!=typeof e)continue;const a=n[e];if(!a)continue;const l=Pv(a.color||[1,1,1],t.useByteColors??!0),c=a.intensity??1,A=a.range,u=Iv(o,r,s);switch(a.type){case"directional":i.push(Mv(u,l,c));break;case"point":i.push(Rv(u,l,c,A));break;case"spot":i.push(Lv(u,l,c,A,a.spot))}}return i}function Pv(e,t){return t?e.map(e=>255*e):qs(e,!1)}function Rv(e,t,n,i){let r=[1,0,0];return void 0!==i&&i>0&&(r=[1,0,1/(i*i)]),{type:"point",position:Ov(e),color:t,intensity:n,attenuation:r}}function Mv(e,t,n){return{type:"directional",direction:Bv(e),color:t,intensity:n}}function Lv(e,t,n,i,r={}){let s=[1,0,0];return void 0!==i&&i>0&&(s=[1,0,1/(i*i)]),{type:"spot",position:Ov(e),direction:Bv(e),color:t,intensity:n,attenuation:s,innerConeAngle:r.innerConeAngle??0,outerConeAngle:r.outerConeAngle??Math.PI/4}}function Iv(e,t,n){const i=n.get(e.id);if(i)return i;const r=function(e){if(e.matrix)return new Rn.k(e.matrix);const t=new Rn.k;e.translation&&t.translate(e.translation);e.rotation&&t.multiplyRight((new Rn.k).fromQuaternion(e.rotation));e.scale&&t.scale(e.scale);return t}(e),s=t.get(e.id),o=s?new Rn.k(Iv(s,t,n)).multiplyRight(r):r;return n.set(e.id,o),o}function Ov(e){return e.transformAsPoint([0,0,0])}function Bv(e){return e.transformDirection([0,0,-1])}function Nv(e,{input:t,interpolation:n,output:i},r,s){const o=kv(e,{input:t,interpolation:n,output:i},s);o&&function(e,t,n){switch(t){case"translation":return e.setPosition(n).updateMatrix();case"rotation":return e.setRotation(n).updateMatrix();case"scale":return e.setScale(n).updateMatrix();default:Hi.R.warn(`Bad animation path ${t}`)()}}(r,s,o)}function kv(e,{input:t,interpolation:n,output:i},r){const s=t[t.length-1];if(!Number.isFinite(s)||s<=0)return i[0]||null;const o=e%s,a=t.findIndex(e=>e>=o);if(a<0)return i[i.length-1]||null;const l=Math.max(0,a-1),c=t[l],A=t[a];switch(n){case"STEP":return i[l];case"LINEAR":if(A>c){const e=(o-c)/(A-c);return function(e,t,n,i){if("rotation"===e)return(new Quaternion).slerp({start:t,target:n,ratio:i});const r=[];for(let e=0;e<t.length;e++)r[e]=i*n[e]+(1-i)*t[e];return r}(r,i[l],i[a],e)}return i[l]||null;case"CUBICSPLINE":if(A>c){const e=(o-c)/(A-c),t=A-c;return function({p0:e,outTangent0:t,inTangent1:n,p1:i,tDiff:r,ratio:s}){const o=[];for(let a=0;a<e.length;a++){const l=t[a]*r,c=n[a]*r;o[a]=(2*Math.pow(s,3)-3*Math.pow(s,2)+1)*e[a]+(Math.pow(s,3)-2*Math.pow(s,2)+s)*l+(-2*Math.pow(s,3)+3*Math.pow(s,2))*i[a]+(Math.pow(s,3)-Math.pow(s,2))*c}return o}({p0:i[3*l+1],outTangent0:i[3*l+2],inTangent1:i[3*a+0],p1:i[3*a+1],tDiff:t,ratio:e})}return i[3*l+1]||null;default:return Hi.R.warn(`Interpolation ${n} not supported`)(),null}}class GLTFSingleAnimator{animation;gltfNodeIdToNodeMap;materials;startTime=0;playing=!0;speed=1;materialTextureTransformState=new Map;constructor(e){if(this.animation=e.animation,this.gltfNodeIdToNodeMap=e.gltfNodeIdToNodeMap,this.materials=e.materials||[],this.animation.name||="unnamed",Object.assign(this,e),this.animation.channels.some(e=>"node"!==e.type)&&!this.materials.length)throw new Error(`Animation ${this.animation.name} targets materials, but GLTFAnimator was created without a materials array`)}setTime(e){if(!this.playing)return;const t=(e/1e3-this.startTime)*this.speed;this.animation.channels.forEach(e=>{if("node"===e.type){const{sampler:n,targetNodeId:i,path:r}=e,s=this.gltfNodeIdToNodeMap.get(i);if(!s)throw new Error(`Cannot find animation target node ${i}`);return void Nv(t,n,s,r)}const n=this.materials[e.targetMaterialIndex];if(!n)throw new Error(`Cannot find animation target material ${e.targetMaterialIndex} for ${e.pointer}`);const i=kv(t,e.sampler);i&&("material"===e.type?function(e,t,n){const i=void 0!==t.component?{[t.property]:Dv(Fv(e,t.property),t.component,n[0])}:{[t.property]:1===n.length?n[0]:n};e.setProps({pbrMaterial:i})}(n,e,i):function(e,t,n,i){const r=dv(t.textureSlot),s=function(e,t,n){const i=e.get(t)||{};let r=i[n.textureSlot];r||(r={offset:[...n.baseTransform.offset],rotation:n.baseTransform.rotation,scale:[...n.baseTransform.scale]},i[n.textureSlot]=r,e.set(t,i));return r}(i,e,t);switch(t.path){case"offset":void 0!==t.component?s.offset[t.component]=n[0]:s.offset=[n[0],n[1]];break;case"rotation":s.rotation=n[0];break;case"scale":void 0!==t.component?s.scale[t.component]=n[0]:s.scale=[n[0],n[1]]}e.setProps({pbrMaterial:{[r.uvTransformUniform]:mv(t.baseTransform,s)}})}(n,e,i,this.materialTextureTransformState))})}}class GLTFAnimator{animations;constructor(e){this.animations=e.animations.map((t,n)=>{const i=t.name||`Animation-${n}`;return new GLTFSingleAnimator({gltfNodeIdToNodeMap:e.gltfNodeIdToNodeMap,materials:e.materials,animation:{name:i,channels:t.channels}})})}animate(e){Hi.R.warn("GLTFAnimator#animate is deprecated. Use GLTFAnimator#setTime instead")(),this.setTime(e)}setTime(e){this.animations.forEach(t=>t.setTime(e))}getAnimations(){return this.animations}}function Fv(e,t){const n=e.shaderInputs.getUniformValues(),i=n.pbrMaterial?.[t];return Array.isArray(i)?[...i]:[]}function Dv(e,t,n){const i=[...e];return i[t]=n,i}const Uv={supportLevel:"none",comment:"Not currently listed in the luma.gl glTF extension support registry."},Vv={KHR_draco_mesh_compression:{supportLevel:"built-in",comment:"Decoded by loaders.gl before luma.gl builds the scenegraph."},EXT_meshopt_compression:{supportLevel:"built-in",comment:"Meshopt-compressed primitives are decoded during load."},KHR_mesh_quantization:{supportLevel:"built-in",comment:"Quantized accessors are unpacked before geometry creation."},KHR_lights_punctual:{supportLevel:"built-in",comment:"Parsed into luma.gl Light objects."},KHR_materials_unlit:{supportLevel:"built-in",comment:"Unlit materials bypass the default lighting path."},KHR_materials_emissive_strength:{supportLevel:"built-in",comment:"Applied by the stock PBR shader."},KHR_texture_basisu:{supportLevel:"built-in",comment:"BasisU / KTX2 textures pass through when the device supports them."},KHR_texture_transform:{supportLevel:"built-in",comment:"UV transforms are applied during load."},EXT_texture_webp:{supportLevel:"loader-only",comment:"Texture source is resolved during load; final support depends on browser and device decode support."},EXT_texture_avif:{supportLevel:"loader-only",comment:"Texture source is resolved during load; final support depends on browser and device decode support."},KHR_materials_specular:{supportLevel:"built-in",comment:"The stock shader now applies specular factors and textures to the dielectric F0 term."},KHR_materials_ior:{supportLevel:"built-in",comment:"The stock shader now drives dielectric reflectance from the glTF IOR value."},KHR_materials_transmission:{supportLevel:"built-in",comment:"The stock shader now applies transmission to the base layer and exposes transparency through alpha, without a scene-color refraction buffer."},KHR_materials_volume:{supportLevel:"built-in",comment:"Thickness and attenuation now tint transmitted light in the stock shader."},KHR_materials_clearcoat:{supportLevel:"built-in",comment:"The stock shader now adds a secondary clearcoat specular lobe."},KHR_materials_sheen:{supportLevel:"built-in",comment:"The stock shader now adds a sheen lobe for cloth-like materials."},KHR_materials_iridescence:{supportLevel:"built-in",comment:"The stock shader now tints specular response with a view-dependent thin-film iridescence approximation."},KHR_materials_anisotropy:{supportLevel:"built-in",comment:"The stock shader now shapes highlights and IBL response with an anisotropy-direction approximation."},KHR_materials_pbrSpecularGlossiness:{supportLevel:"loader-only",comment:"Extension data can be loaded, but it is not translated into the default metallic-roughness material path."},KHR_materials_variants:{supportLevel:"loader-only",comment:"Variant metadata can be loaded, but applications must choose and apply variants."},EXT_mesh_gpu_instancing:{supportLevel:"none",comment:"GPU instancing data is not yet converted into luma.gl instanced draw setup."},KHR_node_visibility:{supportLevel:"none",comment:"Node-visibility animations and toggles are not mapped onto runtime scenegraph state."},KHR_animation_pointer:{supportLevel:"parsed-and-wired",comment:"Selected node TRS, material factor, and KHR_texture_transform offset/rotation/scale pointers are wired to runtime updates; unsupported targets are skipped."},KHR_materials_diffuse_transmission:{supportLevel:"none",comment:"Diffuse-transmission shading is not implemented in the stock PBR shader."},KHR_materials_dispersion:{supportLevel:"none",comment:"Chromatic dispersion is not implemented in the stock PBR shader."},KHR_materials_volume_scatter:{supportLevel:"none",comment:"Volume scattering is not implemented in the stock PBR shader."},KHR_xmp:{supportLevel:"none",comment:"Metadata payloads remain in the loaded glTF, but luma.gl does not interpret them."},KHR_xmp_json_ld:{supportLevel:"none",comment:"Metadata is preserved in the glTF, but luma.gl does not interpret it."},EXT_lights_image_based:{supportLevel:"none",comment:"Use loadPBREnvironment() or custom environment setup instead."},EXT_texture_video:{supportLevel:"none",comment:"Video textures are not created automatically by the stock pipeline."},MSFT_lod:{supportLevel:"none",comment:"Level-of-detail switching is not implemented in the stock scenegraph loader."}};function zv(e){const t=Array.from(function(e){const t=e,n=new Set;jv(n,e.extensionsUsed),jv(n,e.extensionsRequired),jv(n,t.extensionsRemoved),jv(n,Object.keys(e.extensions||{})),(t.lights?.length||(e.nodes||[]).some(e=>"light"in e))&&n.add("KHR_lights_punctual");(e.materials||[]).some(e=>{const t=e;return t.unlit||t.extensions?.KHR_materials_unlit})&&n.add("KHR_materials_unlit");return n}(e)).sort(),n=t.map(e=>{const t=Vv[e]||Uv;return[e,{extensionName:e,supported:"built-in"===t.supportLevel||"parsed-and-wired"===t.supportLevel,supportLevel:t.supportLevel,comment:t.comment}]});return new Map(n)}function Gv(e){return Vv[e]||null}function jv(e,t=[]){for(const n of t)e.add(n)}const Hv={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Wv={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function qv(e){const t=Wv[e.componentType],n=Hv[e.type],i=n*e.count,{buffer:r,byteOffset:s=0}=e.bufferView?.data??{};return{typedArray:new t(r,s+(e.byteOffset||0),i),components:n}}function Kv(e){const t=e.animations||[],n=new Map,i=new Map;return t.flatMap((t,r)=>{const s=t.name||`Animation-${r}`,o=new Map,a=t.channels.flatMap(({sampler:r,target:s})=>{let a=o.get(r);if(!a){const s=t.samplers[r];if(!s)throw new Error(`Cannot find animation sampler ${r}`);const{input:l,interpolation:c="LINEAR",output:A}=s;a={input:Jv(e.accessors[l],n),interpolation:c,output:ey(e.accessors[A],i)},o.set(r,a)}const l=function(e,t,n){if("pointer"===t.path)return function(e,t,n){const i=t.extensions?.KHR_animation_pointer?.pointer;if("string"!=typeof i||!i.startsWith("/"))return Hi.R.warn("KHR_animation_pointer channel is missing a valid JSON pointer and will be skipped")(),null;const r=function(e){return e.slice(1).split("/").map(e=>e.replace(/~1/g,"/").replace(/~0/g,"~"))}(i);switch(r[0]){case"nodes":return function(e,t,n,i){if(3!==t.length)return Yv(i,"node pointers must use /nodes/{index}/{translation|rotation|scale|weights}"),null;const r=Number(t[1]),s=e.nodes[r];if(!Number.isInteger(r)||!s)return Hi.R.warn(`KHR_animation_pointer target ${i} references a missing node and will be skipped`)(),null;const o=Qv(t[2]);if(!o)return Yv(i,`node property "${t[2]}" has no runtime animation mapping`),null;if("weights"===o)return Hi.R.warn(`KHR_animation_pointer target ${i} will be skipped because morph weights are not implemented in GLTFAnimator`)(),null;return{type:"node",sampler:n,targetNodeId:s.id,path:o}}(e,r,n,i);case"materials":return function(e,t,n,i){if(t.length<3)return Yv(i,"material pointers must include a material index and target property path"),null;const r=Number(t[1]),s=e.materials[r];if(!Number.isInteger(r)||!s)return Hi.R.warn(`KHR_animation_pointer target ${i} references a missing material and will be skipped`)(),null;const o=function(e,t){const n=function(e,t){const n=t.lastIndexOf("extensions");if(n<0||"KHR_texture_transform"!==t[n+1]||n<1)return{reason:"not-a-texture-transform-target"};const i=function(e){return Av.find(t=>t.pathSegments.length===e.length&&t.pathSegments.every((t,n)=>e[n]===t))||null}(t.slice(0,n));if(!i)return{reason:$v(t.slice(0,n))};const r=function(e,t){let n=e;for(const e of t)if(n=n?.[e],!n)return null;return n}(e,i.pathSegments);if(!r)return{reason:`texture-transform target "${t.slice(0,n).join("/")}" does not exist on the referenced material`};const s=t[n+2];if("texCoord"===s)return{reason:"animated KHR_texture_transform.texCoord is unsupported because texCoord selection is structural, not a runtime float/vector update"};if("offset"!==s&&"rotation"!==s&&"scale"!==s)return{reason:`KHR_texture_transform property "${s}" is not animatable; supported properties are offset, rotation, and scale`};const o=t[n+3];if(t.length>n+4)return{reason:`KHR_texture_transform.${s} does not support nested property paths`};let a;if(void 0!==o){if(a=Number(o),"rotation"===s)return{reason:"KHR_texture_transform.rotation does not support component indices"};if(!Number.isInteger(a)||a<0||a>1)return{reason:`KHR_texture_transform.${s} component index "${o}" is invalid; only 0 and 1 are supported`}}return{type:"textureTransform",textureSlot:i.slot,path:s,component:a,baseTransform:fv(r)}}(e,t);if(!("reason"in n))return n;if("not-a-texture-transform-target"!==n.reason)return n;switch(t.join("/")){case"pbrMetallicRoughness/baseColorFactor":return e.pbrMetallicRoughness?{type:"material",property:"baseColorFactor"}:{reason:Xv(t)};case"pbrMetallicRoughness/metallicFactor":return e.pbrMetallicRoughness?{type:"material",property:"metallicRoughnessValues",component:0}:{reason:Xv(t)};case"pbrMetallicRoughness/roughnessFactor":return e.pbrMetallicRoughness?{type:"material",property:"metallicRoughnessValues",component:1}:{reason:Xv(t)};case"normalTexture/scale":return e.normalTexture?{type:"material",property:"normalScale"}:{reason:Xv(t)};case"occlusionTexture/strength":return e.occlusionTexture?{type:"material",property:"occlusionStrength"}:{reason:Xv(t)};case"emissiveFactor":return{type:"material",property:"emissiveFactor"};case"alphaCutoff":return{type:"material",property:"alphaCutoff"};case"extensions/KHR_materials_specular/specularFactor":return e.extensions?.KHR_materials_specular?{type:"material",property:"specularIntensityFactor"}:{reason:Xv(t)};case"extensions/KHR_materials_specular/specularColorFactor":return e.extensions?.KHR_materials_specular?{type:"material",property:"specularColorFactor"}:{reason:Xv(t)};case"extensions/KHR_materials_ior/ior":return e.extensions?.KHR_materials_ior?{type:"material",property:"ior"}:{reason:Xv(t)};case"extensions/KHR_materials_transmission/transmissionFactor":return e.extensions?.KHR_materials_transmission?{type:"material",property:"transmissionFactor"}:{reason:Xv(t)};case"extensions/KHR_materials_volume/thicknessFactor":return e.extensions?.KHR_materials_volume?{type:"material",property:"thicknessFactor"}:{reason:Xv(t)};case"extensions/KHR_materials_volume/attenuationDistance":return e.extensions?.KHR_materials_volume?{type:"material",property:"attenuationDistance"}:{reason:Xv(t)};case"extensions/KHR_materials_volume/attenuationColor":return e.extensions?.KHR_materials_volume?{type:"material",property:"attenuationColor"}:{reason:Xv(t)};case"extensions/KHR_materials_clearcoat/clearcoatFactor":return e.extensions?.KHR_materials_clearcoat?{type:"material",property:"clearcoatFactor"}:{reason:Xv(t)};case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":return e.extensions?.KHR_materials_clearcoat?{type:"material",property:"clearcoatRoughnessFactor"}:{reason:Xv(t)};case"extensions/KHR_materials_sheen/sheenColorFactor":return e.extensions?.KHR_materials_sheen?{type:"material",property:"sheenColorFactor"}:{reason:Xv(t)};case"extensions/KHR_materials_sheen/sheenRoughnessFactor":return e.extensions?.KHR_materials_sheen?{type:"material",property:"sheenRoughnessFactor"}:{reason:Xv(t)};case"extensions/KHR_materials_iridescence/iridescenceFactor":return e.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceFactor"}:{reason:Xv(t)};case"extensions/KHR_materials_iridescence/iridescenceIor":return e.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceIor"}:{reason:Xv(t)};case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":return e.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceThicknessRange",component:0}:{reason:Xv(t)};case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":return e.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceThicknessRange",component:1}:{reason:Xv(t)};case"extensions/KHR_materials_anisotropy/anisotropyStrength":return e.extensions?.KHR_materials_anisotropy?{type:"material",property:"anisotropyStrength"}:{reason:Xv(t)};case"extensions/KHR_materials_anisotropy/anisotropyRotation":return e.extensions?.KHR_materials_anisotropy?{type:"material",property:"anisotropyRotation"}:{reason:Xv(t)};case"extensions/KHR_materials_emissive_strength/emissiveStrength":return e.extensions?.KHR_materials_emissive_strength?{type:"material",property:"emissiveStrength"}:{reason:Xv(t)};default:return{reason:Xv(t)}}}(s,t.slice(2));if("reason"in o)return Yv(i,o.reason),null;return{sampler:n,pointer:i,targetMaterialIndex:r,...o}}(e,r,n,i);default:return Yv(i,`top-level target "${r[0]}" has no runtime animation mapping`),null}}(e,t,n);const i=Qv(t.path);if(!i)return null;const r=e.nodes[t.node??0];if(!r)throw new Error(`Cannot find animation target ${t.node}`);return{type:"node",sampler:n,targetNodeId:r.id,path:i}}(e,s,a);return l?[l]:[]});return a.length?[{name:s,channels:a}]:[]})}function Qv(e){switch(e){case"translation":case"rotation":case"scale":case"weights":return e;default:return null}}function Xv(e){const t=Zv(e);if(t){const e=Gv(t);if("none"===e?.supportLevel)return`${t} is referenced by this pointer, but ${e.comment.charAt(0).toLowerCase()}${e.comment.slice(1)}`}return`no runtime target exists for material property "${e.join("/")}"`}function $v(e){const t=Zv(e);if(t){const e=Gv(t);if("none"===e?.supportLevel)return`${t} is referenced by this pointer, but ${e.comment.charAt(0).toLowerCase()}${e.comment.slice(1)}`}return`texture-transform target "${e.join("/")}" has no runtime texture-slot mapping`}function Zv(e){const t=e.indexOf("extensions"),n=e[t+1];return t>=0&&n?n:null}function Yv(e,t){Hi.R.warn(`KHR_animation_pointer target ${e} will be skipped because ${t}`)()}function Jv(e,t){if(t.has(e))return t.get(e);const{typedArray:n,components:i}=qv(e);ty(1===i,"accessorToJsArray1D must have exactly 1 component");const r=Array.from(n);return t.set(e,r),r}function ey(e,t){if(t.has(e))return t.get(e);const{typedArray:n,components:i}=qv(e);ty(i>=1,"accessorToJsArray2D must have at least 1 component");const r=[];for(let e=0;e<n.length;e+=i)r.push(Array.from(n.slice(e,e+i)));return t.set(e,r),r}function ty(e,t){if(!e)throw new Error(t)}function ny(e,t,n){const{scenes:i,materials:r,gltfMeshIdToNodeMap:s,gltfNodeIdToNodeMap:o,gltfNodeIndexToNodeMap:a}=Ev(e,t,n),l=Kv(t),c=new GLTFAnimator({animations:l,gltfNodeIdToNodeMap:o,materials:r}),A=Cv(t,{useByteColors:n?.useByteColors??!0}),u=zv(t),h=i.map(e=>iy(e.getBounds())),d=function(e){let t=null;for(const n of e)if(n.bounds)if(t)for(let e=0;e<3;e++)t[0][e]=Math.min(t[0][e],n.bounds[0][e]),t[1][e]=Math.max(t[1][e],n.bounds[1][e]);else t=[[...n.bounds[0]],[...n.bounds[1]]];return iy(t)}(h);return{scenes:i,materials:r,animator:c,lights:A,extensionSupport:u,sceneBounds:h,modelBounds:d,gltfMeshIdToNodeMap:s,gltfNodeIdToNodeMap:o,gltfNodeIndexToNodeMap:a,gltf:t}}function iy(e){if(!e)return{bounds:null,center:[0,0,0],size:[0,0,0],radius:.5,recommendedOrbitDistance:1};const t=[[e[0][0],e[0][1],e[0][2]],[e[1][0],e[1][1],e[1][2]]],n=[t[1][0]-t[0][0],t[1][1]-t[0][1],t[1][2]-t[0][2]],i=[t[0][0]+.5*n[0],t[0][1]+.5*n[1],t[0][2]+.5*n[2]],r=.5*Math.max(n[0],n[1],n[2]),s=Math.max(.5*Math.hypot(n[0],n[1],n[2]),.001);return{bounds:t,center:i,size:n,radius:s,recommendedOrbitDistance:Math.max(Math.max(r,.001)/Math.tan(Math.PI/6)*1.15,1.1*s)}}function ry(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}function sy(e){try{return JSON.parse(e)}catch(t){throw new Error(`Failed to parse JSON from data starting with "${function(e,t=5){if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return ry(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer)return ry(e,0,t);return""}(e)}"`)}}function oy(e,t,n){const i=void 0!==n?new Uint8Array(e).subarray(t,t+n):new Uint8Array(e).subarray(t);return new Uint8Array(i).buffer}async function ay(e,t,n,i){return i._parse(e,t,n,i)}function ly(e,t){if(!e)throw new Error(t||"loader assertion failed.")}"undefined"!=typeof self&&self,"undefined"!=typeof window&&window,"undefined"!=typeof globalThis&&globalThis,"undefined"!=typeof document&&document;const cy=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),Ay="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version),uy=(Ay&&parseFloat(Ay[1]),globalThis.loaders?.parseImageNode),hy="undefined"!=typeof Image,dy="undefined"!=typeof ImageBitmap,fy=Boolean(uy),py=!!cy||fy;function gy(e){const t=by(e);if(!t)throw new Error("Not an image");return t}function my(e){switch(gy(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 by(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 _y=/^data:image\/svg\+xml/,vy=/\.svg((\?|#).*)?$/;function yy(e){return e&&(_y.test(e)||vy.test(e))}function wy(e,t){if(yy(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function xy(e,t,n){const i=function(e,t){if(yy(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 wy(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 Ty=!0;async function Ey(e,t,n){let i;if(yy(n)){i=await xy(e,t,n)}else i=wy(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)&&Ty||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),Ty=!1}return await createImageBitmap(e)}(i,r)}function Sy(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 Cy=!1,Py=!0;function Ry(e){const t=My(e);return function(e){const t=My(e),n=t.byteLength>=24&&2303741511===t.getUint32(0,Cy);if(!n)return null;return{mimeType:"image/png",width:t.getUint32(16,Cy),height:t.getUint32(20,Cy)}}(t)||function(e){const t=My(e),n=t.byteLength>=3&&65496===t.getUint16(0,Cy)&&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,Cy);if(r.has(e))return{mimeType:"image/jpeg",height:t.getUint16(s+5,Cy),width:t.getUint16(s+7,Cy)};if(!i.has(e))return null;s+=2,s+=t.getUint16(s,Cy)}return null}(t)||function(e){const t=My(e),n=t.byteLength>=10&&1195984440===t.getUint32(0,Cy);if(!n)return null;return{mimeType:"image/gif",width:t.getUint16(6,Py),height:t.getUint16(8,Py)}}(t)||function(e){const t=My(e),n=t.byteLength>=14&&16973===t.getUint16(0,Cy)&&t.getUint32(2,Py)===t.byteLength;if(!n)return null;return{mimeType:"image/bmp",width:t.getUint32(18,Py),height:t.getUint32(22,Py)}}(t)||function(e){const t=new Uint8Array(e instanceof DataView?e.buffer:e),n=Sy(t);if(!n)return null;return{mimeType:n.mimeType,width:0,height:0}}(t)}function My(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 Ly={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:"4.4.5",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(dy)return"imagebitmap";if(hy)return"image";if(py)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return dy||hy||py;case"imagebitmap":return dy;case"image":return hy;case"data":return py;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}(e),e}}(i)){case"imagebitmap":s=await Ey(e,t,r);break;case"image":s=await xy(e,t,r);break;case"data":s=await async function(e){const{mimeType:t}=Ry(e)||{},n=globalThis.loaders?.parseImageNode;return ly(n),await n(e,t)}(e);break;default:ly(!1)}return"data"===i&&(s=my(s)),s},tests:[e=>Boolean(Ry(new DataView(e)))],options:{image:{type:"auto",decode:!0}}},Iy=("undefined"!=typeof self&&self,"undefined"!=typeof window&&window,"undefined"!=typeof globalThis&&globalThis,"undefined"!=typeof document&&document,"object"!=typeof process||"[object process]"!==String(process)||process.browser),Oy="function"==typeof importScripts,By=("undefined"!=typeof window&&window.orientation,"undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version));By&&parseFloat(By[1]);const Ny=(globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.4.5"),globalThis._loadersgl_.version),ky={};function Fy(e={}){const t=e.useLocalLibraries??e.core?.useLocalLibraries,n=e.CDN??e.core?.CDN,i=e.modules;return{...void 0!==t?{useLocalLibraries:t}:{},...void 0!==n?{CDN:n}:{},...void 0!==i?{modules:i}:{}}}async function Dy(e,t=null,n={},i=null){return t&&(e=function(e,t,n={},i=null){if(n?.core)throw new Error("loadLibrary: options.core must be pre-normalized");if(!n.useLocalLibraries&&e.startsWith("http"))return e;i=i||e;const r=n.modules||{};if(r[i])return r[i];if(!Iy)return`modules/${t}/dist/libs/${i}`;if(n.CDN)return function(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}(n.CDN.startsWith("http")),`${n.CDN}/${t}@${Ny}/dist/libs/${i}`;if(Oy)return`../src/libs/${i}`;return`modules/${t}/src/libs/${i}`}(e,t,n,i)),ky[e]=ky[e]||async function(e){if(e.endsWith("wasm"))return await async function(e){const{readFileAsArrayBuffer:t}=globalThis.loaders||{};if(Iy||!t||e.startsWith("http")){const t=await fetch(e);return await t.arrayBuffer()}try{return await t(e)}catch{if(e.includes("/dist/libs/"))return await t(e.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load ArrayBuffer from ${e}`)}}(e);if(!Iy){const{requireFromFile:t}=globalThis.loaders||{};try{const n=await(t?.(e));return n||!e.includes("/dist/libs/")?n:await(t?.(e.replace("/dist/libs/","/src/libs/")))}catch(n){if(e.includes("/dist/libs/"))try{return await(t?.(e.replace("/dist/libs/","/src/libs/")))}catch{}return console.error(n),null}}if(Oy)return importScripts(e);const t=await async function(e){const{readFileAsText:t}=globalThis.loaders||{};if(Iy||!t||e.startsWith("http")){const t=await fetch(e);return await t.text()}try{return await t(e)}catch{if(e.includes("/dist/libs/"))return await t(e.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load text from ${e}`)}}(e);return function(e,t){if(!Iy){const{requireFromString:n}=globalThis.loaders||{};return n?.(e,t)}if(Oy)return eval.call(globalThis,e),null;const n=document.createElement("script");n.id=t;try{n.appendChild(document.createTextNode(e))}catch(t){n.text=e}return document.body.appendChild(n),null}(t,e)}(e),await ky[e]}const Uy="basis_transcoder.js",Vy="basis_transcoder.wasm",zy="basis_encoder.js",Gy="basis_encoder.wasm";let jy,Hy;async function Wy(e){var t;t=e.modules,globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,t);const n=function(e){const t=globalThis.loaders?.modules?.[e];return t||null}("basis");return n||(jy||=async function(e){let t=null,n=null;return[t,n]=await Promise.all([await Dy(Uy,"textures",e),await Dy(Vy,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const n={};t&&(n.wasmBinary=t);return new Promise(t=>{e(n).then(e=>{const{BasisFile:n,initializeBasis:i}=e;i(),t({BasisFile:n})})})}(t,n)}(e),await jy)}async function qy(e){const t=e.modules||{};return t.basisEncoder?t.basisEncoder:(Hy=Hy||async function(e){let t=null,n=null;return[t,n]=await Promise.all([await Dy(zy,"textures",e),await Dy(Gy,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const n={};t&&(n.wasmBinary=t);return new Promise(t=>{e(n).then(e=>{const{BasisFile:n,KTX2File:i,initializeBasis:r,BasisEncoder:s}=e;r(),t({BasisFile:n,KTX2File:i,BasisEncoder:s})})})}(t,n)}(e),await Hy)}const Ky=["","WEBKIT_","MOZ_"],Qy={WEBGL_compressed_texture_s3tc:["bc1-rgb-unorm-webgl","bc1-rgba-unorm","bc2-rgba-unorm","bc3-rgba-unorm"],WEBGL_compressed_texture_s3tc_srgb:["bc1-rgb-unorm-srgb-webgl","bc1-rgba-unorm-srgb","bc2-rgba-unorm-srgb","bc3-rgba-unorm-srgb"],EXT_texture_compression_rgtc:["bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm"],EXT_texture_compression_bptc:["bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"],WEBGL_compressed_texture_etc1:["etc1-rgb-unorm-webgl"],WEBGL_compressed_texture_etc:["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"],WEBGL_compressed_texture_pvrtc:["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rgb2unorm-webgl","pvrtc-rgba2unorm-webgl"],WEBGL_compressed_texture_atc:["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"],WEBGL_compressed_texture_astc:["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]};let Xy=null;function $y(e){if(!Xy){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,Xy=new Set;for(const t of Ky)for(const n in Qy)if(e&&e.getExtension(`${t}${n}`))for(const e of Qy[n])Xy.add(e)}return Xy}const Zy=[171,75,84,88,32,50,48,187,13,10,26,10];let Yy=Promise.resolve();const Jy={etc1:{basisFormat:0,compressed:!0,format:36196,textureFormat:"etc1-rgb-unorm-webgl"},etc2:{basisFormat:1,compressed:!0,format:37493,textureFormat:"etc2-rgba8unorm"},bc1:{basisFormat:2,compressed:!0,format:33776,textureFormat:"bc1-rgb-unorm-webgl"},bc3:{basisFormat:3,compressed:!0,format:33779,textureFormat:"bc3-rgba-unorm"},bc4:{basisFormat:4,compressed:!0,format:36283,textureFormat:"bc4-r-unorm"},bc5:{basisFormat:5,compressed:!0,format:36285,textureFormat:"bc5-rg-unorm"},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0,format:36492,textureFormat:"bc7-rgba-unorm"},"bc7-m5":{basisFormat:7,compressed:!0,format:36492,textureFormat:"bc7-rgba-unorm"},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:35840,textureFormat:"pvrtc-rgb4unorm-webgl"},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:35842,textureFormat:"pvrtc-rgba4unorm-webgl"},"astc-4x4":{basisFormat:10,compressed:!0,format:37808,textureFormat:"astc-4x4-unorm"},"atc-rgb":{basisFormat:11,compressed:!0,format:35986,textureFormat:"atc-rgb-unorm-webgl"},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0,format:34798,textureFormat:"atc-rgbai-unorm-webgl"},rgba32:{basisFormat:13,compressed:!1,format:32856,textureFormat:"rgba8unorm"},rgb565:{basisFormat:14,compressed:!1,format:36194,textureFormat:"rgb565unorm-webgl"},bgr565:{basisFormat:15,compressed:!1,format:36194,textureFormat:"rgb565unorm-webgl"},rgba4444:{basisFormat:16,compressed:!1,format:32854,textureFormat:"rgba4unorm-webgl"}};Object.freeze(Object.keys(Jy));function ew(e,t,n){const i=new e(new Uint8Array(t));try{if(!i.startTranscoding())throw new Error("Failed to start basis transcoding");const e=i.getNumImages(),t=[];for(let r=0;r<e;r++){const e=i.getNumLevels(r),s=[];for(let t=0;t<e;t++)s.push(tw(i,r,t,n));t.push(s)}return t}finally{i.close(),i.delete()}}function tw(e,t,n,i){const r=e.getImageWidth(t,n),s=e.getImageHeight(t,n),o=e.getHasAlpha(),{compressed:a,format:l,basisFormat:c,textureFormat:A}=rw(i,o),u=e.getImageTranscodedSizeInBytes(t,n,c),h=new Uint8Array(u);if(!e.transcodeImage(h,t,n,c,0,0))throw new Error("failed to start Basis transcoding");return{shape:"texture-level",width:r,height:s,data:h,compressed:a,...void 0!==l?{format:l}:{},...void 0!==A?{textureFormat:A}:{},hasAlpha:o}}function nw(e,t,n){const i=new e(new Uint8Array(t));try{if(!i.startTranscoding())throw new Error("failed to start KTX2 transcoding");const e=i.getLevels(),t=[];for(let r=0;r<e;r++)t.push(iw(i,r,n));return[t]}finally{i.close(),i.delete()}}function iw(e,t,n){const{alphaFlag:i,height:r,width:s}=e.getImageLevelInfo(t,0,0),{compressed:o,format:a,basisFormat:l,textureFormat:c}=rw(n,i),A=e.getImageTranscodedSizeInBytes(t,0,0,l),u=new Uint8Array(A);if(!e.transcodeImage(u,t,0,0,l,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{shape:"texture-level",width:s,height:r,data:u,compressed:o,...void 0!==a?{format:a}:{},...void 0!==c?{textureFormat:c}:{},levelSize:A,hasAlpha:i}}function rw(e,t){let n=e.basis?.format||"auto";"auto"===n&&(n=e.basis?.supportedTextureFormats?sw(e.basis.supportedTextureFormats):sw()),"object"==typeof n&&(n=t?n.alpha:n.noAlpha);const i=n.toLowerCase(),r=Jy[i];if(!r)throw new Error(`Unknown Basis format ${n}`);return r}function sw(e=$y()){const t=new Set(e);return ow(t,["astc-4x4-unorm","astc-4x4-unorm-srgb"])?"astc-4x4":ow(t,["bc7-rgba-unorm","bc7-rgba-unorm-srgb"])?{alpha:"bc7-m5",noAlpha:"bc7-m6-opaque-only"}:ow(t,["bc1-rgb-unorm-webgl","bc1-rgb-unorm-srgb-webgl","bc1-rgba-unorm","bc1-rgba-unorm-srgb","bc2-rgba-unorm","bc2-rgba-unorm-srgb","bc3-rgba-unorm","bc3-rgba-unorm-srgb"])?{alpha:"bc3",noAlpha:"bc1"}:ow(t,["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rgb2unorm-webgl","pvrtc-rgba2unorm-webgl"])?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:ow(t,["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"])?"etc2":t.has("etc1-rgb-unorm-webgl")?"etc1":ow(t,["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"])?{alpha:"atc-rgba-interpolated-alpha",noAlpha:"atc-rgb"}:"rgb565"}function ow(e,t){return t.some(t=>e.has(t))}const aw={dataType:null,batchType:null,name:"Basis",id:"basis",module:"textures",version:"4.4.5",worker:!0,extensions:["basis","ktx2"],mimeTypes:["application/octet-stream","image/ktx2"],tests:["sB"],binary:!0,options:{basis:{format:"auto",containerFormat:"auto",module:"transcoder"}},parse:async function(e,t={}){const n=Fy(t);return await async function(e){const t=Yy;let n;Yy=new Promise(e=>{n=e}),await t;try{return await e()}finally{n()}}(async()=>{if(!t.basis?.containerFormat||"auto"===t.basis.containerFormat){if(function(e){const t=new Uint8Array(e);return!(t.byteLength<Zy.length||t[0]!==Zy[0]||t[1]!==Zy[1]||t[2]!==Zy[2]||t[3]!==Zy[3]||t[4]!==Zy[4]||t[5]!==Zy[5]||t[6]!==Zy[6]||t[7]!==Zy[7]||t[8]!==Zy[8]||t[9]!==Zy[9]||t[10]!==Zy[10]||t[11]!==Zy[11])}(e)){return nw((await qy(n)).KTX2File,e,t)}const{BasisFile:i}=await Wy(n);return ew(i,e,t)}if("encoder"===t.basis.module){const i=await qy(n);return"ktx2"===t.basis.containerFormat?nw(i.KTX2File,e,t):ew(i.BasisFile,e,t)}{const{BasisFile:i}=await Wy(n);return ew(i,e,t)}})}};function lw(e,t){if(!e)throw new Error(t||"assert failed: gltf")}function cw(e,t){return ly(e>=0),ly(t>0),e+(t-1)&~(t-1)}function Aw(e,t,n){let i;if(e instanceof ArrayBuffer)i=new Uint8Array(e);else{const t=e.byteOffset,n=e.byteLength;i=new Uint8Array(e.buffer||e.arrayBuffer,t,n)}return t.set(i,n),n+cw(i.byteLength,4)}const uw=!0,hw=1735152710,dw=1313821514,fw=5130562;function pw(e,t,n=0,i={}){const r=new DataView(t),s=function(e,t=0){return`${String.fromCharCode(e.getUint8(t+0))}${String.fromCharCode(e.getUint8(t+1))}${String.fromCharCode(e.getUint8(t+2))}${String.fromCharCode(e.getUint8(t+3))}`}(r,n+0),o=r.getUint32(n+4,uw),a=r.getUint32(n+8,uw);switch(Object.assign(e,{header:{byteOffset:n,byteLength:a,hasBinChunk:!1},type:s,version:o,json:{},binChunks:[]}),n+=12,e.version){case 1:return function(e,t,n){ly(e.header.byteLength>20);const i=t.getUint32(n+0,uw),r=t.getUint32(n+4,uw);return n+=8,ly(0===r),gw(e,t,n,i),n+=i,n+=mw(e,t,n,e.header.byteLength),n}(e,r,n);case 2:return function(e,t,n,i){return ly(e.header.byteLength>20),function(e,t,n,i){for(;n+8<=e.header.byteLength;){const r=t.getUint32(n+0,uw),s=t.getUint32(n+4,uw);switch(n+=8,s){case dw:gw(e,t,n,r);break;case fw:mw(e,t,n,r);break;case 0:i.strict||gw(e,t,n,r);break;case 1:i.strict||mw(e,t,n,r)}n+=cw(r,4)}}(e,t,n,i),n+e.header.byteLength}(e,r,n,{});default:throw new Error(`Invalid GLB version ${e.version}. Only supports version 1 and 2.`)}}function gw(e,t,n,i){const r=new Uint8Array(t.buffer,n,i),s=new TextDecoder("utf8").decode(r);return e.json=JSON.parse(s),cw(i,4)}function mw(e,t,n,i){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:n,byteLength:i,arrayBuffer:t.buffer}),cw(i,4)}function bw(e,t,n){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const i=n?.baseUrl||function(e){if(!e)return;if(e.endsWith("/"))return e;const t=e.lastIndexOf("/");return t>=0?e.slice(0,t+1):""}(t?.core?.baseUrl);if(!i)throw new Error(`'baseUrl' must be provided to resolve relative url ${e}`);return i.endsWith("/")?`${i}${e}`:`${i}/${e}`}const _w={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},vw={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};const yw=["SCALAR","VEC2","VEC3","VEC4"],ww=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],xw=new Map(ww),Tw={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ew={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Sw={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Cw(e){return yw[e-1]||yw[0]}function Pw(e){const t=xw.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function Rw(e,t){const n=Sw[e.componentType],i=Tw[e.type],r=Ew[e.componentType],s=e.count*i,o=e.count*i*r;lw(o>=0&&o<=t.byteLength);return{ArrayType:n,length:s,byteLength:o,componentByteSize:vw[e.componentType],numberOfComponentsInElement:_w[e.type]}}function Mw(e,t,n){const i=e.bufferViews[n];lw(i);const r=t[i.buffer];lw(r);const s=(i.byteOffset||0)+r.byteOffset;return new Uint8Array(r.arrayBuffer,s,i.byteLength)}class GLTFScenegraph{gltf;sourceBuffers;byteLength;constructor(e){this.gltf={json:e?.json||{asset:{version:"2.0",generator:"loaders.gl"},buffers:[],extensions:{},extensionsRequired:[],extensionsUsed:[]},buffers:e?.buffers||[],images:e?.images||[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}hasExtension(e){const t=this.getUsedExtensions().find(t=>t===e),n=this.getRequiredExtensions().find(t=>t===e);return"string"==typeof t||"string"==typeof n}getExtension(e){const t=this.getUsedExtensions().find(t=>t===e),n=this.json.extensions||{};return t?n[e]:null}getRequiredExtension(e){return this.getRequiredExtensions().find(t=>t===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,t){return(e.extensions||{})[t]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,t){if("object"==typeof t)return t;const n=this.json[e]&&this.json[e][t];if(!n)throw new Error(`glTF file error: Could not find ${e}[${t}]`);return n}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,n=this.gltf.buffers[t];lw(n);const i=(e.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,i,e.byteLength)}getTypedArrayForAccessor(e){const t=this.getAccessor(e);return function(e,t,n){const i="number"==typeof n?e.accessors?.[n]:n;if(!i)throw new Error(`No gltf accessor ${JSON.stringify(n)}`);const r=e.bufferViews?.[i.bufferView||0];if(!r)throw new Error(`No gltf buffer view for accessor ${r}`);const{arrayBuffer:s,byteOffset:o}=t[r.buffer],a=(o||0)+(i.byteOffset||0)+(r.byteOffset||0),{ArrayType:l,length:c,componentByteSize:A,numberOfComponentsInElement:u}=Rw(i,r),h=A*u,d=r.byteStride||h;if(void 0===r.byteStride||r.byteStride===h)return new l(s,a,c);const f=new l(c);for(let e=0;e<i.count;e++){const t=new l(s,a+e*d,u);f.set(t,e*u)}return f}(this.gltf.json,this.gltf.buffers,t)}getTypedArrayForImageData(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),n=this.getBuffer(t.buffer).data,i=t.byteOffset||0;return new Uint8Array(n,i,t.byteLength)}addApplicationData(e,t){return this.json[e]=t,this}addExtraData(e,t){return this.json.extras=this.json.extras||{},this.json.extras[e]=t,this}addObjectExtension(e,t,n){return e.extensions=e.extensions||{},e.extensions[t]=n,this.registerUsedExtension(t),this}setObjectExtension(e,t,n){(e.extensions||{})[t]=n}removeObjectExtension(e,t){const n=e?.extensions||{};if(n[t]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];const e=this.json.extensionsRemoved;e.includes(t)||e.push(t)}delete n[t]}addExtension(e,t={}){return lw(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),t}addRequiredExtension(e,t={}){return lw(t),this.addExtension(e,t),this.registerRequiredExtension(e),t}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(t=>t===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(t=>t===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(this.json.extensions?.[e]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];const t=this.json.extensionsRemoved;t.includes(e)||t.push(e)}this.json.extensions&&delete this.json.extensions[e],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e)}setDefaultScene(e){this.json.scene=e}addScene(e){const{nodeIndices:t}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}addNode(e){const{meshIndex:t,matrix:n}=e;this.json.nodes=this.json.nodes||[];const i={mesh:t};return n&&(i.matrix=n),this.json.nodes.push(i),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:n,material:i,mode:r=4}=e,s={primitives:[{attributes:this._addAttributes(t),mode:r}]};if(n){const e=this._addIndices(n);s.primitives[0].indices=e}return Number.isFinite(i)&&(s.primitives[0].material=i),this.json.meshes=this.json.meshes||[],this.json.meshes.push(s),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addImage(e,t){const n=Ry(e),i=t||n?.mimeType,r={bufferView:this.addBufferView(e),mimeType:i};return this.json.images=this.json.images||[],this.json.images.push(r),this.json.images.length-1}addBufferView(e,t=0,n=this.byteLength){const i=e.byteLength;lw(Number.isFinite(i)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const r={buffer:t,byteOffset:n,byteLength:i};return this.byteLength+=cw(i,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(r),this.json.bufferViews.length-1}addAccessor(e,t){const n={bufferView:e,type:Cw(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(n),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const n=this.addBufferView(e);let i={min:t.min,max:t.max};i.min&&i.max||(i=this._getAccessorMinMax(e,t.size));const r={size:t.size,componentType:Pw(e),count:Math.round(e.length/t.size),min:i.min,max:i.max};return this.addAccessor(n,Object.assign(r,t))}addTexture(e){const{imageIndex:t}=e,n={source:t};return this.json.textures=this.json.textures||[],this.json.textures.push(n),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){const e=this.byteLength,t=new ArrayBuffer(e),n=new Uint8Array(t);let i=0;for(const e of this.sourceBuffers||[])i=Aw(e,n,i);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=e:this.json.buffers=[{byteLength:e}],this.gltf.binary=t,this.sourceBuffers=[t],this.gltf.buffers=[{arrayBuffer:t,byteOffset:0,byteLength:t.byteLength}]}_removeStringFromArray(e,t){let n=!0;for(;n;){const i=e.indexOf(t);i>-1?e.splice(i,1):n=!1}}_addAttributes(e={}){const t={};for(const n in e){const i=e[n],r=this._getGltfAttributeName(n),s=this.addBinaryBuffer(i.value,i);t[r]=s}return t}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,t){const n={min:null,max:null};if(e.length<t)return n;n.min=[],n.max=[];const i=e.subarray(0,t);for(const e of i)n.min.push(e),n.max.push(e);for(let i=t;i<e.length;i+=t)for(let r=0;r<t;r++)n.min[0+r]=Math.min(n.min[0+r],e[i+r]),n.max[0+r]=Math.max(n.max[0+r],e[i+r]);return n}}function Lw(e){if(e instanceof ArrayBuffer)return e;if(t=e,"undefined"!=typeof SharedArrayBuffer&&t instanceof SharedArrayBuffer)return Iw(e);var t;const{buffer:n,byteOffset:i,byteLength:r}=e;return n instanceof ArrayBuffer&&0===i&&r===n.byteLength?n:Iw(n,i,r)}function Iw(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 Ow(e){return(e%1+1)%1}const Bw={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16,BOOLEAN:1,STRING:1,ENUM:1},Nw={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:BigInt64Array,UINT64:BigUint64Array,FLOAT32:Float32Array,FLOAT64:Float64Array},kw={INT8:1,UINT8:1,INT16:2,UINT16:2,INT32:4,UINT32:4,INT64:8,UINT64:8,FLOAT32:4,FLOAT64:8};function Fw(e,t){return kw[t]*Bw[e]}function Dw(e,t,n,i){if("UINT8"!==n&&"UINT16"!==n&&"UINT32"!==n&&"UINT64"!==n)return null;const r=Uw(e.getTypedArrayForBufferView(t),"SCALAR",n,i+1);return r instanceof BigInt64Array||r instanceof BigUint64Array?null:r}function Uw(e,t,n,i=1){const r=Nw[n],s=kw[n],o=i*Bw[t],a=o*s;let l=e.buffer,c=e.byteOffset;if(c%s!==0){l=new Uint8Array(l).slice(c,c+a).buffer,c=0}return new r(Lw(l),c,o)}function Vw(e,t,n){const i=`TEXCOORD_${t.texCoord||0}`,r=n.attributes[i],s=e.getTypedArrayForAccessor(r),o=e.gltf.json,a=t.index,l=o.textures?.[a]?.source;if(void 0!==l){const n=o.images?.[l]?.mimeType,i=e.gltf.images?.[l];if(i&&void 0!==i.width){const e=[];for(let r=0;r<s.length;r+=2){const o=Gw(i,n,s,r,t.channels);e.push(o)}return e}}return[]}function zw(e,t,n,i,r){if(!n?.length)return;const s=[];for(const e of n){let t=i.findIndex(t=>t===e);-1===t&&(t=i.push(e)-1),s.push(t)}const o=new Uint32Array(s),a=e.gltf.buffers.push({arrayBuffer:o.buffer,byteOffset:o.byteOffset,byteLength:o.byteLength})-1,l=e.addBufferView(o,a,0),c=e.addAccessor(l,{size:1,componentType:Pw(o),count:o.length});r.attributes[t]=c}function Gw(e,t,n,i,r=[0]){const s={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},o=n[i],a=n[i+1];let l=1;!t||-1===t.indexOf("image/jpeg")&&-1===t.indexOf("image/png")||(l=4);const c=function(e,t,n,i=1){const r=n.width,s=Ow(e)*(r-1),o=Math.round(s),a=n.height,l=Ow(t)*(a-1),c=Math.round(l),A=n.components?n.components:i,u=(c*r+o)*A;return u}(o,a,e,l);let A=0;for(const t of r){const n="number"==typeof t?Object.values(s)[t]:s[t],i=c+n.offset,r=my(e);if(r.data.length<=i)throw new Error(`${r.data.length} <= ${i}`);A|=r.data[i]<<n.shift}return A}function jw(e,t,n,i,r){const s=[];for(let o=0;o<t;o++){const t=n[o],a=n[o+1]-n[o];if(a+t>i)break;const l=t/r,c=a/r;s.push(e.slice(l,l+c))}return s}function Hw(e,t,n){const i=[];for(let r=0;r<t;r++){const t=r*n;i.push(e.slice(t,t+n))}return i}function Ww(e,t,n,i){if(n)throw new Error("Not implemented - arrayOffsets for strings is specified");if(i){const n=[],r=new TextDecoder("utf8");let s=0;for(let o=0;o<e;o++){const e=i[o+1]-i[o];if(e+s<=t.length){const i=t.subarray(s,e+s),o=r.decode(i);n.push(o),s+=e}}return n}return[]}const qw="EXT_mesh_features",Kw=qw;async function Qw(e,t){!function(e,t){const n=e.gltf.json;if(!n.meshes)return;for(const i of n.meshes)for(const n of i.primitives)$w(e,n,t)}(new GLTFScenegraph(e),t)}function Xw(e,t){const n=new GLTFScenegraph(e);return function(e){const t=e.gltf.json.meshes;if(!t)return;for(const n of t)for(const t of n.primitives)Yw(e,t)}(n),n.createBinaryChunk(),n.gltf}function $w(e,t,n){if(!n?.gltf?.loadBuffers)return;const i=t.extensions?.[qw],r=i?.featureIds;if(r)for(const i of r){let r;if(void 0!==i.attribute){const n=`_FEATURE_ID_${i.attribute}`,s=t.attributes[n];r=e.getTypedArrayForAccessor(s)}else r=void 0!==i.texture&&n?.gltf?.loadImages?Vw(e,i.texture,t):[];i.data=r}}function Zw(e,t,n,i){t.extensions||(t.extensions={});let r=t.extensions[qw];r||(r={featureIds:[]},t.extensions[qw]=r);const{featureIds:s}=r,o={featureCount:n.length,propertyTable:i,data:n};s.push(o),e.addObjectExtension(t,qw,r)}function Yw(e,t){const n=t.extensions?.[qw];if(!n)return;const i=n.featureIds;i.forEach((n,r)=>{if(n.data){const{accessorKey:s,index:o}=function(e){const t="_FEATURE_ID_",n=Object.keys(e).filter(e=>0===e.indexOf(t));let i=-1;for(const e of n){const n=Number(e.substring(t.length));n>i&&(i=n)}i++;const r=`${t}${i}`;return{accessorKey:r,index:i}}(t.attributes),a=new Uint32Array(n.data);i[r]={featureCount:a.length,propertyTable:n.propertyTable,attribute:o},e.gltf.buffers.push({arrayBuffer:a.buffer,byteOffset:a.byteOffset,byteLength:a.byteLength});const l=e.addBufferView(a),c=e.addAccessor(l,{size:1,componentType:Pw(a),count:a.length});t.attributes[s]=c}})}const Jw="EXT_structural_metadata",ex=Jw;async function tx(e,t){!function(e,t){if(!t.gltf?.loadBuffers)return;const n=e.getExtension(Jw);if(!n)return;t.gltf?.loadImages&&function(e,t){const n=t.propertyTextures,i=e.gltf.json;if(n&&i.meshes)for(const r of i.meshes)for(const i of r.primitives)rx(e,n,i,t)}(e,n);!function(e,t){const n=t.schema;if(!n)return;const i=n.classes,r=t.propertyTables;if(i&&r)for(const t in i){const i=ix(r,t);i&&ox(e,n,i)}}(e,n)}(new GLTFScenegraph(e),t)}function nx(e,t){const n=new GLTFScenegraph(e);return function(e){const t=e.getExtension(Jw);if(!t)return;if(t.propertyTables)for(const n of t.propertyTables){const i=n.class,r=t.schema?.classes?.[i];n.properties&&r&&Ax(n,r,e)}}(n),n.createBinaryChunk(),n.gltf}function ix(e,t){for(const n of e)if(n.class===t)return n;return null}function rx(e,t,n,i){if(!t)return;const r=n.extensions?.[Jw],s=r?.propertyTextures;if(s)for(const r of s){sx(e,t[r],n,i)}}function sx(e,t,n,i){if(!t.properties)return;i.dataAttributeNames||(i.dataAttributeNames=[]);const r=t.class;for(const s in t.properties){const o=`${r}_${s}`,a=t.properties?.[s];if(!a)continue;a.data||(a.data=[]);const l=a.data,c=Vw(e,a,n);null!==c&&(zw(e,o,c,l,n),a.data=l,i.dataAttributeNames.push(o))}}function ox(e,t,n){const i=t.classes?.[n.class];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${n.class}`);const r=n.count;for(const s in i.properties){const o=i.properties[s],a=n.properties?.[s];if(a){const n=ax(e,t,o,r,a);a.data=n}}}function ax(e,t,n,i,r){let s=[];const o=r.values,a=e.getTypedArrayForBufferView(o),l=function(e,t,n,i){if(t.array&&void 0===t.count&&void 0!==n.arrayOffsets)return Dw(e,n.arrayOffsets,n.arrayOffsetType||"UINT32",i);return null}(e,n,r,i),c=function(e,t,n){if(void 0!==t.stringOffsets)return Dw(e,t.stringOffsets,t.stringOffsetType||"UINT32",n);return null}(e,r,i);switch(n.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":s=function(e,t,n,i){const r=e.array,s=e.count,o=Fw(e.type,e.componentType),a=n.byteLength/o;let l;l=e.componentType?Uw(n,e.type,e.componentType,a):n;if(r)return i?jw(l,t,i,n.length,o):s?Hw(l,t,s):[];return l}(n,i,a,l);break;case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${n.type}`);case"STRING":s=Ww(i,a,l,c);break;case"ENUM":s=function(e,t,n,i,r){const s=t.enumType;if(!s)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");const o=e.enums?.[s];if(!o)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${s}`);const a=o.valueType||"UINT16",l=Fw(t.type,a),c=i.byteLength/l;let A=Uw(i,t.type,a,c);A||(A=i);if(t.array){if(r)return function(e){const{valuesData:t,numberOfElements:n,arrayOffsets:i,valuesDataBytesLength:r,elementSize:s,enumEntry:o}=e,a=[];for(let e=0;e<n;e++){const n=i[e],l=i[e+1]-i[e];if(l+n>r)break;const c=lx(t,n/s,l/s,o);a.push(c)}return a}({valuesData:A,numberOfElements:n,arrayOffsets:r,valuesDataBytesLength:i.length,elementSize:l,enumEntry:o});const e=t.count;return e?function(e,t,n,i){const r=[];for(let s=0;s<t;s++){const t=lx(e,n*s,n,i);r.push(t)}return r}(A,n,e,o):[]}return lx(A,0,n,o)}(t,n,i,a,l);break;default:throw new Error(`Unknown classProperty type ${n.type}`)}return s}function lx(e,t,n,i){const r=[];for(let s=0;s<n;s++)if(e instanceof BigInt64Array||e instanceof BigUint64Array)r.push("");else{const n=cx(i,e[t+s]);n?r.push(n.name):r.push("")}return r}function cx(e,t){for(const n of e.values)if(n.value===t)return n;return null}function Ax(e,t,n){for(const i in e.properties){const r=e.properties[i].data;if(r){const s=t.properties[i];if(s){const t=hx(r,s,n);e.properties[i]=t}}}}function ux(e,t,n="schemaClassId"){let i=e.getExtension(Jw);i||(i=e.addExtension(Jw)),i.schema=function(e,t,n){const i=n??{id:"schema_id"},r={properties:{}};for(const t of e){const e={type:t.elementType,componentType:t.componentType};r.properties[t.name]=e}return i.classes={},i.classes[t]=r,i}(t,n,i.schema);const r=function(e,t,n){const i={class:t,count:0};let r=0;const s=n.classes?.[t];for(const t of e){if(0===r&&(r=t.values.length),r!==t.values.length&&t.values.length)throw new Error("Illegal values in attributes");const e=s?.properties[t.name];e&&(i.properties||(i.properties={}),i.properties[t.name]={values:0,data:t.values})}return i.count=r,i}(t,n,i.schema);return i.propertyTables||(i.propertyTables=[]),i.propertyTables.push(r)-1}function hx(e,t,n){const i={values:0};if("STRING"===t.type){const{stringData:t,stringOffsets:r}=function(e){const t=new TextEncoder,n=[];let i=0;for(const r of e){const e=t.encode(r);i+=e.length,n.push(e)}const r=new Uint8Array(i),s=[];let o=0;for(const e of n)r.set(e,o),s.push(o),o+=e.length;s.push(o);const a=new Uint32Array(s);return{stringData:r,stringOffsets:a}}(e);i.stringOffsets=fx(r,n),i.values=fx(t,n)}else if("SCALAR"===t.type&&t.componentType){const r=function(e,t){const n=[];for(const t of e)n.push(Number(t));const i=dx[t];if(!i)throw new Error("Illegal component type");return new i(n)}(e,t.componentType);i.values=fx(r,n)}return i}const dx={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:Int32Array,UINT64:Uint32Array,FLOAT32:Float32Array,FLOAT64:Float64Array};function fx(e,t){return t.gltf.buffers.push({arrayBuffer:Lw(e.buffer),byteOffset:e.byteOffset,byteLength:e.byteLength}),t.addBufferView(e)}var px=function(){var e=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if("object"!=typeof WebAssembly)return{supported:!1};var n,i=WebAssembly.validate(e)?s("b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:59Dklbzik94evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaeai86b:q:W:cjbaecitab8Piw83i:q:G:cjbaecefgecjd9hmbkk:SBlEud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaialfgxar9RhodnadTgmmbavaoad;8qbbkaicefhPcj;abad9Uc;WFbGcjdadca0EhsdndndnadTmbaoadfhzcbhHinaeaH9nmdaxaP9RaD6miabaHad2fgOavcjdfasaeaH9RaHasfae6EgAaAcsfgoc9WGgCSEhXaPaDfhQaocl4cifcd4hLavcj;cbfaCcetfhKavcj;cbfaCci2fhYavcj;cbfaCfh8AcbhEaoc;ab6h3incbh5dnawTmbaPaEcd4fRbbh5kcbh8Eavcj;cbfh8Findndndndna5a8Ecet4ciGgoc9:fPdebdkaxaQ9RaC6mwdnaCTmbavcj;cbfa8EaC2faQaC;8qbbkaQaAfhQxdkaCTmeavcj;cbfa8EaC2fcbaC;8kbxekaxaQ9RaL6moaoclVcbawEhraQaLfhocbhidna3mbaxao9Rc;Gb6mbcbhlina8FalfhidndndndndndnaQalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaoclffa8JRb:q:W:cjbfhoxikaiaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaocwffa8JRb:q:W:cjbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbagaocdffa8JRb:q:W:cjbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaoclffa8JRb:q:W:cjbfhoxikaiczfaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaocwffa8JRb:q:W:cjbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbagaocdffa8JRb:q:W:cjbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaoclffa8JRb:q:W:cjbfhoxikaicafaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaocwffa8JRb:q:W:cjbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbagaocdffa8JRb:q:W:cjbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsaap5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbaiaoclffaqRb:q:W:cjbfhoxikaic8Wfaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsaap5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbaiaocwffaqRb:q:W:cjbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitpbi:q:G:cjbaiRb:q:W:cjbgipsaoRbegqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqRb:q:W:cjbfhokalc;abfhialcjefaC0meaihlaxao9Rc;Fb0mbkkdnaiaC9pmbaici4hlinaxao9RcK6mwa8FaifhqdndndndndndnaQaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spkbbagaoclffa8JRb:q:W:cjbfhoxikaqaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spkbbagaocwffa8JRb:q:W:cjbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpkbbagaocdffa8JRb:q:W:cjbfhokalcdfhlaiczfgiaC6mbkkaohQaoTmoka8FaCfh8Fa8Ecefg8Ecl9hmbkdndndndnawTmbazaEcd4fRbbglciGPlbedwbkaCTmdaXaEfhlavaEfpbdbh8Kcbhoinalavcj;cbfaofpblbg8La8Aaofpblbg8MpmbzeHdOiAlCvXoQrLg8NaKaofpblbgyaYaofpblbg8PpmbzeHdOiAlCvXoQrLgIpmbezHdiOAlvCXorQLgacep9Taapxeeeeeeeeeeeeeeeeghp9op9Hp9rgaa8Kp9Ug8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp9Ug8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp9Ug8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9Abbbaladfgla8Ka8NaIpmwDKYqk8AExm35Ps8E8Fgacep9Taaahp9op9Hp9rgap9Ug8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp9Ug8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp9Ug8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9Abbbaladfgla8Ka8La8MpmwKDYq8AkEx3m5P8Es8Fg8Laya8PpmwKDYq8AkEx3m5P8Es8Fg8MpmbezHdiOAlvCXorQLgacep9Taaahp9op9Hp9rgap9Ug8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp9Ug8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp9Ug8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9Abbbaladfgla8Ka8La8MpmwDKYqk8AExm35Ps8E8Fgacep9Taaahp9op9Hp9rgap9Ughp9Abbbaladfglahaaaapmlvorlvorlvorlvorp9Ughp9AbbbaladfglahaaaapmwDqkwDqkwDqkwDqkp9Ughp9AbbbaladfglahaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9AbbbaladfhlaoczfgoaC6mbxikkaCTmeaXaEfhlavaEfpbdbh8Kcbhoinalavcj;cbfaofpblbg8La8Aaofpblbg8MpmbzeHdOiAlCvXoQrLg8NaKaofpblbgyaYaofpblbg8PpmbzeHdOiAlCvXoQrLgIpmbezHdiOAlvCXorQLgacep:neaapxebebebebebebebebghp9op:bep9rgaa8Kp:oeg8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp:oeg8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp:oeg8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9Abbbaladfgla8Ka8NaIpmwDKYqk8AExm35Ps8E8Fgacep:neaaahp9op:bep9rgap:oeg8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp:oeg8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp:oeg8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9Abbbaladfgla8Ka8La8MpmwKDYq8AkEx3m5P8Es8Fg8Laya8PpmwKDYq8AkEx3m5P8Es8Fg8MpmbezHdiOAlvCXorQLgacep:neaaahp9op:bep9rgap:oeg8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp:oeg8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp:oeg8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9Abbbaladfgla8Ka8La8MpmwDKYqk8AExm35Ps8E8Fgacep:neaaahp9op:bep9rgap:oeghp9Abbbaladfglahaaaapmlvorlvorlvorlvorp:oeghp9AbbbaladfglahaaaapmwDqkwDqkwDqkwDqkp:oeghp9AbbbaladfglahaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9AbbbaladfhlaoczfgoaC6mbxdkkaCTmbaXaEfhrcbhocbalcl4gl9Rc8FGhiavaEfpbdbhhinaravcj;cbfaofpblbg8Ka8Aaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaKaofpblbg8NaYaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLgaaip:Reaaalp:Tep9qgaahp9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9Abbbaradfgraha8Ma8PpmwDKYqk8AExm35Ps8E8Fgaaip:Reaaalp:Tep9qgap9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9Abbbaradfgraha8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLgaaip:Reaaalp:Tep9qgap9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9Abbbaradfgraha8Ka8LpmwDKYqk8AExm35Ps8E8Fgaaip:Reaaalp:Tep9qgap9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9AbbbaradfhraoczfgoaC6mbkkaEclfgEad6mbkdnaXavcjdf9hmbaAad2goTmbaOavcjdfao;8qbbkdnammbavaXaAcufad2fad;8qbbkaAaHfhHc9:hoaQhPaQmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdasaeao9Raoasfae6Eaofgoae6mbkaial9RhPkcbc99axaP9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbkNsezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk;Toio97eue97aec98Ghedndnadcl9hmbaeTmecbhdinababpbbbgicKp:RecKp:Sep;6eglaicwp:RecKp:Sep;6ealp;Geaiczp:RecKp:Sep;6egvp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgwp9op9rp;Keglpxbb;:9cbb;:9cbb;:9cbb;:9calalp;Meaoaop;Meavaravawp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFbbbFbbbFbbbFbbbp9oaipxbbbFbbbFbbbFbbbFp9op9qalavp;Mearp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaoavp;Mearp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgDaDpbbbgipxbbbbbbFFbbbbbbFFgwp9oabpbbbgoaipmbediwDqkzHOAKY8AEgvczp:Reczp:Sep;6eglaoaipmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eavczp:Sep;6egvp;Gealp;Gep;Kep;Legipxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgqp9op9rp;Keglpxb;:FSb;:FSb;:FSb;:FSalalp;Meaiaip;Meavaravaqp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbp9oaiavp;Mearp;Keczp:Rep9qgialavp;Mearp;KepxFFbbFFbbFFbbFFbbp9oglpmwDKYqk8AExm35Ps8E8Fp9qpkbbabaoawp9oaialpmbezHdiOAlvCXorQLp9qpkbbabcafhbadclfgdae6mbkkk;2ileue97euo97dnaec98GgiTmbcbheinabcKfpx:ji:1S:ji:1S:ji:1S:ji:1SabpbbbglabczfgvpbbbgopmlvorxmPsCXQL358E8Fgrczp:Segwpxibbbibbbibbbibbbp9qp;6egDp;NegqaDaDp;MegDaDp;KealaopmbediwDqkzHOAKY8AEgDczp:Reczp:Sep;6eglalp;MeaDczp:Sep;6egoaop;Mearczp:Reczp:Sep;6egrarp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gDp;KepxFFbbFFbbFFbbFFbbgkp9oaqaop;MeaDp;Keczp:Rep9qgoaqalp;MeaDp;Keakp9oaqarp;MeaDp;Keczp:Rep9qgDpmwDKYqk8AExm35Ps8E8Fglp5eawclp:RegqpEi:T:j83ibavalp5baqpEd:T:j83ibabcwfaoaDpmbezHdiOAlvCXorQLgDp5eaqpEe:T:j83ibabaDp5baqpEb:T:j83ibabcafhbaeclfgeai6mbkkkuee97dnadcd4ae2c98GgeTmbcbhdinababpbbbgicwp:Recwp:Sep;6eaicep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbabczfhbadclfgdae6mbkkk:Sodw97euaec98Ghedndnadcl9hmbaeTmecbhdinabpxbbuJbbuJbbuJbbuJabpbbbgicKp:TeglaicYp:Tep9qgvcdp:Teavp9qgvclp:Teavp9qgop;6ep;Negvaicwp:RecKp:SegraipxFbbbFbbbFbbbFbbbgwp9ogDp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oavaDarp:Xeaiczp:RecKp:Segip:Uep;6ep;Meaqp;Keawp9op9qavaDaraip:Uep:Xep;6ep;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qavaoalcep:Rep9oalpxebbbebbbebbbebbbp9op9qp;6ep;Meaqp;KecKp:Rep9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgkpxbFu9hbFu9hbFu9hbFu9habpbbbglakpbbbgrpmlvorxmPsCXQL358E8Fgvczp:TegqavcHp:Tep9qgicdp:Teaip9qgiclp:Teaip9qgicwp:Teaip9qgop;6ep;NegialarpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbglp9ograDczp:Segwp:Ueavczp:Reczp:SegDp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gvp;Kealp9oaiarawaDp:Uep:Xep;6ep;Meavp;Keczp:Rep9qgwaiaoaqcep:Rep9oaqpxebbbebbbebbbebbbp9op9qp;6ep;Meavp;Keczp:ReaiaDarp:Uep;6ep;Meavp;Kealp9op9qgipmwDKYqk8AExm35Ps8E8FpkbbabawaipmbezHdiOAlvCXorQLpkbbabcafhbadclfgdae6mbkkk9teiucbcbydj:G:cjbgeabcifc98GfgbBdj:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkxebcj:Gdklz:zbb"):s("b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq1Zkdbk:kYi5ud9:du8Jjjjjbcjq9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCaAcethXaxaDfhiaOaeaoaeao6E9RhQalcl4cifcd4hLazcjdfaAfhKcbhYabaOad2fg8AhEaHh3incbh5dnawTmbaxaYcd4fRbbh5kcbh8Eazcjdfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcjdfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcjdfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaL6mva8FaLfhidnaCTmbaPai9RcK6mbaocdtc:q:G:cjbfcj:G:cjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bwar9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfcbaicdfa8J9c8N1:NfghRbbag9cjjjjjw:dg8J9qE86bbarcVfcbaha8J9c8M1:NfghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fcbaha8J9c8N1:NfgiRbbag9cjjjjjw:dg8J9qE86bbarc96fcbaia8J9c8M1:NfgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbw83bwarai8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasaYcd4fRbbgociGPlbedrbkaATmdazaYfh8Fazcjdfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeazaYfhaazcjdfhhcbhoceh8EaKh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaQaocefgofmbka8FaXfh8FcdhoaacdfhaahaXfhha8EceGhlcbh8EalmbxdkkaATmbaocl4h8EazaYfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaKhainazcjdfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E94aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3aYclfgYad6mbkaza8AaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcjqf8Kjjjjbaok:ysezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:kjjjb8Aav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk:4ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxalarcefciGcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGgkfcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkalarcufciGcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkalakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K:G:cjbgeabcifc98GfgbBd:K:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk83dbcj:Gdk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:K:Gdkl8W:qbb"),r=WebAssembly.instantiate(i,{}).then(function(e){(n=e.instance).exports.__wasm_call_ctors()});function s(e){for(var n=new Uint8Array(e.length),i=0;i<e.length;++i){var r=e.charCodeAt(i);n[i]=r>96?r-97:r>64?r-39:r+4}var s=0;for(i=0;i<e.length;++i)n[s++]=n[i]<60?t[n[i]]:64*(n[i]-60)+n[++i];return n.buffer.slice(0,s)}function o(e,t,n,i,r,s,o){var a=e.exports.sbrk,l=i+3&-4,c=a(l*r),A=a(s.length),u=new Uint8Array(e.exports.memory.buffer);u.set(s,A);var h=t(c,i,r,A,s.length);if(0==h&&o&&o(c,l,r),n.set(u.subarray(c,c+i*r)),a(c-a(0)),0!=h)throw new Error("Malformed buffer data: "+h)}var a={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp",COLOR:"meshopt_decodeFilterColor"},l={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},c=[],A=0;function u(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var n=e.data;t.pending-=n.count,t.requests[n.id][n.action](n.value),delete t.requests[n.id]},t}function h(e){var t=e.data;self.ready.then(function(e){if(!t.id)return self.close();try{var n=new Uint8Array(t.count*t.size);o(e,e.exports[t.mode],n,t.count,t.size,t.source,e.exports[t.filter]),self.postMessage({id:t.id,count:t.count,action:"resolve",value:n},[n.buffer])}catch(e){self.postMessage({id:t.id,count:t.count,action:"reject",value:e})}})}return{ready:r,supported:!0,useWorkers:function(e){!function(e){for(var t="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(i)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+h.name+";"+o.toString()+h.toString(),n=new Blob([t],{type:"text/javascript"}),r=URL.createObjectURL(n),s=c.length;s<e;++s)c[s]=u(r);for(s=e;s<c.length;++s)c[s].object.postMessage({});c.length=e,URL.revokeObjectURL(r)}(e)},decodeVertexBuffer:function(e,t,i,r,s){o(n,n.exports.meshopt_decodeVertexBuffer,e,t,i,r,n.exports[a[s]])},decodeIndexBuffer:function(e,t,i,r){o(n,n.exports.meshopt_decodeIndexBuffer,e,t,i,r)},decodeIndexSequence:function(e,t,i,r){o(n,n.exports.meshopt_decodeIndexSequence,e,t,i,r)},decodeGltfBuffer:function(e,t,i,r,s,c){o(n,n.exports[l[s]],e,t,i,r,n.exports[a[c]])},decodeGltfBufferAsync:function(e,t,i,s,u){return c.length>0?function(e,t,n,i,r){for(var s=c[0],o=1;o<c.length;++o)c[o].pending<s.pending&&(s=c[o]);return new Promise(function(o,a){var l=new Uint8Array(n),c=++A;s.pending+=e,s.requests[c]={resolve:o,reject:a},s.object.postMessage({id:c,count:e,size:t,source:l,mode:i,filter:r},[l.buffer])})}(e,t,i,l[s],a[u]):r.then(function(){var r=new Uint8Array(e*t);return o(n,n.exports[l[s]],r,e,t,i,n.exports[a[u]]),r})}}}();function gx(e){return"string"==typeof e?e:["NONE","OCTAHEDRAL","QUATERNION","EXPONENTIAL","COLOR"][e]}async function mx(e,t,n){if(!t.gltf?.decompressMeshes||!t.gltf.loadBuffers)return;!function(e){const t=e.bufferViews||[];for(let e=0;e<t.length;e++){const n=t[e].extensions;if(n?.KHR_meshopt_compression&&n.EXT_meshopt_compression)throw new Error(`glTF bufferView ${e} cannot use both KHR_meshopt_compression and EXT_meshopt_compression.`)}const n=e.buffers||[];for(let e=0;e<n.length;e++){const t=n[e].extensions;if(t?.KHR_meshopt_compression&&t.EXT_meshopt_compression)throw new Error(`glTF buffer ${e} cannot use both KHR_meshopt_compression and EXT_meshopt_compression.`)}}(e.json);const i=new GLTFScenegraph(e),r=e.json.bufferViews||[],s=r.map(e=>async function(e,t,n){const i=e.getObjectExtension(t,n);if(!i)return;const{byteOffset:r=0,byteLength:s,byteStride:o,count:a,mode:l,filter:c="NONE",buffer:A}=i,u=e.gltf.buffers[A],h=e.gltf.buffers[t.buffer],d=new Uint8Array(u.arrayBuffer,u.byteOffset+r,s),f=new Uint8Array(h.arrayBuffer,h.byteOffset+(t.byteOffset||0),t.byteLength);await async function(e,t,n,i,r,s="NONE"){await px.ready,px.decodeGltfBuffer(e,t,n,i,r,gx(s))}(f,a,o,d,l,c)}(i,e,n));await Promise.all(s);for(const e of r)i.removeObjectExtension(e,n);for(const t of e.json.buffers||[])i.removeObjectExtension(t,n);i.removeExtension(n)}const bx="EXT_meshopt_compression";async function _x(e,t){await mx(e,t,bx)}const vx="KHR_meshopt_compression";async function yx(e,t){await mx(e,t,vx)}const wx={};function xx(e){if(void 0===wx[e]){const t=cy?function(e){switch(e){case"image/avif":case"image/webp":return function(e){try{const t=document.createElement("canvas");return 0===t.toDataURL(e).indexOf(`data:${e}`)}catch{return!1}}(e);default:return!0}}(e):Tx(e);wx[e]=t}return wx[e]}function Tx(e){const t=globalThis.loaders?.imageFormatsNode||["image/png","image/jpeg","image/gif"],n=globalThis.loaders?.parseImageNode;return Boolean(n)&&t.includes(e)}const Ex="EXT_texture_webp",Sx=Ex;function Cx(e,t){const n=new GLTFScenegraph(e);if(!xx("image/webp")){if(n.getRequiredExtensions().includes(Ex))throw new Error(`gltf: Required extension ${Ex} not supported by browser`);return}const{json:i}=n;for(const e of i.textures||[]){const t=n.getObjectExtension(e,Ex);t&&(e.source=t.source),n.removeObjectExtension(e,Ex)}n.removeExtension(Ex)}const Px="KHR_texture_basisu",Rx=Px;function Mx(e,t){const n=new GLTFScenegraph(e),{json:i}=n;for(const e of i.textures||[]){const t=n.getObjectExtension(e,Px);t&&(e.source=t.source,n.removeObjectExtension(e,Px))}n.removeExtension(Px)}function Lx(e){switch(e.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function Ix(e,t,n){const i=Lx(t.value),r=n||function(e){const t={};"byteOffset"in e&&(t.byteOffset=e.byteOffset.toString(10));"byteStride"in e&&(t.byteStride=e.byteStride.toString(10));"normalized"in e&&(t.normalized=e.normalized.toString());return t}(t);return{name:e,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:i}]},nullable:!1,metadata:r}}function Ox(e,t,n){return Ix(e,t,n?Bx(n.metadata):void 0)}function Bx(e){Object.entries(e);const t={};for(const n in e)t[`${n}.string`]=JSON.stringify(e[n]);return t}const Nx={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},kx={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class DracoParser{draco;decoder;metadataQuerier;constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,t={}){const n=new this.draco.DecoderBuffer;n.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const i=this.decoder.GetEncodedGeometryType(n),r=i===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(i){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(n,r);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(n,r);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!r.ptr){const t=`DRACO decompression failed: ${e.error_msg()}`;throw new Error(t)}const s=this._getDracoLoaderData(r,i,t),o=this._getMeshData(r,s,t),a=function(e){let t=1/0,n=1/0,i=1/0,r=-1/0,s=-1/0,o=-1/0;const a=e.POSITION?e.POSITION.value:[],l=a&&a.length;for(let e=0;e<l;e+=3){const l=a[e],c=a[e+1],A=a[e+2];t=l<t?l:t,n=c<n?c:n,i=A<i?A:i,r=l>r?l:r,s=c>s?c:s,o=A>o?A:o}return[[t,n,i],[r,s,o]]}(o.attributes),l=function(e,t,n){const i=Bx(t.metadata),r=[],s=function(e){const t={};for(const n in e){const i=e[n];t[i.name||"undefined"]=i}return t}(t.attributes);for(const t in e){const n=Ox(t,e[t],s[t]);r.push(n)}if(n){const e=Ox("indices",n);r.push(e)}return{fields:r,metadata:i}}(o.attributes,s,o.indices);return{loader:"draco",loaderData:s,header:{vertexCount:r.num_points(),boundingBox:a},...o,schema:l}}finally{this.draco.destroy(n),r&&this.draco.destroy(r)}}_getDracoLoaderData(e,t,n){const i=this._getTopLevelMetadata(e),r=this._getDracoAttributes(e,n);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:i,attributes:r}}_getDracoAttributes(e,t){const n={};for(let i=0;i<e.num_attributes();i++){const r=this.decoder.GetAttribute(e,i),s=this._getAttributeMetadata(e,i);n[r.unique_id()]={unique_id:r.unique_id(),attribute_type:r.attribute_type(),data_type:r.data_type(),num_components:r.num_components(),byte_offset:r.byte_offset(),byte_stride:r.byte_stride(),normalized:r.normalized(),attribute_index:i,metadata:s};const o=this._getQuantizationTransform(r,t);o&&(n[r.unique_id()].quantization_transform=o);const a=this._getOctahedronTransform(r,t);a&&(n[r.unique_id()].octahedron_transform=a)}return n}_getMeshData(e,t,n){const i=this._getMeshAttributes(t,e,n);if(!i.POSITION)throw new Error("DRACO: No position attribute found.");return e instanceof this.draco.Mesh?"triangle-strip"===n.topology?{topology:"triangle-strip",mode:4,attributes:i,indices:{value:this._getTriangleStripIndices(e),size:1}}:{topology:"triangle-list",mode:5,attributes:i,indices:{value:this._getTriangleListIndices(e),size:1}}:{topology:"point-list",mode:0,attributes:i}}_getMeshAttributes(e,t,n){const i={};for(const r of Object.values(e.attributes)){const e=this._deduceAttributeName(r,n);r.name=e;const s=this._getAttributeValues(t,r);if(s){const{value:t,size:n}=s;i[e]={value:t,size:n,byteOffset:r.byte_offset,byteStride:r.byte_stride,normalized:r.normalized}}}return i}_getTriangleListIndices(e){const t=3*e.num_faces(),n=4*t,i=this.draco._malloc(n);try{return this.decoder.GetTrianglesUInt32Array(e,n,i),new Uint32Array(this.draco.HEAPF32.buffer,i,t).slice()}finally{this.draco._free(i)}}_getTriangleStripIndices(e){const t=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,t),function(e){const t=e.size(),n=new Int32Array(t);for(let i=0;i<t;i++)n[i]=e.GetValue(i);return n}(t)}finally{this.draco.destroy(t)}}_getAttributeValues(e,t){const n=kx[t.data_type];if(!n)return console.warn(`DRACO: Unsupported attribute type ${t.data_type}`),null;const i=t.num_components,r=e.num_points()*i,s=r*n.BYTES_PER_ELEMENT,o=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32;default:return e.DT_INVALID}}(this.draco,n);let a;const l=this.draco._malloc(s);try{const i=this.decoder.GetAttribute(e,t.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,i,o,s,l),a=new n(this.draco.HEAPF32.buffer,l,r).slice()}finally{this.draco._free(l)}return{value:a,size:i}}_deduceAttributeName(e,t){const n=e.unique_id;for(const[e,i]of Object.entries(t.extraAttributes||{}))if(i===n)return e;const i=e.attribute_type;for(const e in Nx){if(this.draco[e]===i)return Nx[e]}const r=t.attributeNameEntry||"name";return e.metadata[r]?e.metadata[r].string:`CUSTOM_ATTRIBUTE_${n}`}_getTopLevelMetadata(e){const t=this.decoder.GetMetadata(e);return this._getDracoMetadata(t)}_getAttributeMetadata(e,t){const n=this.decoder.GetAttributeMetadata(e,t);return this._getDracoMetadata(n)}_getDracoMetadata(e){if(!e||!e.ptr)return{};const t={},n=this.metadataQuerier.NumEntries(e);for(let i=0;i<n;i++){const n=this.metadataQuerier.GetEntryName(e,i);t[n]=this._getDracoMetadataField(e,n)}return t}_getDracoMetadataField(e,t){const n=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,t,n);const i=function(e){const t=e.size(),n=new Int32Array(t);for(let i=0;i<t;i++)n[i]=e.GetValue(i);return n}(n);return{int:this.metadataQuerier.GetIntEntry(e,t),string:this.metadataQuerier.GetStringEntry(e,t),double:this.metadataQuerier.GetDoubleEntry(e,t),intArray:i}}finally{this.draco.destroy(n)}}_disableAttributeTransforms(e){const{quantizedAttributes:t=[],octahedronAttributes:n=[]}=e,i=[...t,...n];for(const e of i)this.decoder.SkipAttributeTransform(this.draco[e])}_getQuantizationTransform(e,t){const{quantizedAttributes:n=[]}=t,i=e.attribute_type();if(n.map(e=>this.decoder[e]).includes(i)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map(e=>t.min_value(e))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:n=[]}=t,i=e.attribute_type();if(n.map(e=>this.decoder[e]).includes(i)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}const Fx="https://www.gstatic.com/draco/versioned/decoders/1.5.6",Dx="draco_wasm_wrapper.js",Ux="draco_decoder.wasm",Vx="draco_decoder.js",zx="draco_encoder.js",Gx={[Dx]:`${Fx}/${Dx}`,[Ux]:`${Fx}/${Ux}`,[Vx]:`${Fx}/${Vx}`,[zx]:`https://raw.githubusercontent.com/google/draco/1.4.1/javascript/${zx}`};let jx;async function Hx(e={},t){const n=e.modules||{};return n.draco3d?jx||=n.draco3d.createDecoderModule({}).then(e=>({draco:e})):jx||=async function(e,t){let n,i;if("js"===t)n=await Dy(Gx[Vx],"draco",e,Vx);else try{[n,i]=await Promise.all([await Dy(Gx[Dx],"draco",e,Dx),await Dy(Gx[Ux],"draco",e,Ux)])}catch{n=null,i=null}n=Wx(n,"DracoDecoderModule"),n=n||globalThis.DracoDecoderModule,n||Iy||([n,i]=await Promise.all([await Dy(Gx[Dx],"draco",{...e,useLocalLibraries:!0},Dx),await Dy(Gx[Ux],"draco",{...e,useLocalLibraries:!0},Ux)]),n=Wx(n,"DracoDecoderModule"),n=n||globalThis.DracoDecoderModule);return await function(e,t){if("function"!=typeof e)throw new Error("DracoDecoderModule could not be loaded");const n={};t&&(n.wasmBinary=t);return new Promise(t=>{e({...n,onModuleLoaded:e=>t({draco:e})})})}(n,i)}(e,t),await jx}function Wx(e,t){if(e&&"object"==typeof e){if(e.default)return e.default;if(e[t])return e[t]}return e}const qx={...{dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:"4.4.5",worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:"object"==typeof WebAssembly?"wasm":"js",extraAttributes:{},attributeNameEntry:void 0}}},parse:async function(e,t){const{draco:n}=await Hx(Fy(t),t?.draco?.decoderType||"wasm"),i=new DracoParser(n);try{return i.parseSync(e,t?.draco)}finally{i.destroy()}}};function Kx(e){const{buffer:t,size:n,count:i}=function(e){let t=e,n=1,i=0;e&&e.value&&(t=e.value,n=e.size||1);t&&(ArrayBuffer.isView(t)||(t=function(e,t,n=!1){if(!e)return null;if(Array.isArray(e))return new t(e);if(n&&!(e instanceof t))return new t(e);return e}(t,Float32Array)),i=t.length/n);return{buffer:t,size:n,count:i}}(e);return{value:t,size:n,byteOffset:0,count:i,type:Cw(n),componentType:Pw(t)}}const Qx="KHR_draco_mesh_compression",Xx=Qx;function $x(e,t,n){const i=new GLTFScenegraph(e);for(const e of tT(i))i.getObjectExtension(e,Qx)}async function Zx(e,t,n){if(!t?.gltf?.decompressMeshes)return;const i=new GLTFScenegraph(e),r=[];for(const e of tT(i))i.getObjectExtension(e,Qx)&&r.push(Jx(i,e,t,n));await Promise.all(r),i.removeExtension(Qx)}function Yx(e,t={}){const n=new GLTFScenegraph(e);for(const e of n.json.meshes||[])eT(e,t),n.addRequiredExtension(Qx)}async function Jx(e,t,n,i){const r=e.getObjectExtension(t,Qx);if(!r)return;const s=e.getTypedArrayForBufferView(r.bufferView),o=oy(s.buffer,s.byteOffset),a={...n};delete a["3d-tiles"];const l=await ay(o,qx,a,i),c=function(e){const t={};for(const n in e){const i=e[n];if("indices"!==n){const e=Kx(i);t[n]=e}}return t}(l.attributes);for(const[n,i]of Object.entries(c))if(n in t.attributes){const r=t.attributes[n],s=e.getAccessor(r);s?.min&&s?.max&&(i.min=s.min,i.max=s.max)}t.attributes=c,l.indices&&(t.indices=Kx(l.indices)),e.removeObjectExtension(t,Qx),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function eT(e,t,n=4,i,r){if(!i.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const s=i.DracoWriter.encodeSync({attributes:e}),o=r?.parseSync?.({attributes:e}),a=i._addFauxAttributes(o.attributes),l=i.addBufferView(s);return{primitives:[{attributes:a,mode:n,extensions:{[Qx]:{bufferView:l,attributes:a}}}]}}function*tT(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}const nT="KHR_texture_transform",iT=nT,rT=new oi.P,sT=new Matrix3,oT=new Matrix3;async function aT(e,t){if(!new GLTFScenegraph(e).hasExtension(nT)||!t.gltf?.loadBuffers)return;const n=e.json.materials||[];for(let t=0;t<n.length;t++)lT(t,e)}function lT(e,t){const n=t.json.materials?.[e],i=[n?.pbrMetallicRoughness?.baseColorTexture,n?.emissiveTexture,n?.normalTexture,n?.occlusionTexture,n?.pbrMetallicRoughness?.metallicRoughnessTexture],r=[];for(const n of i)n&&n?.extensions?.[nT]&&cT(t,e,n,r)}function cT(e,t,n,i){const r=function(e,t){const n=e.extensions?.[nT],{texCoord:i=0}=e,{texCoord:r=i}=n,s=-1!==t.findIndex(([e,t])=>e===i&&t===r);if(!s){const s=function(e){const{offset:t=[0,0],rotation:n=0,scale:i=[1,1]}=e,r=(new Matrix3).set(1,0,0,0,1,0,t[0],t[1],1),s=sT.set(Math.cos(n),Math.sin(n),0,-Math.sin(n),Math.cos(n),0,0,0,1),o=oT.set(i[0],0,0,0,i[1],0,0,0,1);return r.multiplyRight(s).multiplyRight(o)}(n);return i!==r&&(e.texCoord=r),t.push([i,r]),{originalTexCoord:i,texCoord:r,matrix:s}}return null}(n,i);if(!r)return;const s=e.json.meshes||[];for(const n of s)for(const i of n.primitives){const n=i.material;Number.isFinite(n)&&t===n&&AT(e,i,r)}}function AT(e,t,n){const{originalTexCoord:i,texCoord:r,matrix:s}=n,o=t.attributes[`TEXCOORD_${i}`];if(Number.isFinite(o)){const n=e.json.accessors?.[o];if(n&&void 0!==n.bufferView){const o=e.json.bufferViews?.[n.bufferView];if(o){const{arrayBuffer:a,byteOffset:l}=e.buffers[o.buffer],c=(l||0)+(n.byteOffset||0)+(o.byteOffset||0),{ArrayType:A,length:u}=Rw(n,o),h=vw[n.componentType],d=_w[n.type],f=o.byteStride||h*d,p=new Float32Array(u);for(let e=0;e<n.count;e++){const t=new A(a,c+e*f,2);rT.set(t[0],t[1],1),rT.transformByMatrix3(s),p.set([rT[0],rT[1]],e*d)}i===r?function(e,t,n,i){e.componentType=5126,e.byteOffset=0;const r=t.json.accessors||[],s=r.reduce((e,t)=>t.bufferView===i?e+1:e,0),o=s>1;t.buffers.push({arrayBuffer:Lw(n.buffer),byteOffset:0,byteLength:n.buffer.byteLength});const a=t.buffers.length-1;if(t.json.bufferViews=t.json.bufferViews||[],o)return t.json.bufferViews.push({buffer:a,byteLength:n.buffer.byteLength,byteOffset:0}),void(e.bufferView=t.json.bufferViews.length-1);const l=t.json.bufferViews[i];if(!l)return;l.buffer=a,l.byteOffset=0,l.byteLength=n.buffer.byteLength,void 0!==l.byteStride&&delete l.byteStride}(n,e,p,n.bufferView):function(e,t,n,i,r){i.buffers.push({arrayBuffer:Lw(r.buffer),byteOffset:0,byteLength:r.buffer.byteLength}),i.json.bufferViews=i.json.bufferViews||[];const s=i.json.bufferViews;s.push({buffer:i.buffers.length-1,byteLength:r.buffer.byteLength,byteOffset:0});const o=i.json.accessors;if(!o)return;o.push({bufferView:s?.length-1,byteOffset:0,componentType:5126,count:t.count,type:"VEC2"}),n.attributes[`TEXCOORD_${e}`]=o.length-1}(r,n,t,e,p)}}}}const uT="KHR_lights_punctual",hT=uT;async function dT(e){const t=new GLTFScenegraph(e),{json:n}=t,i=t.getExtension(uT);i&&(t.json.lights=i.lights,t.removeExtension(uT));for(const e of n.nodes||[]){const n=t.getObjectExtension(e,uT);n&&(e.light=n.light),t.removeObjectExtension(e,uT)}}async function fT(e){const t=new GLTFScenegraph(e),{json:n}=t;if(n.lights){const e=t.addExtension(uT);lw(!e.lights),e.lights=n.lights,delete n.lights}if(t.json.lights){for(const e of t.json.lights){const n=e.node;t.addObjectExtension(n,uT,e)}delete t.json.lights}}const pT="KHR_materials_unlit",gT=pT;async function mT(e){const t=new GLTFScenegraph(e),{json:n}=t;for(const e of n.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),t.removeObjectExtension(e,pT)}t.removeExtension(pT)}function bT(e){const t=new GLTFScenegraph(e),{json:n}=t;if(t.materials)for(const e of n.materials||[])e.unlit&&(delete e.unlit,t.addObjectExtension(e,pT,{}),t.addExtension(pT))}const _T="KHR_techniques_webgl",vT=_T;async function yT(e){const t=new GLTFScenegraph(e),{json:n}=t,i=t.getExtension(_T);if(i){const e=function(e,t){const{programs:n=[],shaders:i=[],techniques:r=[]}=e,s=new TextDecoder;return i.forEach(e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=s.decode(t.getTypedArrayForBufferView(e.bufferView))}),n.forEach(e=>{e.fragmentShader=i[e.fragmentShader],e.vertexShader=i[e.vertexShader]}),r.forEach(e=>{e.program=n[e.program]}),r}(i,t);for(const i of n.materials||[]){const n=t.getObjectExtension(i,_T);n&&(i.technique=Object.assign({},n,e[n.technique]),i.technique.values=xT(i.technique,t)),t.removeObjectExtension(i,_T)}t.removeExtension(_T)}}async function wT(e,t){}function xT(e,t){const n=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach(t=>{e.uniforms[t].value&&!(t in n)&&(n[t]=e.uniforms[t].value)}),Object.keys(n).forEach(e=>{"object"==typeof n[e]&&void 0!==n[e].index&&(n[e].texture=t.getTexture(n[e].index))}),n}const TT="EXT_feature_metadata",ET=TT;async function ST(e,t){!function(e,t){if(!t.gltf?.loadBuffers)return;const n=e.getExtension(TT);if(!n)return;t.gltf?.loadImages&&function(e,t){const n=t.schema;if(!n)return;const i=n.classes,{featureTextures:r}=t;if(i&&r)for(const t in i){const n=i[t],s=PT(r,t);s&&MT(e,s,n)}}(e,n);!function(e,t){const n=t.schema;if(!n)return;const i=n.classes,r=t.featureTables;if(i&&r)for(const t in i){const i=CT(r,t);i&&RT(e,n,i)}}(e,n)}(new GLTFScenegraph(e),t)}function CT(e,t){for(const n in e){const i=e[n];if(i.class===t)return i}return null}function PT(e,t){for(const n in e){const i=e[n];if(i.class===t)return i}return null}function RT(e,t,n){if(!n.class)return;const i=t.classes?.[n.class];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${n.class}`);const r=n.count;for(const s in i.properties){const o=i.properties[s],a=n.properties?.[s];if(a){const n=LT(e,t,o,r,a);a.data=n}}}function MT(e,t,n){const i=t.class;for(const r in n.properties){const n=t?.properties?.[r];if(n){const t=IT(e,n,i);n.data=t}}}function LT(e,t,n,i,r){let s=[];const o=r.bufferView,a=e.getTypedArrayForBufferView(o),l=function(e,t,n,i){if("ARRAY"===t.type&&void 0===t.componentCount&&void 0!==n.arrayOffsetBufferView)return Dw(e,n.arrayOffsetBufferView,n.offsetType||"UINT32",i);return null}(e,n,r,i),c=function(e,t,n,i){if(void 0!==n.stringOffsetBufferView)return Dw(e,n.stringOffsetBufferView,n.offsetType||"UINT32",i);return null}(e,0,r,i);return"STRING"===n.type||"STRING"===n.componentType?s=Ww(i,a,l,c):function(e){const t=["UINT8","INT16","UINT16","INT32","UINT32","INT64","UINT64","FLOAT32","FLOAT64"];return t.includes(e.type)||void 0!==e.componentType&&t.includes(e.componentType)}(n)&&(s=function(e,t,n,i){const r="ARRAY"===e.type,s=e.componentCount,o="SCALAR",a=e.componentType||e.type,l=Fw(o,a),c=n.byteLength/l,A=Uw(n,o,a,c);if(r)return i?jw(A,t,i,n.length,l):s?Hw(A,t,s):[];return A}(n,i,a,l)),s}function IT(e,t,n){const i=e.gltf.json;if(!i.meshes)return[];const r=[];for(const s of i.meshes)for(const i of s.primitives)OT(e,n,t,r,i);return r}function OT(e,t,n,i,r){const s=Vw(e,{channels:n.channels,...n.texture},r);s&&zw(e,t,s,i,r)}const BT=[s,r,a,o,l,c,A,h,d,f,u,p];function NT(e,t){const n=t?.gltf?.excludeExtensions||{};return!(e in n&&!n[e])}const kT="KHR_binary_glTF";const FT={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},DT={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class GLTFV1Normalizer{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(e,t){this.json=e.json;const n=e.json;switch(n.asset&&n.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return void console.warn(`glTF: Unknown version ${n.asset.version}`)}if(!t.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(n),this._convertTopLevelObjectsToArrays(n),function(e){const t=new GLTFScenegraph(e),{json:n}=t;for(const e of n.images||[]){const n=t.getObjectExtension(e,kT);n&&Object.assign(e,n),t.removeObjectExtension(e,kT)}n.buffers&&n.buffers[0]&&delete n.buffers[0].uri,t.removeExtension(kT)}(e),this._convertObjectIdsToArrayIndices(n),this._updateObjects(n),this._updateMaterial(n)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(const t in FT)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const n=e[t];if(n&&!Array.isArray(n)){e[t]=[];for(const i in n){const r=n[i];r.id=r.id||i;const s=e[t].length;e[t].push(r),this.idToIndexMap[t][i]=s}}}_convertObjectIdsToArrayIndices(e){for(const t in FT)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const t of e.textures)this._convertTextureIds(t);for(const t of e.meshes)this._convertMeshIds(t);for(const t of e.nodes)this._convertNodeIds(t);for(const t of e.scenes)this._convertSceneIds(t)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const t of e.primitives){const{attributes:e,indices:n,material:i}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");n&&(t.indices=this._convertIdToIndex(n,"accessor")),i&&(t.material=this._convertIdToIndex(i,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(e=>this._convertIdToIndex(e,"node"))),e.meshes&&(e.meshes=e.meshes.map(e=>this._convertIdToIndex(e,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(e=>this._convertIdToIndex(e,"node")))}_convertIdsToIndices(e,t){e[t]||(console.warn(`gltf v1: json doesn't contain attribute ${t}`),e[t]=[]);for(const n of e[t])for(const e in n){const t=n[e],i=this._convertIdToIndex(t,e);n[e]=i}}_convertIdToIndex(e,t){const n=DT[t];if(n in this.idToIndexMap){const i=this.idToIndexMap[n][e];if(!Number.isFinite(i))throw new Error(`gltf v1: failed to resolve ${t} with id ${e}`);return i}return e}_updateObjects(e){for(const e of this.json.buffers)delete e.type}_updateMaterial(e){for(const t of e.materials){t.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const n=t.values?.tex||t.values?.texture2d_0||t.values?.diffuseTex,i=e.textures.findIndex(e=>e.id===n);-1!==i&&(t.pbrMetallicRoughness.baseColorTexture={index:i})}}}async function UT(e,t,n=0,i,r){return function(e,t,n,i){i.core?.baseUrl&&(e.baseUri=i.core?.baseUrl);if(t instanceof ArrayBuffer&&!function(e,t=0,n={}){const i=new DataView(e),{magic:r=hw}=n,s=i.getUint32(t,!1);return s===r||s===hw}(t,n,i.glb)){t=(new TextDecoder).decode(t)}if("string"==typeof t)e.json=sy(t);else if(t instanceof ArrayBuffer){const r={};n=pw(r,t,n,i.glb),lw("glTF"===r.type,`Invalid GLB magic string ${r.type}`),e._glb=r,e.json=r.json}else lw(!1,"GLTF: must be ArrayBuffer or string");const r=e.json.buffers||[];if(e.buffers=new Array(r.length).fill(null),e._glb&&e._glb.header.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const s=e.json.images||[];e.images=new Array(s.length).fill({})}(e,t,n,i),function(e,t={}){(new GLTFV1Normalizer).normalize(e,t)}(e,{normalize:i?.gltf?.normalize}),function(e,t={},n){const i=BT.filter(e=>NT(e.name,t));for(const r of i)r.preprocess?.(e,t,n)}(e,i,r),i?.gltf?.loadBuffers&&e.json.buffers&&await async function(e,t,n){const i=e.json.buffers||[];for(let r=0;r<i.length;++r){const s=i[r];if(s.uri){const{fetch:i}=n;lw(i);const o=bw(s.uri,t,n),a=await(n?.fetch?.(o)),l=await(a?.arrayBuffer?.());e.buffers[r]={arrayBuffer:l,byteOffset:0,byteLength:l.byteLength},delete s.uri}else null===e.buffers[r]&&(e.buffers[r]={arrayBuffer:new ArrayBuffer(s.byteLength),byteOffset:0,byteLength:s.byteLength})}}(e,i,r),i?.gltf?.loadImages&&await async function(e,t,n){const i=function(e){const t=new Set,n=e.json.textures||[];for(const e of n)void 0!==e.source&&t.add(e.source);return Array.from(t).sort()}(e),r=e.json.images||[],s=[];for(const o of i)s.push(VT(e,r[o],o,t,n));return await Promise.all(s)}(e,i,r),await async function(e,t={},n){const i=BT.filter(e=>NT(e.name,t));for(const r of i)await(r.decode?.(e,t,n))}(e,i,r),e}async function VT(e,t,n,i,r){let s;if(t.uri&&!t.hasOwnProperty("bufferView")){const e=bw(t.uri,i,r),{fetch:n}=r,o=await n(e);s=await o.arrayBuffer(),t.bufferView={data:s}}if(Number.isFinite(t.bufferView)){const n=Mw(e.json,e.buffers,t.bufferView);s=oy(n.buffer,n.byteOffset,n.byteLength)}lw(s,"glTF image has no data");const o=function(e,t){const n=e.basis,i=n?.format;return{...e,core:{...e.core,mimeType:t},basis:{...n,format:i&&"auto"!==i?i:sw(n?.supportedTextureFormats)}}}(i,t.mimeType);let a=await ay(s,[Ly,aw],o,r);a&&a[0]&&(a={compressed:!0,mipmaps:!1,width:a[0].width,height:a[0].height,data:a[0]}),e.images=e.images||[],e.images[n]=a}const zT={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:"4.4.5",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e,t={},n){const i={...zT.options,...t};i.gltf={...zT.options.gltf,...i.gltf};const r=t?.glb?.byteOffset||0;return await UT({},e,r,i,n)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0}}};const GT={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},jT={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},HT=10240,WT=10241,qT=10242,KT=10243,QT=10497,XT=9729,$T=9986,ZT={magFilter:HT,minFilter:WT,wrapS:qT,wrapT:KT},YT={[HT]:XT,[WT]:$T,[qT]:QT,[KT]:QT};class GLTFPostProcessor{baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(e,t={}){const{json:n,buffers:i=[],images:r=[]}=e,{baseUri:s=""}=e;return lw(n),this.baseUri=s,this.buffers=i,this.images=r,this.jsonUnprocessed=n,this.json=this._resolveTree(e.json,t),this.json}_resolveTree(e,t={}){const n={...e};return this.json=n,e.bufferViews&&(n.bufferViews=e.bufferViews.map((e,t)=>this._resolveBufferView(e,t))),e.images&&(n.images=e.images.map((e,t)=>this._resolveImage(e,t))),e.samplers&&(n.samplers=e.samplers.map((e,t)=>this._resolveSampler(e,t))),e.textures&&(n.textures=e.textures.map((e,t)=>this._resolveTexture(e,t))),e.accessors&&(n.accessors=e.accessors.map((e,t)=>this._resolveAccessor(e,t))),e.materials&&(n.materials=e.materials.map((e,t)=>this._resolveMaterial(e,t))),e.meshes&&(n.meshes=e.meshes.map((e,t)=>this._resolveMesh(e,t))),e.nodes&&(n.nodes=e.nodes.map((e,t)=>this._resolveNode(e,t)),n.nodes=n.nodes.map((e,t)=>this._resolveNodeChildren(e))),e.skins&&(n.skins=e.skins.map((e,t)=>this._resolveSkin(e,t))),e.scenes&&(n.scenes=e.scenes.map((e,t)=>this._resolveScene(e,t))),"number"==typeof this.json.scene&&n.scenes&&(n.scene=n.scenes[this.json.scene]),n}getScene(e){return this._get(this.json.scenes,e)}getNode(e){return this._get(this.json.nodes,e)}getSkin(e){return this._get(this.json.skins,e)}getMesh(e){return this._get(this.json.meshes,e)}getMaterial(e){return this._get(this.json.materials,e)}getAccessor(e){return this._get(this.json.accessors,e)}getCamera(e){return this._get(this.json.cameras,e)}getTexture(e){return this._get(this.json.textures,e)}getSampler(e){return this._get(this.json.samplers,e)}getImage(e){return this._get(this.json.images,e)}getBufferView(e){return this._get(this.json.bufferViews,e)}getBuffer(e){return this._get(this.json.buffers,e)}_get(e,t){if("object"==typeof t)return t;const n=e&&e[t];return n||console.warn(`glTF file error: Could not find ${e}[${t}]`),n}_resolveScene(e,t){return{...e,id:e.id||`scene-${t}`,nodes:(e.nodes||[]).map(e=>this.getNode(e))}}_resolveNode(e,t){const n={...e,id:e?.id||`node-${t}`};return void 0!==e.mesh&&(n.mesh=this.getMesh(e.mesh)),void 0!==e.camera&&(n.camera=this.getCamera(e.camera)),void 0!==e.skin&&(n.skin=this.getSkin(e.skin)),void 0!==e.meshes&&e.meshes.length&&(n.mesh=e.meshes.reduce((e,t)=>{const n=this.getMesh(t);return e.id=n.id,e.primitives=e.primitives.concat(n.primitives),e},{primitives:[]})),n}_resolveNodeChildren(e){return e.children&&(e.children=e.children.map(e=>this.getNode(e))),e}_resolveSkin(e,t){const n="number"==typeof e.inverseBindMatrices?this.getAccessor(e.inverseBindMatrices):void 0;return{...e,id:e.id||`skin-${t}`,inverseBindMatrices:n}}_resolveMesh(e,t){const n={...e,id:e.id||`mesh-${t}`,primitives:[]};return e.primitives&&(n.primitives=e.primitives.map((e,t)=>{const i={...e,attributes:{},indices:void 0,material:void 0},r=e.attributes;for(const e in r)i.attributes[e]=this.getAccessor(r[e]);return void 0!==e.indices&&(i.indices=this.getAccessor(e.indices)),void 0!==e.material&&(i.material=this.getMaterial(e.material)),function(e,t,n){if(2!==e.mode&&6!==e.mode)return e;const i=e.indices?.value,r=e.indices?.count??function(e){const t=Object.values(e.attributes)[0];return lw(t,"glTF primitive must define at least one attribute"),t.count}(e),s=function(e,t){if(!e)return Math.max(0,t-1);let n=0;for(let i=0;i<t;i++)n=Math.max(n,Number(e[i]));return n}(i,r),o=s<=65535?Uint16Array:Uint32Array,a=2===e.mode?function(e,t,n){if(t<2)return new n(0);const i=new n(2*t);for(let n=0;n<t;n++)i[2*n]=eE(e,n),i[2*n+1]=eE(e,(n+1)%t);return i}(i,r,o):function(e,t,n){const i=Math.max(0,t-2),r=new n(3*i);for(let t=0;t<i;t++)r[3*t]=eE(e,0),r[3*t+1]=eE(e,t+1),r[3*t+2]=eE(e,t+2);return r}(i,r,o);return e.mode=2===e.mode?1:4,e.indices={id:`${t}-primitive-${n}-portable-indices`,components:1,bytesPerComponent:o.BYTES_PER_ELEMENT,bytesPerElement:o.BYTES_PER_ELEMENT,componentType:o===Uint16Array?5123:5125,normalized:!1,count:a.length,type:"SCALAR",min:a.length?[JT(a)]:void 0,max:a.length?[s]:void 0,value:a},e}(i,n.id,t)})),n}_resolveMaterial(e,t){const n={...e,id:e.id||`material-${t}`};if(n.normalTexture&&(n.normalTexture={...n.normalTexture},n.normalTexture.texture=this.getTexture(n.normalTexture.index)),n.occlusionTexture&&(n.occlusionTexture={...n.occlusionTexture},n.occlusionTexture.texture=this.getTexture(n.occlusionTexture.index)),n.emissiveTexture&&(n.emissiveTexture={...n.emissiveTexture},n.emissiveTexture.texture=this.getTexture(n.emissiveTexture.index)),n.emissiveFactor||(n.emissiveFactor=n.emissiveTexture?[1,1,1]:[0,0,0]),n.pbrMetallicRoughness){n.pbrMetallicRoughness={...n.pbrMetallicRoughness};const e=n.pbrMetallicRoughness;e.baseColorTexture&&(e.baseColorTexture={...e.baseColorTexture},e.baseColorTexture.texture=this.getTexture(e.baseColorTexture.index)),e.metallicRoughnessTexture&&(e.metallicRoughnessTexture={...e.metallicRoughnessTexture},e.metallicRoughnessTexture.texture=this.getTexture(e.metallicRoughnessTexture.index))}return n}_resolveAccessor(e,t){const n=(i=e.componentType,jT[i]);var i;const r=(s=e.type,GT[s]);var s;const o=n*r,a={...e,id:e.id||`accessor-${t}`,bytesPerComponent:n,components:r,bytesPerElement:o,value:void 0,bufferView:void 0,sparse:void 0};if(void 0!==e.bufferView&&(a.bufferView=this.getBufferView(e.bufferView)),a.bufferView){const e=a.bufferView.buffer,{ArrayType:t,byteLength:n}=Rw(a,a.bufferView),i=(a.bufferView.byteOffset||0)+(a.byteOffset||0)+e.byteOffset;let r=Iw(e.arrayBuffer,i,n);a.bufferView.byteStride&&(r=this._getValueFromInterleavedBuffer(e,i,a.bufferView.byteStride,a.bytesPerElement,a.count)),a.value=new t(r)}else{const{ArrayType:e}=Rw(a,{byteLength:a.count*a.bytesPerElement});a.value=new e(a.count*a.components)}return e.sparse&&this._applySparseAccessor(a,e.sparse),a}_applySparseAccessor(e,t){const n=function(e){switch(e){case 5121:return Uint8Array;case 5123:return Uint16Array;case 5125:return Uint32Array;default:throw new Error(`Invalid glTF sparse index component type ${e}`)}}(t.indices.componentType),i=this._getTypedArrayFromBufferView(n,this.getBufferView(t.indices.bufferView),t.indices.byteOffset||0,t.count),r=e.value.constructor,s=this._getTypedArrayFromBufferView(r,this.getBufferView(t.values.bufferView),t.values.byteOffset||0,t.count*e.components);for(let n=0;n<t.count;n++){const t=Number(i[n]);lw(Number.isInteger(t)&&t>=0&&t<e.count,"glTF sparse accessor index is out of bounds");for(let i=0;i<e.components;i++){const r=t*e.components+i,o=n*e.components+i;Reflect.set(e.value,r,s[o])}}}_getTypedArrayFromBufferView(e,t,n,i){const r=i*e.BYTES_PER_ELEMENT;lw(n+r<=t.byteLength,"glTF sparse accessor data exceeds its buffer view");const s=t.buffer,o=s.byteOffset+(t.byteOffset||0)+n;return new e(Iw(s.arrayBuffer,o,r))}_getValueFromInterleavedBuffer(e,t,n,i,r){const s=new Uint8Array(r*i);for(let o=0;o<r;o++){const r=t+o*n;s.set(new Uint8Array(e.arrayBuffer.slice(r,r+i)),o*i)}return s.buffer}_resolveTexture(e,t){return{...e,id:e.id||`texture-${t}`,sampler:"number"==typeof e.sampler?this.getSampler(e.sampler):{id:"default-sampler",parameters:YT},source:"number"==typeof e.source?this.getImage(e.source):void 0}}_resolveSampler(e,t){const n={id:e.id||`sampler-${t}`,...e,parameters:{}};for(const e in n){const t=this._enumSamplerParameter(e);void 0!==t&&(n.parameters[t]=n[e])}return n}_enumSamplerParameter(e){return ZT[e]}_resolveImage(e,t){const n={...e,id:e.id||`image-${t}`,image:null,bufferView:void 0!==e.bufferView?this.getBufferView(e.bufferView):void 0},i=this.images[t];return i&&(n.image=i),n}_resolveBufferView(e,t){const n=e.buffer,i=this.buffers[n].arrayBuffer;let r=this.buffers[n].byteOffset||0;e.byteOffset&&(r+=e.byteOffset);return{id:`bufferView-${t}`,...e,buffer:this.buffers[n],data:new Uint8Array(i,r,e.byteLength)}}_resolveCamera(e,t){const n={...e,id:e.id||`camera-${t}`};return n.perspective,n.orthographic,n}}function JT(e){let t=1/0;for(const n of e)t=Math.min(t,n);return t}function eE(e,t){return e?Number(e[t]):t}async function tE(e){const t=[];return e.scenes.forEach(e=>{e.traverse(e=>{})}),await async function(e){for(;e();)await new Promise(e=>requestAnimationFrame(e))}(()=>t.some(e=>!e.loaded))}const nE=Math.PI/180,iE=new Float32Array(16),rE=new Float32Array(12);function sE(e,t,n){const i=t[0]*nE,r=t[1]*nE,s=t[2]*nE,o=Math.sin(s),a=Math.sin(i),l=Math.sin(r),c=Math.cos(s),A=Math.cos(i),u=Math.cos(r),h=n[0],d=n[1],f=n[2];e[0]=h*u*A,e[1]=h*l*A,e[2]=h*-a,e[3]=d*(-l*c+u*a*o),e[4]=d*(u*c+l*a*o),e[5]=d*A*o,e[6]=f*(l*o+u*a*c),e[7]=f*(-u*o+l*a*c),e[8]=f*A*c}function oE(e){return e[0]=e[0],e[1]=e[1],e[2]=e[2],e[3]=e[4],e[4]=e[5],e[5]=e[6],e[6]=e[8],e[7]=e[9],e[8]=e[10],e[9]=e[12],e[10]=e[13],e[11]=e[14],e.subarray(0,12)}const aE={size:12,accessor:["getOrientation","getScale","getTranslation","getTransformMatrix"],shaderAttributes:{instanceModelMatrixCol0:{size:3,elementOffset:0},instanceModelMatrixCol1:{size:3,elementOffset:3},instanceModelMatrixCol2:{size:3,elementOffset:6},instanceTranslation:{size:3,elementOffset:9}},update(e,{startRow:t,endRow:n}){const{data:i,getOrientation:r,getScale:s,getTranslation:o,getTransformMatrix:a}=this.props,l=Array.isArray(a),c=l&&16===a.length,A=Array.isArray(s),u=Array.isArray(r),h=Array.isArray(o),d=c||!l&&Boolean(a(i[0]));e.constant=d?c:u&&A&&h;const f=e.value;if(e.constant){let t;if(d)iE.set(a),t=oE(iE);else{t=rE;sE(t,r,s),t.set(o,9)}e.value=new Float32Array(t)}else{let l=t*e.size;const{iterable:p,objectInfo:g}=br(i,t,n);for(const e of p){let t;if(g.index++,d)iE.set(c?a:a(e,g)),t=oE(iE);else{t=rE;sE(t,u?r:r(e,g),A?s:s(e,g)),t.set(h?o:o(e,g),9)}f[l++]=t[0],f[l++]=t[1],f[l++]=t[2],f[l++]=t[3],f[l++]=t[4],f[l++]=t[5],f[l++]=t[6],f[l++]=t[7],f[l++]=t[8],f[l++]=t[9],f[l++]=t[10],f[l++]=t[11]}}}};function lE(e,t){return"cartesian"===t||"meter-offsets"===t||"default"===t&&!e.isGeospatial}const cE="layout(std140) uniform scenegraphUniforms {\n float sizeScale;\n float sizeMinPixels;\n float sizeMaxPixels;\n mat4 sceneModelMatrix;\n bool composeModelMatrix;\n} scenegraph;\n",AE={name:"scenegraph",vs:cE,fs:cE,uniformTypes:{sizeScale:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",sceneModelMatrix:"mat4x4<f32>",composeModelMatrix:"f32"}},uE=[255,255,255,255],hE={scenegraph:{type:"object",value:null,async:!0},getScene:e=>e&&e.scenes?"object"==typeof e.scene?e.scene:e.scenes[e.scene||0]:e,getAnimator:e=>e&&e.animator,_animations:null,onFirstDraw:{type:"function",value:()=>{}},sizeScale:{type:"number",value:1,min:0},sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},getPosition:{type:"accessor",value:e=>e.position},getColor:{type:"accessor",value:uE},_lighting:"flat",_imageBasedLightingEnvironment:void 0,getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},loaders:[zT]};class ScenegraphLayer extends Ts{getShaders(){const e={};let t;"pbr"===this.props._lighting?(t=W_,e.LIGHTING_PBR=1):t={name:"pbrMaterial"};const n=[Xs,Qs,AE,t];return super.getShaders({defines:e,vs:"#version 300 es\n#define SHADER_NAME scenegraph-layer-vertex-shader\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec3 instanceModelMatrixCol0;\nin vec3 instanceModelMatrixCol1;\nin vec3 instanceModelMatrixCol2;\nin vec3 instanceTranslation;\nin vec3 positions;\n#ifdef HAS_UV\nin vec2 texCoords;\n#endif\n#ifdef LIGHTING_PBR\n#ifdef HAS_NORMALS\nin vec3 normals;\n#endif\n#endif\nout vec4 vColor;\n#ifndef LIGHTING_PBR\n#ifdef HAS_UV\nout vec2 vTEXCOORD_0;\n#endif\n#endif\nvoid main(void) {\n#if defined(HAS_UV) && !defined(LIGHTING_PBR)\nvTEXCOORD_0 = texCoords;\ngeometry.uv = texCoords;\n#endif\ngeometry.worldPosition = instancePositions;\ngeometry.pickingColor = instancePickingColors;\nmat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);\nvec3 normal = vec3(0.0, 0.0, 1.0);\n#ifdef LIGHTING_PBR\n#ifdef HAS_NORMALS\nnormal = instanceModelMatrix * (scenegraph.sceneModelMatrix * vec4(normals, 0.0)).xyz;\n#endif\n#endif\nfloat originalSize = project_size_to_pixel(scenegraph.sizeScale);\nfloat clampedSize = clamp(originalSize, scenegraph.sizeMinPixels, scenegraph.sizeMaxPixels);\nvec3 pos = (instanceModelMatrix * (scenegraph.sceneModelMatrix * vec4(positions, 1.0)).xyz) * scenegraph.sizeScale * (clampedSize / originalSize) + instanceTranslation;\nif(scenegraph.composeModelMatrix) {\nDECKGL_FILTER_SIZE(pos, geometry);\ngeometry.normal = project_normal(normal);\ngeometry.worldPosition += pos;\ngl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\n}\nelse {\npos = project_size(pos);\nDECKGL_FILTER_SIZE(pos, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, geometry.position);\ngeometry.normal = project_normal(normal);\n}\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n#ifdef LIGHTING_PBR\npbr_vPosition = geometry.position.xyz;\n#ifdef HAS_NORMALS\npbr_vNormal = geometry.normal;\n#endif\n#ifdef HAS_UV\npbr_vUV0 = texCoords;\n#else\npbr_vUV0 = vec2(0., 0.);\n#endif\npbr_vUV1 = vec2(0., 0.);\ngeometry.uv = pbr_vUV0;\n#endif\nvColor = instanceColors;\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME scenegraph-layer-fragment-shader\nin vec4 vColor;\nout vec4 fragColor;\n#ifndef LIGHTING_PBR\n#if defined(HAS_UV) && defined(HAS_BASECOLORMAP)\nin vec2 vTEXCOORD_0;\nuniform sampler2D pbr_baseColorSampler;\n#endif\n#endif\nvoid main(void) {\n#ifdef LIGHTING_PBR\nfragColor = vColor * pbr_filterColor(vec4(0));\ngeometry.uv = pbr_vUV0;\n#else\n#if defined(HAS_UV) && defined(HAS_BASECOLORMAP)\nfragColor = vColor * texture(pbr_baseColorSampler, vTEXCOORD_0);\ngeometry.uv = vTEXCOORD_0;\n#else\nfragColor = vColor;\n#endif\n#endif\nfragColor.a *= layer.opacity;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:n})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),accessor:"getPosition",transition:!0},instanceColors:{type:"unorm8",size:this.props.colorFormat.length,accessor:"getColor",defaultValue:uE,transition:!0},instanceModelMatrix:aE})}updateState(e){super.updateState(e);const{props:t,oldProps:n}=e;t.scenegraph!==n.scenegraph?this._updateScenegraph():t._animations!==n._animations&&this._applyAnimationsProp(this.state.animator,t._animations)}finalizeState(e){super.finalizeState(e),this._destroyScenegraphAssets()}get isLoaded(){return Boolean(this.state?.scenegraph&&super.isLoaded)}_updateScenegraph(){const e=this.props,{device:t}=this.context;let n=null;if(e.scenegraph instanceof ScenegraphNode)n={scenes:[e.scenegraph]};else if(e.scenegraph&&"object"==typeof e.scenegraph){const i=e.scenegraph,r=i.json?function(e,t){return(new GLTFPostProcessor).postProcess(e,t)}(i):i,s=ny(t,r,this._getModelOptions());n=s,tE(s).then(()=>this.setNeedsRedraw()).catch(e=>{this.raiseError(e,"loading glTF")})}const i={layer:this,device:this.context.device},r=e.getScene(n,i),s=e.getAnimator(n,i);if(r instanceof GroupNode){this._destroyScenegraphAssets(),this._applyAnimationsProp(s,e._animations);const t=[];r.traverse(e=>{e instanceof ModelNode&&t.push(e.model)}),this.setState({scenegraph:r,animator:s,materials:n?.materials||null,models:t,firstDrawSignaled:!1}),this.getAttributeManager().invalidateAll()}else null!==r&&Ie.A.warn("invalid scenegraph:",r)()}_destroyScenegraphAssets(){this.state.scenegraph?.destroy(),this.state.materials?.forEach(e=>e.destroy()),this.state.scenegraph=null,this.state.animator=null,this.state.materials=null,this.state.models=[]}_applyAnimationsProp(e,t){if(!e||!t)return;const n=e.getAnimations();Object.keys(t).sort().forEach(e=>{const i=t[e];if("*"===e)n.forEach(e=>{Object.assign(e,i)});else if(Number.isFinite(Number(e))){const t=Number(e);t>=0&&t<n.length?Object.assign(n[t],i):Ie.A.warn(`animation ${e} not found`)()}else{const t=n.find(({animation:t})=>t.name===e);t?Object.assign(t,i):Ie.A.warn(`animation ${e} not found`)()}})}_getModelOptions(){const{_imageBasedLightingEnvironment:e}=this.props;let t;return e&&(t="function"==typeof e?e({gl:this.context.gl,layer:this}):e),{imageBasedLightingEnvironment:t,modelOptions:{id:this.props.id,isInstanced:!0,bufferLayout:this.getAttributeManager().getBufferLayouts(),...this.getShaders()},useTangents:!1}}draw({context:e}){if(!this.state.scenegraph)return;this.props._animations&&this.state.animator&&(this.state.animator.setTime(e.timeline.getTime()),this.setNeedsRedraw());const{viewport:t,renderPass:n}=this.context,{sizeScale:i,sizeMinPixels:r,sizeMaxPixels:s,coordinateSystem:o}=this.props,a={camera:t.cameraPosition},l=this.getNumInstances();this.state.scenegraph.traverse((e,{worldMatrix:c})=>{if(e instanceof ModelNode){const{model:A}=e;A.setInstanceCount(l);const u={sizeScale:i,sizeMinPixels:r,sizeMaxPixels:s,composeModelMatrix:lE(t,o),sceneModelMatrix:c};A.shaderInputs.setProps({pbrProjection:a,scenegraph:u}),A.draw(n)}}),this.state.firstDrawSignaled||(this.state.firstDrawSignaled=!0,this.props.onFirstDraw?.())}}ScenegraphLayer.defaultProps=hE,ScenegraphLayer.layerName="ScenegraphLayer";const dE=ScenegraphLayer;var fE;function pE(e){return{addressModeU:gE(e.wrapS),addressModeV:gE(e.wrapT),magFilter:mE(e.magFilter),...bE(e.minFilter)}}function gE(e){switch(e){case fE.CLAMP_TO_EDGE:return"clamp-to-edge";case fE.REPEAT:return"repeat";case fE.MIRRORED_REPEAT:return"mirror-repeat";default:return}}function mE(e){switch(e){case fE.NEAREST:return"nearest";case fE.LINEAR:return"linear";default:return}}function bE(e){switch(e){case fE.NEAREST:return{minFilter:"nearest"};case fE.LINEAR:return{minFilter:"linear"};case fE.NEAREST_MIPMAP_NEAREST:return{minFilter:"nearest",mipmapFilter:"nearest"};case fE.LINEAR_MIPMAP_NEAREST:return{minFilter:"linear",mipmapFilter:"nearest"};case fE.NEAREST_MIPMAP_LINEAR:return{minFilter:"nearest",mipmapFilter:"linear"};case fE.LINEAR_MIPMAP_LINEAR:return{minFilter:"linear",mipmapFilter:"linear"};default:return{}}}!function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ONE=1]="ONE",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST=9728]="NEAREST",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"}(fE||(fE={}));const _E=[yE("baseColor","pbr_baseColorSampler","baseColorTexture",["pbrMetallicRoughness","baseColorTexture"]),yE("metallicRoughness","pbr_metallicRoughnessSampler","metallicRoughnessTexture",["pbrMetallicRoughness","metallicRoughnessTexture"]),yE("normal","pbr_normalSampler","normalTexture",["normalTexture"]),yE("occlusion","pbr_occlusionSampler","occlusionTexture",["occlusionTexture"]),yE("emissive","pbr_emissiveSampler","emissiveTexture",["emissiveTexture"]),yE("specularColor","pbr_specularColorSampler","KHR_materials_specular.specularColorTexture",["extensions","KHR_materials_specular","specularColorTexture"]),yE("specularIntensity","pbr_specularIntensitySampler","KHR_materials_specular.specularTexture",["extensions","KHR_materials_specular","specularTexture"]),yE("transmission","pbr_transmissionSampler","KHR_materials_transmission.transmissionTexture",["extensions","KHR_materials_transmission","transmissionTexture"]),yE("thickness","pbr_thicknessSampler","KHR_materials_volume.thicknessTexture",["extensions","KHR_materials_volume","thicknessTexture"]),yE("clearcoat","pbr_clearcoatSampler","KHR_materials_clearcoat.clearcoatTexture",["extensions","KHR_materials_clearcoat","clearcoatTexture"]),yE("clearcoatRoughness","pbr_clearcoatRoughnessSampler","KHR_materials_clearcoat.clearcoatRoughnessTexture",["extensions","KHR_materials_clearcoat","clearcoatRoughnessTexture"]),yE("clearcoatNormal","pbr_clearcoatNormalSampler","KHR_materials_clearcoat.clearcoatNormalTexture",["extensions","KHR_materials_clearcoat","clearcoatNormalTexture"]),yE("sheenColor","pbr_sheenColorSampler","KHR_materials_sheen.sheenColorTexture",["extensions","KHR_materials_sheen","sheenColorTexture"]),yE("sheenRoughness","pbr_sheenRoughnessSampler","KHR_materials_sheen.sheenRoughnessTexture",["extensions","KHR_materials_sheen","sheenRoughnessTexture"]),yE("iridescence","pbr_iridescenceSampler","KHR_materials_iridescence.iridescenceTexture",["extensions","KHR_materials_iridescence","iridescenceTexture"]),yE("iridescenceThickness","pbr_iridescenceThicknessSampler","KHR_materials_iridescence.iridescenceThicknessTexture",["extensions","KHR_materials_iridescence","iridescenceThicknessTexture"]),yE("anisotropy","pbr_anisotropySampler","KHR_materials_anisotropy.anisotropyTexture",["extensions","KHR_materials_anisotropy","anisotropyTexture"])],vE=new Map(_E.map(e=>[e.slot,e]));function yE(e,t,n,i){return{slot:e,binding:t,displayName:n,pathSegments:i,uvSetUniform:`${e}UVSet`,uvTransformUniform:`${e}UVTransform`}}function wE(e){const t=e?.extensions?.KHR_texture_transform;return t?.texCoord??e?.texCoord??0}function xE(e){const t=(new Matrix3).set(1,0,0,0,1,0,e.offset[0],e.offset[1],1),n=(new Matrix3).set(Math.cos(e.rotation),Math.sin(e.rotation),0,-Math.sin(e.rotation),Math.cos(e.rotation),0,0,0,1),i=(new Matrix3).set(e.scale[0],0,0,0,e.scale[1],0,0,0,1);return Array.from(t.multiplyRight(n).multiplyRight(i))}function TE(e,t,n,i){const r={defines:{MANUAL_SRGB:!0,SRGB_FAST_APPROXIMATION:!0},bindings:{},uniforms:{camera:[0,0,0],metallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};r.defines.USE_TEX_LOD=!0;const{imageBasedLightingEnvironment:s}=i;return s&&(r.bindings.pbr_diffuseEnvSampler=s.diffuseEnvSampler.texture,r.bindings.pbr_specularEnvSampler=s.specularEnvSampler.texture,r.bindings.pbr_brdfLUT=s.brdfLutTexture.texture,r.uniforms.IBLenabled=!0,r.uniforms.scaleIBLAmbient=[1,1]),i?.pbrDebug&&(r.defines.PBR_DEBUG=!0,r.uniforms.scaleDiffBaseMR=[0,0,0,0],r.uniforms.scaleFGDSpec=[0,0,0,0]),n.NORMAL&&(r.defines.HAS_NORMALS=!0),n.TANGENT&&i?.useTangents&&(r.defines.HAS_TANGENTS=!0),n.TEXCOORD_0&&(r.defines.HAS_UV=!0),n.TEXCOORD_1&&(r.defines.HAS_UV_1=!0),n.JOINTS_0&&n.WEIGHTS_0&&(r.defines.HAS_SKIN=!0),n.COLOR_0&&(r.defines.HAS_COLORS=!0),i?.imageBasedLightingEnvironment&&(r.defines.USE_IBL=!0),i?.lights&&(r.defines.USE_LIGHTS=!0),t&&(!1!==i.validateAttributes&&function(e,t){const n=EE(e,0);n.length>0&&!t.TEXCOORD_0&&Hi.R.warn(`glTF material uses ${n.join(", ")} but primitive is missing TEXCOORD_0; textured shading will sample the default UV coordinates`)();const i=EE(e,1);i.length>0&&!t.TEXCOORD_1&&Hi.R.warn(`glTF material uses ${i.join(", ")} with TEXCOORD_1 but primitive is missing TEXCOORD_1; those textures will be skipped`)();const r=Boolean(e.unlit||e.extensions?.KHR_materials_unlit);if(r||t.NORMAL)return;const s=e.normalTexture?"lit PBR shading with normalTexture":"lit PBR shading";Hi.R.warn(`glTF primitive is missing NORMAL while using ${s}; shading will fall back to geometric normals`)()}(t,n),function(e,t,n,i,r){n.uniforms.unlit=Boolean(t.unlit||t.extensions?.KHR_materials_unlit),t.pbrMetallicRoughness&&function(e,t,n,i,r){t.baseColorTexture&&CE(e,t.baseColorTexture,"pbr_baseColorSampler",n,{featureOptions:{define:"HAS_BASECOLORMAP",enabledUniformName:"baseColorMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"baseColor"});n.uniforms.baseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&CE(e,t.metallicRoughnessTexture,"pbr_metallicRoughnessSampler",n,{featureOptions:{define:"HAS_METALROUGHNESSMAP",enabledUniformName:"metallicRoughnessMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"metallicRoughness"});const{metallicFactor:s=1,roughnessFactor:o=1}=t;n.uniforms.metallicRoughnessValues=[s,o]}(e,t.pbrMetallicRoughness,n,i,r);if(t.normalTexture){CE(e,t.normalTexture,"pbr_normalSampler",n,{featureOptions:{define:"HAS_NORMALMAP",enabledUniformName:"normalMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"normal"});const{scale:s=1}=t.normalTexture;n.uniforms.normalScale=s}if(t.occlusionTexture){CE(e,t.occlusionTexture,"pbr_occlusionSampler",n,{featureOptions:{define:"HAS_OCCLUSIONMAP",enabledUniformName:"occlusionMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"occlusion"});const{strength:s=1}=t.occlusionTexture;n.uniforms.occlusionStrength=s}n.uniforms.emissiveFactor=t.emissiveFactor||[0,0,0],t.emissiveTexture&&CE(e,t.emissiveTexture,"pbr_emissiveSampler",n,{featureOptions:{define:"HAS_EMISSIVEMAP",enabledUniformName:"emissiveMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"emissive"});switch(function(e,t,n,i,r={}){if(!t)return;(function(e){return Boolean(e.KHR_materials_specular||e.KHR_materials_ior||e.KHR_materials_transmission||e.KHR_materials_volume||e.KHR_materials_clearcoat||e.KHR_materials_sheen||e.KHR_materials_iridescence||e.KHR_materials_anisotropy)})(t)&&(n.defines.USE_MATERIAL_EXTENSIONS=!0);(function(e,t,n,i,r={}){if(!t)return;t.specularColorFactor&&(n.uniforms.specularColorFactor=t.specularColorFactor);void 0!==t.specularFactor&&(n.uniforms.specularIntensityFactor=t.specularFactor);t.specularColorTexture&&CE(e,t.specularColorTexture,"pbr_specularColorSampler",n,{featureOptions:{define:"HAS_SPECULARCOLORMAP",enabledUniformName:"specularColorMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"specularColor"});t.specularTexture&&CE(e,t.specularTexture,"pbr_specularIntensitySampler",n,{featureOptions:{define:"HAS_SPECULARINTENSITYMAP",enabledUniformName:"specularIntensityMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"specularIntensity"})})(e,t.KHR_materials_specular,n,i,r),function(e,t){void 0!==e?.ior&&(t.uniforms.ior=e.ior)}(t.KHR_materials_ior,n),function(e,t,n,i,r={}){if(!t)return;void 0!==t.transmissionFactor&&(n.uniforms.transmissionFactor=t.transmissionFactor);t.transmissionTexture&&CE(e,t.transmissionTexture,"pbr_transmissionSampler",n,{featureOptions:{define:"HAS_TRANSMISSIONMAP",enabledUniformName:"transmissionMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"transmission"});((t.transmissionFactor??0)>0||t.transmissionTexture)&&(Hi.R.warn("KHR_materials_transmission uses a premultiplied-alpha blending approximation and may require mesh sorting")(),function(e){e.parameters.blend=!0,e.parameters.depthWriteEnabled=!1,e.parameters.blendColorOperation="add",e.parameters.blendColorSrcFactor="one",e.parameters.blendColorDstFactor="one-minus-src-alpha",e.parameters.blendAlphaOperation="add",e.parameters.blendAlphaSrcFactor="one",e.parameters.blendAlphaDstFactor="one-minus-src-alpha",e.glParameters.blend=!0,e.glParameters.depthMask=!1,e.glParameters.blendEquation=fE.FUNC_ADD,e.glParameters.blendFunc=[fE.ONE,fE.ONE_MINUS_SRC_ALPHA,fE.ONE,fE.ONE_MINUS_SRC_ALPHA]}(n))}(e,t.KHR_materials_transmission,n,i,r),function(e,t,n,i,r={}){if(!t)return;void 0!==t.thicknessFactor&&(n.uniforms.thicknessFactor=t.thicknessFactor);t.thicknessTexture&&CE(e,t.thicknessTexture,"pbr_thicknessSampler",n,{featureOptions:{define:"HAS_THICKNESSMAP"},gltf:i,attributes:r,textureTransformSlot:"thickness"});void 0!==t.attenuationDistance&&(n.uniforms.attenuationDistance=t.attenuationDistance);t.attenuationColor&&(n.uniforms.attenuationColor=t.attenuationColor)}(e,t.KHR_materials_volume,n,i,r),function(e,t,n,i,r={}){if(!t)return;void 0!==t.clearcoatFactor&&(n.uniforms.clearcoatFactor=t.clearcoatFactor);void 0!==t.clearcoatRoughnessFactor&&(n.uniforms.clearcoatRoughnessFactor=t.clearcoatRoughnessFactor);t.clearcoatTexture&&CE(e,t.clearcoatTexture,"pbr_clearcoatSampler",n,{featureOptions:{define:"HAS_CLEARCOATMAP",enabledUniformName:"clearcoatMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"clearcoat"});t.clearcoatRoughnessTexture&&CE(e,t.clearcoatRoughnessTexture,"pbr_clearcoatRoughnessSampler",n,{featureOptions:{define:"HAS_CLEARCOATROUGHNESSMAP",enabledUniformName:"clearcoatRoughnessMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"clearcoatRoughness"});t.clearcoatNormalTexture&&CE(e,t.clearcoatNormalTexture,"pbr_clearcoatNormalSampler",n,{featureOptions:{define:"HAS_CLEARCOATNORMALMAP"},gltf:i,attributes:r,textureTransformSlot:"clearcoatNormal"})}(e,t.KHR_materials_clearcoat,n,i,r),function(e,t,n,i,r={}){if(!t)return;t.sheenColorFactor&&(n.uniforms.sheenColorFactor=t.sheenColorFactor);void 0!==t.sheenRoughnessFactor&&(n.uniforms.sheenRoughnessFactor=t.sheenRoughnessFactor);t.sheenColorTexture&&CE(e,t.sheenColorTexture,"pbr_sheenColorSampler",n,{featureOptions:{define:"HAS_SHEENCOLORMAP",enabledUniformName:"sheenColorMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"sheenColor"});t.sheenRoughnessTexture&&CE(e,t.sheenRoughnessTexture,"pbr_sheenRoughnessSampler",n,{featureOptions:{define:"HAS_SHEENROUGHNESSMAP",enabledUniformName:"sheenRoughnessMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"sheenRoughness"})}(e,t.KHR_materials_sheen,n,i,r),function(e,t,n,i,r={}){if(!t)return;void 0!==t.iridescenceFactor&&(n.uniforms.iridescenceFactor=t.iridescenceFactor);void 0!==t.iridescenceIor&&(n.uniforms.iridescenceIor=t.iridescenceIor);void 0===t.iridescenceThicknessMinimum&&void 0===t.iridescenceThicknessMaximum||(n.uniforms.iridescenceThicknessRange=[t.iridescenceThicknessMinimum??100,t.iridescenceThicknessMaximum??400]);t.iridescenceTexture&&CE(e,t.iridescenceTexture,"pbr_iridescenceSampler",n,{featureOptions:{define:"HAS_IRIDESCENCEMAP",enabledUniformName:"iridescenceMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"iridescence"});t.iridescenceThicknessTexture&&CE(e,t.iridescenceThicknessTexture,"pbr_iridescenceThicknessSampler",n,{featureOptions:{define:"HAS_IRIDESCENCETHICKNESSMAP"},gltf:i,attributes:r,textureTransformSlot:"iridescenceThickness"})}(e,t.KHR_materials_iridescence,n,i,r),function(e,t,n,i,r={}){if(!t)return;void 0!==t.anisotropyStrength&&(n.uniforms.anisotropyStrength=t.anisotropyStrength);void 0!==t.anisotropyRotation&&(n.uniforms.anisotropyRotation=t.anisotropyRotation);t.anisotropyTexture&&CE(e,t.anisotropyTexture,"pbr_anisotropySampler",n,{featureOptions:{define:"HAS_ANISOTROPYMAP",enabledUniformName:"anisotropyMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"anisotropy"})}(e,t.KHR_materials_anisotropy,n,i,r),function(e,t){void 0!==e?.emissiveStrength&&(t.uniforms.emissiveStrength=e.emissiveStrength)}(t.KHR_materials_emissive_strength,n)}(e,t.extensions,n,r,i),t.alphaMode||"OPAQUE"){case"OPAQUE":break;case"MASK":{const{alphaCutoff:e=.5}=t;n.defines.ALPHA_CUTOFF=!0,n.uniforms.alphaCutoffEnabled=!0,n.uniforms.alphaCutoff=e;break}case"BLEND":Hi.R.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),function(e){e.parameters.blend=!0,e.parameters.blendColorOperation="add",e.parameters.blendColorSrcFactor="src-alpha",e.parameters.blendColorDstFactor="one-minus-src-alpha",e.parameters.blendAlphaOperation="add",e.parameters.blendAlphaSrcFactor="one",e.parameters.blendAlphaDstFactor="one-minus-src-alpha",e.glParameters.blend=!0,e.glParameters.blendEquation=fE.FUNC_ADD,e.glParameters.blendFunc=[fE.SRC_ALPHA,fE.ONE_MINUS_SRC_ALPHA,fE.ONE,fE.ONE_MINUS_SRC_ALPHA]}(n)}}(e,t,r,n,i.gltf)),r}function EE(e,t){const n=[];for(const i of _E){const r=SE(e,i.pathSegments);r&&(wE(r)===t&&n.push(i.displayName))}return n}function SE(e,t){let n=e;for(const e of t)if(n=n?.[e],!n)return null;return n}function CE(e,t,n,i,r={}){const{featureOptions:s={},gltf:o,attributes:a={},textureTransformSlot:l}=r,{define:c,enabledUniformName:A}=s,u=wE(t);if(u>1)return void Hi.R.warn(`Skipping ${String(n)} because ${u} is not supported; only TEXCOORD_0 and TEXCOORD_1 are currently available`)();if(1===u&&!a.TEXCOORD_1)return void Hi.R.warn(`Skipping ${String(n)} because it requires TEXCOORD_1 but the primitive does not provide TEXCOORD_1`)();const h=function(e,t){if(e.texture||void 0===e.index||!t?.textures)return e;const n=t.textures[e.index];if(!n)return e;if("texture"in n&&n.texture)return{...n,...e,texture:n.texture};if(!("source"in n))return e;return{...e,texture:n}}(t,o),d=h.texture?.source?.image;if(!d)return void Hi.R.warn(`Skipping unresolved glTF texture for ${String(n)}`)();const f={wrapS:10497,wrapT:10497,minFilter:9729,magFilter:9729,...h?.texture?.sampler},p={id:h.uniformName||h.id,sampler:pE(f)};let g;if(d.compressed)g=function(e,t,n){let i;i=Array.isArray(t.data)&&t.data[0]?.data?t.data:"mipmaps"in t&&Array.isArray(t.mipmaps)?t.mipmaps:[];if(0===i.length||!i[0]?.data)return Hi.R.warn("createCompressedTexture: compressed image has no valid mip levels, creating fallback")(),PE(e,n);const r=i[0],s=r.width??t.width??0,o=r.height??t.height??0;if(s<=0||o<=0)return Hi.R.warn("createCompressedTexture: base level has invalid dimensions, creating fallback")(),PE(e,n);const a=RE(r);if(!a)return Hi.R.warn("createCompressedTexture: compressed image has no textureFormat, creating fallback")(),PE(e,n);const l=function(e,t,n){const{blockWidth:i=1,blockHeight:r=1}=sv.vz.getInfo(n);let s=1;for(let n=1;;n++){const o=Math.max(1,e>>n),a=Math.max(1,t>>n);if(o<i||a<r)break;s++}return s}(s,o,a),c=Math.min(i.length,l);let A=1;for(let e=1;e<c;e++){const t=i[e];if(!t.data||t.width<=0||t.height<=0){Hi.R.warn(`createCompressedTexture: mip level ${e} has invalid data/dimensions, truncating`)();break}const n=RE(t);if(n&&n!==a){Hi.R.warn(`createCompressedTexture: mip level ${e} format '${n}' differs from base '${a}', truncating`)();break}const r=Math.max(1,s>>e),l=Math.max(1,o>>e);if(t.width!==r||t.height!==l){Hi.R.warn(`createCompressedTexture: mip level ${e} dimensions ${t.width}x${t.height} don't match expected ${r}x${l}, truncating`)();break}A++}const u=e.createTexture({...n,format:a,usage:Pi.g.TEXTURE|Pi.g.COPY_DST,width:s,height:o,mipLevels:A,data:r.data});for(let e=1;e<A;e++)u.writeData(i[e].data,{width:i[e].width,height:i[e].height,mipLevel:e});return u}(e,d,p);else{const{width:t,height:n}=e.getExternalImageSize(d);g=e.createTexture({...p,width:t,height:n,data:d})}if(i.bindings[n]=g,c&&(i.defines[c]=!0),A&&(i.uniforms[A]=!0),l){const e=function(e){const t=vE.get(e);if(!t)throw new Error(`Unknown PBR texture transform slot ${e}`);return t}(l);i.uniforms[e.uvSetUniform]=u,i.uniforms[e.uvTransformUniform]=xE(function(e){const t=e?.extensions?.KHR_texture_transform;return{offset:t?.offset?[t.offset[0],t.offset[1]]:[0,0],rotation:t?.rotation??0,scale:t?.scale?[t.scale[0],t.scale[1]]:[1,1]}}(t))}i.generatedTextures.push(g)}function PE(e,t){return e.createTexture({...t,format:"rgba8unorm",width:1,height:1,mipLevels:1})}function RE(e){return e.textureFormat}const ME="layout(std140) uniform simpleMeshUniforms {\n float sizeScale;\n bool composeModelMatrix;\n bool hasTexture;\n bool flatShading;\n} simpleMesh;\n",LE={name:"simpleMesh",vs:ME,fs:ME,uniformTypes:{sizeScale:"f32",composeModelMatrix:"f32",hasTexture:"f32",flatShading:"f32"}};function IE(e){const t=e.positions||e.POSITION;Ie.A.assert(t,'no "postions" or "POSITION" attribute in mesh');const n=t.value.length/t.size;let i=e.COLOR_0||e.colors;i||(i={size:3,value:new Float32Array(3*n).fill(1)});let r=e.NORMAL||e.normals;r||(r={size:3,value:new Float32Array(3*n).fill(0)});let s=e.TEXCOORD_0||e.texCoords;return s||(s={size:2,value:new Float32Array(2*n).fill(0)}),{positions:t,colors:i,normals:r,texCoords:s}}function OE(e){return e instanceof Geometry?(e.attributes=IE(e.attributes),e):e.attributes?new Geometry({...e,topology:"triangle-list",attributes:IE(e.attributes)}):new Geometry({topology:"triangle-list",attributes:IE(e)})}const BE={mesh:{type:"object",value:null,async:!0},texture:{type:"image",value:null,async:!0},sizeScale:{type:"number",value:1,min:0},_instanced:!0,wireframe:!1,material:!0,getPosition:{type:"accessor",value:e=>e.position},getColor:{type:"accessor",value:[0,0,0,255]},getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},textureParameters:{type:"object",ignore:!0,value:null}};class SimpleMeshLayer extends Ts{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-vs\nin vec3 positions;\nin vec3 normals;\nin vec3 colors;\nin vec2 texCoords;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec3 instanceModelMatrixCol0;\nin vec3 instanceModelMatrixCol1;\nin vec3 instanceModelMatrixCol2;\nin vec3 instanceTranslation;\nout vec2 vTexCoord;\nout vec3 cameraPosition;\nout vec3 normals_commonspace;\nout vec4 position_commonspace;\nout vec4 vColor;\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.uv = texCoords;\ngeometry.pickingColor = instancePickingColors;\nvTexCoord = texCoords;\ncameraPosition = project.cameraPosition;\nvColor = vec4(colors * instanceColors.rgb, instanceColors.a);\nmat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);\nvec3 pos = (instanceModelMatrix * positions) * simpleMesh.sizeScale + instanceTranslation;\nif (simpleMesh.composeModelMatrix) {\nDECKGL_FILTER_SIZE(pos, geometry);\nnormals_commonspace = project_normal(instanceModelMatrix * normals);\ngeometry.worldPosition += pos;\ngl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), position_commonspace);\ngeometry.position = position_commonspace;\n}\nelse {\npos = project_size(pos);\nDECKGL_FILTER_SIZE(pos, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, position_commonspace);\ngeometry.position = position_commonspace;\nnormals_commonspace = project_normal(instanceModelMatrix * normals);\n}\ngeometry.normal = normals_commonspace;\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-fs\nprecision highp float;\nuniform sampler2D sampler;\nin vec2 vTexCoord;\nin vec3 cameraPosition;\nin vec3 normals_commonspace;\nin vec4 position_commonspace;\nin vec4 vColor;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = vTexCoord;\nvec3 normal;\nif (simpleMesh.flatShading) {\nnormal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\n} else {\nnormal = normals_commonspace;\n}\nvec4 color = simpleMesh.hasTexture ? texture(sampler, vTexCoord) : vColor;\nDECKGL_FILTER_COLOR(color, geometry);\nvec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);\nfragColor = vec4(lightColor, color.a * layer.opacity);\n}\n",modules:[Xs,Ao,Qs,LE]})}getBounds(){if(this.props._instanced)return super.getBounds();let e=this.state.positionBounds;if(e)return e;const{mesh:t}=this.props;if(!t)return null;if(e=t.header?.boundingBox,!e){const{attributes:n}=OE(t);n.POSITION=n.POSITION||n.positions,e=function(e){let t=1/0,n=1/0,i=1/0,r=-1/0,s=-1/0,o=-1/0;const a=e.POSITION?e.POSITION.value:[],l=a&&a.length;for(let e=0;e<l;e+=3){const l=a[e],c=a[e+1],A=a[e+2];t=l<t?l:t,n=c<n?c:n,i=A<i?A:i,r=l>r?l:r,s=c>s?c:s,o=A>o?A:o}return[[t,n,i],[r,s,o]]}(n)}return this.state.positionBounds=e,e}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{transition:!0,type:"float64",fp64:this.use64bitPositions(),size:3,accessor:"getPosition"},instanceColors:{type:"unorm8",transition:!0,size:this.props.colorFormat.length,accessor:"getColor",defaultValue:[0,0,0,255]},instanceModelMatrix:aE}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState(e){super.updateState(e);const{props:t,oldProps:n,changeFlags:i}=e;if(t.mesh!==n.mesh||i.extensionsChanged){if(this.state.positionBounds=null,this.state.model?.destroy(),t.mesh){this.state.model=this.getModel(t.mesh);const e=t.mesh.attributes||t.mesh;this.setState({hasNormals:Boolean(e.NORMAL||e.normals)})}this.getAttributeManager().invalidateAll()}t.texture!==n.texture&&t.texture instanceof Pi.g&&this.setTexture(t.texture),this.state.model&&this.state.model.setTopology(this.props.wireframe?"line-strip":"triangle-list")}finalizeState(e){super.finalizeState(e),this.state.emptyTexture.delete()}draw({uniforms:e}){const{model:t}=this.state;if(!t)return;const{viewport:n,renderPass:i}=this.context,{sizeScale:r,coordinateSystem:s,_instanced:o}=this.props,a={sizeScale:r,composeModelMatrix:!o||lE(n,s),flatShading:!this.state.hasNormals};t.shaderInputs.setProps({simpleMesh:a}),t.draw(i)}get isLoaded(){return Boolean(this.state?.model&&super.isLoaded)}getModel(e){const t=new Sr.K(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:OE(e),isInstanced:!0}),{texture:n}=this.props,{emptyTexture:i}=this.state,r={sampler:n||i,hasTexture:Boolean(n)};return t.shaderInputs.setProps({simpleMesh:r}),t}setTexture(e){const{emptyTexture:t,model:n}=this.state;if(n){const i={sampler:e||t,hasTexture:Boolean(e)};n.shaderInputs.setProps({simpleMesh:i})}}}SimpleMeshLayer.defaultProps=BE,SimpleMeshLayer.layerName="SimpleMeshLayer";const NE=SimpleMeshLayer,kE="layout(std140) uniform meshUniforms {\n bool pickFeatureIds;\n} mesh;\n",FE={name:"mesh",vs:kE,fs:kE,uniformTypes:{pickFeatureIds:"f32"}};class MeshLayer extends NE{getShaders(){const e=super.getShaders();return e.modules.push(W_,FE),{...e,vs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-vs\nin vec3 positions;\nin vec3 normals;\nin vec3 colors;\nin vec2 texCoords;\nin vec4 uvRegions;\nin vec3 featureIdsPickingColors;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec3 instanceModelMatrixCol0;\nin vec3 instanceModelMatrixCol1;\nin vec3 instanceModelMatrixCol2;\nout vec2 vTexCoord;\nout vec3 cameraPosition;\nout vec3 normals_commonspace;\nout vec4 position_commonspace;\nout vec4 vColor;\nvec2 applyUVRegion(vec2 uv) {\n#ifdef HAS_UV_REGIONS\nreturn fract(uv) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;\n#else\nreturn uv;\n#endif\n}\nvoid main(void) {\nvec2 uv = applyUVRegion(texCoords);\ngeometry.uv = uv;\nif (mesh.pickFeatureIds) {\ngeometry.pickingColor = featureIdsPickingColors;\n} else {\ngeometry.pickingColor = instancePickingColors;\n}\nmat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);\nvTexCoord = uv;\ncameraPosition = project.cameraPosition;\nvColor = vec4(colors * instanceColors.rgb, instanceColors.a);\nvec3 pos = (instanceModelMatrix * positions) * simpleMesh.sizeScale;\nvec3 projectedPosition = project_position(positions);\nposition_commonspace = vec4(projectedPosition, 1.0);\ngl_Position = project_common_position_to_clipspace(position_commonspace);\ngeometry.position = position_commonspace;\nnormals_commonspace = project_normal(instanceModelMatrix * normals);\ngeometry.normal = normals_commonspace;\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n#ifdef MODULE_PBRMATERIAL\npbr_vPosition = geometry.position.xyz;\n#ifdef HAS_NORMALS\npbr_vNormal = geometry.normal;\n#endif\n#ifdef HAS_UV\npbr_vUV0 = uv;\n#else\npbr_vUV0 = vec2(0., 0.);\n#endif\npbr_vUV1 = vec2(0., 0.);\ngeometry.uv = pbr_vUV0;\n#endif\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-fs\nprecision highp float;\nuniform sampler2D sampler;\nin vec2 vTexCoord;\nin vec3 cameraPosition;\nin vec3 normals_commonspace;\nin vec4 position_commonspace;\nin vec4 vColor;\nout vec4 fragColor;\nvoid main(void) {\n#ifdef MODULE_PBRMATERIAL\nfragColor = vColor * pbr_filterColor(vec4(0));\ngeometry.uv = pbr_vUV0;\nfragColor.a *= layer.opacity;\n#else\ngeometry.uv = vTexCoord;\nvec3 normal;\nif (simpleMesh.flatShading) {\nnormal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\n} else {\nnormal = normals_commonspace;\n}\nvec4 color = simpleMesh.hasTexture ? texture(sampler, vTexCoord) : vColor;\nvec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);\nfragColor = vec4(lightColor, color.a * layer.opacity);\n#endif\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n"}}initializeState(){const{featureIds:e}=this.props;super.initializeState();const t=this.getAttributeManager();e&&t.add({featureIdsPickingColors:{type:"uint8",size:3,noAlloc:!0,update:this.calculateFeatureIdsPickingColors}})}updateState(e){super.updateState(e);const{props:t,oldProps:n}=e;t.pbrMaterial!==n.pbrMaterial&&this.updatePbrMaterialUniforms(t.pbrMaterial)}draw(e){const{featureIds:t}=this.props,{model:n}=this.state;if(!n)return;const i={pickFeatureIds:Boolean(t)},r={camera:this.context.viewport.cameraPosition};n.shaderInputs.setProps({pbrProjection:r,mesh:i}),super.draw(e)}getModel(e){const{id:t}=this.props,n=this.parseMaterial(this.props.pbrMaterial,e);this.setState({parsedPBRMaterial:n});const i=this.getShaders();!function(e){const t=e.positions||e.POSITION,n=t.value.length/t.size;e.COLOR_0||e.colors||(e.colors={size:4,value:new Uint8Array(4*n).fill(255),normalized:!0})}(e.attributes);return new Sr.K(this.context.device,{...this.getShaders(),id:t,geometry:e,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...i.defines,...n?.defines,HAS_UV_REGIONS:e.attributes.uvRegions?1:0},parameters:n?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(e){const{model:t}=this.state;if(t){const{mesh:n}=this.props,i=this.parseMaterial(e,n);this.setState({parsedPBRMaterial:i});const{pbr_baseColorSampler:r}=i.bindings,{emptyTexture:s}=this.state,o={sampler:r||s,hasTexture:Boolean(r)},{camera:a,...l}={...i.bindings,...i.uniforms};t.shaderInputs.setProps({simpleMesh:o,pbrMaterial:l})}}parseMaterial(e,t){const n=Boolean(e.pbrMetallicRoughness&&e.pbrMetallicRoughness.baseColorTexture);return TE(this.context.device,{unlit:n,...e},{NORMAL:t.attributes.normals,TEXCOORD_0:t.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingColors(e){const t=this.props.featureIds,n=new Uint8ClampedArray(t.length*e.size),i=[];for(let e=0;e<t.length;e++)this.encodePickingColor(t[e],i),n[3*e]=i[0],n[3*e+1]=i[1],n[3*e+2]=i[2];e.value=n}finalizeState(e){super.finalizeState(e),this.state.parsedPBRMaterial?.generatedTextures.forEach(e=>e.destroy()),this.setState({parsedPBRMaterial:null})}}MeshLayer.layerName="MeshLayer",MeshLayer.defaultProps={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}};const DE=MeshLayer,UE=6378137,VE=6378137,zE=6356752.314245179;Math.max(UE,VE,zE);function GE(e){return e}new oi.P;function jE(e,t=[],n=GE){return"longitude"in e?(t[0]=n(e.longitude),t[1]=n(e.latitude),t[2]=e.height):"x"in e?(t[0]=n(e.x),t[1]=n(e.y),t[2]=e.z):(t[0]=n(e[0]),t[1]=n(e[1]),t[2]=e[2]),t}function HE(e,t,n=GE){return"longitude"in t?(t.longitude=n(e[0]),t.latitude=n(e[1]),t.height=e[2]):"x"in t?(t.x=n(e[0]),t.y=n(e[1]),t.z=e[2]):(t[0]=n(e[0]),t[1]=n(e[1]),t[2]=e[2]),t}const WE=new oi.P,qE={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},KE={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},QE={east:new oi.P,north:new oi.P,up:new oi.P,west:new oi.P,south:new oi.P,down:new oi.P},XE=new oi.P,$E=new oi.P,ZE=new oi.P;function YE(e,t,n,i,r,s){const o=qE[t]&&qE[t][n];let a,l,c;(0,jb.v)(o&&(!i||i===o));const A=WE.copy(r);if((0,xn.aI)(A.x,0,1e-14)&&(0,xn.aI)(A.y,0,1e-14)){const e=Math.sign(A.z);a=XE.fromArray(KE[t]),"east"!==t&&"west"!==t&&a.scale(e),l=$E.fromArray(KE[n]),"east"!==n&&"west"!==n&&l.scale(e),c=ZE.fromArray(KE[i]),"east"!==i&&"west"!==i&&c.scale(e)}else{const{up:r,east:s,north:o}=QE;s.set(-A.y,A.x,0).normalize(),e.geodeticSurfaceNormal(A,r),o.copy(r).cross(s);const{down:u,west:h,south:d}=QE;u.copy(r).scale(-1),h.copy(s).scale(-1),d.copy(o).scale(-1),a=QE[t],l=QE[n],c=QE[i]}return s[0]=a.x,s[1]=a.y,s[2]=a.z,s[3]=0,s[4]=l.x,s[5]=l.y,s[6]=l.z,s[7]=0,s[8]=c.x,s[9]=c.y,s[10]=c.z,s[11]=0,s[12]=A.x,s[13]=A.y,s[14]=A.z,s[15]=1,s}const JE=new oi.P,eS=new oi.P,tS=new oi.P;const nS=new oi.P,iS=new oi.P,rS=new oi.P,sS=new oi.P,oS=new oi.P,aS=new oi.P;class Ellipsoid{constructor(e=0,t=0,n=0){this.centerToleranceSquared=.1,(0,jb.v)(e>=0),(0,jb.v)(t>=0),(0,jb.v)(n>=0),this.radii=new oi.P(e,t,n),this.radiiSquared=new oi.P(e*e,t*t,n*n),this.radiiToTheFourth=new oi.P(e*e*e*e,t*t*t*t,n*n*n*n),this.oneOverRadii=new oi.P(0===e?0:1/e,0===t?0:1/t,0===n?0:1/n),this.oneOverRadiiSquared=new oi.P(0===e?0:1/(e*e),0===t?0:1/(t*t),0===n?0:1/(n*n)),this.minimumRadius=Math.min(e,t,n),this.maximumRadius=Math.max(e,t,n),0!==this.radiiSquared.z&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(e){return this===e||Boolean(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,t=[0,0,0]){const n=iS,i=rS,[,,r]=e;this.geodeticSurfaceNormalCartographic(e,n),i.copy(this.radiiSquared).scale(n);const s=Math.sqrt(n.dot(i));return i.scale(1/s),n.scale(r),i.add(n),i.to(t)}cartesianToCartographic(e,t=[0,0,0]){aS.from(e);const n=this.scaleToGeodeticSurface(aS,sS);if(!n)return;const i=this.geodeticSurfaceNormal(n,iS),r=oS;r.copy(aS).subtract(n);return function(e,t){return HE(e,t,xn.$W._cartographicRadians?GE:xn.xW)}([Math.atan2(i.y,i.x),Math.asin(i.z),Math.sign(In.Om(r,aS))*In.Bw(r)],t)}eastNorthUpToFixedFrame(e,t=new Rn.k){return YE(this,"east","north","up",e,t)}localFrameToFixedFrame(e,t,n,i,r=new Rn.k){return YE(this,e,t,n,i,r)}geocentricSurfaceNormal(e,t=[0,0,0]){return nS.from(e).normalize().to(t)}geodeticSurfaceNormalCartographic(e,t=[0,0,0]){const n=function(e,t=[]){return jE(e,t,xn.$W._cartographicRadians?GE:xn.eh)}(e),i=n[0],r=n[1],s=Math.cos(r);return nS.set(s*Math.cos(i),s*Math.sin(i),Math.sin(r)).normalize(),nS.to(t)}geodeticSurfaceNormal(e,t=[0,0,0]){return nS.from(e).scale(this.oneOverRadiiSquared).normalize().to(t)}scaleToGeodeticSurface(e,t){return function(e,t,n=[]){const{oneOverRadii:i,oneOverRadiiSquared:r,centerToleranceSquared:s}=t;JE.from(e);const o=JE.x,a=JE.y,l=JE.z,c=i.x,A=i.y,u=i.z,h=o*o*c*c,d=a*a*A*A,f=l*l*u*u,p=h+d+f,g=Math.sqrt(1/p);if(!Number.isFinite(g))return;const m=eS;if(m.copy(e).scale(g),p<s)return m.to(n);const b=r.x,_=r.y,v=r.z,y=tS;y.set(m.x*b*2,m.y*_*2,m.z*v*2);let w,x,T,E,S=(1-g)*JE.len()/(.5*y.len()),C=0;do{S-=C,w=1/(1+S*b),x=1/(1+S*_),T=1/(1+S*v);const e=w*w,t=x*x,n=T*T;E=h*e+d*t+f*n-1,C=E/(-2*(h*(e*w)*b+d*(t*x)*_+f*(n*T)*v))}while(Math.abs(E)>1e-12);return JE.scale([w,x,T]).to(n)}(e,this,t)}scaleToGeocentricSurface(e,t=[0,0,0]){sS.from(e);const n=sS.x,i=sS.y,r=sS.z,s=this.oneOverRadiiSquared,o=1/Math.sqrt(n*n*s.x+i*i*s.y+r*r*s.z);return sS.multiplyScalar(o).to(t)}transformPositionToScaledSpace(e,t=[0,0,0]){return sS.from(e).scale(this.oneOverRadii).to(t)}transformPositionFromScaledSpace(e,t=[0,0,0]){return sS.from(e).scale(this.radii).to(t)}getSurfaceNormalIntersectionWithZAxis(e,t=0,n=[0,0,0]){(0,jb.v)((0,xn.aI)(this.radii.x,this.radii.y,1e-15)),(0,jb.v)(this.radii.z>0),sS.from(e);const i=sS.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(i)>=this.radii.z-t))return sS.set(0,0,i).to(n)}}function lS(){if("undefined"!=typeof process&&void 0!==process.cwd)return process.cwd();const e=window.location?.pathname;return e?.slice(0,e.lastIndexOf("/")+1)||""}function cS(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}function AS(...e){const t=[];for(let n=0;n<e.length;n++)t[n]=e[n];let n,i="",r=!1;for(let e=t.length-1;e>=-1&&!r;e--){let s;e>=0?s=t[e]:(void 0===n&&(n=lS()),s=n),0!==s.length&&(i=`${s}/${i}`,r=s.charCodeAt(0)===uS)}return i=function(e,t){let n,i="",r=-1,s=0,o=!1;for(let a=0;a<=e.length;++a){if(a<e.length)n=e.charCodeAt(a);else{if(n===uS)break;n=uS}if(n===uS){if(r===a-1||1===s);else if(r!==a-1&&2===s){if(i.length<2||!o||i.charCodeAt(i.length-1)!==hS||i.charCodeAt(i.length-2)!==hS)if(i.length>2){const e=i.length-1;let t=e;for(;t>=0&&i.charCodeAt(t)!==uS;--t);if(t!==e){i=-1===t?"":i.slice(0,t),r=a,s=0,o=!1;continue}}else if(2===i.length||1===i.length){i="",r=a,s=0,o=!1;continue}t&&(i.length>0?i+="/..":i="..",o=!0)}else{const t=e.slice(r+1,a);i.length>0?i+=`/${t}`:i=t,o=!1}r=a,s=0}else n===hS&&-1!==s?++s:s=-1}return i}(i,!r),r?`/${i}`:i.length>0?i:"."}Ellipsoid.WGS84=new Ellipsoid(UE,VE,zE);const uS=47,hS=46;const dS={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0};class request_scheduler_RequestScheduler{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...dS,...e},this.stats=new lt.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--,this._issueNewRequests())};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)}}class DoublyLinkedListNode{item;previous;next;constructor(e,t,n){this.item=e,this.previous=t,this.next=n}}class DoublyLinkedList{head=null;tail=null;_length=0;get length(){return this._length}add(e){const t=new DoublyLinkedListNode(e,this.tail,null);return this.tail?(this.tail.next=t,this.tail=t):(this.head=t,this.tail=t),++this._length,t}remove(e){e&&(e.previous&&e.next?(e.previous.next=e.next,e.next.previous=e.previous):e.previous?(e.previous.next=null,this.tail=e.previous):e.next?(e.next.previous=null,this.head=e.next):(this.head=null,this.tail=null),e.next=null,e.previous=null,--this._length)}splice(e,t){e!==t&&(this.remove(t),this._insert(e,t))}_insert(e,t){const n=e.next;e.next=t,this.tail===e?this.tail=t:n.previous=t,t.next=n,t.previous=e,++this._length}}class TilesetCache{_list;_sentinel;_trimTiles;constructor(){this._list=new DoublyLinkedList,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){const t=e._cacheNode;t&&this._list.splice(this._sentinel,t)}add(e,t,n){t._cacheNode||(t._cacheNode=this._list.add(t),n&&n(e,t))}unloadTile(e,t,n){const i=t._cacheNode;i&&(this._list.remove(i),t._cacheNode=null,n&&n(e,t))}unloadTiles(e,t){const n=this._trimTiles;this._trimTiles=!1;const i=this._list,r=1024*e.maximumMemoryUsage*1024,s=this._sentinel;let o=i.head;for(;o!==s&&(e.gpuMemoryUsageInBytes>r||n);){const n=o.item;o=o.next,this.unloadTile(e,n,t)}}trim(){this._trimTiles=!0}}function fS(e,t){le(e),le(t);const{rtcCenter:n,gltfUpAxis:i}=t,{computedTransform:r,boundingVolume:{center:s}}=e;let o=new Rn.k(r);switch(n&&o.translate(n),i){case"Z":default:break;case"Y":const e=(new Rn.k).rotateX(Math.PI/2);o=o.multiplyRight(e);break;case"X":const t=(new Rn.k).rotateY(-Math.PI/2);o=o.multiplyRight(t)}t.isQuantized&&o.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);const a=new oi.P(s);t.cartesianModelMatrix=o,t.cartesianOrigin=a;const l=Ellipsoid.WGS84.cartesianToCartographic(a,new oi.P),c=Ellipsoid.WGS84.eastNorthUpToFixedFrame(a).invert();t.cartographicModelMatrix=c.multiplyRight(o),t.cartographicOrigin=l;const A=function(e){const t=e.gltf;if(!t)return null;const n="number"==typeof t.scene?t.scene:0,i=t.scenes?.[n],r=i?.nodes?.[0];if(!r?.matrix)return null;const s=r.matrix;return s[12]*s[12]+s[13]*s[13]+s[14]*s[14]<=pS?null:r}(t);A&&(t.cartesianModelMatrix=new Rn.k(o).multiplyRight(A.matrix),t.cartographicModelMatrix.multiplyRight(A.matrix),A.matrix=Rn.k.IDENTITY),t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}const pS=1e6**2;const gS=new oi.P,mS=new oi.P,bS=new CullingVolume([new Plane,new Plane,new Plane,new Plane,new Plane,new Plane]);function _S(e,t){const{cameraDirection:n,cameraUp:i,height:r}=e,{metersPerUnit:s}=e.distanceScales,o=yS(e,e.center),a=Ellipsoid.WGS84.eastNorthUpToFixedFrame(o),l=e.unprojectPosition(e.cameraPosition),c=Ellipsoid.WGS84.cartographicToCartesian(l,new oi.P),A=new oi.P(a.transformAsVector(new oi.P(n).scale(s))).normalize(),u=new oi.P(a.transformAsVector(new oi.P(i).scale(s))).normalize();!function(e){const t=e.getFrustumPlanes(),n=vS(t.near,e.cameraPosition),i=yS(e,n),r=yS(e,e.cameraPosition,mS);let s=0;bS.planes[s++].fromPointNormal(i,gS.copy(i).subtract(r));for(const r in t){if("near"===r)continue;const o=yS(e,vS(t[r],n,mS),mS);bS.planes[s++].fromPointNormal(o,gS.copy(i).subtract(o))}}(e);const h=e.constructor,{longitude:d,latitude:f,width:p,bearing:g,zoom:m}=e;return{camera:{position:c,direction:A,up:u},viewport:e,topDownViewport:new h({longitude:d,latitude:f,height:r,width:p,bearing:g,zoom:m,pitch:0}),height:r,cullingVolume:bS,frameNumber:t,sseDenominator:1.15}}function vS(e,t,n=new oi.P){const i=e.normal.dot(t);return n.copy(e.normal).scale(e.distance-i).add(t),n}function yS(e,t,n=new oi.P){const i=e.unprojectPosition(t);return Ellipsoid.WGS84.cartographicToCartesian(i,n)}const wS=6356752.314245179,xS=new oi.P;function TS(e,t){if(e instanceof OrientedBoundingBox){const{halfAxes:n}=e,i=function(e){e.getColumn(0,xS);const t=e.getColumn(1),n=e.getColumn(2),i=xS.add(t).add(n).len();return i}(n);return Math.log2(wS/(i+t[2]))}if(e instanceof BoundingSphere){const{radius:n}=e;return Math.log2(wS/(n+t[2]))}if(e.width&&e.height){const{width:t,height:n}=e;return(Math.log2(6378137/t)+Math.log2(6378137/n))/2}return 1}function ES(e,t,n){Ellipsoid.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],xS);const i=Math.sqrt(Math.pow(xS[0]-n[0],2)+Math.pow(xS[1]-n[1],2)+Math.pow(xS[2]-n[2],2));return Math.log2(wS/(i+t[2]))}const SS=0,CS=1,PS=3,RS=4,MS=5;var LS,IS,OS,BS;!function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"}(LS||(LS={})),function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"}(IS||(IS={})),function(e){e.I3S="I3S",e.TILES3D="TILES3D"}(OS||(OS={})),function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"}(BS||(BS={}));const NS=1;function kS(e){return null!=e}const FS=new oi.P,DS=new oi.P,US=new oi.P,VS=new oi.P,zS=new oi.P,GS=new oi.P,jS=new oi.P,HS=new oi.P;function WS(e,t,n){if(le(e,"3D Tile: boundingVolume must be defined"),e.box)return KS(e.box,t,n);if(e.region)return function(e){const[t,n,i,r,s,o]=e,a=Ellipsoid.WGS84.cartographicToCartesian([(0,xn.uj)(t),(0,xn.uj)(r),s],US),l=Ellipsoid.WGS84.cartographicToCartesian([(0,xn.uj)(i),(0,xn.uj)(n),o],VS),c=(new oi.P).addVectors(a,l).multiplyByScalar(.5);return Ellipsoid.WGS84.cartesianToCartographic(c,zS),Ellipsoid.WGS84.cartographicToCartesian([(0,xn.uj)(i),zS[1],zS[2]],GS),Ellipsoid.WGS84.cartographicToCartesian([zS[0],(0,xn.uj)(r),zS[2]],jS),Ellipsoid.WGS84.cartographicToCartesian([zS[0],zS[1],o],HS),KS([...c,...GS.subtract(c),...jS.subtract(c),...HS.subtract(c)],new Rn.k)}(e.region);if(e.sphere)return function(e,t,n){const i=new oi.P(e[0],e[1],e[2]);t.transform(i,i);const r=t.getScale(DS),s=Math.max(Math.max(r[0],r[1]),r[2]),o=e[3]*s;if(kS(n))return n.center=i,n.radius=o,n;return new BoundingSphere(i,o)}(e.sphere,t,n);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function qS(e,t){if(e.box)return function(e){const t=QS(),{halfAxes:n}=e,i=new oi.P(n.getColumn(0)),r=new oi.P(n.getColumn(1)),s=new oi.P(n.getColumn(2));for(let n=0;n<2;n++){for(let n=0;n<2;n++){for(let n=0;n<2;n++)FS.copy(e.center),FS.add(i),FS.add(r),FS.add(s),XS(t,FS),s.negate();r.negate()}i.negate()}return t}(t);if(e.region){const[t,n,i,r,s,o]=e.region;return[[(0,xn.uj)(t),(0,xn.uj)(n),s],[(0,xn.uj)(i),(0,xn.uj)(r),o]]}if(e.sphere)return function(e){const t=QS(),{center:n,radius:i}=e,r=Ellipsoid.WGS84.scaleToGeodeticSurface(n,FS);let s;s=r?Ellipsoid.WGS84.geodeticSurfaceNormal(r):new oi.P(0,0,1);let o=new oi.P(s[2],-s[1],0);o.len()>0?o.normalize():o=new oi.P(0,1,0);const a=o.clone().cross(s);for(const e of[o,a,s]){DS.copy(e).scale(i);for(let e=0;e<2;e++)FS.copy(n),FS.add(DS),XS(t,FS),DS.negate()}return t}(t);throw new Error("Unkown boundingVolume type")}function KS(e,t,n){const i=new oi.P(e[0],e[1],e[2]);t.transform(i,i);let r=[];if(10===e.length){const t=e.slice(3,6),n=new Quaternion;n.fromArray(e,6);const i=new oi.P([1,0,0]),s=new oi.P([0,1,0]),o=new oi.P([0,0,1]);i.transformByQuaternion(n),i.scale(t[0]),s.transformByQuaternion(n),s.scale(t[1]),o.transformByQuaternion(n),o.scale(t[2]),r=[...i.toArray(),...s.toArray(),...o.toArray()]}else r=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];const s=t.transformAsVector(r.slice(0,3)),o=t.transformAsVector(r.slice(3,6)),a=t.transformAsVector(r.slice(6,9)),l=new Matrix3([s[0],s[1],s[2],o[0],o[1],o[2],a[0],a[1],a[2]]);return kS(n)?(n.center=i,n.halfAxes=l,n):new OrientedBoundingBox(i,l)}function QS(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function XS(e,t){Ellipsoid.WGS84.cartesianToCartographic(t,FS),e[0][0]=Math.min(e[0][0],FS[0]),e[0][1]=Math.min(e[0][1],FS[1]),e[0][2]=Math.min(e[0][2],FS[2]),e[1][0]=Math.max(e[1][0],FS[0]),e[1][1]=Math.max(e[1][1],FS[1]),e[1][2]=Math.max(e[1][2],FS[2])}new oi.P,new oi.P,new Rn.k,new oi.P,new oi.P,new oi.P;function $S(e,t){if(e.dynamicScreenSpaceError&&e.dynamicScreenSpaceErrorComputedDensity){const n=e.dynamicScreenSpaceErrorComputedDensity,i=e.dynamicScreenSpaceErrorFactor,r=function(e,t){const n=e*t;return 1-Math.exp(-n*n)}(t,n)*i;return r}return 0}const ZS=new oi.P,YS=new oi.P,JS=new oi.P,eC=new oi.P,tC=new oi.P,nC=new Rn.k,iC=new Rn.k;function rC(e,t){const{topDownViewport:n}=t,i=e.header.mbs[1],r=e.header.mbs[0],s=e.header.mbs[2],o=e.header.mbs[3],a=[...e.boundingVolume.center],l=n.unprojectPosition(n.cameraPosition);Ellipsoid.WGS84.cartographicToCartesian(l,ZS),YS.copy(ZS).subtract(a).normalize(),Ellipsoid.WGS84.eastNorthUpToFixedFrame(a,nC),iC.copy(nC).invert(),JS.copy(ZS).transform(iC);const c=Math.sqrt(JS[0]*JS[0]+JS[1]*JS[1]),A=c*c/JS[2];eC.copy([JS[0],JS[1],A]);const u=eC.transform(nC).subtract(a).normalize(),h=YS.cross(u).normalize().scale(o).add(a),d=Ellipsoid.WGS84.cartesianToCartographic(h),f=n.project([r,i,s]),p=n.project(d);return tC.copy(f).subtract(p).magnitude()}class ManagedArray{_map=new Map;_array;_length;constructor(e=0){this._array=new Array(e),this._length=e}get length(){return this._length}set length(e){this._length=e,e>this._array.length&&(this._array.length=e)}get values(){return this._array}get(e){return le(e<this._array.length),this._array[e]}set(e,t){le(e>=0),e>=this.length&&(this.length=e+1),this._map.has(this._array[e])&&this._map.delete(this._array[e]),this._array[e]=t,this._map.set(t,e)}delete(e){const t=this._map.get(e);t>=0&&(this._array.splice(t,1),this._map.delete(e),this.length--)}peek(){return this._array[this._length-1]}push(e){if(!this._map.has(e)){const t=this.length++;this._array[t]=e,this._map.set(e,t)}}pop(){const e=this._array[--this.length];return this._map.delete(e),e}reserve(e){le(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){le(e>=0),this.length=e}trim(e){null==e&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}}const sC={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""};class TilesetTraverser{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=(new Date).getTime();updateDebounceTime=1e3;_traversalStack=new ManagedArray;_emptyTraversalStack=new ManagedArray;_frameNumber=null;traversalFinished(e){return!0}constructor(e){this.options={...sC,...e}}traverse(e,t,n){this.root=e,this.options={...this.options,...n},this.reset(),this.updateTile(e,t),this._frameNumber=t.frameNumber,this.executeTraversal(e,t)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(e,t){const n=this._traversalStack;for(e._selectionDepth=1,n.push(e);n.length>0;){const e=n.pop();let i=!1;this.canTraverse(e,t)&&(this.updateChildTiles(e,t),i=this.updateAndPushChildren(e,t,n,e.hasRenderContent?e._selectionDepth+1:e._selectionDepth));const r=e.parent,s=Boolean(!r||r._shouldRefine),o=!i;e.hasRenderContent?e.refine===LS.ADD?(this.loadTile(e,t),this.selectTile(e,t)):e.refine===LS.REPLACE&&(this.loadTile(e,t),o&&this.selectTile(e,t)):(this.emptyTiles[e.id]=e,this.loadTile(e,t),o&&this.selectTile(e,t)),this.touchTile(e,t),e._shouldRefine=i&&s}const i=(new Date).getTime();(this.traversalFinished(t)||i-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=i,this.options.onTraversalEnd(t))}updateChildTiles(e,t){const n=e.children;for(const e of n)this.updateTile(e,t)}updateAndPushChildren(e,t,n,i){const{loadSiblings:r,skipLevelOfDetail:s}=this.options,o=e.children;o.sort(this.compareDistanceToCamera.bind(this));const a=e.refine===LS.REPLACE&&e.hasRenderContent&&!s;let l=!1,c=!0;for(const e of o)if(e._selectionDepth=i,e.isVisibleAndInRequestVolume?(n.find(e)&&n.delete(e),n.push(e),l=!0):(a||r)&&(this.loadTile(e,t),this.touchTile(e,t)),a){let n;if(n=!!e._inRequestVolume&&(e.hasRenderContent?e.contentAvailable:this.executeEmptyTraversal(e,t)),c=c&&n,!c)return!1}return l||(c=!1),c}updateTile(e,t){this.updateTileVisibility(e,t)}selectTile(e,t){this.shouldSelectTile(e)&&(e._selectedFrame=t.frameNumber,this.selectedTiles[e.id]=e)}loadTile(e,t){this.shouldLoadTile(e)&&(e._requestedFrame=t.frameNumber,e._priority=e._getPriority(),this.requestedTiles[e.id]=e)}touchTile(e,t){e.tileset._cache.touch(e),e._touchedFrame=t.frameNumber}canTraverse(e,t){return!!e.hasChildren&&(e.hasTilesetContent?!e.contentExpired:this.shouldRefine(e,t))}shouldLoadTile(e){return e.hasUnloadedContent||e.contentExpired}shouldSelectTile(e){return e.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(e,t,n=!1){let i=e._screenSpaceError;return n&&(i=e.getScreenSpaceError(t,!0)),i>e.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(e,t){const n=[];if(this.options.viewportTraversersMap)for(const e in this.options.viewportTraversersMap){this.options.viewportTraversersMap[e]===t.viewport.id&&n.push(e)}else n.push(t.viewport.id);e.updateVisibility(t,n)}compareDistanceToCamera(e,t){return e._distanceToCamera-t._distanceToCamera}anyChildrenVisible(e,t){let n=!1;for(const i of e.children)i.updateVisibility(t),n=n||i.isVisibleAndInRequestVolume;return n}executeEmptyTraversal(e,t){let n=!0;const i=this._emptyTraversalStack;for(i.push(e);i.length>0;){const e=i.pop(),r=!e.hasRenderContent&&this.canTraverse(e,t),s=!e.hasRenderContent&&0===e.children.length;if(r||e.contentAvailable||s||(n=!1),this.updateTile(e,t),e.isVisibleAndInRequestVolume||(this.loadTile(e,t),this.touchTile(e,t)),r){const t=e.children;for(const e of t)i.push(e)}}return e.hasEmptyContent||n}}const oC=new oi.P;class Tile3D{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=SS;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new Rn.k;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new TilesetTraverser({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new Rn.k;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;tileDrawn=!0;constructor(e,t,n,i=""){this.header=t,this.tileset=e,this.id=i||t.id,this.url=t.url,this.parent=n,this.refine=this._getRefine(t.refine),this.type=t.type,this.contentUrl=t.contentUrl,this._initializeLodMetric(t),this._initializeTransforms(t),this._initializeBoundingVolumes(t),this._initializeContent(t),this._initializeRenderingState(t),Object.seal(this)}destroy(){this.header=null}isDestroyed(){return null===this.header}get selected(){return this._selectedFrame===this.tileset._frameNumber}get isVisible(){return this._visible}get isVisibleAndInRequestVolume(){return this._visible&&this._inRequestVolume}get hasRenderContent(){return!this.hasEmptyContent&&!this.hasTilesetContent}get hasChildren(){return this.children.length>0||this.header.children&&this.header.children.length>0}get contentReady(){return this.contentState===PS||this.hasEmptyContent}get contentAvailable(){return Boolean(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===SS}get contentExpired(){return this.contentState===RS}get contentFailed(){return this.contentState===MS}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=qS(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(e,t){switch(this.tileset.type){case OS.I3S:return rC(this,e);case OS.TILES3D:return function(e,t,n){const i=e.tileset,r=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,s=n?r:e.lodMetricValue;if(0===s)return 0;const o=Math.max(e._distanceToCamera,1e-7),{height:a,sseDenominator:l}=t,{viewDistanceScale:c}=i.options;let A=s*a*(c||1)/(o*l);return A-=$S(i,o),A}(this,e,t);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){const e=this.tileset._traverser,{skipLevelOfDetail:t}=e.options,n=this.refine===LS.ADD||t;if(n&&!this.isVisible&&void 0!==this._visible)return-1;if(this.tileset._frameNumber-this._touchedFrame>=1)return-1;if(this.contentState===SS)return-1;const i=this.parent,r=i&&(!n||0===this._screenSpaceError||i.hasTilesetContent)?i._screenSpaceError:this._screenSpaceError,s=e.root?e.root._screenSpaceError:0;return Math.max(s-r,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=CS;const e=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!e)return this.contentState=SS,!1;try{const e=this.tileset.getTileUrl(this.contentUrl),t=this.tileset.loader,n=this.tileset.loadOptions[t.id]||{},i={...this.tileset.loadOptions,[t.id]:{...n,isTileset:"json"===this.type,...this._getLoaderSpecificOptions(t.id)}};return this.content=await un(e,t,i),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=PS,this._onContentLoaded(),!0}catch(e){throw this.contentState=MS,e}finally{e.done()}}unloadContent(){return this.content&&this.content.destroy&&this.content.destroy(),this.content=null,this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=SS,this.tileDrawn=!0,!0}updateVisibility(e,t){if(this._frameNumber===e.frameNumber)return;const n=this.parent,i=n?n._visibilityPlaneMask:CullingVolume.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){const e=n?n.computedTransform:this.tileset.modelMatrix;this._updateTransform(e)}this._distanceToCamera=this.distanceToTile(e),this._screenSpaceError=this.getScreenSpaceError(e,!1),this._visibilityPlaneMask=this.visibility(e,i),this._visible=this._visibilityPlaneMask!==CullingVolume.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=t}visibility(e,t){const{cullingVolume:n}=e,{boundingVolume:i}=this;return n.computeVisibilityWithPlaneMask(i,t)}contentVisibility(){return!0}distanceToTile(e){const t=this.boundingVolume;return Math.sqrt(Math.max(t.distanceSquaredTo(e.camera.position),0))}cameraSpaceZDepth({camera:e}){const t=this.boundingVolume;return oC.subVectors(t.center,e.position),e.direction.dot(oC)}insideViewerRequestVolume(e){const t=this._viewerRequestVolume;return!t||t.distanceSquaredTo(e.camera.position)<=0}updateExpiration(){if(null!=this._expireDate&&this.contentReady&&!this.hasEmptyContent){const e=Date.now();Date.lessThan(this._expireDate,e)&&(this.contentState=RS,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){"lodMetricType"in e?this.lodMetricType=e.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in e?this.lodMetricValue=e.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(e){this.transform=e.transform?new Rn.k(e.transform):new Rn.k;const t=this.parent,n=this.tileset,i=t&&t.computedTransform?t.computedTransform.clone():n.modelMatrix.clone();this.computedTransform=new Rn.k(i).multiplyRight(this.transform);const r=t&&t._initialTransform?t._initialTransform.clone():new Rn.k;this._initialTransform=new Rn.k(r).multiplyRight(this.transform)}_initializeBoundingVolumes(e){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(e)}_initializeContent(e){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=SS,this.hasTilesetContent=!1,e.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(e){this.depth=e.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=CullingVolume.MASK_INDETERMINATE,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._frameNumber=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._priority=0}_getRefine(e){return e||this.parent&&this.parent.refine||LS.REPLACE}_isTileset(){return-1!==this.contentUrl.indexOf(".json")}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(e){this.boundingVolume=WS(e.boundingVolume,this.computedTransform,this.boundingVolume);const t=e.content;t&&(t.boundingVolume&&(this._contentBoundingVolume=WS(t.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=WS(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(e=new Rn.k){const t=e.clone().multiplyRight(this.transform);!t.equals(this.computedTransform)&&(this.computedTransform=t,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(e){return"i3s"===e?{...this.tileset.options.i3s,_tileOptions:{attributeUrls:this.header.attributeUrls,textureUrl:this.header.textureUrl,textureFormat:this.header.textureFormat,textureLoaderOptions:this.header.textureLoaderOptions,materialDefinition:this.header.materialDefinition,isDracoGeometry:this.header.isDracoGeometry,mbs:this.header.mbs},_tilesetOptions:{store:this.tileset.tileset.store,attributeStorageInfo:this.tileset.tileset.attributeStorageInfo,fields:this.tileset.tileset.fields},isTileHeader:!1}:{assetGltfUpAxis:(t=this.tileset.tileset).asset&&t.asset.gltfUpAxis||"Y"};var t}}class Tileset3DTraverser extends TilesetTraverser{compareDistanceToCamera(e,t){return 0===t._distanceToCamera&&0===e._distanceToCamera?t._centerZDepth-e._centerZDepth:t._distanceToCamera-e._distanceToCamera}updateTileVisibility(e,t){if(super.updateTileVisibility(e,t),!e.isVisibleAndInRequestVolume)return;const n=e.children.length>0;if(e.hasTilesetContent&&n){const n=e.children[0];return this.updateTileVisibility(n,t),void(e._visible=n._visible)}if(this.meetsScreenSpaceErrorEarly(e,t))return void(e._visible=!1);const i=e.refine===LS.REPLACE,r=e._optimChildrenWithinParent===NS;i&&r&&n&&!this.anyChildrenVisible(e,t)&&(e._visible=!1)}meetsScreenSpaceErrorEarly(e,t){const{parent:n}=e;return!(!n||n.hasTilesetContent||n.refine!==LS.ADD)&&!this.shouldRefine(e,t,!0)}}class I3SPendingTilesRegister{frameNumberMap=new Map;register(e,t){const n=this.frameNumberMap.get(e)||new Map,i=n.get(t)||0;n.set(t,i+1),this.frameNumberMap.set(e,n)}deregister(e,t){const n=this.frameNumberMap.get(e);if(!n)return;const i=n.get(t)||1;n.set(t,i-1)}isZero(e,t){return 0===(this.frameNumberMap.get(e)?.get(t)||0)}}const aC="REQUESTED",lC="COMPLETED",cC="ERROR";class I3STileManager{_statusMap;pendingTilesRegister=new I3SPendingTilesRegister;constructor(){this._statusMap={}}add(e,t,n,i){if(!this._statusMap[t]){const{frameNumber:r,viewport:{id:s}}=i;this._statusMap[t]={request:e,callback:n,key:t,frameState:i,status:aC},this.pendingTilesRegister.register(s,r),e().then(e=>{this._statusMap[t].status=lC;const{frameNumber:n,viewport:{id:r}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(r,n),this._statusMap[t].callback(e,i)}).catch(e=>{this._statusMap[t].status=cC;const{frameNumber:i,viewport:{id:r}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(r,i),n(e)})}}update(e,t){if(this._statusMap[e]){const{frameNumber:n,viewport:{id:i}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(i,n);const{frameNumber:r,viewport:{id:s}}=t;this.pendingTilesRegister.register(s,r),this._statusMap[e].frameState=t}}find(e){return this._statusMap[e]}hasPendingTiles(e,t){return!this.pendingTilesRegister.isZero(e,t)}}class I3STilesetTraverser extends TilesetTraverser{_tileManager;constructor(e){super(e),this._tileManager=new I3STileManager}traversalFinished(e){return!this._tileManager.hasPendingTiles(e.viewport.id,this._frameNumber||0)}shouldRefine(e,t){return e._lodJudge=function(e,t){if(0===e.lodMetricValue||isNaN(e.lodMetricValue))return"DIG";const n=2*rC(e,t);return n<2?"OUT":!e.header.children||n<=e.lodMetricValue?"DRAW":e.header.children?"DIG":"OUT"}(e,t),"DIG"===e._lodJudge}updateChildTiles(e,t){const n=e.header.children||[],i=e.children,r=e.tileset;for(const s of n){const n=`${s.id}-${t.viewport.id}`,o=i&&i.find(e=>e.id===n);if(o)o&&this.updateTile(o,t);else{let i=()=>this._loadTile(s.id,r);this._tileManager.find(n)?this._tileManager.update(n,t):(r.tileset.nodePages&&(i=()=>r.tileset.nodePagesTile.formTileFromNodePages(s.id)),this._tileManager.add(i,n,t=>this._onTileLoad(t,e,n),t))}}return!1}async _loadTile(e,t){const{loader:n}=t,i=t.getTileUrl(`${t.url}/nodes/${e}`),r={...t.loadOptions,i3s:{...t.loadOptions.i3s,isTileHeader:!0}};return await un(i,n,r)}_onTileLoad(e,t,n){const i=new Tile3D(t.tileset,e,t,n);t.children.push(i);const r=this._tileManager.find(i.id).frameState;this.updateTile(i,r),this._frameNumber===r.frameNumber&&(this.traversalFinished(r)||(new Date).getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(i,r)}}const AC={description:"",ellipsoid:Ellipsoid.WGS84,modelMatrix:new Rn.k,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,memoryCacheOverflow:1,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:e=>e,onUpdate:()=>{},contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,memoryAdjustedScreenSpaceError:!1,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},uC="Tiles In Tileset(s)",hC="Tiles In Memory",dC="Tiles In View",fC="Tiles To Render",pC="Tiles Loaded",gC="Tiles Loading",mC="Tiles Unloaded",bC="Failed Tile Loads",_C="Points/Vertices",vC="Tile Memory Use",yC="Maximum Screen Space Error";class Tileset3D{options;loadOptions;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};description="";properties;extras=null;attributions={};credits={};stats;contentFormats={draco:!1,meshopt:!1,dds:!1,ktx2:!1};cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;maximumMemoryUsage=32;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=0;_cacheOverflowBytes=0;_frameNumber=0;_queryParams={};_extensionsUsed=[];_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_traverser;_cache=new TilesetCache;_requestScheduler;_heldTiles=new Set;updatePromise=null;tilesetInitializationPromise;constructor(e,t){this.options={...AC,...t},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||cS(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=e.lodMetricType,this.lodMetricValue=e.lodMetricValue,this.refine=e.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new request_scheduler_RequestScheduler({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=1024*this.options.maximumMemoryUsage*1024,this._cacheOverflowBytes=1024*this.options.memoryCacheOverflow*1024,this.stats=new lt.A({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(e)}destroy(){this._destroy()}isLoaded(){return 0===this._pendingCount&&0!==this._frameNumber&&0===this._requestedTiles.length}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return new URLSearchParams(this._queryParams).toString()}setProps(e){this.options={...this.options,...e}}getTileUrl(e){if(e.startsWith("data:"))return e;let t=e;return this.queryParams.length&&(t=`${e}${e.includes("?")?"&":"?"}${this.queryParams}`),t}hasExtension(e){return Boolean(this._extensionsUsed.indexOf(e)>-1)}update(e=null){this.tilesetInitializationPromise.then(()=>{!e&&this.lastUpdatedVieports?e=this.lastUpdatedVieports:this.lastUpdatedVieports=e,e&&this.doUpdate(e)})}async selectTiles(e=null){return await this.tilesetInitializationPromise,e&&(this.lastUpdatedVieports=e),this.updatePromise||(this.updatePromise=new Promise(e=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),e(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytes<this._cacheBytes?this.memoryAdjustedScreenSpaceError=Math.max(this.memoryAdjustedScreenSpaceError/1.02,this.options.maximumScreenSpaceError):this.gpuMemoryUsageInBytes>this._cacheBytes+this._cacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(e){if("loadTiles"in this.options&&!this.options.loadTiles)return;if(this.traverseCounter>0)return;const t=e instanceof Array?e:[e];this._cache.reset(),this._frameNumber++,this.traverseCounter=t.length;const n=[];for(const e of t){const t=e.id;this._needTraverse(t)?n.push(t):this.traverseCounter--}for(const e of t){const t=e.id;if(this.roots[t]||(this.roots[t]=this._initializeTileHeaders(this.tileset,null)),!n.includes(t))continue;const i=_S(e,this._frameNumber);this._traverser.traverse(this.roots[t],i,this.options)}}_needTraverse(e){let t=e;return this.options.viewportTraversersMap&&(t=this.options.viewportTraversersMap[e]),t===e}_onTraversalEnd(e){const t=e.viewport.id;this.frameStateData[t]||(this.frameStateData[t]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});const n=this.frameStateData[t],i=Object.values(this._traverser.selectedTiles),[r,s]=function(e,t,n){if(0===n||e.length<=n)return[e,[]];const i=[],{longitude:r,latitude:s}=t.viewport;for(const[t,n]of e.entries()){const[e,o]=n.header.mbs,a=Math.abs(r-e),l=Math.abs(s-o),c=Math.sqrt(l*l+a*a);i.push([t,c])}const o=i.sort((e,t)=>e[1]-t[1]),a=[];for(let t=0;t<n;t++)a.push(e[o[t][0]]);const l=[];for(let t=n;t<o.length;t++)l.push(e[o[t][0]]);return[a,l]}(i,e,this.options.maximumTilesSelected);n.selectedTiles=r;for(const e of s)e.unselect();n._requestedTiles=Object.values(this._traverser.requestedTiles),n._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,this.traverseCounter>0||this._updateTiles()}_updateTiles(){const e=this.selectedTiles;this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(const e in this.frameStateData){const t=this.frameStateData[e];this.selectedTiles=this.selectedTiles.concat(t.selectedTiles),this._requestedTiles=this._requestedTiles.concat(t._requestedTiles),this._emptyTiles=this._emptyTiles.concat(t._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);const t=new Set(this.selectedTiles.map(e=>e.id));let n=0;if(this.selectedTiles.some(e=>!e.tileDrawn)){for(const e of t)this._heldTiles.add(e);for(const e of this._heldTiles){if(t.has(e))continue;const i=this._tiles[e];i&&i.contentAvailable?(i._selectedFrame=this._frameNumber,this.selectedTiles.push(i),n++):this._heldTiles.delete(e)}}else this._heldTiles=t;n>0&&setTimeout(()=>{this.selectTiles()},0);for(const e of this.selectedTiles)this._tiles[e.id]=e;this._loadTiles(),this._unloadTiles(),this._updateStats(),this._tilesChanged(e,this.selectedTiles)&&this.options.onUpdate()}_tilesChanged(e,t){if(e.length!==t.length)return!0;const n=new Set(e.map(e=>e.id)),i=new Set(t.map(e=>e.id));let r=e.filter(e=>!i.has(e.id)).length>0;return r=r||t.filter(e=>!n.has(e.id)).length>0,r}_loadTiles(){this._requestedTiles.sort((e,t)=>e._priority-t._priority);for(const e of this._requestedTiles)e.contentUnloaded&&this._loadTile(e)}_unloadTiles(){this._cache.unloadTiles(this,(e,t)=>e._unloadTile(t))}_updateStats(){let e=0,t=0;for(const n of this.selectedTiles)n.contentAvailable&&n.content&&(e++,n.content.pointCount?t+=n.content.pointCount:t+=n.content.vertexCount);this.stats.get(dC).count=this.selectedTiles.length,this.stats.get(fC).count=e,this.stats.get(_C).count=t,this.stats.get(yC).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(e){this.type===OS.I3S&&(this.calculateViewPropsI3S(),e.root=await e.root),this.root=this._initializeTileHeaders(e,null),this.type===OS.TILES3D&&(this._initializeTiles3DTileset(e),this.calculateViewPropsTiles3D()),this.type===OS.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){const e=this.tileset.fullExtent;if(e){const{xmin:t,xmax:n,ymin:i,ymax:r,zmin:s,zmax:o}=e;return this.cartographicCenter=new oi.P(t+(n-t)/2,i+(r-i)/2,s+(o-s)/2),this.cartesianCenter=new oi.P,Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),void(this.zoom=ES(e,this.cartographicCenter,this.cartesianCenter))}const t=this.tileset.store?.extent;if(t){const[e,n,i,r]=t;return this.cartographicCenter=new oi.P(e+(i-e)/2,n+(r-n)/2,0),this.cartesianCenter=new oi.P,Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),void(this.zoom=function(e,t,n){const[i,r,s,o]=e;return ES({xmin:i,xmax:s,ymin:r,ymax:o,zmin:0,zmax:0},t,n)}(t,this.cartographicCenter,this.cartesianCenter))}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new oi.P,this.zoom=1}calculateViewPropsTiles3D(){const e=this.root,{center:t}=e.boundingVolume;if(!t)return console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new oi.P,void(this.zoom=1);0!==t[0]||0!==t[1]||0!==t[2]?(this.cartographicCenter=new oi.P,Ellipsoid.WGS84.cartesianToCartographic(t,this.cartographicCenter)):this.cartographicCenter=new oi.P(0,0,-Ellipsoid.WGS84.radii[0]),this.cartesianCenter=t,this.zoom=TS(e.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(uC),this.stats.get(gC),this.stats.get(hC),this.stats.get(dC),this.stats.get(fC),this.stats.get(pC),this.stats.get(mC),this.stats.get(bC),this.stats.get(_C),this.stats.get(vC,"memory"),this.stats.get(yC)}_initializeTileHeaders(e,t){const n=new Tile3D(this,e.root,t);if(t&&(t.children.push(n),n.depth=t.depth+1),this.type===OS.TILES3D){const e=[];for(e.push(n);e.length>0;){const t=e.pop();this.stats.get(uC).incrementCount();const n=t.header.children||[];for(const i of n){const n=new Tile3D(this,i,t);if(n.contentUrl?.includes("?session=")){const e=new URL(n.contentUrl).searchParams.get("session");e&&(this._queryParams.session=e)}t.children.push(n),n.depth=t.depth+1,e.push(n)}}}return n}_initializeTraverser(){let e;switch(this.type){case OS.TILES3D:e=Tileset3DTraverser;break;case OS.I3S:e=I3STilesetTraverser;break;default:e=TilesetTraverser}return new e({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(e){this._destroySubtree(e)}async _loadTile(e){let t;try{this._onStartTileLoading(),t=await e.loadContent()}catch(t){this._onTileLoadError(e,t instanceof Error?t:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(e,t)}}_onTileLoadError(e,t){this.stats.get(bC).incrementCount();const n=t.message||t.toString(),i=e.url;console.error(`A 3D tile failed to load: ${e.url} ${n}`),this.options.onTileError(e,n,i)}_onTileLoad(e,t){if(t){if(this.type===OS.I3S){const e=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(uC).reset(),this.stats.get(uC).addCount(e)}e&&e.content&&fS(e,e.content),this.updateContentTypes(e),this._addTileToCache(e),this.options.onTileLoad(e)}}updateContentTypes(e){if(this.type===OS.I3S)switch(e.header.isDracoGeometry&&(this.contentFormats.draco=!0),e.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0}else if(this.type===OS.TILES3D){const{extensionsRemoved:t=[]}=e.content?.gltf||{};t.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),t.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),t.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0)}}_onStartTileLoading(){this._pendingCount++,this.stats.get(gC).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(gC).decrementCount()}_addTileToCache(e){this._cache.add(this,e,t=>t._updateCacheStats(e))}_updateCacheStats(e){this.stats.get(pC).incrementCount(),this.stats.get(hC).incrementCount(),this.gpuMemoryUsageInBytes+=e.gpuMemoryUsageInBytes||0,this.stats.get(vC).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.gpuMemoryUsageInBytes||0,this.stats.get(hC).decrementCount(),this.stats.get(mC).incrementCount(),this.stats.get(vC).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(e),e.unloadContent()}_destroy(){const e=[];for(this.root&&e.push(this.root);e.length>0;){const t=e.pop();for(const n of t.children)e.push(n);this._destroyTile(t)}this.root=null}_destroySubtree(e){const t=e,n=[];for(n.push(t);n.length>0;){e=n.pop();for(const t of e.children)n.push(t);e!==t&&this._destroyTile(e)}t.children=[]}_destroyTile(e){this._cache.unloadTile(this,e),this._unloadTile(e),e.destroy()}_initializeTiles3DTileset(e){if(e.queryString){const t=new URLSearchParams(e.queryString),n=Object.fromEntries(t.entries());this._queryParams={...this._queryParams,...n}}if(this.asset=e.asset,!this.asset)throw new Error("Tileset must have an asset property.");if("0.0"!==this.asset.version&&"1.0"!==this.asset.version&&"1.1"!==this.asset.version)throw new Error("The tileset must be 3D Tiles version either 0.0 or 1.0 or 1.1.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=e.properties,this.geometricError=e.geometricError,this._extensionsUsed=e.extensionsUsed||[],this.extras=e.extras}_initializeI3STileset(){const e=this.loadOptions.i3s;e&&"object"==typeof e&&"token"in e&&(this._queryParams.token=e.token)}}const wC={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GEOMETRY:"geom",VECTOR:"vect",GLTF:"glTF"};Object.keys(wC);function xC(e,t,n){le(e instanceof ArrayBuffer);const i=new TextDecoder("utf8"),r=new Uint8Array(e,t,n);return i.decode(r)}"undefined"!=typeof self&&self,"undefined"!=typeof window&&window,"undefined"!=typeof globalThis&&globalThis,"undefined"!=typeof document&&document;const TC="object"!=typeof process||"[object process]"!==String(process)||process.browser,EC="function"==typeof importScripts,SC=("undefined"!=typeof window&&window.orientation,"undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version));SC&&parseFloat(SC[1]);const CC=(globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.5.1"),globalThis._loadersgl_.version),PC={};function RC(e={}){const t=e.useLocalLibraries??e.core?.useLocalLibraries,n=e.CDN??e.core?.CDN,i=e.modules;return{...void 0!==t?{useLocalLibraries:t}:{},...void 0!==n?{CDN:n}:{},...void 0!==i?{modules:i}:{}}}async function MC(e,t=null,n={},i=null){return t&&(e=function(e,t,n={},i=null){if(n?.core)throw new Error("loadLibrary: options.core must be pre-normalized");if(!n.useLocalLibraries&&e.startsWith("http"))return e;i=i||e;const r=n.modules||{};if(r[i])return r[i];if(!TC)return`modules/${t}/dist/libs/${i}`;if(n.CDN)return function(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}(n.CDN.startsWith("http")),`${n.CDN}/${t}@${CC}/dist/libs/${i}`;if(EC)return`../src/libs/${i}`;return`modules/${t}/src/libs/${i}`}(e,t,n,i)),PC[e]=PC[e]||async function(e){if(e.endsWith("wasm"))return await async function(e){const{readFileAsArrayBuffer:t}=globalThis.loaders||{};if(TC||!t||e.startsWith("http")){const t=await fetch(e);return await t.arrayBuffer()}try{return await t(e)}catch{if(e.includes("/dist/libs/"))return await t(e.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load ArrayBuffer from ${e}`)}}(e);if(!TC){const{requireFromFile:t}=globalThis.loaders||{};try{const n=await(t?.(e));return n||!e.includes("/dist/libs/")?n:await(t?.(e.replace("/dist/libs/","/src/libs/")))}catch(n){if(e.includes("/dist/libs/"))try{return await(t?.(e.replace("/dist/libs/","/src/libs/")))}catch{}return console.error(n),null}}if(EC)return importScripts(e);const t=await async function(e){const{readFileAsText:t}=globalThis.loaders||{};if(TC||!t||e.startsWith("http")){const t=await fetch(e);return await t.text()}try{return await t(e)}catch{if(e.includes("/dist/libs/"))return await t(e.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load text from ${e}`)}}(e);return function(e,t){if(!TC){const{requireFromString:n}=globalThis.loaders||{};return n?.(e,t)}if(EC)return eval.call(globalThis,e),null;const n=document.createElement("script");n.id=t;try{n.appendChild(document.createTextNode(e))}catch(t){n.text=e}return document.body.appendChild(n),null}(t,e)}(e),await PC[e]}function LC(e){switch(e.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function IC(e,t,n){const i=LC(t.value),r=n||function(e){const t={};"byteOffset"in e&&(t.byteOffset=e.byteOffset.toString(10));"byteStride"in e&&(t.byteStride=e.byteStride.toString(10));"normalized"in e&&(t.normalized=e.normalized.toString());return t}(t);return{name:e,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:i}]},nullable:!1,metadata:r}}function OC(e,t,n){return IC(e,t,n?BC(n.metadata):void 0)}function BC(e){Object.entries(e);const t={};for(const n in e)t[`${n}.string`]=JSON.stringify(e[n]);return t}const NC={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},kC={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class draco_parser_DracoParser{draco;decoder;metadataQuerier;constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,t={}){const n=new this.draco.DecoderBuffer;n.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const i=this.decoder.GetEncodedGeometryType(n),r=i===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(i){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(n,r);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(n,r);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!r.ptr){const t=`DRACO decompression failed: ${e.error_msg()}`;throw new Error(t)}const s=this._getDracoLoaderData(r,i,t),o=this._getMeshData(r,s,t),a=function(e){let t=1/0,n=1/0,i=1/0,r=-1/0,s=-1/0,o=-1/0;const a=e.POSITION?e.POSITION.value:[],l=a&&a.length;for(let e=0;e<l;e+=3){const l=a[e],c=a[e+1],A=a[e+2];t=l<t?l:t,n=c<n?c:n,i=A<i?A:i,r=l>r?l:r,s=c>s?c:s,o=A>o?A:o}return[[t,n,i],[r,s,o]]}(o.attributes),l=function(e,t,n){const i=BC(t.metadata),r=[],s=function(e){const t={};for(const n in e){const i=e[n];t[i.name||"undefined"]=i}return t}(t.attributes);for(const t in e){const n=OC(t,e[t],s[t]);r.push(n)}if(n){const e=OC("indices",n);r.push(e)}return{fields:r,metadata:i}}(o.attributes,s,o.indices);return{loader:"draco",loaderData:s,header:{vertexCount:r.num_points(),boundingBox:a},...o,schema:l}}finally{this.draco.destroy(n),r&&this.draco.destroy(r)}}_getDracoLoaderData(e,t,n){const i=this._getTopLevelMetadata(e),r=this._getDracoAttributes(e,n);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:i,attributes:r}}_getDracoAttributes(e,t){const n={};for(let i=0;i<e.num_attributes();i++){const r=this.decoder.GetAttribute(e,i),s=this._getAttributeMetadata(e,i);n[r.unique_id()]={unique_id:r.unique_id(),attribute_type:r.attribute_type(),data_type:r.data_type(),num_components:r.num_components(),byte_offset:r.byte_offset(),byte_stride:r.byte_stride(),normalized:r.normalized(),attribute_index:i,metadata:s};const o=this._getQuantizationTransform(r,t);o&&(n[r.unique_id()].quantization_transform=o);const a=this._getOctahedronTransform(r,t);a&&(n[r.unique_id()].octahedron_transform=a)}return n}_getMeshData(e,t,n){const i=this._getMeshAttributes(t,e,n);if(!i.POSITION)throw new Error("DRACO: No position attribute found.");return e instanceof this.draco.Mesh?"triangle-strip"===n.topology?{topology:"triangle-strip",mode:4,attributes:i,indices:{value:this._getTriangleStripIndices(e),size:1}}:{topology:"triangle-list",mode:5,attributes:i,indices:{value:this._getTriangleListIndices(e),size:1}}:{topology:"point-list",mode:0,attributes:i}}_getMeshAttributes(e,t,n){const i={};for(const r of Object.values(e.attributes)){const e=this._deduceAttributeName(r,n);r.name=e;const s=this._getAttributeValues(t,r);if(s){const{value:t,size:n}=s;i[e]={value:t,size:n,byteOffset:r.byte_offset,byteStride:r.byte_stride,normalized:r.normalized}}}return i}_getTriangleListIndices(e){const t=3*e.num_faces(),n=4*t,i=this.draco._malloc(n);try{return this.decoder.GetTrianglesUInt32Array(e,n,i),new Uint32Array(this.draco.HEAPF32.buffer,i,t).slice()}finally{this.draco._free(i)}}_getTriangleStripIndices(e){const t=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,t),function(e){const t=e.size(),n=new Int32Array(t);for(let i=0;i<t;i++)n[i]=e.GetValue(i);return n}(t)}finally{this.draco.destroy(t)}}_getAttributeValues(e,t){const n=kC[t.data_type];if(!n)return console.warn(`DRACO: Unsupported attribute type ${t.data_type}`),null;const i=t.num_components,r=e.num_points()*i,s=r*n.BYTES_PER_ELEMENT,o=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32;default:return e.DT_INVALID}}(this.draco,n);let a;const l=this.draco._malloc(s);try{const i=this.decoder.GetAttribute(e,t.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,i,o,s,l),a=new n(this.draco.HEAPF32.buffer,l,r).slice()}finally{this.draco._free(l)}return{value:a,size:i}}_deduceAttributeName(e,t){const n=e.unique_id;for(const[e,i]of Object.entries(t.extraAttributes||{}))if(i===n)return e;const i=e.attribute_type;for(const e in NC){if(this.draco[e]===i)return NC[e]}const r=t.attributeNameEntry||"name";return e.metadata[r]?e.metadata[r].string:`CUSTOM_ATTRIBUTE_${n}`}_getTopLevelMetadata(e){const t=this.decoder.GetMetadata(e);return this._getDracoMetadata(t)}_getAttributeMetadata(e,t){const n=this.decoder.GetAttributeMetadata(e,t);return this._getDracoMetadata(n)}_getDracoMetadata(e){if(!e||!e.ptr)return{};const t={},n=this.metadataQuerier.NumEntries(e);for(let i=0;i<n;i++){const n=this.metadataQuerier.GetEntryName(e,i);t[n]=this._getDracoMetadataField(e,n)}return t}_getDracoMetadataField(e,t){const n=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,t,n);const i=function(e){const t=e.size(),n=new Int32Array(t);for(let i=0;i<t;i++)n[i]=e.GetValue(i);return n}(n);return{int:this.metadataQuerier.GetIntEntry(e,t),string:this.metadataQuerier.GetStringEntry(e,t),double:this.metadataQuerier.GetDoubleEntry(e,t),intArray:i}}finally{this.draco.destroy(n)}}_disableAttributeTransforms(e){const{quantizedAttributes:t=[],octahedronAttributes:n=[]}=e,i=[...t,...n];for(const e of i)this.decoder.SkipAttributeTransform(this.draco[e])}_getQuantizationTransform(e,t){const{quantizedAttributes:n=[]}=t,i=e.attribute_type();if(n.map(e=>this.decoder[e]).includes(i)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map(e=>t.min_value(e))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:n=[]}=t,i=e.attribute_type();if(n.map(e=>this.decoder[e]).includes(i)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}const FC="https://www.gstatic.com/draco/versioned/decoders/1.5.6",DC="draco_wasm_wrapper.js",UC="draco_decoder.wasm",VC="draco_decoder.js",zC="draco_encoder.js",GC={[DC]:`${FC}/${DC}`,[UC]:`${FC}/${UC}`,[VC]:`${FC}/${VC}`,[zC]:`https://raw.githubusercontent.com/google/draco/1.4.1/javascript/${zC}`};let jC;async function HC(e={},t){const n=e.modules||{};return n.draco3d?jC||=n.draco3d.createDecoderModule({}).then(e=>({draco:e})):jC||=async function(e,t){let n,i;if("js"===t)n=await MC(GC[VC],"draco",e,VC);else try{[n,i]=await Promise.all([await MC(GC[DC],"draco",e,DC),await MC(GC[UC],"draco",e,UC)])}catch{n=null,i=null}n=WC(n,"DracoDecoderModule"),n=n||globalThis.DracoDecoderModule,n||TC||([n,i]=await Promise.all([await MC(GC[DC],"draco",{...e,useLocalLibraries:!0},DC),await MC(GC[UC],"draco",{...e,useLocalLibraries:!0},UC)]),n=WC(n,"DracoDecoderModule"),n=n||globalThis.DracoDecoderModule);return await function(e,t){if("function"!=typeof e)throw new Error("DracoDecoderModule could not be loaded");const n={};t&&(n.wasmBinary=t);return new Promise(t=>{e({...n,onModuleLoaded:e=>t({draco:e})})})}(n,i)}(e,t),await jC}function WC(e,t){if(e&&"object"==typeof e){if(e.default)return e.default;if(e[t])return e[t]}return e}const qC={...{dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:"4.5.1",worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:"object"==typeof WebAssembly?"wasm":"js",extraAttributes:{},attributeNameEntry:void 0}}},parse:async function(e,t){const{draco:n}=await HC(RC(t),t?.draco?.decoderType||"wasm"),i=new draco_parser_DracoParser(n);try{return i.parseSync(e,t?.draco)}finally{i.destroy()}}};async function KC(e,t,n,i){return i._parse(e,t,n,i)}const QC={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},XC={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,...QC},$C={[QC.DOUBLE]:Float64Array,[QC.FLOAT]:Float32Array,[QC.UNSIGNED_SHORT]:Uint16Array,[QC.UNSIGNED_INT]:Uint32Array,[QC.UNSIGNED_BYTE]:Uint8Array,[QC.BYTE]:Int8Array,[QC.SHORT]:Int16Array,[QC.INT]:Int32Array},ZC={DOUBLE:QC.DOUBLE,FLOAT:QC.FLOAT,UNSIGNED_SHORT:QC.UNSIGNED_SHORT,UNSIGNED_INT:QC.UNSIGNED_INT,UNSIGNED_BYTE:QC.UNSIGNED_BYTE,BYTE:QC.BYTE,SHORT:QC.SHORT,INT:QC.INT},YC="Failed to convert GL type";class GLType{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(const t in $C){if($C[t]===e)return t}throw new Error(YC)}static fromName(e){const t=ZC[e];if(!t)throw new Error(YC);return t}static getArrayType(e){switch(e){case QC.UNSIGNED_SHORT_5_6_5:case QC.UNSIGNED_SHORT_4_4_4_4:case QC.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:const t=$C[e];if(!t)throw new Error(YC);return t}}static getByteSize(e){return GLType.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return Boolean(GLType.getArrayType(e))}static createTypedArray(e,t,n=0,i){void 0===i&&(i=(t.byteLength-n)/GLType.getByteSize(e));const r=ArrayBuffer.isView(t)?t.buffer:t;return new(GLType.getArrayType(e))(r,n,i)}}class Tile3DFeatureTable{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(e,t){this.json=e,this.buffer=t}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return Boolean(this.json[e])}getGlobalProperty(e,t=XC.UNSIGNED_INT,n=1){const i=this.json[e];return i&&Number.isFinite(i.byteOffset)?this._getTypedArrayFromBinary(e,t,n,1,i.byteOffset):i}getPropertyArray(e,t,n){const i=this.json[e];return i&&Number.isFinite(i.byteOffset)?("componentType"in i&&(t=GLType.fromName(i.componentType)),this._getTypedArrayFromBinary(e,t,n,this.featuresLength,i.byteOffset)):this._getTypedArrayFromArray(e,t,i)}getProperty(e,t,n,i,r){const s=this.json[e];if(!s)return s;const o=this.getPropertyArray(e,t,n);if(1===n)return o[i];for(let e=0;e<n;++e)r[e]=o[n*i+e];return r}_getTypedArrayFromBinary(e,t,n,i,r){const s=this._cachedTypedArrays;let o=s[e];return o||(o=GLType.createTypedArray(t,this.buffer.buffer,this.buffer.byteOffset+r,i*n),s[e]=o),o}_getTypedArrayFromArray(e,t,n){const i=this._cachedTypedArrays;let r=i[e];if(!r){if(ArrayBuffer.isView(n)){const e=n.byteOffset,i=n.byteLength/GLType.getByteSize(t);r=GLType.createTypedArray(t,n.buffer,e,i)}else if(n instanceof ArrayBuffer)r=GLType.createTypedArray(t,n);else{r=new(GLType.getArrayType(t))(n)}i[e]=r}return r}}const JC={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},eP={SCALAR:(e,t)=>e[t],VEC2:(e,t)=>[e[2*t+0],e[2*t+1]],VEC3:(e,t)=>[e[3*t+0],e[3*t+1],e[3*t+2]],VEC4:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT2:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT3:(e,t)=>[e[9*t+0],e[9*t+1],e[9*t+2],e[9*t+3],e[9*t+4],e[9*t+5],e[9*t+6],e[9*t+7],e[9*t+8]],MAT4:(e,t)=>[e[16*t+0],e[16*t+1],e[16*t+2],e[16*t+3],e[16*t+4],e[16*t+5],e[16*t+6],e[16*t+7],e[16*t+8],e[16*t+9],e[16*t+10],e[16*t+11],e[16*t+12],e[16*t+13],e[16*t+14],e[16*t+15]]},tP={SCALAR:(e,t,n)=>{t[n]=e},VEC2:(e,t,n)=>{t[2*n+0]=e[0],t[2*n+1]=e[1]},VEC3:(e,t,n)=>{t[3*n+0]=e[0],t[3*n+1]=e[1],t[3*n+2]=e[2]},VEC4:(e,t,n)=>{t[4*n+0]=e[0],t[4*n+1]=e[1],t[4*n+2]=e[2],t[4*n+3]=e[3]},MAT2:(e,t,n)=>{t[4*n+0]=e[0],t[4*n+1]=e[1],t[4*n+2]=e[2],t[4*n+3]=e[3]},MAT3:(e,t,n)=>{t[9*n+0]=e[0],t[9*n+1]=e[1],t[9*n+2]=e[2],t[9*n+3]=e[3],t[9*n+4]=e[4],t[9*n+5]=e[5],t[9*n+6]=e[6],t[9*n+7]=e[7],t[9*n+8]=e[8],t[9*n+9]=e[9]},MAT4:(e,t,n)=>{t[16*n+0]=e[0],t[16*n+1]=e[1],t[16*n+2]=e[2],t[16*n+3]=e[3],t[16*n+4]=e[4],t[16*n+5]=e[5],t[16*n+6]=e[6],t[16*n+7]=e[7],t[16*n+8]=e[8],t[16*n+9]=e[9],t[16*n+10]=e[10],t[16*n+11]=e[11],t[16*n+12]=e[12],t[16*n+13]=e[13],t[16*n+14]=e[14],t[16*n+15]=e[15]}};const nP=e=>void 0!==e;function iP(e,t,n){if(!t)return null;let i=e.getExtension("3DTILES_batch_table_hierarchy");const r=t.HIERARCHY;return r&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),t.extensions=t.extensions||{},t.extensions["3DTILES_batch_table_hierarchy"]=r,i=r),i?function(e,t){let n,i,r;const s=e.instancesLength,o=e.classes;let a,l=e.classIds,c=e.parentCounts,A=e.parentIds,u=s;nP(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,r=getBinaryAccessor(l),l=r.createArrayBufferView(t.buffer,t.byteOffset+l.byteOffset,s));if(nP(c))for(nP(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,r=getBinaryAccessor(c),c=r.createArrayBufferView(t.buffer,t.byteOffset+c.byteOffset,s)),a=new Uint16Array(s),u=0,n=0;n<s;++n)a[n]=u,u+=c[n];nP(A)&&nP(A.byteOffset)&&(A.componentType=defaultValue(A.componentType,GL.UNSIGNED_SHORT),A.type=AttributeType.SCALAR,r=getBinaryAccessor(A),A=r.createArrayBufferView(t.buffer,t.byteOffset+A.byteOffset,u));const h=o.length;for(n=0;n<h;++n){const e=o[n].length,i=o[n].instances,r=getBinaryProperties(e,i,t);o[n].instances=combine(r,i)}const d=new Array(h).fill(0),f=new Uint16Array(s);for(n=0;n<s;++n)i=l[n],f[n]=d[i],++d[i];const p={classes:o,classIds:l,classIndexes:f,parentCounts:c,parentIndexes:a,parentIds:A};return function(e){const t=e.classIds,n=t.length;for(let t=0;t<n;++t)sP(e,t,stack)}(p),p}(i,n):null}function rP(e,t,n){if(!e)return;const i=e.parentCounts;return e.parentIds?n(e,t):i>0?function(e,t,n){const i=e.classIds,r=e.parentCounts,s=e.parentIds,o=e.parentIndexes,a=i.length,l=scratchVisited;l.length=Math.max(l.length,a);const c=++marker,A=scratchStack;A.length=0,A.push(t);for(;A.length>0;){if(l[t=A.pop()]===c)continue;l[t]=c;const i=n(e,t);if(nP(i))return i;const a=r[t],u=o[t];for(let e=0;e<a;++e){const n=s[u+e];n!==t&&A.push(n)}}return null}(e,t,n):function(e,t,n){let i=!0;for(;i;){const r=n(e,t);if(nP(r))return r;const s=e.parentIds[t];i=s!==t,t=s}throw new Error("traverseHierarchySingleParent")}(e,t,n)}function sP(e,t,n){const i=e.parentCounts,r=e.parentIds,s=e.parentIndexes,o=e.classIds.length;if(!nP(r))return;assert(t<o,`Parent index ${t} exceeds the total number of instances: ${o}`),assert(-1===n.indexOf(t),"Circular dependency detected in the batch table hierarchy."),n.push(t);const a=nP(i)?i[t]:1,l=nP(i)?s[t]:t;for(let i=0;i<a;++i){const s=r[l+i];s!==t&&sP(e,s,n)}n.pop(t)}function oP(e){return null!=e}const aP=(e,t)=>e,lP={HIERARCHY:!0,extensions:!0,extras:!0};class Tile3DBatchTableParser{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(e,t,n,i={}){le(n>=0),this.json=e||{},this.binary=t,this.featureCount=n,this._extensions=this.json?.extensions||{},this._properties={};for(const e in this.json)lP[e]||(this._properties[e]=this.json[e]);this._binaryProperties=this._initializeBinaryProperties(),i["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=iP(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,t){if(this._checkBatchId(e),le("string"==typeof t,t),this._hierarchy){return oP(rP(this._hierarchy,e,(e,n)=>{const i=e.classIds[n];return e.classes[i].name===t}))}return!1}isExactClass(e,t){return le("string"==typeof t,t),this.getExactClassName(e)===t}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){const t=this._hierarchy.classIds[e];return this._hierarchy.classes[t].name}}hasProperty(e,t){return this._checkBatchId(e),le("string"==typeof t,t),oP(this._properties[t])||this._hasPropertyInHierarchy(e,t)}getPropertyNames(e,t){this._checkBatchId(e),(t=oP(t)?t:[]).length=0;const n=Object.keys(this._properties);return t.push(...n),this._hierarchy&&this._getPropertyNamesInHierarchy(e,t),t}getProperty(e,t){if(this._checkBatchId(e),le("string"==typeof t,t),this._binaryProperties){const n=this._binaryProperties[t];if(oP(n))return this._getBinaryProperty(n,e)}const n=this._properties[t];if(oP(n))return aP(n[e]);if(this._hierarchy){const n=this._getHierarchyProperty(e,t);if(oP(n))return n}}setProperty(e,t,n){const i=this.featureCount;if(this._checkBatchId(e),le("string"==typeof t,t),this._binaryProperties){const i=this._binaryProperties[t];if(i)return void this._setBinaryProperty(i,e,n)}if(this._hierarchy&&this._setHierarchyProperty(this,e,t,n))return;let r=this._properties[t];oP(r)||(this._properties[t]=new Array(i),r=this._properties[t]),r[e]=aP(n)}_checkBatchId(e){if(!(e>=0&&e<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(e,t){return e.unpack(e.typedArray,t)}_setBinaryProperty(e,t,n){e.pack(n,e.typedArray,t)}_initializeBinaryProperties(){let e=null;for(const t in this._properties){const n=this._properties[t],i=this._initializeBinaryProperty(t,n);i&&(e=e||{},e[t]=i)}return e}_initializeBinaryProperty(e,t){if("byteOffset"in t){const n=t;le(this.binary,`Property ${e} requires a batch table binary.`),le(n.type,`Property ${e} requires a type.`);const i=function(e,t,n,i){const{componentType:r}=e;le(e.componentType);const s="string"==typeof r?GLType.fromName(r):r,o=JC[e.type],a=eP[e.type],l=tP[e.type];return n+=e.byteOffset,{values:GLType.createTypedArray(s,t,n,o*i),type:s,size:o,unpacker:a,packer:l}}(n,this.binary.buffer,0|this.binary.byteOffset,this.featureCount);return{typedArray:i.values,componentCount:i.size,unpack:i.unpacker,pack:i.packer}}return null}_hasPropertyInHierarchy(e,t){if(!this._hierarchy)return!1;const n=rP(this._hierarchy,e,(e,n)=>{const i=e.classIds[n];return oP(e.classes[i].instances[t])});return oP(n)}_getPropertyNamesInHierarchy(e,t){rP(this._hierarchy,e,(e,n)=>{const i=e.classIds[n],r=e.classes[i].instances;for(const e in r)r.hasOwnProperty(e)&&-1===t.indexOf(e)&&t.push(e)})}_getHierarchyProperty(e,t){return rP(this._hierarchy,e,(e,n)=>{const i=e.classIds[n],r=e.classes[i],s=e.classIndexes[n],o=r.instances[t];return oP(o)?oP(o.typedArray)?this._getBinaryProperty(o,s):aP(o[s]):null})}_setHierarchyProperty(e,t,n,i){const r=rP(this._hierarchy,t,(e,r)=>{const s=e.classIds[r],o=e.classes[s],a=e.classIndexes[r],l=o.instances[n];return!!oP(l)&&(le(r===t,`Inherited property "${n}" is read-only.`),oP(l.typedArray)?this._setBinaryProperty(l,a,i):l[a]=aP(i),!0)});return oP(r)}}function cP(e,t,n=0){const i=new DataView(t);if(e.magic=i.getUint32(n,!0),n+=4,e.version=i.getUint32(n,!0),n+=4,e.byteLength=i.getUint32(n,!0),n+=4,1!==e.version)throw new Error(`3D Tile Version ${e.version} not supported`);return n}const AP="b3dm tile in legacy format.";function uP(e,t,n){const i=new DataView(t);let r;e.header=e.header||{};let s=i.getUint32(n,!0);n+=4;let o=i.getUint32(n,!0);n+=4;let a=i.getUint32(n,!0);n+=4;let l=i.getUint32(n,!0);return n+=4,a>=570425344?(n-=8,r=s,a=o,l=0,s=0,o=0,console.warn(AP)):l>=570425344&&(n-=4,r=a,a=s,l=o,s=0,o=0,console.warn(AP)),e.header.featureTableJsonByteLength=s,e.header.featureTableBinaryByteLength=o,e.header.batchTableJsonByteLength=a,e.header.batchTableBinaryByteLength=l,e.header.batchLength=r,n}function hP(e,t,n,i){return n=function(e,t,n){const{featureTableJsonByteLength:i,featureTableBinaryByteLength:r,batchLength:s}=e.header||{};if(e.featureTableJson={BATCH_LENGTH:s||0},i&&i>0){const r=xC(t,n,i);e.featureTableJson=JSON.parse(r)}return n+=i||0,e.featureTableBinary=new Uint8Array(t,n,r),n+=r||0,n}(e,t,n),n=function(e,t,n){const{batchTableJsonByteLength:i,batchTableBinaryByteLength:r}=e.header||{};if(i&&i>0){const s=xC(t,n,i);e.batchTableJson=JSON.parse(s),n+=i,r&&r>0&&(e.batchTableBinary=new Uint8Array(t,n,r),e.batchTableBinary=new Uint8Array(e.batchTableBinary),n+=r)}return n}(e,t,n),n}function dP(e,t=[0,0,0]){const n=e>>11&31,i=e>>5&63,r=31&e;return t[0]=n<<3,t[1]=i<<2,t[2]=r<<3,t}function fP(e,t,n){if(!(t||e&&e.batchIds&&n))return null;const{batchIds:i,isRGB565:r,pointCount:s=0}=e;if(i&&n){const e=new Uint8ClampedArray(3*s);for(let t=0;t<s;t++){const r=i[t],s=n.getProperty(r,"dimensions").map(e=>255*e);e[3*t]=s[0],e[3*t+1]=s[1],e[3*t+2]=s[2]}return{type:XC.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}if(t&&r){const e=new Uint8ClampedArray(3*s);for(let n=0;n<s;n++){const i=dP(t[n]);e[3*n]=i[0],e[3*n+1]=i[1],e[3*n+2]=i[2]}return{type:XC.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}return t&&t.length===3*s?{type:XC.UNSIGNED_BYTE,value:t,size:3,normalized:!0}:{type:XC.UNSIGNED_BYTE,value:t||new Uint8ClampedArray,size:4,normalized:!0}}class vector2_Vector2 extends ub.M{constructor(e=0,t=0){super(2),(0,xn.cy)(e)&&1===arguments.length?this.copy(e):(xn.$W.debug&&((0,eb.ws)(e),(0,eb.ws)(t)),this[0]=e,this[1]=t)}set(e,t){return this[0]=e,this[1]=t,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this.check()}fromObject(e){return xn.$W.debug&&((0,eb.ws)(e.x),(0,eb.ws)(e.y)),this[0]=e.x,this[1]=e.y,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return(0,ob.Z0)(this,this,e),this.check()}transformAsVector(e){return(0,tb.B$)(this,this,e),this.check()}transformByMatrix3(e){return(0,ob.ei)(this,this,e),this.check()}transformByMatrix2x3(e){return(0,ob.l0)(this,this,e),this.check()}transformByMatrix2(e){return(0,ob.ZF)(this,this,e),this.check()}}new vector2_Vector2,new oi.P,new vector2_Vector2,new vector2_Vector2,new Uint8Array(1);function pP(e,t=255){return(0,xn.qE)(e,0,t)/t*2-1}function gP(e){return e<0?-1:1}function mP(e,t,n,i){if(function(e,t){if(!e)throw new Error(`math.gl assertion failed. ${t}`)}(i),e<0||e>n||t<0||t>n)throw new Error(`x and y must be unsigned normalized integers between 0 and ${n}`);if(i.x=pP(e,n),i.y=pP(t,n),i.z=1-(Math.abs(i.x)+Math.abs(i.y)),i.z<0){const e=i.x;i.x=(1-Math.abs(i.y))*gP(e),i.y=(1-Math.abs(e))*gP(i.y)}return i.normalize()}function bP(e,t,n){return mP(e,t,255,n)}const _P=new oi.P;function vP(e,t,n){return e.isQuantized?n["3d-tiles"]&&n["3d-tiles"].decodeQuantizedPositions?(e.isQuantized=!1,function(e,t){const n=new oi.P,i=new Float32Array(3*e.pointCount);for(let r=0;r<e.pointCount;r++)n.set(t[3*r],t[3*r+1],t[3*r+2]).scale(1/e.quantizedRange).multiply(e.quantizedVolumeScale).add(e.quantizedVolumeOffset).toArray(i,3*r);return i}(e,t)):{type:XC.UNSIGNED_SHORT,value:t,size:3,normalized:!0}:t}async function yP(e,t,n,i,r){n=hP(e,t,n=uP(e,t,n=cP(e,t,n))),function(e){e.attributes={positions:null,colors:null,normals:null,batchIds:null},e.isQuantized=!1,e.isTranslucent=!1,e.isRGB565=!1,e.isOctEncoded16P=!1}(e);const{featureTable:s,batchTable:o}=function(e){const t=new Tile3DFeatureTable(e.featureTableJson,e.featureTableBinary),n=t.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(n))throw new Error("POINTS_LENGTH must be defined");t.featuresLength=n,e.featuresLength=n,e.pointsLength=n,e.pointCount=n,e.rtcCenter=t.getGlobalProperty("RTC_CENTER",XC.FLOAT,3);const i=function(e,t){let n=null;if(!e.batchIds&&t.hasProperty("BATCH_ID")&&(e.batchIds=t.getPropertyArray("BATCH_ID",XC.UNSIGNED_SHORT,1),e.batchIds)){const i=t.getGlobalProperty("BATCH_LENGTH");if(!i)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");const{batchTableJson:r,batchTableBinary:s}=e;n=new Tile3DBatchTableParser(r,s,i)}return n}(e,t);return{featureTable:t,batchTable:i}}(e);return await async function(e,t,n,i,r){let s,o,a;const l=e.batchTableJson&&e.batchTableJson.extensions&&e.batchTableJson.extensions["3DTILES_draco_point_compression"];l&&(a=l.properties);const c=t.getExtension("3DTILES_draco_point_compression");if(c){o=c.properties;const t=c.byteOffset,n=c.byteLength;if(!o||!Number.isFinite(t)||!n)throw new Error("Draco properties, byteOffset, and byteLength must be defined");s=(e.featureTableBinary||[]).slice(t,t+n),e.hasPositions=Number.isFinite(o.POSITION),e.hasColors=Number.isFinite(o.RGB)||Number.isFinite(o.RGBA),e.hasNormals=Number.isFinite(o.NORMAL),e.hasBatchIds=Number.isFinite(o.BATCH_ID),e.isTranslucent=Number.isFinite(o.RGBA)}if(!s)return!0;const A={buffer:s,properties:{...o,...a},featureTableProperties:o,batchTableProperties:a,dequantizeInShader:!1};return await async function(e,t,n,i){if(!i)return;const r={...n,draco:{...n?.draco,extraAttributes:t.batchTableProperties||{}}};delete r["3d-tiles"];const s=await KC(t.buffer,qC,r,i),o=s.attributes.POSITION&&s.attributes.POSITION.value,a=s.attributes.COLOR_0&&s.attributes.COLOR_0.value,l=s.attributes.NORMAL&&s.attributes.NORMAL.value,c=s.attributes.BATCH_ID&&s.attributes.BATCH_ID.value,A=o&&s.attributes.POSITION.value.quantization,u=l&&s.attributes.NORMAL.value.quantization;if(A){const t=s.POSITION.data.quantization,n=t.range;e.quantizedVolumeScale=new oi.P(n,n,n),e.quantizedVolumeOffset=new oi.P(t.minValues),e.quantizedRange=(1<<t.quantizationBits)-1,e.isQuantizedDraco=!0}u&&(e.octEncodedRange=(1<<s.NORMAL.data.quantization.quantizationBits)-1,e.isOctEncodedDraco=!0);const h={};if(t.batchTableProperties)for(const e of Object.keys(t.batchTableProperties))s.attributes[e]&&s.attributes[e].value&&(h[e.toLowerCase()]=s.attributes[e].value);e.attributes={positions:o,colors:fP(e,a,void 0),normals:l,batchIds:c,...h}}(e,A,i,r)}(e,s,0,i,r),function(e,t,n){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.positions)if(t.hasProperty("POSITION"))e.attributes.positions=t.getPropertyArray("POSITION",XC.FLOAT,3);else if(t.hasProperty("POSITION_QUANTIZED")){const i=t.getPropertyArray("POSITION_QUANTIZED",XC.UNSIGNED_SHORT,3);if(e.isQuantized=!0,e.quantizedRange=65535,e.quantizedVolumeScale=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",XC.FLOAT,3),!e.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(e.quantizedVolumeOffset=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",XC.FLOAT,3),!e.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");e.attributes.positions=vP(e,i,n)}if(!e.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}(e,s,i),function(e,t,n){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.colors){let i=null;t.hasProperty("RGBA")?(i=t.getPropertyArray("RGBA",XC.UNSIGNED_BYTE,4),e.isTranslucent=!0):t.hasProperty("RGB")?i=t.getPropertyArray("RGB",XC.UNSIGNED_BYTE,3):t.hasProperty("RGB565")&&(i=t.getPropertyArray("RGB565",XC.UNSIGNED_SHORT,1),e.isRGB565=!0),e.attributes.colors=fP(e,i,n)}t.hasProperty("CONSTANT_RGBA")&&(e.constantRGBA=t.getGlobalProperty("CONSTANT_RGBA",XC.UNSIGNED_BYTE,4))}(e,s,o),function(e,t){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.normals){let n=null;t.hasProperty("NORMAL")?n=t.getPropertyArray("NORMAL",XC.FLOAT,3):t.hasProperty("NORMAL_OCT16P")&&(n=t.getPropertyArray("NORMAL_OCT16P",XC.UNSIGNED_BYTE,2),e.isOctEncoded16P=!0),e.attributes.normals=function(e,t){if(!t)return null;if(e.isOctEncoded16P){const n=new Float32Array(3*(e.pointsLength||0));for(let i=0;i<(e.pointsLength||0);i++)bP(t[2*i],t[2*i+1],_P),_P.toArray(n,3*i);return{type:XC.FLOAT,size:2,value:n}}return{type:XC.FLOAT,size:2,value:t}}(e,n)}}(e,s),n}function wP(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}function xP(e){try{return JSON.parse(e)}catch(t){throw new Error(`Failed to parse JSON from data starting with "${function(e,t=5){if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return wP(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer)return wP(e,0,t);return""}(e)}"`)}}function TP(e,t,n){const i=void 0!==n?new Uint8Array(e).subarray(t,t+n):new Uint8Array(e).subarray(t);return new Uint8Array(i).buffer}const EP="basis_transcoder.js",SP="basis_transcoder.wasm",CP="basis_encoder.js",PP="basis_encoder.wasm";let RP,MP;async function LP(e){var t;t=e.modules,globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,t);const n=function(e){const t=globalThis.loaders?.modules?.[e];return t||null}("basis");return n||(RP||=async function(e){let t=null,n=null;return[t,n]=await Promise.all([await MC(EP,"textures",e),await MC(SP,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const n={};t&&(n.wasmBinary=t);return new Promise(t=>{e(n).then(e=>{const{BasisFile:n,initializeBasis:i}=e;i(),t({BasisFile:n})})})}(t,n)}(e),await RP)}async function IP(e){const t=e.modules||{};return t.basisEncoder?t.basisEncoder:(MP=MP||async function(e){let t=null,n=null;return[t,n]=await Promise.all([await MC(CP,"textures",e),await MC(PP,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const n={};t&&(n.wasmBinary=t);return new Promise(t=>{e(n).then(e=>{const{BasisFile:n,KTX2File:i,initializeBasis:r,BasisEncoder:s}=e;r(),t({BasisFile:n,KTX2File:i,BasisEncoder:s})})})}(t,n)}(e),await MP)}const OP=["","WEBKIT_","MOZ_"],BP={WEBGL_compressed_texture_s3tc:["bc1-rgb-unorm-webgl","bc1-rgba-unorm","bc2-rgba-unorm","bc3-rgba-unorm"],WEBGL_compressed_texture_s3tc_srgb:["bc1-rgb-unorm-srgb-webgl","bc1-rgba-unorm-srgb","bc2-rgba-unorm-srgb","bc3-rgba-unorm-srgb"],EXT_texture_compression_rgtc:["bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm"],EXT_texture_compression_bptc:["bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"],WEBGL_compressed_texture_etc1:["etc1-rgb-unorm-webgl"],WEBGL_compressed_texture_etc:["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"],WEBGL_compressed_texture_pvrtc:["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rgb2unorm-webgl","pvrtc-rgba2unorm-webgl"],WEBGL_compressed_texture_atc:["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"],WEBGL_compressed_texture_astc:["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]};let NP=null;function kP(e){if(!NP){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,NP=new Set;for(const t of OP)for(const n in BP)if(e&&e.getExtension(`${t}${n}`))for(const e of BP[n])NP.add(e)}return NP}const FP=[171,75,84,88,32,50,48,187,13,10,26,10];let DP=Promise.resolve();const UP={etc1:{basisFormat:0,compressed:!0,format:36196,textureFormat:"etc1-rgb-unorm-webgl"},etc2:{basisFormat:1,compressed:!0,format:37493,textureFormat:"etc2-rgba8unorm"},bc1:{basisFormat:2,compressed:!0,format:33776,textureFormat:"bc1-rgb-unorm-webgl"},bc3:{basisFormat:3,compressed:!0,format:33779,textureFormat:"bc3-rgba-unorm"},bc4:{basisFormat:4,compressed:!0,format:36283,textureFormat:"bc4-r-unorm"},bc5:{basisFormat:5,compressed:!0,format:36285,textureFormat:"bc5-rg-unorm"},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0,format:36492,textureFormat:"bc7-rgba-unorm"},"bc7-m5":{basisFormat:7,compressed:!0,format:36492,textureFormat:"bc7-rgba-unorm"},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:35840,textureFormat:"pvrtc-rgb4unorm-webgl"},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:35842,textureFormat:"pvrtc-rgba4unorm-webgl"},"astc-4x4":{basisFormat:10,compressed:!0,format:37808,textureFormat:"astc-4x4-unorm"},"atc-rgb":{basisFormat:11,compressed:!0,format:35986,textureFormat:"atc-rgb-unorm-webgl"},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0,format:34798,textureFormat:"atc-rgbai-unorm-webgl"},rgba32:{basisFormat:13,compressed:!1,format:32856,textureFormat:"rgba8unorm"},rgb565:{basisFormat:14,compressed:!1,format:36194,textureFormat:"rgb565unorm-webgl"},bgr565:{basisFormat:15,compressed:!1,format:36194,textureFormat:"rgb565unorm-webgl"},rgba4444:{basisFormat:16,compressed:!1,format:32854,textureFormat:"rgba4unorm-webgl"}};Object.freeze(Object.keys(UP));function VP(e,t,n){const i=new e(new Uint8Array(t));try{if(!i.startTranscoding())throw new Error("Failed to start basis transcoding");const e=i.getNumImages(),t=[];for(let r=0;r<e;r++){const e=i.getNumLevels(r),s=[];for(let t=0;t<e;t++)s.push(zP(i,r,t,n));t.push(s)}return t}finally{i.close(),i.delete()}}function zP(e,t,n,i){const r=e.getImageWidth(t,n),s=e.getImageHeight(t,n),o=e.getHasAlpha(),{compressed:a,format:l,basisFormat:c,textureFormat:A}=HP(i,o),u=e.getImageTranscodedSizeInBytes(t,n,c),h=new Uint8Array(u);if(!e.transcodeImage(h,t,n,c,0,0))throw new Error("failed to start Basis transcoding");return{shape:"texture-level",width:r,height:s,data:h,compressed:a,...void 0!==l?{format:l}:{},...void 0!==A?{textureFormat:A}:{},hasAlpha:o}}function GP(e,t,n){const i=new e(new Uint8Array(t));try{if(!i.startTranscoding())throw new Error("failed to start KTX2 transcoding");const e=i.getLevels(),t=[];for(let r=0;r<e;r++)t.push(jP(i,r,n));return[t]}finally{i.close(),i.delete()}}function jP(e,t,n){const{alphaFlag:i,height:r,width:s}=e.getImageLevelInfo(t,0,0),{compressed:o,format:a,basisFormat:l,textureFormat:c}=HP(n,i),A=e.getImageTranscodedSizeInBytes(t,0,0,l),u=new Uint8Array(A);if(!e.transcodeImage(u,t,0,0,l,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{shape:"texture-level",width:s,height:r,data:u,compressed:o,...void 0!==a?{format:a}:{},...void 0!==c?{textureFormat:c}:{},levelSize:A,hasAlpha:i}}function HP(e,t){let n=e.basis?.format||"auto";"auto"===n&&(n=e.basis?.supportedTextureFormats?WP(e.basis.supportedTextureFormats):WP()),"object"==typeof n&&(n=t?n.alpha:n.noAlpha);const i=n.toLowerCase(),r=UP[i];if(!r)throw new Error(`Unknown Basis format ${n}`);return r}function WP(e=kP()){const t=new Set(e);return qP(t,["astc-4x4-unorm","astc-4x4-unorm-srgb"])?"astc-4x4":qP(t,["bc7-rgba-unorm","bc7-rgba-unorm-srgb"])?{alpha:"bc7-m5",noAlpha:"bc7-m6-opaque-only"}:qP(t,["bc1-rgb-unorm-webgl","bc1-rgb-unorm-srgb-webgl","bc1-rgba-unorm","bc1-rgba-unorm-srgb","bc2-rgba-unorm","bc2-rgba-unorm-srgb","bc3-rgba-unorm","bc3-rgba-unorm-srgb"])?{alpha:"bc3",noAlpha:"bc1"}:qP(t,["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rgb2unorm-webgl","pvrtc-rgba2unorm-webgl"])?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:qP(t,["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"])?"etc2":t.has("etc1-rgb-unorm-webgl")?"etc1":qP(t,["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"])?{alpha:"atc-rgba-interpolated-alpha",noAlpha:"atc-rgb"}:"rgb565"}function qP(e,t){return t.some(t=>e.has(t))}const KP={dataType:null,batchType:null,name:"Basis",id:"basis",module:"textures",version:"4.5.1",worker:!0,extensions:["basis","ktx2"],mimeTypes:["application/octet-stream","image/ktx2"],tests:["sB"],binary:!0,options:{basis:{format:"auto",containerFormat:"auto",module:"transcoder"}},parse:async function(e,t={}){const n=RC(t);return await async function(e){const t=DP;let n;DP=new Promise(e=>{n=e}),await t;try{return await e()}finally{n()}}(async()=>{if(!t.basis?.containerFormat||"auto"===t.basis.containerFormat){if(function(e){const t=new Uint8Array(e);return!(t.byteLength<FP.length||t[0]!==FP[0]||t[1]!==FP[1]||t[2]!==FP[2]||t[3]!==FP[3]||t[4]!==FP[4]||t[5]!==FP[5]||t[6]!==FP[6]||t[7]!==FP[7]||t[8]!==FP[8]||t[9]!==FP[9]||t[10]!==FP[10]||t[11]!==FP[11])}(e)){return GP((await IP(n)).KTX2File,e,t)}const{BasisFile:i}=await LP(n);return VP(i,e,t)}if("encoder"===t.basis.module){const i=await IP(n);return"ktx2"===t.basis.containerFormat?GP(i.KTX2File,e,t):VP(i.BasisFile,e,t)}{const{BasisFile:i}=await LP(n);return VP(i,e,t)}})}};function QP(e,t){if(!e)throw new Error(t||"assert failed: gltf")}function XP(e,t){return le(e>=0),le(t>0),e+(t-1)&~(t-1)}function $P(e,t,n){let i;if(e instanceof ArrayBuffer)i=new Uint8Array(e);else{const t=e.byteOffset,n=e.byteLength;i=new Uint8Array(e.buffer||e.arrayBuffer,t,n)}return t.set(i,n),n+XP(i.byteLength,4)}const ZP=!0,YP=1735152710,JP=1313821514,eR=5130562;function tR(e,t,n=0,i={}){const r=new DataView(t),s=function(e,t=0){return`${String.fromCharCode(e.getUint8(t+0))}${String.fromCharCode(e.getUint8(t+1))}${String.fromCharCode(e.getUint8(t+2))}${String.fromCharCode(e.getUint8(t+3))}`}(r,n+0),o=r.getUint32(n+4,ZP),a=r.getUint32(n+8,ZP);switch(Object.assign(e,{header:{byteOffset:n,byteLength:a,hasBinChunk:!1},type:s,version:o,json:{},binChunks:[]}),n+=12,e.version){case 1:return function(e,t,n){le(e.header.byteLength>20);const i=t.getUint32(n+0,ZP),r=t.getUint32(n+4,ZP);return n+=8,le(0===r),nR(e,t,n,i),n+=i,n+=iR(e,t,n,e.header.byteLength),n}(e,r,n);case 2:return function(e,t,n,i){return le(e.header.byteLength>20),function(e,t,n,i){for(;n+8<=e.header.byteLength;){const r=t.getUint32(n+0,ZP),s=t.getUint32(n+4,ZP);switch(n+=8,s){case JP:nR(e,t,n,r);break;case eR:iR(e,t,n,r);break;case 0:i.strict||nR(e,t,n,r);break;case 1:i.strict||iR(e,t,n,r)}n+=XP(r,4)}}(e,t,n,i),n+e.header.byteLength}(e,r,n,{});default:throw new Error(`Invalid GLB version ${e.version}. Only supports version 1 and 2.`)}}function nR(e,t,n,i){const r=new Uint8Array(t.buffer,n,i),s=new TextDecoder("utf8").decode(r);return e.json=JSON.parse(s),XP(i,4)}function iR(e,t,n,i){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:n,byteLength:i,arrayBuffer:t.buffer}),XP(i,4)}function rR(e,t,n){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const i=n?.baseUrl||function(e){if(!e)return;if(e.endsWith("/"))return e;const t=e.lastIndexOf("/");return t>=0?e.slice(0,t+1):""}(t?.core?.baseUrl);if(!i)throw new Error(`'baseUrl' must be provided to resolve relative url ${e}`);return i.endsWith("/")?`${i}${e}`:`${i}/${e}`}const sR={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},oR={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};const aR=["SCALAR","VEC2","VEC3","VEC4"],lR=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],cR=new Map(lR),AR={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},uR={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},hR={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function dR(e){return aR[e-1]||aR[0]}function fR(e){const t=cR.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function pR(e,t){const n=hR[e.componentType],i=AR[e.type],r=uR[e.componentType],s=e.count*i,o=e.count*i*r;QP(o>=0&&o<=t.byteLength);return{ArrayType:n,length:s,byteLength:o,componentByteSize:oR[e.componentType],numberOfComponentsInElement:sR[e.type]}}function gR(e){let{images:t,bufferViews:n}=e;t=t||[],n=n||[];const i=t.map(e=>e.bufferView);n=n.filter(e=>!i.includes(e));const r=n.reduce((e,t)=>e+t.byteLength,0),s=t.reduce((e,t)=>{const{width:n,height:i}=t.image;return e+n*i},0);return r+Math.ceil(4*s*1.33)}function mR(e,t,n){const i=e.bufferViews[n];QP(i);const r=t[i.buffer];QP(r);const s=(i.byteOffset||0)+r.byteOffset;return new Uint8Array(r.arrayBuffer,s,i.byteLength)}class gltf_scenegraph_GLTFScenegraph{gltf;sourceBuffers;byteLength;constructor(e){this.gltf={json:e?.json||{asset:{version:"2.0",generator:"loaders.gl"},buffers:[],extensions:{},extensionsRequired:[],extensionsUsed:[]},buffers:e?.buffers||[],images:e?.images||[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}hasExtension(e){const t=this.getUsedExtensions().find(t=>t===e),n=this.getRequiredExtensions().find(t=>t===e);return"string"==typeof t||"string"==typeof n}getExtension(e){const t=this.getUsedExtensions().find(t=>t===e),n=this.json.extensions||{};return t?n[e]:null}getRequiredExtension(e){return this.getRequiredExtensions().find(t=>t===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,t){return(e.extensions||{})[t]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,t){if("object"==typeof t)return t;const n=this.json[e]&&this.json[e][t];if(!n)throw new Error(`glTF file error: Could not find ${e}[${t}]`);return n}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,n=this.gltf.buffers[t];QP(n);const i=(e.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,i,e.byteLength)}getTypedArrayForAccessor(e){const t=this.getAccessor(e);return function(e,t,n){const i="number"==typeof n?e.accessors?.[n]:n;if(!i)throw new Error(`No gltf accessor ${JSON.stringify(n)}`);const r=e.bufferViews?.[i.bufferView||0];if(!r)throw new Error(`No gltf buffer view for accessor ${r}`);const{arrayBuffer:s,byteOffset:o}=t[r.buffer],a=(o||0)+(i.byteOffset||0)+(r.byteOffset||0),{ArrayType:l,length:c,componentByteSize:A,numberOfComponentsInElement:u}=pR(i,r),h=A*u,d=r.byteStride||h;if(void 0===r.byteStride||r.byteStride===h)return new l(s,a,c);const f=new l(c);for(let e=0;e<i.count;e++){const t=new l(s,a+e*d,u);f.set(t,e*u)}return f}(this.gltf.json,this.gltf.buffers,t)}getTypedArrayForImageData(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),n=this.getBuffer(t.buffer).data,i=t.byteOffset||0;return new Uint8Array(n,i,t.byteLength)}addApplicationData(e,t){return this.json[e]=t,this}addExtraData(e,t){return this.json.extras=this.json.extras||{},this.json.extras[e]=t,this}addObjectExtension(e,t,n){return e.extensions=e.extensions||{},e.extensions[t]=n,this.registerUsedExtension(t),this}setObjectExtension(e,t,n){(e.extensions||{})[t]=n}removeObjectExtension(e,t){const n=e?.extensions||{};if(n[t]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];const e=this.json.extensionsRemoved;e.includes(t)||e.push(t)}delete n[t]}addExtension(e,t={}){return QP(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),t}addRequiredExtension(e,t={}){return QP(t),this.addExtension(e,t),this.registerRequiredExtension(e),t}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(t=>t===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(t=>t===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(this.json.extensions?.[e]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];const t=this.json.extensionsRemoved;t.includes(e)||t.push(e)}this.json.extensions&&delete this.json.extensions[e],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e)}setDefaultScene(e){this.json.scene=e}addScene(e){const{nodeIndices:t}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}addNode(e){const{meshIndex:t,matrix:n}=e;this.json.nodes=this.json.nodes||[];const i={mesh:t};return n&&(i.matrix=n),this.json.nodes.push(i),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:n,material:i,mode:r=4}=e,s={primitives:[{attributes:this._addAttributes(t),mode:r}]};if(n){const e=this._addIndices(n);s.primitives[0].indices=e}return Number.isFinite(i)&&(s.primitives[0].material=i),this.json.meshes=this.json.meshes||[],this.json.meshes.push(s),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addImage(e,t){const n=Re(e),i=t||n?.mimeType,r={bufferView:this.addBufferView(e),mimeType:i};return this.json.images=this.json.images||[],this.json.images.push(r),this.json.images.length-1}addBufferView(e,t=0,n=this.byteLength){const i=e.byteLength;QP(Number.isFinite(i)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const r={buffer:t,byteOffset:n,byteLength:i};return this.byteLength+=XP(i,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(r),this.json.bufferViews.length-1}addAccessor(e,t){const n={bufferView:e,type:dR(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(n),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const n=this.addBufferView(e);let i={min:t.min,max:t.max};i.min&&i.max||(i=this._getAccessorMinMax(e,t.size));const r={size:t.size,componentType:fR(e),count:Math.round(e.length/t.size),min:i.min,max:i.max};return this.addAccessor(n,Object.assign(r,t))}addTexture(e){const{imageIndex:t}=e,n={source:t};return this.json.textures=this.json.textures||[],this.json.textures.push(n),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){const e=this.byteLength,t=new ArrayBuffer(e),n=new Uint8Array(t);let i=0;for(const e of this.sourceBuffers||[])i=$P(e,n,i);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=e:this.json.buffers=[{byteLength:e}],this.gltf.binary=t,this.sourceBuffers=[t],this.gltf.buffers=[{arrayBuffer:t,byteOffset:0,byteLength:t.byteLength}]}_removeStringFromArray(e,t){let n=!0;for(;n;){const i=e.indexOf(t);i>-1?e.splice(i,1):n=!1}}_addAttributes(e={}){const t={};for(const n in e){const i=e[n],r=this._getGltfAttributeName(n),s=this.addBinaryBuffer(i.value,i);t[r]=s}return t}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,t){const n={min:null,max:null};if(e.length<t)return n;n.min=[],n.max=[];const i=e.subarray(0,t);for(const e of i)n.min.push(e),n.max.push(e);for(let i=t;i<e.length;i+=t)for(let r=0;r<t;r++)n.min[0+r]=Math.min(n.min[0+r],e[i+r]),n.max[0+r]=Math.max(n.max[0+r],e[i+r]);return n}}function bR(e){if(e instanceof ArrayBuffer)return e;if(t=e,"undefined"!=typeof SharedArrayBuffer&&t instanceof SharedArrayBuffer)return _R(e);var t;const{buffer:n,byteOffset:i,byteLength:r}=e;return n instanceof ArrayBuffer&&0===i&&r===n.byteLength?n:_R(n,i,r)}function _R(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 vR(e){return(e%1+1)%1}const yR={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16,BOOLEAN:1,STRING:1,ENUM:1},wR={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:BigInt64Array,UINT64:BigUint64Array,FLOAT32:Float32Array,FLOAT64:Float64Array},xR={INT8:1,UINT8:1,INT16:2,UINT16:2,INT32:4,UINT32:4,INT64:8,UINT64:8,FLOAT32:4,FLOAT64:8};function TR(e,t){return xR[t]*yR[e]}function ER(e,t,n,i){if("UINT8"!==n&&"UINT16"!==n&&"UINT32"!==n&&"UINT64"!==n)return null;const r=SR(e.getTypedArrayForBufferView(t),"SCALAR",n,i+1);return r instanceof BigInt64Array||r instanceof BigUint64Array?null:r}function SR(e,t,n,i=1){const r=wR[n],s=xR[n],o=i*yR[t],a=o*s;let l=e.buffer,c=e.byteOffset;if(c%s!==0){l=new Uint8Array(l).slice(c,c+a).buffer,c=0}return new r(bR(l),c,o)}function CR(e,t,n){const i=`TEXCOORD_${t.texCoord||0}`,r=n.attributes[i],s=e.getTypedArrayForAccessor(r),o=e.gltf.json,a=t.index,l=o.textures?.[a]?.source;if(void 0!==l){const n=o.images?.[l]?.mimeType,i=e.gltf.images?.[l];if(i&&void 0!==i.width){const e=[];for(let r=0;r<s.length;r+=2){const o=RR(i,n,s,r,t.channels);e.push(o)}return e}}return[]}function PR(e,t,n,i,r){if(!n?.length)return;const s=[];for(const e of n){let t=i.findIndex(t=>t===e);-1===t&&(t=i.push(e)-1),s.push(t)}const o=new Uint32Array(s),a=e.gltf.buffers.push({arrayBuffer:o.buffer,byteOffset:o.byteOffset,byteLength:o.byteLength})-1,l=e.addBufferView(o,a,0),c=e.addAccessor(l,{size:1,componentType:fR(o),count:o.length});r.attributes[t]=c}function RR(e,t,n,i,r=[0]){const s={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},o=n[i],a=n[i+1];let l=1;!t||-1===t.indexOf("image/jpeg")&&-1===t.indexOf("image/png")||(l=4);const c=function(e,t,n,i=1){const r=n.width,s=vR(e)*(r-1),o=Math.round(s),a=n.height,l=vR(t)*(a-1),c=Math.round(l),A=n.components?n.components:i,u=(c*r+o)*A;return u}(o,a,e,l);let A=0;for(const t of r){const n="number"==typeof t?Object.values(s)[t]:s[t],i=c+n.offset,r=me(e);if(r.data.length<=i)throw new Error(`${r.data.length} <= ${i}`);A|=r.data[i]<<n.shift}return A}function MR(e,t,n,i,r){const s=[];for(let o=0;o<t;o++){const t=n[o],a=n[o+1]-n[o];if(a+t>i)break;const l=t/r,c=a/r;s.push(e.slice(l,l+c))}return s}function LR(e,t,n){const i=[];for(let r=0;r<t;r++){const t=r*n;i.push(e.slice(t,t+n))}return i}function IR(e,t,n,i){if(n)throw new Error("Not implemented - arrayOffsets for strings is specified");if(i){const n=[],r=new TextDecoder("utf8");let s=0;for(let o=0;o<e;o++){const e=i[o+1]-i[o];if(e+s<=t.length){const i=t.subarray(s,e+s),o=r.decode(i);n.push(o),s+=e}}return n}return[]}const OR="EXT_mesh_features",BR=OR;async function NR(e,t){!function(e,t){const n=e.gltf.json;if(!n.meshes)return;for(const i of n.meshes)for(const n of i.primitives)FR(e,n,t)}(new gltf_scenegraph_GLTFScenegraph(e),t)}function kR(e,t){const n=new gltf_scenegraph_GLTFScenegraph(e);return function(e){const t=e.gltf.json.meshes;if(!t)return;for(const n of t)for(const t of n.primitives)UR(e,t)}(n),n.createBinaryChunk(),n.gltf}function FR(e,t,n){if(!n?.gltf?.loadBuffers)return;const i=t.extensions?.[OR],r=i?.featureIds;if(r)for(const i of r){let r;if(void 0!==i.attribute){const n=`_FEATURE_ID_${i.attribute}`,s=t.attributes[n];r=e.getTypedArrayForAccessor(s)}else r=void 0!==i.texture&&n?.gltf?.loadImages?CR(e,i.texture,t):[];i.data=r}}function DR(e,t,n,i){t.extensions||(t.extensions={});let r=t.extensions[OR];r||(r={featureIds:[]},t.extensions[OR]=r);const{featureIds:s}=r,o={featureCount:n.length,propertyTable:i,data:n};s.push(o),e.addObjectExtension(t,OR,r)}function UR(e,t){const n=t.extensions?.[OR];if(!n)return;const i=n.featureIds;i.forEach((n,r)=>{if(n.data){const{accessorKey:s,index:o}=function(e){const t="_FEATURE_ID_",n=Object.keys(e).filter(e=>0===e.indexOf(t));let i=-1;for(const e of n){const n=Number(e.substring(t.length));n>i&&(i=n)}i++;const r=`${t}${i}`;return{accessorKey:r,index:i}}(t.attributes),a=new Uint32Array(n.data);i[r]={featureCount:a.length,propertyTable:n.propertyTable,attribute:o},e.gltf.buffers.push({arrayBuffer:a.buffer,byteOffset:a.byteOffset,byteLength:a.byteLength});const l=e.addBufferView(a),c=e.addAccessor(l,{size:1,componentType:fR(a),count:a.length});t.attributes[s]=c}})}const VR="EXT_structural_metadata",zR=VR;async function GR(e,t){!function(e,t){if(!t.gltf?.loadBuffers)return;const n=e.getExtension(VR);if(!n)return;t.gltf?.loadImages&&function(e,t){const n=t.propertyTextures,i=e.gltf.json;if(n&&i.meshes)for(const r of i.meshes)for(const i of r.primitives)WR(e,n,i,t)}(e,n);!function(e,t){const n=t.schema;if(!n)return;const i=n.classes,r=t.propertyTables;if(i&&r)for(const t in i){const i=HR(r,t);i&&KR(e,n,i)}}(e,n)}(new gltf_scenegraph_GLTFScenegraph(e),t)}function jR(e,t){const n=new gltf_scenegraph_GLTFScenegraph(e);return function(e){const t=e.getExtension(VR);if(!t)return;if(t.propertyTables)for(const n of t.propertyTables){const i=n.class,r=t.schema?.classes?.[i];n.properties&&r&&ZR(n,r,e)}}(n),n.createBinaryChunk(),n.gltf}function HR(e,t){for(const n of e)if(n.class===t)return n;return null}function WR(e,t,n,i){if(!t)return;const r=n.extensions?.[VR],s=r?.propertyTextures;if(s)for(const r of s){qR(e,t[r],n,i)}}function qR(e,t,n,i){if(!t.properties)return;i.dataAttributeNames||(i.dataAttributeNames=[]);const r=t.class;for(const s in t.properties){const o=`${r}_${s}`,a=t.properties?.[s];if(!a)continue;a.data||(a.data=[]);const l=a.data,c=CR(e,a,n);null!==c&&(PR(e,o,c,l,n),a.data=l,i.dataAttributeNames.push(o))}}function KR(e,t,n){const i=t.classes?.[n.class];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${n.class}`);const r=n.count;for(const s in i.properties){const o=i.properties[s],a=n.properties?.[s];if(a){const n=QR(e,t,o,r,a);a.data=n}}}function QR(e,t,n,i,r){let s=[];const o=r.values,a=e.getTypedArrayForBufferView(o),l=function(e,t,n,i){if(t.array&&void 0===t.count&&void 0!==n.arrayOffsets)return ER(e,n.arrayOffsets,n.arrayOffsetType||"UINT32",i);return null}(e,n,r,i),c=function(e,t,n){if(void 0!==t.stringOffsets)return ER(e,t.stringOffsets,t.stringOffsetType||"UINT32",n);return null}(e,r,i);switch(n.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":s=function(e,t,n,i){const r=e.array,s=e.count,o=TR(e.type,e.componentType),a=n.byteLength/o;let l;l=e.componentType?SR(n,e.type,e.componentType,a):n;if(r)return i?MR(l,t,i,n.length,o):s?LR(l,t,s):[];return l}(n,i,a,l);break;case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${n.type}`);case"STRING":s=IR(i,a,l,c);break;case"ENUM":s=function(e,t,n,i,r){const s=t.enumType;if(!s)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");const o=e.enums?.[s];if(!o)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${s}`);const a=o.valueType||"UINT16",l=TR(t.type,a),c=i.byteLength/l;let A=SR(i,t.type,a,c);A||(A=i);if(t.array){if(r)return function(e){const{valuesData:t,numberOfElements:n,arrayOffsets:i,valuesDataBytesLength:r,elementSize:s,enumEntry:o}=e,a=[];for(let e=0;e<n;e++){const n=i[e],l=i[e+1]-i[e];if(l+n>r)break;const c=XR(t,n/s,l/s,o);a.push(c)}return a}({valuesData:A,numberOfElements:n,arrayOffsets:r,valuesDataBytesLength:i.length,elementSize:l,enumEntry:o});const e=t.count;return e?function(e,t,n,i){const r=[];for(let s=0;s<t;s++){const t=XR(e,n*s,n,i);r.push(t)}return r}(A,n,e,o):[]}return XR(A,0,n,o)}(t,n,i,a,l);break;default:throw new Error(`Unknown classProperty type ${n.type}`)}return s}function XR(e,t,n,i){const r=[];for(let s=0;s<n;s++)if(e instanceof BigInt64Array||e instanceof BigUint64Array)r.push("");else{const n=$R(i,e[t+s]);n?r.push(n.name):r.push("")}return r}function $R(e,t){for(const n of e.values)if(n.value===t)return n;return null}function ZR(e,t,n){for(const i in e.properties){const r=e.properties[i].data;if(r){const s=t.properties[i];if(s){const t=JR(r,s,n);e.properties[i]=t}}}}function YR(e,t,n="schemaClassId"){let i=e.getExtension(VR);i||(i=e.addExtension(VR)),i.schema=function(e,t,n){const i=n??{id:"schema_id"},r={properties:{}};for(const t of e){const e={type:t.elementType,componentType:t.componentType};r.properties[t.name]=e}return i.classes={},i.classes[t]=r,i}(t,n,i.schema);const r=function(e,t,n){const i={class:t,count:0};let r=0;const s=n.classes?.[t];for(const t of e){if(0===r&&(r=t.values.length),r!==t.values.length&&t.values.length)throw new Error("Illegal values in attributes");const e=s?.properties[t.name];e&&(i.properties||(i.properties={}),i.properties[t.name]={values:0,data:t.values})}return i.count=r,i}(t,n,i.schema);return i.propertyTables||(i.propertyTables=[]),i.propertyTables.push(r)-1}function JR(e,t,n){const i={values:0};if("STRING"===t.type){const{stringData:t,stringOffsets:r}=function(e){const t=new TextEncoder,n=[];let i=0;for(const r of e){const e=t.encode(r);i+=e.length,n.push(e)}const r=new Uint8Array(i),s=[];let o=0;for(const e of n)r.set(e,o),s.push(o),o+=e.length;s.push(o);const a=new Uint32Array(s);return{stringData:r,stringOffsets:a}}(e);i.stringOffsets=tM(r,n),i.values=tM(t,n)}else if("SCALAR"===t.type&&t.componentType){const r=function(e,t){const n=[];for(const t of e)n.push(Number(t));const i=eM[t];if(!i)throw new Error("Illegal component type");return new i(n)}(e,t.componentType);i.values=tM(r,n)}return i}const eM={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:Int32Array,UINT64:Uint32Array,FLOAT32:Float32Array,FLOAT64:Float64Array};function tM(e,t){return t.gltf.buffers.push({arrayBuffer:bR(e.buffer),byteOffset:e.byteOffset,byteLength:e.byteLength}),t.addBufferView(e)}function nM(e){return"string"==typeof e?e:["NONE","OCTAHEDRAL","QUATERNION","EXPONENTIAL","COLOR"][e]}async function iM(e,t,n){if(!t.gltf?.decompressMeshes||!t.gltf.loadBuffers)return;!function(e){const t=e.bufferViews||[];for(let e=0;e<t.length;e++){const n=t[e].extensions;if(n?.KHR_meshopt_compression&&n.EXT_meshopt_compression)throw new Error(`glTF bufferView ${e} cannot use both KHR_meshopt_compression and EXT_meshopt_compression.`)}const n=e.buffers||[];for(let e=0;e<n.length;e++){const t=n[e].extensions;if(t?.KHR_meshopt_compression&&t.EXT_meshopt_compression)throw new Error(`glTF buffer ${e} cannot use both KHR_meshopt_compression and EXT_meshopt_compression.`)}}(e.json);const i=new gltf_scenegraph_GLTFScenegraph(e),r=e.json.bufferViews||[],s=r.map(e=>async function(e,t,n){const i=e.getObjectExtension(t,n);if(!i)return;const{byteOffset:r=0,byteLength:s,byteStride:o,count:a,mode:l,filter:c="NONE",buffer:A}=i,u=e.gltf.buffers[A],h=e.gltf.buffers[t.buffer],d=new Uint8Array(u.arrayBuffer,u.byteOffset+r,s),f=new Uint8Array(h.arrayBuffer,h.byteOffset+(t.byteOffset||0),t.byteLength);await async function(e,t,n,i,r,s="NONE"){await px.ready,px.decodeGltfBuffer(e,t,n,i,r,nM(s))}(f,a,o,d,l,c)}(i,e,n));await Promise.all(s);for(const e of r)i.removeObjectExtension(e,n);for(const t of e.json.buffers||[])i.removeObjectExtension(t,n);i.removeExtension(n)}const rM="EXT_meshopt_compression";async function sM(e,t){await iM(e,t,rM)}const oM="KHR_meshopt_compression";async function aM(e,t){await iM(e,t,oM)}const lM=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/tiff","image/svg","image/svg+xml","image/bmp","image/vnd.microsoft.icon"];let cM=null;async function AM(){return cM||(cM=async function(){const e=new Set;for(const t of lM){(ce?await pM(t):dM(t))&&e.add(t)}return e}()),await cM}const uM={};function hM(e){if(void 0===uM[e]){const t=ce?function(e){switch(e){case"image/avif":case"image/webp":return function(e){try{const t=document.createElement("canvas");return 0===t.toDataURL(e).indexOf(`data:${e}`)}catch{return!1}}(e);default:return!0}}(e):dM(e);uM[e]=t}return uM[e]}function dM(e){const t=globalThis.loaders?.imageFormatsNode||["image/png","image/jpeg","image/gif"],n=globalThis.loaders?.parseImageNode;return Boolean(n)&&t.includes(e)}const fM={"image/avif":"data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=","image/webp":"data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA"};async function pM(e){const t=fM[e];return!t||await async function(e){return new Promise(t=>{const n=new Image;n.src=e,n.onload=()=>t(n.height>0),n.onerror=()=>t(!1)})}(t)}const gM="EXT_texture_webp",mM=gM;function bM(e,t){const n=new gltf_scenegraph_GLTFScenegraph(e);if(!hM("image/webp")){if(n.getRequiredExtensions().includes(gM))throw new Error(`gltf: Required extension ${gM} not supported by browser`);return}const{json:i}=n;for(const e of i.textures||[]){const t=n.getObjectExtension(e,gM);t&&(e.source=t.source),n.removeObjectExtension(e,gM)}n.removeExtension(gM)}const _M="EXT_texture_avif",vM=_M;async function yM(e,t){const n=new gltf_scenegraph_GLTFScenegraph(e);if(!(await AM()).has("image/avif")){if(n.getRequiredExtensions().includes(_M))throw new Error(`gltf: Required extension ${_M} not supported by browser`);return}const{json:i}=n;for(const e of i.textures||[]){const t=n.getObjectExtension(e,_M);t&&(e.source=t.source),n.removeObjectExtension(e,_M)}n.removeExtension(_M)}const wM="KHR_texture_basisu",xM=wM;function TM(e,t){const n=new gltf_scenegraph_GLTFScenegraph(e),{json:i}=n;for(const e of i.textures||[]){const t=n.getObjectExtension(e,wM);t&&(e.source=t.source,n.removeObjectExtension(e,wM))}n.removeExtension(wM)}function EM(e){const{buffer:t,size:n,count:i}=function(e){let t=e,n=1,i=0;e&&e.value&&(t=e.value,n=e.size||1);t&&(ArrayBuffer.isView(t)||(t=function(e,t,n=!1){if(!e)return null;if(Array.isArray(e))return new t(e);if(n&&!(e instanceof t))return new t(e);return e}(t,Float32Array)),i=t.length/n);return{buffer:t,size:n,count:i}}(e);return{value:t,size:n,byteOffset:0,count:i,type:dR(n),componentType:fR(t)}}const SM="KHR_draco_mesh_compression",CM=SM;function PM(e,t,n){const i=new gltf_scenegraph_GLTFScenegraph(e);for(const e of OM(i))i.getObjectExtension(e,SM)}async function RM(e,t,n){if(!t?.gltf?.decompressMeshes)return;const i=new gltf_scenegraph_GLTFScenegraph(e),r=[];for(const e of OM(i))i.getObjectExtension(e,SM)&&r.push(LM(i,e,t,n));await Promise.all(r),i.removeExtension(SM)}function MM(e,t={}){const n=new gltf_scenegraph_GLTFScenegraph(e);for(const e of n.json.meshes||[])IM(e,t),n.addRequiredExtension(SM)}async function LM(e,t,n,i){const r=e.getObjectExtension(t,SM);if(!r)return;const s=e.getTypedArrayForBufferView(r.bufferView),o=TP(s.buffer,s.byteOffset),a={...n};delete a["3d-tiles"];const l=await KC(o,qC,a,i),c=function(e){const t={};for(const n in e){const i=e[n];if("indices"!==n){const e=EM(i);t[n]=e}}return t}(l.attributes);for(const[n,i]of Object.entries(c))if(n in t.attributes){const r=t.attributes[n],s=e.getAccessor(r);s?.min&&s?.max&&(i.min=s.min,i.max=s.max)}t.attributes=c,l.indices&&(t.indices=EM(l.indices)),e.removeObjectExtension(t,SM),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function IM(e,t,n=4,i,r){if(!i.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const s=i.DracoWriter.encodeSync({attributes:e}),o=r?.parseSync?.({attributes:e}),a=i._addFauxAttributes(o.attributes),l=i.addBufferView(s);return{primitives:[{attributes:a,mode:n,extensions:{[SM]:{bufferView:l,attributes:a}}}]}}function*OM(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}const BM="KHR_texture_transform",NM=BM,kM=new oi.P,FM=new Matrix3,DM=new Matrix3;async function UM(e,t){const n=new gltf_scenegraph_GLTFScenegraph(e);if(!n.hasExtension(BM)||!t.gltf?.loadBuffers)return;const i=e.json.materials||[];for(let t=0;t<i.length;t++)VM(t,e,n);i.some(e=>zM(e).length>0)||n.removeExtension(BM)}function VM(e,t,n){const i=t.json.materials?.[e],r=zM(i),s=new Map;let o=function(e){let t=-1;for(const n of e.json.meshes||[])for(const e of n.primitives)for(const n of Object.keys(e.attributes)){const e=/^TEXCOORD_(\d+)$/.exec(n);e&&(t=Math.max(t,Number(e[1])))}return t+1}(t);for(const i of r){const r=i.extensions?.[BM];if(r){const a=r.texCoord??i.texCoord??0,l=GM(a,r);let c=s.get(l);if(!c){if(c={sourceTexCoord:a,texCoord:o,matrix:WM(r)},!jM(t,e,c))continue;o++,s.set(l,c)}i.texCoord=c.texCoord,n.removeObjectExtension(i,BM),i.extensions&&0===Object.keys(i.extensions).length&&delete i.extensions}}}function zM(e){if(!e||"object"!=typeof e)return[];const t=e,n=[],i=t.extensions;Number.isFinite(t.index)&&i?.[BM]&&n.push(t);for(const[e,i]of Object.entries(t))"extras"!==e&&n.push(...zM(i));return n}function GM(e,t){const{offset:n=[0,0],rotation:i=0,scale:r=[1,1]}=t;return JSON.stringify([e,n,i,r])}function jM(e,t,n){const i=[],r=e.json.meshes||[];for(const e of r)for(const n of e.primitives){const e=n.material;Number.isFinite(e)&&t===e&&i.push(n)}if(0===i.length||i.some(t=>!function(e,t,n){const i=t.attributes[`TEXCOORD_${n}`];if(!Number.isFinite(i))return!1;const r=e.json.accessors?.[i];if(!r||void 0===r.bufferView||r.sparse)return!1;const s=e.json.bufferViews?.[r.bufferView];return Boolean(s&&e.buffers[s.buffer])}(e,t,n.sourceTexCoord)))return!1;for(const t of i)HM(e,t,n);return!0}function HM(e,t,n){const{sourceTexCoord:i,texCoord:r,matrix:s}=n,o=t.attributes[`TEXCOORD_${i}`];if(Number.isFinite(o)){const n=e.json.accessors?.[o];if(n&&void 0!==n.bufferView){const i=e.json.bufferViews?.[n.bufferView];if(i){const{arrayBuffer:o,byteOffset:a}=e.buffers[i.buffer],l=(a||0)+(n.byteOffset||0)+(i.byteOffset||0),{ArrayType:c,length:A}=pR(n,i),u=oR[n.componentType],h=sR[n.type],d=i.byteStride||u*h,f=new Float32Array(A);for(let e=0;e<n.count;e++){const t=new c(o,l+e*d,2);kM.set(t[0],t[1],1),kM.transformByMatrix3(s),f.set([kM[0],kM[1]],e*h)}!function(e,t,n,i,r){i.buffers.push({arrayBuffer:bR(r.buffer),byteOffset:0,byteLength:r.buffer.byteLength}),i.json.bufferViews=i.json.bufferViews||[];const s=i.json.bufferViews;s.push({buffer:i.buffers.length-1,byteLength:r.buffer.byteLength,byteOffset:0});const o=i.json.accessors;if(!o)return;o.push({bufferView:s?.length-1,byteOffset:0,componentType:5126,count:t.count,type:"VEC2"}),n.attributes[`TEXCOORD_${e}`]=o.length-1}(r,n,t,e,f)}}}}function WM(e){const{offset:t=[0,0],rotation:n=0,scale:i=[1,1]}=e,r=(new Matrix3).set(1,0,0,0,1,0,t[0],t[1],1),s=FM.set(Math.cos(n),Math.sin(n),0,-Math.sin(n),Math.cos(n),0,0,0,1),o=DM.set(i[0],0,0,0,i[1],0,0,0,1);return r.multiplyRight(s).multiplyRight(o)}const qM="KHR_lights_punctual",KM=qM;async function QM(e){const t=new gltf_scenegraph_GLTFScenegraph(e),{json:n}=t,i=t.getExtension(qM);i&&(t.json.lights=i.lights,t.removeExtension(qM));for(const e of n.nodes||[]){const n=t.getObjectExtension(e,qM);n&&(e.light=n.light),t.removeObjectExtension(e,qM)}}async function XM(e){const t=new gltf_scenegraph_GLTFScenegraph(e),{json:n}=t;if(n.lights){const e=t.addExtension(qM);QP(!e.lights),e.lights=n.lights,delete n.lights}if(t.json.lights){for(const e of t.json.lights){const n=e.node;t.addObjectExtension(n,qM,e)}delete t.json.lights}}const $M="KHR_materials_unlit",ZM=$M;async function YM(e){const t=new gltf_scenegraph_GLTFScenegraph(e),{json:n}=t;for(const e of n.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),t.removeObjectExtension(e,$M)}t.removeExtension($M)}function JM(e){const t=new gltf_scenegraph_GLTFScenegraph(e),{json:n}=t;if(t.materials)for(const e of n.materials||[])e.unlit&&(delete e.unlit,t.addObjectExtension(e,$M,{}),t.addExtension($M))}const eL="KHR_techniques_webgl",tL=eL;async function nL(e){const t=new gltf_scenegraph_GLTFScenegraph(e),{json:n}=t,i=t.getExtension(eL);if(i){const e=function(e,t){const{programs:n=[],shaders:i=[],techniques:r=[]}=e,s=new TextDecoder;return i.forEach(e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=s.decode(t.getTypedArrayForBufferView(e.bufferView))}),n.forEach(e=>{e.fragmentShader=i[e.fragmentShader],e.vertexShader=i[e.vertexShader]}),r.forEach(e=>{e.program=n[e.program]}),r}(i,t);for(const i of n.materials||[]){const n=t.getObjectExtension(i,eL);n&&(i.technique=Object.assign({},n,e[n.technique]),i.technique.values=rL(i.technique,t)),t.removeObjectExtension(i,eL)}t.removeExtension(eL)}}async function iL(e,t){}function rL(e,t){const n=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach(t=>{e.uniforms[t].value&&!(t in n)&&(n[t]=e.uniforms[t].value)}),Object.keys(n).forEach(e=>{"object"==typeof n[e]&&void 0!==n[e].index&&(n[e].texture=t.getTexture(n[e].index))}),n}const sL="EXT_feature_metadata",oL=sL;async function aL(e,t){!function(e,t){if(!t.gltf?.loadBuffers)return;const n=e.getExtension(sL);if(!n)return;t.gltf?.loadImages&&function(e,t){const n=t.schema;if(!n)return;const i=n.classes,{featureTextures:r}=t;if(i&&r)for(const t in i){const n=i[t],s=cL(r,t);s&&uL(e,s,n)}}(e,n);!function(e,t){const n=t.schema;if(!n)return;const i=n.classes,r=t.featureTables;if(i&&r)for(const t in i){const i=lL(r,t);i&&AL(e,n,i)}}(e,n)}(new gltf_scenegraph_GLTFScenegraph(e),t)}function lL(e,t){for(const n in e){const i=e[n];if(i.class===t)return i}return null}function cL(e,t){for(const n in e){const i=e[n];if(i.class===t)return i}return null}function AL(e,t,n){if(!n.class)return;const i=t.classes?.[n.class];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${n.class}`);const r=n.count;for(const s in i.properties){const o=i.properties[s],a=n.properties?.[s];if(a){const n=hL(e,t,o,r,a);a.data=n}}}function uL(e,t,n){const i=t.class;for(const r in n.properties){const n=t?.properties?.[r];if(n){const t=dL(e,n,i);n.data=t}}}function hL(e,t,n,i,r){let s=[];const o=r.bufferView,a=e.getTypedArrayForBufferView(o),l=function(e,t,n,i){if("ARRAY"===t.type&&void 0===t.componentCount&&void 0!==n.arrayOffsetBufferView)return ER(e,n.arrayOffsetBufferView,n.offsetType||"UINT32",i);return null}(e,n,r,i),c=function(e,t,n,i){if(void 0!==n.stringOffsetBufferView)return ER(e,n.stringOffsetBufferView,n.offsetType||"UINT32",i);return null}(e,0,r,i);return"STRING"===n.type||"STRING"===n.componentType?s=IR(i,a,l,c):function(e){const t=["UINT8","INT16","UINT16","INT32","UINT32","INT64","UINT64","FLOAT32","FLOAT64"];return t.includes(e.type)||void 0!==e.componentType&&t.includes(e.componentType)}(n)&&(s=function(e,t,n,i){const r="ARRAY"===e.type,s=e.componentCount,o="SCALAR",a=e.componentType||e.type,l=TR(o,a),c=n.byteLength/l,A=SR(n,o,a,c);if(r)return i?MR(A,t,i,n.length,l):s?LR(A,t,s):[];return A}(n,i,a,l)),s}function dL(e,t,n){const i=e.gltf.json;if(!i.meshes)return[];const r=[];for(const s of i.meshes)for(const i of s.primitives)fL(e,n,t,r,i);return r}function fL(e,t,n,i,r){const s=CR(e,{channels:n.channels,...n.texture},r);s&&PR(e,t,s,i,r)}const pL=[m,g,_,b,y,v,w,x,E,S,C,T,P];function gL(e,t){const n=t?.gltf?.excludeExtensions||{};return!(e in n&&!n[e])}const mL="KHR_binary_glTF";const bL={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},_L={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class normalize_gltf_v1_GLTFV1Normalizer{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(e,t){this.json=e.json;const n=e.json;switch(n.asset&&n.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return void console.warn(`glTF: Unknown version ${n.asset.version}`)}if(!t.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(n),this._convertTopLevelObjectsToArrays(n),function(e){const t=new gltf_scenegraph_GLTFScenegraph(e),{json:n}=t;for(const e of n.images||[]){const n=t.getObjectExtension(e,mL);n&&Object.assign(e,n),t.removeObjectExtension(e,mL)}n.buffers&&n.buffers[0]&&delete n.buffers[0].uri,t.removeExtension(mL)}(e),this._convertObjectIdsToArrayIndices(n),this._updateObjects(n),this._updateMaterial(n)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(const t in bL)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const n=e[t];if(n&&!Array.isArray(n)){e[t]=[];for(const i in n){const r=n[i];r.id=r.id||i;const s=e[t].length;e[t].push(r),this.idToIndexMap[t][i]=s}}}_convertObjectIdsToArrayIndices(e){for(const t in bL)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const t of e.textures)this._convertTextureIds(t);for(const t of e.meshes)this._convertMeshIds(t);for(const t of e.nodes)this._convertNodeIds(t);for(const t of e.scenes)this._convertSceneIds(t)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const t of e.primitives){const{attributes:e,indices:n,material:i}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");n&&(t.indices=this._convertIdToIndex(n,"accessor")),i&&(t.material=this._convertIdToIndex(i,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(e=>this._convertIdToIndex(e,"node"))),e.meshes&&(e.meshes=e.meshes.map(e=>this._convertIdToIndex(e,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(e=>this._convertIdToIndex(e,"node")))}_convertIdsToIndices(e,t){e[t]||(console.warn(`gltf v1: json doesn't contain attribute ${t}`),e[t]=[]);for(const n of e[t])for(const e in n){const t=n[e],i=this._convertIdToIndex(t,e);n[e]=i}}_convertIdToIndex(e,t){const n=_L[t];if(n in this.idToIndexMap){const i=this.idToIndexMap[n][e];if(!Number.isFinite(i))throw new Error(`gltf v1: failed to resolve ${t} with id ${e}`);return i}return e}_updateObjects(e){for(const e of this.json.buffers)delete e.type}_updateMaterial(e){for(const t of e.materials){t.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const n=t.values?.tex||t.values?.texture2d_0||t.values?.diffuseTex,i=e.textures.findIndex(e=>e.id===n);-1!==i&&(t.pbrMetallicRoughness.baseColorTexture={index:i})}}}async function vL(e,t,n=0,i,r){return function(e,t,n,i){i.core?.baseUrl&&(e.baseUri=i.core?.baseUrl);if(t instanceof ArrayBuffer&&!function(e,t=0,n={}){const i=new DataView(e),{magic:r=YP}=n,s=i.getUint32(t,!1);return s===r||s===YP}(t,n,i.glb)){t=(new TextDecoder).decode(t)}if("string"==typeof t)e.json=xP(t);else if(t instanceof ArrayBuffer){const r={};n=tR(r,t,n,i.glb),QP("glTF"===r.type,`Invalid GLB magic string ${r.type}`),e._glb=r,e.json=r.json}else QP(!1,"GLTF: must be ArrayBuffer or string");const r=e.json.buffers||[];if(e.buffers=new Array(r.length).fill(null),e._glb&&e._glb.header.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const s=e.json.images||[];e.images=new Array(s.length).fill({})}(e,t,n,i),function(e,t={}){(new normalize_gltf_v1_GLTFV1Normalizer).normalize(e,t)}(e,{normalize:i?.gltf?.normalize}),await async function(e,t={},n){const i=pL.filter(e=>gL(e.name,t));for(const r of i)await(r.preprocess?.(e,t,n))}(e,i,r),i?.gltf?.loadBuffers&&e.json.buffers&&await async function(e,t,n){const i=e.json.buffers||[];for(let r=0;r<i.length;++r){const s=i[r];if(s.uri){const{fetch:i}=n;QP(i);const o=rR(s.uri,t,n),a=await(n?.fetch?.(o)),l=await(a?.arrayBuffer?.());e.buffers[r]={arrayBuffer:l,byteOffset:0,byteLength:l.byteLength},delete s.uri}else null===e.buffers[r]&&(e.buffers[r]={arrayBuffer:new ArrayBuffer(s.byteLength),byteOffset:0,byteLength:s.byteLength})}}(e,i,r),i?.gltf?.loadImages&&await async function(e,t,n){const i=function(e){const t=new Set,n=e.json.textures||[];for(const e of n)void 0!==e.source&&t.add(e.source);return Array.from(t).sort()}(e),r=e.json.images||[],s=[];for(const o of i)s.push(yL(e,r[o],o,t,n));return await Promise.all(s)}(e,i,r),await async function(e,t={},n){const i=pL.filter(e=>gL(e.name,t));for(const r of i)await(r.decode?.(e,t,n))}(e,i,r),e}async function yL(e,t,n,i,r){let s;if(t.uri&&!t.hasOwnProperty("bufferView")){const e=rR(t.uri,i,r),{fetch:n}=r,o=await n(e);s=await o.arrayBuffer(),t.bufferView={data:s}}if(Number.isFinite(t.bufferView)){const n=mR(e.json,e.buffers,t.bufferView);s=TP(n.buffer,n.byteOffset,n.byteLength)}QP(s,"glTF image has no data");const o=function(e,t){const n=e.basis,i=n?.format;return{...e,core:{...e.core,mimeType:t},basis:{...n,format:i&&"auto"!==i?i:WP(n?.supportedTextureFormats)}}}(i,t.mimeType);let a=await KC(s,[Le,KP],o,r);a&&a[0]&&(a={compressed:!0,mipmaps:!1,width:a[0].width,height:a[0].height,data:a[0]}),e.images=e.images||[],e.images[n]=a}const wL={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:"4.5.1",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e,t={},n){const i={...wL.options,...t};i.gltf={...wL.options.gltf,...i.gltf};const r=t?.glb?.byteOffset||0;return await vL({},e,r,i,n)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0}}};const xL={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},TL={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},EL=10240,SL=10241,CL=10242,PL=10243,RL=10497,ML=9729,LL=9986,IL={magFilter:EL,minFilter:SL,wrapS:CL,wrapT:PL},OL={[EL]:ML,[SL]:LL,[CL]:RL,[PL]:RL};class post_process_gltf_GLTFPostProcessor{baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(e,t={}){const{json:n,buffers:i=[],images:r=[]}=e,{baseUri:s=""}=e;return QP(n),this.baseUri=s,this.buffers=i,this.images=r,this.jsonUnprocessed=n,this.json=this._resolveTree(e.json,t),this.json}_resolveTree(e,t={}){const n={...e};return this.json=n,e.bufferViews&&(n.bufferViews=e.bufferViews.map((e,t)=>this._resolveBufferView(e,t))),e.images&&(n.images=e.images.map((e,t)=>this._resolveImage(e,t))),e.samplers&&(n.samplers=e.samplers.map((e,t)=>this._resolveSampler(e,t))),e.textures&&(n.textures=e.textures.map((e,t)=>this._resolveTexture(e,t))),e.accessors&&(n.accessors=e.accessors.map((e,t)=>this._resolveAccessor(e,t))),e.materials&&(n.materials=e.materials.map((e,t)=>this._resolveMaterial(e,t))),e.meshes&&(n.meshes=e.meshes.map((e,t)=>this._resolveMesh(e,t))),e.nodes&&(n.nodes=e.nodes.map((e,t)=>this._resolveNode(e,t)),n.nodes=n.nodes.map((e,t)=>this._resolveNodeChildren(e))),e.skins&&(n.skins=e.skins.map((e,t)=>this._resolveSkin(e,t))),e.scenes&&(n.scenes=e.scenes.map((e,t)=>this._resolveScene(e,t))),"number"==typeof this.json.scene&&n.scenes&&(n.scene=n.scenes[this.json.scene]),n}getScene(e){return this._get(this.json.scenes,e)}getNode(e){return this._get(this.json.nodes,e)}getSkin(e){return this._get(this.json.skins,e)}getMesh(e){return this._get(this.json.meshes,e)}getMaterial(e){return this._get(this.json.materials,e)}getAccessor(e){return this._get(this.json.accessors,e)}getCamera(e){return this._get(this.json.cameras,e)}getTexture(e){return this._get(this.json.textures,e)}getSampler(e){return this._get(this.json.samplers,e)}getImage(e){return this._get(this.json.images,e)}getBufferView(e){return this._get(this.json.bufferViews,e)}getBuffer(e){return this._get(this.json.buffers,e)}_get(e,t){if("object"==typeof t)return t;const n=e&&e[t];return n||console.warn(`glTF file error: Could not find ${e}[${t}]`),n}_resolveScene(e,t){return{...e,id:e.id||`scene-${t}`,nodes:(e.nodes||[]).map(e=>this.getNode(e))}}_resolveNode(e,t){const n={...e,id:e?.id||`node-${t}`};return void 0!==e.mesh&&(n.mesh=this.getMesh(e.mesh)),void 0!==e.camera&&(n.camera=this.getCamera(e.camera)),void 0!==e.skin&&(n.skin=this.getSkin(e.skin)),void 0!==e.meshes&&e.meshes.length&&(n.mesh=e.meshes.reduce((e,t)=>{const n=this.getMesh(t);return e.id=n.id,e.primitives=e.primitives.concat(n.primitives),e},{primitives:[]})),n}_resolveNodeChildren(e){return e.children&&(e.children=e.children.map(e=>this.getNode(e))),e}_resolveSkin(e,t){const n="number"==typeof e.inverseBindMatrices?this.getAccessor(e.inverseBindMatrices):void 0;return{...e,id:e.id||`skin-${t}`,inverseBindMatrices:n}}_resolveMesh(e,t){const n={...e,id:e.id||`mesh-${t}`,primitives:[]};return e.primitives&&(n.primitives=e.primitives.map((e,t)=>{const i={...e,attributes:{},indices:void 0,material:void 0},r=e.attributes;for(const e in r)i.attributes[e]=this.getAccessor(r[e]);return void 0!==e.indices&&(i.indices=this.getAccessor(e.indices)),void 0!==e.material&&(i.material=this.getMaterial(e.material)),function(e,t,n){if(2!==e.mode&&6!==e.mode)return e;const i=e.indices?.value,r=e.indices?.count??function(e){const t=Object.values(e.attributes)[0];return QP(t,"glTF primitive must define at least one attribute"),t.count}(e),s=function(e,t){if(!e)return Math.max(0,t-1);let n=0;for(let i=0;i<t;i++)n=Math.max(n,Number(e[i]));return n}(i,r),o=s<=65535?Uint16Array:Uint32Array,a=2===e.mode?function(e,t,n){if(t<2)return new n(0);const i=new n(2*t);for(let n=0;n<t;n++)i[2*n]=NL(e,n),i[2*n+1]=NL(e,(n+1)%t);return i}(i,r,o):function(e,t,n){const i=Math.max(0,t-2),r=new n(3*i);for(let t=0;t<i;t++)r[3*t]=NL(e,0),r[3*t+1]=NL(e,t+1),r[3*t+2]=NL(e,t+2);return r}(i,r,o);return e.mode=2===e.mode?1:4,e.indices={id:`${t}-primitive-${n}-portable-indices`,components:1,bytesPerComponent:o.BYTES_PER_ELEMENT,bytesPerElement:o.BYTES_PER_ELEMENT,componentType:o===Uint16Array?5123:5125,normalized:!1,count:a.length,type:"SCALAR",min:a.length?[BL(a)]:void 0,max:a.length?[s]:void 0,value:a},e}(i,n.id,t)})),n}_resolveMaterial(e,t){const n={...e,id:e.id||`material-${t}`};if(n.normalTexture&&(n.normalTexture={...n.normalTexture},n.normalTexture.texture=this.getTexture(n.normalTexture.index)),n.occlusionTexture&&(n.occlusionTexture={...n.occlusionTexture},n.occlusionTexture.texture=this.getTexture(n.occlusionTexture.index)),n.emissiveTexture&&(n.emissiveTexture={...n.emissiveTexture},n.emissiveTexture.texture=this.getTexture(n.emissiveTexture.index)),n.emissiveFactor||(n.emissiveFactor=n.emissiveTexture?[1,1,1]:[0,0,0]),n.pbrMetallicRoughness){n.pbrMetallicRoughness={...n.pbrMetallicRoughness};const e=n.pbrMetallicRoughness;e.baseColorTexture&&(e.baseColorTexture={...e.baseColorTexture},e.baseColorTexture.texture=this.getTexture(e.baseColorTexture.index)),e.metallicRoughnessTexture&&(e.metallicRoughnessTexture={...e.metallicRoughnessTexture},e.metallicRoughnessTexture.texture=this.getTexture(e.metallicRoughnessTexture.index))}return n}_resolveAccessor(e,t){const n=(i=e.componentType,TL[i]);var i;const r=(s=e.type,xL[s]);var s;const o=n*r,a={...e,id:e.id||`accessor-${t}`,bytesPerComponent:n,components:r,bytesPerElement:o,value:void 0,bufferView:void 0,sparse:void 0};if(void 0!==e.bufferView&&(a.bufferView=this.getBufferView(e.bufferView)),a.bufferView){const e=a.bufferView.buffer,{ArrayType:t,byteLength:n}=pR(a,a.bufferView),i=(a.bufferView.byteOffset||0)+(a.byteOffset||0)+e.byteOffset;let r=_R(e.arrayBuffer,i,n);a.bufferView.byteStride&&(r=this._getValueFromInterleavedBuffer(e,i,a.bufferView.byteStride,a.bytesPerElement,a.count)),a.value=new t(r)}else{const{ArrayType:e}=pR(a,{byteLength:a.count*a.bytesPerElement});a.value=new e(a.count*a.components)}return e.sparse&&this._applySparseAccessor(a,e.sparse),a}_applySparseAccessor(e,t){const n=function(e){switch(e){case 5121:return Uint8Array;case 5123:return Uint16Array;case 5125:return Uint32Array;default:throw new Error(`Invalid glTF sparse index component type ${e}`)}}(t.indices.componentType),i=this._getTypedArrayFromBufferView(n,this.getBufferView(t.indices.bufferView),t.indices.byteOffset||0,t.count),r=e.value.constructor,s=this._getTypedArrayFromBufferView(r,this.getBufferView(t.values.bufferView),t.values.byteOffset||0,t.count*e.components);for(let n=0;n<t.count;n++){const t=Number(i[n]);QP(Number.isInteger(t)&&t>=0&&t<e.count,"glTF sparse accessor index is out of bounds");for(let i=0;i<e.components;i++){const r=t*e.components+i,o=n*e.components+i;Reflect.set(e.value,r,s[o])}}}_getTypedArrayFromBufferView(e,t,n,i){const r=i*e.BYTES_PER_ELEMENT;QP(n+r<=t.byteLength,"glTF sparse accessor data exceeds its buffer view");const s=t.buffer,o=s.byteOffset+(t.byteOffset||0)+n;return new e(_R(s.arrayBuffer,o,r))}_getValueFromInterleavedBuffer(e,t,n,i,r){const s=new Uint8Array(r*i);for(let o=0;o<r;o++){const r=t+o*n;s.set(new Uint8Array(e.arrayBuffer.slice(r,r+i)),o*i)}return s.buffer}_resolveTexture(e,t){return{...e,id:e.id||`texture-${t}`,sampler:"number"==typeof e.sampler?this.getSampler(e.sampler):{id:"default-sampler",parameters:OL},source:"number"==typeof e.source?this.getImage(e.source):void 0}}_resolveSampler(e,t){const n={id:e.id||`sampler-${t}`,...e,parameters:{}};for(const e in n){const t=this._enumSamplerParameter(e);void 0!==t&&(n.parameters[t]=n[e])}return n}_enumSamplerParameter(e){return IL[e]}_resolveImage(e,t){const n={...e,id:e.id||`image-${t}`,image:null,bufferView:void 0!==e.bufferView?this.getBufferView(e.bufferView):void 0},i=this.images[t];return i&&(n.image=i),n}_resolveBufferView(e,t){const n=e.buffer,i=this.buffers[n].arrayBuffer;let r=this.buffers[n].byteOffset||0;e.byteOffset&&(r+=e.byteOffset);return{id:`bufferView-${t}`,...e,buffer:this.buffers[n],data:new Uint8Array(i,r,e.byteLength)}}_resolveCamera(e,t){const n={...e,id:e.id||`camera-${t}`};return n.perspective,n.orthographic,n}}function BL(e){let t=1/0;for(const n of e)t=Math.min(t,n);return t}function NL(e,t){return e?Number(e[t]):t}function kL(e,t){return(new post_process_gltf_GLTFPostProcessor).postProcess(e,t)}const FL=0,DL=1;function UL(e,t,n,i){e.rotateYtoZ=!0;const r=(e.byteOffset||0)+(e.byteLength||0)-n;if(0===r)throw new Error("glTF byte length must be greater than 0.");return e.gltfUpAxis=i?.["3d-tiles"]&&i["3d-tiles"].assetGltfUpAxis?i["3d-tiles"].assetGltfUpAxis:"Y",e.gltfArrayBuffer=TP(t,n,r),e.gltfByteOffset=0,e.gltfByteLength=r,n%4==0||console.warn(`${e.type}: embedded glb is not aligned to a 4-byte boundary.`),(e.byteOffset||0)+(e.byteLength||0)}async function VL(e,t,n,i){const r=n?.["3d-tiles"]||{};if(function(e,t){switch(t){case FL:if(e.gltfArrayBuffer){const t=new Uint8Array(e.gltfArrayBuffer,e.gltfByteOffset),n=(new TextDecoder).decode(t);e.gltfUrl=n.replace(/[\s\0]+$/,"")}delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength;break;case DL:break;default:throw new Error("b3dm: Illegal glTF format field")}}(e,t),r.loadGLTF){if(!i)return;if(e.gltfUrl){const{fetch:t}=i,r=await t(e.gltfUrl,n?.core);e.gltfArrayBuffer=await r.arrayBuffer(),e.gltfByteOffset=0}if(e.gltfArrayBuffer){const t=await KC(e.gltfArrayBuffer,wL,n,i);e.gltf=kL(t),e.gpuMemoryUsageInBytes=gR(e.gltf),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength}}}async function zL(e,t,n,i,r){n=function(e,t,n,i){n=cP(e,t,n),n=uP(e,t,n),n=hP(e,t,n),n=UL(e,t,n,i);const r=new Tile3DFeatureTable(e.featureTableJson,e.featureTableBinary);return e.rtcCenter=r.getGlobalProperty("RTC_CENTER",XC.FLOAT,3),n}(e,t,n,i),await VL(e,DL,i,r);const s=e?.gltf?.extensions;return s&&s.CESIUM_RTC&&(e.rtcCenter=s.CESIUM_RTC.center),n}async function jL(e,t,n,i,r){return n=function(e,t,n,i){if(n=cP(e,t,n),1!==e.version)throw new Error(`Instanced 3D Model version ${e.version} is not supported`);n=uP(e,t,n);const r=new DataView(t);if(e.gltfFormat=r.getUint32(n,!0),n+=4,n=hP(e,t,n),n=UL(e,t,n,i),!e?.header?.featureTableJsonByteLength||0===e.header.featureTableJsonByteLength)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");const s=new Tile3DFeatureTable(e.featureTableJson,e.featureTableBinary),o=s.getGlobalProperty("INSTANCES_LENGTH");if(s.featuresLength=o,!Number.isFinite(o))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");e.eastNorthUp=s.getGlobalProperty("EAST_NORTH_UP"),e.rtcCenter=s.getGlobalProperty("RTC_CENTER",XC.FLOAT,3);new Tile3DBatchTableParser(e.batchTableJson,e.batchTableBinary,o);return function(e,t,n,i){const r=new Array(i),s=new oi.P,o=new oi.P,a=new oi.P,l=new oi.P,c=new Matrix3,A=new Quaternion,u=new oi.P,h={},d=new Rn.k,f=[],p=[],g=[],m=[];for(let n=0;n<i;n++){let i;if(t.hasProperty("POSITION"))i=t.getProperty("POSITION",XC.FLOAT,3,n,s);else if(t.hasProperty("POSITION_QUANTIZED")){i=t.getProperty("POSITION_QUANTIZED",XC.UNSIGNED_SHORT,3,n,s);const e=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",XC.FLOAT,3);if(!e)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");const r=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",XC.FLOAT,3);if(!r)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");const o=65535;for(let t=0;t<3;t++)i[t]=i[t]/o*r[t]+e[t]}if(!i)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");s.copy(i),h.translation=s,e.normalUp=t.getProperty("NORMAL_UP",XC.FLOAT,3,n,f),e.normalRight=t.getProperty("NORMAL_RIGHT",XC.FLOAT,3,n,p);const b=!1;if(e.normalUp){if(!e.normalRight)throw new Error("i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.");e.hasCustomOrientation=!0}else{if(e.octNormalUp=t.getProperty("NORMAL_UP_OCT32P",XC.UNSIGNED_SHORT,2,n,f),e.octNormalRight=t.getProperty("NORMAL_RIGHT_OCT32P",XC.UNSIGNED_SHORT,2,n,p),e.octNormalUp){if(!e.octNormalRight)throw new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");throw new Error("i3dm: oct-encoded orientation not implemented")}e.eastNorthUp?(Ellipsoid.WGS84.eastNorthUpToFixedFrame(s,d),d.getRotationMatrix3(c)):c.identity()}b&&(l.copy(o).cross(a).normalize(),c.setColumn(0,o),c.setColumn(1,a),c.setColumn(2,l)),A.fromMatrix3(c),h.rotation=A,u.set(1,1,1);const _=t.getProperty("SCALE",XC.FLOAT,1,n,g);Number.isFinite(_)&&u.multiplyByScalar(_);const v=t.getProperty("SCALE_NON_UNIFORM",XC.FLOAT,3,n,f);v&&u.scale(v),h.scale=u;let y=t.getProperty("BATCH_ID",XC.UNSIGNED_SHORT,1,n,m);void 0===y&&(y=n);const w=(new Rn.k).fromQuaternion(h.rotation);d.identity(),d.translate(h.translation),d.multiplyRight(w),d.scale(h.scale);const x=d.clone();r[n]={modelMatrix:x,batchId:y}}e.instances=r}(e,s,0,o),n}(e,t,n,i),await VL(e,e.gltfFormat||0,i,r),n}async function HL(e,t=0,n,i,r={shape:"tile3d"}){switch(r.byteOffset=t,r.type=function(e,t=0){const n=new DataView(e);return`${String.fromCharCode(n.getUint8(t+0))}${String.fromCharCode(n.getUint8(t+1))}${String.fromCharCode(n.getUint8(t+2))}${String.fromCharCode(n.getUint8(t+3))}`}(e,t),r.type){case wC.COMPOSITE:return await async function(e,t,n,i,r,s){n=cP(e,t,n);const o=new DataView(t);for(e.tilesLength=o.getUint32(n,!0),n+=4,e.tiles=[];e.tiles.length<e.tilesLength&&(e.byteLength||0)-n>12;){const o={shape:"tile3d"};e.tiles.push(o),n=await s(t,n,i,r,o)}return n}(r,e,t,n,i,HL);case wC.BATCHED_3D_MODEL:return await zL(r,e,t,n,i);case wC.GLTF:return await async function(e,t,n,i){if(e.rotateYtoZ=!0,e.gltfUpAxis=n?.["3d-tiles"]?.assetGltfUpAxis?n["3d-tiles"].assetGltfUpAxis:"Y",n?.["3d-tiles"]?.loadGLTF){if(!i)return t.byteLength;const r=await KC(t,wL,n,i);e.gltf=kL(r),e.gpuMemoryUsageInBytes=gR(e.gltf)}else e.gltfArrayBuffer=t;return t.byteLength}(r,e,n,i);case wC.INSTANCED_3D_MODEL:return await jL(r,e,t,n,i);case wC.POINT_CLOUD:return await yP(r,e,t,n,i);default:throw new Error(`3DTileLoader: unknown type ${r.type}`)}}async function WL(e,t,n,i){const r=Number.isFinite(t.bitstream)?t.bitstream:t.bufferView;if("number"!=typeof r)return;const s=e.bufferViews[r],o=e.buffers[s.buffer];if(!i?.baseUrl)throw new Error("Url is not provided");if(!i.fetch)throw new Error("fetch is not provided");if(o.uri){const e=`${i?.baseUrl||""}/${o.uri}`,n=await i.fetch(e),r=await n.arrayBuffer();return void(t.explicitBitstream=new Uint8Array(r,s.byteOffset,s.byteLength))}const a=e.buffers.slice(0,s.buffer).reduce((e,t)=>e+t.byteLength,0);t.explicitBitstream=new Uint8Array(n.slice(a,a+o.byteLength),s.byteOffset,s.byteLength)}function qL(e){const t=new DataView(e);return t.getUint32(0,!0)+2**32*t.getUint32(4,!0)}const KL={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:"4.5.1",extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:async function(e,t,n){if(1952609651!==new Uint32Array(e.slice(0,4))[0])throw new Error("Wrong subtree file magic number");if(1!==new Uint32Array(e.slice(4,8))[0])throw new Error("Wrong subtree file verson, must be 1");const i=qL(e.slice(8,16)),r=new Uint8Array(e,24,i),s=new TextDecoder("utf8").decode(r),o=JSON.parse(s),a=qL(e.slice(16,24));let l=new ArrayBuffer(0);if(a&&(l=e.slice(24+i)),await WL(o,o.tileAvailability,l,n),Array.isArray(o.contentAvailability))for(const e of o.contentAvailability)await WL(o,e,l,n);else await WL(o,o.contentAvailability,l,n);return await WL(o,o.childSubtreeAvailability,l,n),o},options:{}};var QL=n(78543);globalThis.probe||(globalThis.probe=QL.d);const XL=new j.h({id:"@probe.gl/log"});var $L=null;try{$L=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function ZL(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function YL(e){return!0===(e&&e.__isLong__)}function JL(e){var t=Math.clz32(e&-e);return e?31-t:t}ZL.prototype.__isLong__,Object.defineProperty(ZL.prototype,"__isLong__",{value:!0}),ZL.isLong=YL;var eI={},tI={};function nI(e,t){var n,i,r;return t?(r=0<=(e>>>=0)&&e<256)&&(i=tI[e])?i:(n=rI(e,0,!0),r&&(tI[e]=n),n):(r=-128<=(e|=0)&&e<128)&&(i=eI[e])?i:(n=rI(e,e<0?-1:0,!1),r&&(eI[e]=n),n)}function iI(e,t){if(isNaN(e))return t?dI:hI;if(t){if(e<0)return dI;if(e>=cI)return bI}else{if(e<=-AI)return _I;if(e+1>=AI)return mI}return e<0?iI(-e,t).neg():rI(e%lI|0,e/lI|0,t)}function rI(e,t,n){return new ZL(e,t,n)}ZL.fromInt=nI,ZL.fromNumber=iI,ZL.fromBits=rI;var sI=Math.pow;function oI(e,t,n){if(0===e.length)throw Error("empty string");if("number"==typeof t?(n=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?dI:hI;if((n=n||10)<2||36<n)throw RangeError("radix");var i;if((i=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===i)return oI(e.substring(1),t,n).neg();for(var r=iI(sI(n,8)),s=hI,o=0;o<e.length;o+=8){var a=Math.min(8,e.length-o),l=parseInt(e.substring(o,o+a),n);if(a<8){var c=iI(sI(n,a));s=s.mul(c).add(iI(l))}else s=(s=s.mul(r)).add(iI(l))}return s.unsigned=t,s}function aI(e,t){return"number"==typeof e?iI(e,t):"string"==typeof e?oI(e,t):rI(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}ZL.fromString=oI,ZL.fromValue=aI;var lI=4294967296,cI=lI*lI,AI=cI/2,uI=nI(1<<24),hI=nI(0);ZL.ZERO=hI;var dI=nI(0,!0);ZL.UZERO=dI;var fI=nI(1);ZL.ONE=fI;var pI=nI(1,!0);ZL.UONE=pI;var gI=nI(-1);ZL.NEG_ONE=gI;var mI=rI(-1,2147483647,!1);ZL.MAX_VALUE=mI;var bI=rI(-1,-1,!0);ZL.MAX_UNSIGNED_VALUE=bI;var _I=rI(0,-2147483648,!1);ZL.MIN_VALUE=_I;var vI=ZL.prototype;vI.toInt=function(){return this.unsigned?this.low>>>0:this.low},vI.toNumber=function(){return this.unsigned?(this.high>>>0)*lI+(this.low>>>0):this.high*lI+(this.low>>>0)},vI.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(_I)){var t=iI(e),n=this.div(t),i=n.mul(t).sub(this);return n.toString(e)+i.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var r=iI(sI(e,6),this.unsigned),s=this,o="";;){var a=s.div(r),l=(s.sub(a.mul(r)).toInt()>>>0).toString(e);if((s=a).isZero())return l+o;for(;l.length<6;)l="0"+l;o=""+l+o}},vI.getHighBits=function(){return this.high},vI.getHighBitsUnsigned=function(){return this.high>>>0},vI.getLowBits=function(){return this.low},vI.getLowBitsUnsigned=function(){return this.low>>>0},vI.getNumBitsAbs=function(){if(this.isNegative())return this.eq(_I)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<<t);t--);return 0!=this.high?t+33:t+1},vI.isSafeInteger=function(){var e=this.high>>21;return!e||!this.unsigned&&(-1===e&&!(0===this.low&&-2097152===this.high))},vI.isZero=function(){return 0===this.high&&0===this.low},vI.eqz=vI.isZero,vI.isNegative=function(){return!this.unsigned&&this.high<0},vI.isPositive=function(){return this.unsigned||this.high>=0},vI.isOdd=function(){return!(1&~this.low)},vI.isEven=function(){return!(1&this.low)},vI.equals=function(e){return YL(e)||(e=aI(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},vI.eq=vI.equals,vI.notEquals=function(e){return!this.eq(e)},vI.neq=vI.notEquals,vI.ne=vI.notEquals,vI.lessThan=function(e){return this.comp(e)<0},vI.lt=vI.lessThan,vI.lessThanOrEqual=function(e){return this.comp(e)<=0},vI.lte=vI.lessThanOrEqual,vI.le=vI.lessThanOrEqual,vI.greaterThan=function(e){return this.comp(e)>0},vI.gt=vI.greaterThan,vI.greaterThanOrEqual=function(e){return this.comp(e)>=0},vI.gte=vI.greaterThanOrEqual,vI.ge=vI.greaterThanOrEqual,vI.compare=function(e){if(YL(e)||(e=aI(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},vI.comp=vI.compare,vI.negate=function(){return!this.unsigned&&this.eq(_I)?_I:this.not().add(fI)},vI.neg=vI.negate,vI.add=function(e){YL(e)||(e=aI(e));var t=this.high>>>16,n=65535&this.high,i=this.low>>>16,r=65535&this.low,s=e.high>>>16,o=65535&e.high,a=e.low>>>16,l=0,c=0,A=0,u=0;return A+=(u+=r+(65535&e.low))>>>16,c+=(A+=i+a)>>>16,l+=(c+=n+o)>>>16,l+=t+s,rI((A&=65535)<<16|(u&=65535),(l&=65535)<<16|(c&=65535),this.unsigned)},vI.subtract=function(e){return YL(e)||(e=aI(e)),this.add(e.neg())},vI.sub=vI.subtract,vI.multiply=function(e){if(this.isZero())return this;if(YL(e)||(e=aI(e)),$L)return rI($L.mul(this.low,this.high,e.low,e.high),$L.get_high(),this.unsigned);if(e.isZero())return this.unsigned?dI:hI;if(this.eq(_I))return e.isOdd()?_I:hI;if(e.eq(_I))return this.isOdd()?_I:hI;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(uI)&&e.lt(uI))return iI(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,n=65535&this.high,i=this.low>>>16,r=65535&this.low,s=e.high>>>16,o=65535&e.high,a=e.low>>>16,l=65535&e.low,c=0,A=0,u=0,h=0;return u+=(h+=r*l)>>>16,A+=(u+=i*l)>>>16,u&=65535,A+=(u+=r*a)>>>16,c+=(A+=n*l)>>>16,A&=65535,c+=(A+=i*a)>>>16,A&=65535,c+=(A+=r*o)>>>16,c+=t*l+n*a+i*o+r*s,rI((u&=65535)<<16|(h&=65535),(c&=65535)<<16|(A&=65535),this.unsigned)},vI.mul=vI.multiply,vI.divide=function(e){if(YL(e)||(e=aI(e)),e.isZero())throw Error("division by zero");var t,n,i;if($L)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?rI((this.unsigned?$L.div_u:$L.div_s)(this.low,this.high,e.low,e.high),$L.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?dI:hI;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return dI;if(e.gt(this.shru(1)))return pI;i=dI}else{if(this.eq(_I))return e.eq(fI)||e.eq(gI)?_I:e.eq(_I)?fI:(t=this.shr(1).div(e).shl(1)).eq(hI)?e.isNegative()?fI:gI:(n=this.sub(e.mul(t)),i=t.add(n.div(e)));if(e.eq(_I))return this.unsigned?dI:hI;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=hI}for(n=this;n.gte(e);){t=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var r=Math.ceil(Math.log(t)/Math.LN2),s=r<=48?1:sI(2,r-48),o=iI(t),a=o.mul(e);a.isNegative()||a.gt(n);)a=(o=iI(t-=s,this.unsigned)).mul(e);o.isZero()&&(o=fI),i=i.add(o),n=n.sub(a)}return i},vI.div=vI.divide,vI.modulo=function(e){return YL(e)||(e=aI(e)),$L?rI((this.unsigned?$L.rem_u:$L.rem_s)(this.low,this.high,e.low,e.high),$L.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},vI.mod=vI.modulo,vI.rem=vI.modulo,vI.not=function(){return rI(~this.low,~this.high,this.unsigned)},vI.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},vI.clz=vI.countLeadingZeros,vI.countTrailingZeros=function(){return this.low?JL(this.low):JL(this.high)+32},vI.ctz=vI.countTrailingZeros,vI.and=function(e){return YL(e)||(e=aI(e)),rI(this.low&e.low,this.high&e.high,this.unsigned)},vI.or=function(e){return YL(e)||(e=aI(e)),rI(this.low|e.low,this.high|e.high,this.unsigned)},vI.xor=function(e){return YL(e)||(e=aI(e)),rI(this.low^e.low,this.high^e.high,this.unsigned)},vI.shiftLeft=function(e){return YL(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?rI(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):rI(0,this.low<<e-32,this.unsigned)},vI.shl=vI.shiftLeft,vI.shiftRight=function(e){return YL(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?rI(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):rI(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},vI.shr=vI.shiftRight,vI.shiftRightUnsigned=function(e){return YL(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?rI(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):rI(32===e?this.high:this.high>>>e-32,0,this.unsigned)},vI.shru=vI.shiftRightUnsigned,vI.shr_u=vI.shiftRightUnsigned,vI.rotateLeft=function(e){var t;return YL(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?rI(this.high,this.low,this.unsigned):e<32?(t=32-e,rI(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)):(t=32-(e-=32),rI(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned))},vI.rotl=vI.rotateLeft,vI.rotateRight=function(e){var t;return YL(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?rI(this.high,this.low,this.unsigned):e<32?(t=32-e,rI(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned)):(t=32-(e-=32),rI(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned))},vI.rotr=vI.rotateRight,vI.toSigned=function(){return this.unsigned?rI(this.low,this.high,!1):this},vI.toUnsigned=function(){return this.unsigned?this:rI(this.low,this.high,!0)},vI.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},vI.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},vI.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},ZL.fromBytes=function(e,t,n){return n?ZL.fromBytesLE(e,t):ZL.fromBytesBE(e,t)},ZL.fromBytesLE=function(e,t){return new ZL(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},ZL.fromBytesBE=function(e,t){return new ZL(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)},"function"==typeof BigInt&&(ZL.fromBigInt=function(e,t){return rI(Number(BigInt.asIntN(32,e)),Number(BigInt.asIntN(32,e>>BigInt(32))),t)},ZL.fromValue=function(e,t){return"bigint"==typeof e?ZL.fromBigInt(e,t):aI(e,t)},vI.toBigInt=function(){var e=BigInt(this.low>>>0);return BigInt(this.unsigned?this.high>>>0:this.high)<<BigInt(32)|e});const yI=ZL;function wI(e){"X"===e&&(e="");const t=e.padEnd(16,"0");return yI.fromString(t,!0,16)}const xI=180/Math.PI;function TI(e,t,n){const i=1<<t;return[(e[0]+n[0])/i,(e[1]+n[1])/i]}function EI(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function SI(e){return[EI(e[0]),EI(e[1])]}function CI(e,[t,n]){switch(e){case 0:return[1,t,n];case 1:return[-t,1,n];case 2:return[-t,-n,1];case 3:return[-1,-n,-t];case 4:return[n,-1,-t];case 5:return[n,t,-1];default:throw new Error("Invalid face")}}function PI([e,t,n]){const i=Math.atan2(n,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*xI,i*xI]}function RI(e,t,n,i){if(0===i){1===n&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);const i=t[0];t[0]=t[1],t[1]=i}}function MI(e){const t=function(e){if(e.indexOf("/")>0)return e;const t=wI(e);return function(e){if(e.isZero())return"";let t=e.toString(2);for(;t.length<64;)t="0"+t;const n=t.lastIndexOf("1"),i=t.substring(0,3),r=t.substring(3,n),s=r.length/2,o=yI.fromString(i,!0,2).toString(10);let a="";if(0!==s)for(a=yI.fromString(r,!0,2).toString(4);a.length<s;)a="0"+a;return`${o}/${a}`}(t)}(e);return function(e){if(0===e.length)throw new Error(`Invalid Hilbert quad key ${e}`);const t=e.split("/"),n=parseInt(t[0],10),i=t[1],r=i.length;let s=0;const o=[0,0];for(let e=r-1;e>=0;e--){s=r-e;const t=i[e];let n=0,a=0;"1"===t?a=1:"2"===t?(n=1,a=1):"3"===t&&(n=1);const l=Math.pow(2,s-1);RI(l,o,n,a),o[0]+=l*n,o[1]+=l*a}if(n%2==1){const e=o[0];o[0]=o[1],o[1]=e}return{face:n,ij:o,level:s}}(t)}function LI(e){const{face:t,ij:n,level:i}=e,r=[[0,0],[0,1],[1,1],[1,0],[0,0]],s=Math.max(1,Math.ceil(100*Math.pow(2,-i))),o=new Float64Array(4*s*2+2);let a=0,l=0;for(let e=0;e<4;e++){const c=r[e].slice(0),A=r[e+1],u=(A[0]-c[0])/s,h=(A[1]-c[1])/s;for(let e=0;e<s;e++){c[0]+=u,c[1]+=h;const e=PI(CI(t,SI(TI(n,i,c))));Math.abs(e[1])>89.999&&(e[0]=l);const r=e[0]-l;e[0]+=r>180?-360:r<-180?360:0,o[a++]=e[0],o[a++]=e[1],l=e[0]}}return o[a++]=o[0],o[a++]=o[1],o}function II(e){if(e.length%2!=0)throw new Error("Invalid corners");const t=[],n=[];for(let i=0;i<e.length;i+=2)t.push(e[i]),n.push(e[i+1]);return t.sort((e,t)=>e-t),n.sort((e,t)=>e-t),{west:t[0],east:t[t.length-1],north:n[n.length-1],south:n[0]}}function OI(e,t){const n=t?.minimumHeight||0,i=t?.maximumHeight||0,r=function(e){let t;if(2===e.face||5===e.face){let n=null,i=0;for(let t=0;t<4;t++){const r=LI(MI(`${e.face}/${t}`));null==n&&(n=new Float64Array(4*r.length)),n.set(r,i),i+=r.length}t=II(n)}else t=II(LI(e));return t}(MI(e)),s=r.west,o=r.south,a=r.east,l=r.north,c=[];return c.push(new oi.P(s,l,n)),c.push(new oi.P(a,l,n)),c.push(new oi.P(a,o,n)),c.push(new oi.P(s,o,n)),c.push(new oi.P(s,l,i)),c.push(new oi.P(a,l,i)),c.push(new oi.P(a,o,i)),c.push(new oi.P(s,o,i)),c}function BI(e){return function(e){const t=SI(TI(e.ij,e.level,[.5,.5]));return PI(CI(e.face,t))}(MI(e))}function NI(e){const t=e.token,n={minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight},i=OI(t,n),r=BI(t),s=r[0],o=r[1],a=Ellipsoid.WGS84.cartographicToCartesian([s,o,n.maximumHeight]),l=new oi.P(a[0],a[1],a[2]);i.push(l);const c=h_(i);return[...c.center,...c.halfAxes]}const kI={QUADTREE:4,OCTREE:8};function FI(e,t,n){if(e?.box){const i=function(e,t){const n=function(e){return e.and(e.not().add(1))}(e).shiftRightUnsigned(2);return e.add(yI.fromNumber(2*t+1-4).multiply(n))}(wI(e.s2VolumeInfo.token),t),r=function(e){if(e.isZero())return"X";let t=e.countTrailingZeros();t=(t-t%4)/4;const n=t;t*=4;const i=e.shiftRightUnsigned(t).toString(16).replace(/0+$/,"");return Array(17-n-i.length).join("0")+i}(i),s={...e.s2VolumeInfo};if(s.token=r,"OCTREE"===n){const t=e.s2VolumeInfo,n=t.maximumHeight-t.minimumHeight,i=n/2,r=t.minimumHeight+n/2;t.minimumHeight=r-i,t.maximumHeight=r+i}return{box:NI(s),s2VolumeInfo:s}}}async function DI(e){const{subtree:t,subtreeData:n={level:0,x:0,y:0,z:0},parentData:i={mortonIndex:0,localLevel:-1,localX:0,localY:0,localZ:0},childIndex:r=0,implicitOptions:s,loaderOptions:o,s2VolumeBox:a}=e,{subdivisionScheme:l,subtreeLevels:c,maximumLevel:A,contentUrlTemplate:u,subtreesUriTemplate:h,basePath:d}=s,f={children:[],lodMetricValue:0,contentUrl:""};if("number"!=typeof A||!Number.isFinite(A))return XL.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${u} won't be loaded...`),f;const p=i.localLevel+1,g=n.level+p;if(g>A)return f;const m=kI[l],b=Math.log2(m),_=1&r,v=r>>1&1,y=r>>2&1,w=VI(i.localX,_,1),x=VI(i.localY,v,1),T=VI(i.localZ,y,1),E=VI(n.x,w,p),S=VI(n.y,x,p),C=VI(n.z,T,p),P=VI(i.mortonIndex,r,b);let R,M,L,I;if(p===c&&UI(t.childSubtreeAvailability,P)){const e=zI(`${d}/${h}`,g,E,S,C);R=await un(e,KL,o),I=0,M={level:g,x:E,y:S,z:C},L={mortonIndex:0,localLevel:0,localX:0,localY:0,localZ:0}}else{R=t;I=(m**p-1)/(m-1)+P,M=n,L={mortonIndex:P,localLevel:p,localX:w,localY:x,localZ:T}}if(!UI(R.tileAvailability,I))return f;UI(R.contentAvailability,I)&&(f.contentUrl=zI(u,g,E,S,C));for(let e=0;e<m;e++){const t=FI(a,e,l),n=await DI({subtree:R,subtreeData:M,parentData:L,childIndex:e,implicitOptions:s,loaderOptions:o,s2VolumeBox:t});(n.contentUrl||n.children.length)&&f.children.push(n)}if(f.contentUrl||f.children.length){const e=function(e,t,n,i){const{basePath:r,refine:s,getRefine:o,lodMetricType:a,getTileType:l,rootLodMetricValue:c,rootBoundingVolume:A}=n,u=e.contentUrl&&e.contentUrl.replace(`${r}/`,""),h=c/2**t.level,d=i?.box?{box:i.box}:A,f=function(e,t,n){if(e.region){const{level:i,x:r,y:s,z:o}=t,[a,l,c,A,u,h]=e.region,d=2**i,f=(c-a)/d,[p,g]=[a+f*r,a+f*(r+1)],m=(A-l)/d,[b,_]=[l+m*s,l+m*(s+1)];let v,y;if("OCTREE"===n){const e=(h-u)/d;[v,y]=[u+e*o,u+e*(o+1)]}else[v,y]=[u,h];return{region:[p,b,g,_,v,y]}}if(e.box)return e;throw new Error(`Unsupported bounding volume type ${JSON.stringify(e)}`)}(d,t,n.subdivisionScheme);return{children:e.children,contentUrl:e.contentUrl,content:{uri:u},id:e.contentUrl,refine:o(s),type:l(e),lodMetricType:a,lodMetricValue:h,geometricError:h,transform:e.transform,boundingVolume:f}}(f,{level:g,x:E,y:S,z:C},s,a);return e}return f}function UI(e,t){let n;return Array.isArray(e)?(n=e[0],e.length>1&&XL.once('Not supported extension "3DTILES_multiple_contents" has been detected')):n=e,"constant"in n?Boolean(n.constant):!!n.explicitBitstream&&function(e,t){const n=Math.floor(e/8),i=e%8;return 1==(t[n]>>i&1)}(t,n.explicitBitstream)}function VI(e,t,n){return(e<<n)+t}function zI(e,t,n,i,r){const s=function(e){const t={};for(const n in e)t[`{${n}}`]=e[n];return t}({level:t,x:n,y:i,z:r});return e.replace(/{level}|{x}|{y}|{z}/gi,e=>s[e])}function GI(e,t=""){if(!t)return IS.EMPTY;const n=t.split("?")[0].split(".").pop();switch(n){case"pnts":return IS.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return IS.SCENEGRAPH;default:return n||IS.EMPTY}}function jI(e){switch(e){case"REPLACE":case"replace":return LS.REPLACE;case"ADD":case"add":return LS.ADD;default:return e}}function HI(e,t){if(/^[a-z][0-9a-z+.-]*:/i.test(t)){const n=new URL(e,`${t}/`);return decodeURI(n.toString())}return e.startsWith("/")?e:AS(t,e)}function WI(e,t){if(!e)return null;let n;if(e.content){const i=e.content.uri||e.content?.url;void 0!==i&&(n=HI(i,t))}return{...e,id:n,contentUrl:n,lodMetricType:BS.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:GI(0,n),refine:jI(e.refine)}}async function qI(e,t,n,i,r){const{subdivisionScheme:s,maximumLevel:o,availableLevels:a,subtreeLevels:l,subtrees:{uri:c}}=i,A=HI(zI(c,0,0,0,0),n),u=await un(A,KL,r),h=e.content?.uri,d=h?HI(h,n):"",f=t?.root?.refine,p=e.geometricError,g=e.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(g){const t={box:NI(g),s2VolumeInfo:g};e.boundingVolume=t}const m=e.boundingVolume,b={contentUrlTemplate:d,subtreesUriTemplate:c,subdivisionScheme:s,subtreeLevels:l,maximumLevel:Number.isFinite(a)?a-1:o,refine:f,basePath:n,lodMetricType:BS.GEOMETRIC_ERROR,rootLodMetricValue:p,rootBoundingVolume:m,getTileType:GI,getRefine:jI};return await async function(e,t,n,i,r){if(!e)return null;const{children:s,contentUrl:o}=await DI({subtree:n,implicitOptions:i,loaderOptions:r});let a,l=null;o&&(a=o,l={uri:o.replace(`${t}/`,"")});const c={...e,id:a,contentUrl:a,lodMetricType:BS.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:GI(0,a),refine:jI(e.refine),content:l||e.content,children:s};return c}(e,n,u,b,r)}function KI(e){return e?.extensions?.["3DTILES_implicit_tiling"]||e?.implicitTiling}const QI={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:"4.5.1",extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:async function(e,t={},n){const i=t["3d-tiles"]||{};let r;r="auto"===i.isTileset?n?.url&&-1!==n.url.indexOf(".json"):i.isTileset;return r?async function(e,t,n){const i=JSON.parse((new TextDecoder).decode(e)),r=n?.url||"",s=function(e){return cS(e)}(r),o=await async function(e,t,n){let i=null;const r=KI(e.root);i=r&&e.root?await qI(e.root,e,t,r,n):WI(e.root,t);const s=[];for(s.push(i);s.length>0;){const i=s.pop()||{},r=i.children||[],o=[];for(const i of r){const r=KI(i);let a;a=r?await qI(i,e,t,r,n):WI(i,t),a&&(o.push(a),s.push(a))}i.children=o}return i}(i,s,t||{}),a={...i,shape:"tileset3d",loader:QI,url:r,queryString:n?.queryString||"",basePath:s,root:o||i.root,type:OS.TILES3D,lodMetricType:BS.GEOMETRIC_ERROR,lodMetricValue:i.root?.geometricError||0};return a}(e,t,n):async function(e,t,n){const i={content:{shape:"tile3d",featureIds:null}},r=0;return await HL(e,r,t,n,i.content),i.content}(e,t,n)},options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};const XI=[0],$I={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:QI,onTilesetLoad:{type:"function",value:e=>{}},onTileLoad:{type:"function",value:e=>{}},onTileUnload:{type:"function",value:e=>{}},onTileError:{type:"function",value:(e,t,n)=>{}},_getMeshColor:{type:"function",value:e=>[255,255,255]}};class Tile3DLayer extends Ss{initializeState(){"onTileLoadFail"in this.props&&Ie.A.removed("onTileLoadFail","onTileError")(),this.state={layerMap:{},tileset3d:null,activeViewports:{},lastUpdatedViewports:null}}get isLoaded(){return Boolean(this.state?.tileset3d?.isLoaded()&&super.isLoaded)}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({props:e,oldProps:t,changeFlags:n}){if(e.data&&e.data!==t.data&&this._loadTileset(e.data),n.viewportChanged){const{activeViewports:e}=this.state;Object.keys(e).length&&(this._updateTileset(e),this.state.lastUpdatedViewports=e,this.state.activeViewports={})}if(n.propsChanged){const{layerMap:e}=this.state;for(const t in e)e[t].needsUpdate=!0}}finalizeState(e){this.state.tileset3d?.destroy(),this.state.tileset3d=null,this.state.layerMap={},this.state.activeViewports={},this.state.lastUpdatedViewports=null,super.finalizeState(e)}activateViewport(e){const{activeViewports:t,lastUpdatedViewports:n}=this.state;this.internalState.viewport=e,t[e.id]=e;const i=n?.[e.id];i&&e.equals(i)||(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:e,sourceLayer:t}){const n=t&&t.props.tile;return e.picked&&(e.object=n),e.sourceTile=n,e}filterSubLayer({layer:e,viewport:t,cullRect:n,isPicking:i}){const{tile:r}=e.props,{id:s}=t;if(!r.selected||!r.viewportIds.includes(s))return!1;if(i&&n&&r.content?.cartographicOrigin){const[e,i]=t.project(r.content.cartographicOrigin),s=n.x+n.width/2,o=n.y+n.height/2,a=Math.max(t.width,t.height)/4,l=e-s,c=i-o;if(l*l+c*c>a*a)return!1}return!0}_updateAutoHighlight(e){const t=e.sourceTile,n=this.state.layerMap[t?.id];n&&n.layer&&n.layer.updateAutoHighlight(e)}async _loadTileset(e){const t=this.props.loadOptions||{},n=this.props.loaders?.length?this.props.loaders:this.props.loader,i=Array.isArray(n)?n[0]:n,{tileset:r,...s}=t,o={loadOptions:{...s},...r};let a=e;if("preload"in i&&"function"==typeof i.preload){const n=await i.preload(e,t);n.url&&(a=n.url),n.headers&&(o.loadOptions.core={...o.loadOptions.core,fetch:{...o.loadOptions.core?.fetch,headers:n.headers}}),Object.assign(o,n)}const l=await un(a,i,o.loadOptions),c=new Tileset3D(l,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,onUpdate:()=>this.setNeedsUpdate(),...o});this.setState({tileset3d:c,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(c)}_onTileLoad(e){const{lastUpdatedViewports:t}=this.state;e.tileDrawn=!1,this.props.onTileLoad(e),this._updateTileset(t),this.setNeedsUpdate()}_onTileUnload(e){delete this.state.layerMap[e.id],this.props.onTileUnload(e)}_updateTileset(e){if(!e)return;const{tileset3d:t}=this.state,{timeline:n}=this.context,i=Object.keys(e).length;n&&i&&t&&t.selectTiles(Object.values(e)).then(e=>{this.state.frameNumber!==e&&this.setState({frameNumber:e})})}_getSubLayer(e,t){if(!e.content)return null;switch(e.type){case IS.POINTCLOUD:return this._makePointCloudLayer(e,t);case IS.SCENEGRAPH:return this._make3DModelLayer(e);case IS.MESH:return this._makeSimpleMeshLayer(e,t);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${e.content.type}`)}}_makePointCloudLayer(e,t){const{attributes:n,pointCount:i,constantRGBA:r,cartographicOrigin:s,modelMatrix:o}=e.content,{positions:a,normals:l,colors:c}=n;if(!a)return null;const A=t&&t.props.data||{header:{vertexCount:i},attributes:{POSITION:a,NORMAL:l,COLOR_0:c}},{pointSize:u,getPointColor:h}=this.props;return new(this.getSubLayerClass("pointcloud",oa))({pointSize:u},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${e.id}`,tile:e,data:A,coordinateSystem:Mn.rf.METER_OFFSETS,coordinateOrigin:s,modelMatrix:o,getColor:r||h,_offset:0})}_make3DModelLayer(e){const{gltf:t,instances:n,cartographicOrigin:i,modelMatrix:r}=e.content;return new(this.getSubLayerClass("scenegraph",dE))({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${e.id}`,tile:e,data:n||XI,scenegraph:t,coordinateSystem:Mn.rf.METER_OFFSETS,coordinateOrigin:i,modelMatrix:r,getTransformMatrix:e=>e.modelMatrix,getPosition:[0,0,0],_offset:0,onFirstDraw:()=>{e.tileDrawn=!0}})}_makeSimpleMeshLayer(e,t){const n=e.content,{attributes:i,indices:r,modelMatrix:s,cartographicOrigin:o,coordinateSystem:a=Mn.rf.METER_OFFSETS,material:l,featureIds:c}=n,{_getMeshColor:A}=this.props,u=t&&t.props.mesh||new Geometry({topology:"triangle-list",attributes:YI(i),indices:r});return new(this.getSubLayerClass("mesh",DE))(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${e.id}`,tile:e,mesh:u,data:XI,getColor:A(e),pbrMaterial:l,modelMatrix:s,coordinateOrigin:o,coordinateSystem:a,featureIds:c,_offset:0})}renderLayers(){const{tileset3d:e,layerMap:t}=this.state;return e?e.tiles.map(e=>{const n=t[e.id]=t[e.id]||{tile:e};let{layer:i}=n;return e.selected&&(i?n.needsUpdate&&(i=this._getSubLayer(e,i),n.needsUpdate=!1):i=this._getSubLayer(e)),n.layer=i,i}).filter(Boolean):null}}Tile3DLayer.defaultProps=$I,Tile3DLayer.layerName="Tile3DLayer";const ZI=Tile3DLayer;function YI(e){const t={};return t.positions={...e.positions,value:new Float32Array(e.positions.value)},e.normals&&(t.normals=e.normals),e.texCoords&&(t.texCoords=e.texCoords),e.colors&&(t.colors=e.colors),e.uvRegions&&(t.uvRegions=e.uvRegions),t}const JI={dataType:null,batchType:null,name:"Terrain",id:"terrain",module:"terrain",version:"4.5.1",worker:!0,extensions:["png","pngraw","jpg","jpeg","gif","webp","bmp"],mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp"],options:{terrain:{tesselator:"auto",bounds:void 0,meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0},skirtHeight:void 0}}},eO=[1],tO={...U_.defaultProps,elevationData:__,texture:{...__,optional:!0},meshMaxError:{type:"number",value:4},bounds:{type:"array",value:null,optional:!0,compare:!0},color:{type:"color",value:[255,255,255]},elevationDecoder:{type:"object",value:{rScaler:1,gScaler:0,bScaler:0,offset:0}},workerUrl:"",wireframe:!1,material:!0,loaders:[JI]};function nO(e){return Array.isArray(e)?e.join(";"):e||""}class TerrainLayer extends Ss{updateState({props:e,oldProps:t}){const n=e.elevationData!==t.elevationData;if(n){const{elevationData:t}=e,n=t&&(Array.isArray(t)||rO(t));this.setState({isTiled:n})}const i=n||e.meshMaxError!==t.meshMaxError||e.elevationDecoder!==t.elevationDecoder||e.bounds!==t.bounds;if(!this.state.isTiled&&i){const t=this.loadTerrain(e);this.setState({terrain:t})}e.workerUrl&&Ie.A.removed("workerUrl","loadOptions.terrain.workerUrl")()}loadTerrain({elevationData:e,bounds:t,elevationDecoder:n,meshMaxError:i,signal:r}){if(!e)return null;let s=this.getLoadOptions();s={...s,terrain:{skirtHeight:this.state.isTiled?2*i:0,...s?.terrain,bounds:t,meshMaxError:i,elevationDecoder:n}};const{fetch:o}=this.props;return o(e,{propName:"elevationData",layer:this,loadOptions:s,signal:r})}getTiledTerrainData(e){const{elevationData:t,fetch:n,texture:i,elevationDecoder:r,meshMaxError:s}=this.props,{viewport:o}=this.context,a=y_(t,e),l=i&&y_(i,e),{signal:c}=e;let A=[0,0],u=[0,0];if(o.isGeospatial){const t=e.bbox;A=o.projectFlat([t.west,t.south]),u=o.projectFlat([t.east,t.north])}else{const t=e.bbox;A=[t.left,t.bottom],u=[t.right,t.top]}const h=[A[0],A[1],u[0],u[1]],d=this.loadTerrain({elevationData:a,bounds:h,elevationDecoder:r,meshMaxError:s,signal:c}),f=l?n(l,{propName:"texture",layer:this,loaders:[],signal:c}).catch(e=>null):Promise.resolve(null);return Promise.all([d,f])}renderSubLayers(e){const t=this.getSubLayerClass("mesh",NE),{color:n,wireframe:i,material:r}=this.props,{data:s}=e;if(!s)return null;const[o,a]=s;return new t(e,{data:eO,mesh:o,texture:a,_instanced:!1,coordinateSystem:Mn.rf.CARTESIAN,getPosition:e=>[0,0,0],getColor:n,wireframe:i,material:r})}onViewportLoad(e){if(!e)return;const{zRange:t}=this.state,n=e.map(e=>e.content).filter(Boolean).map(e=>e[0].header.boundingBox.map(e=>e[2]));if(0===n.length)return;const i=Math.min(...n.map(e=>e[0])),r=Math.max(...n.map(e=>e[1]));(!t||i<t[0]||r>t[1])&&this.setState({zRange:[i,r]})}renderLayers(){const{color:e,material:t,elevationData:n,texture:i,wireframe:r,meshMaxError:s,elevationDecoder:o,tileSize:a,maxZoom:l,minZoom:c,extent:A,maxRequests:u,onTileLoad:h,onTileUnload:d,onTileError:f,maxCacheSize:p,maxCacheByteSize:g,refinementStrategy:m,zoomOffset:b}=this.props;if(this.state.isTiled)return new U_(this.getSubLayerProps({id:"tiles"}),{getTileData:this.getTiledTerrainData.bind(this),renderSubLayers:this.renderSubLayers.bind(this),updateTriggers:{getTileData:{elevationData:nO(n),texture:nO(i),meshMaxError:s,elevationDecoder:o,projectionMode:this.context.viewport.projectionMode,zoomOffset:b}},onViewportLoad:this.onViewportLoad.bind(this),zRange:this.state.zRange||null,tileSize:a,maxZoom:l,minZoom:c,extent:A,maxRequests:u,onTileLoad:h,onTileUnload:d,onTileError:f,maxCacheSize:p,maxCacheByteSize:g,refinementStrategy:m,zoomOffset:b});if(!n)return null;return new(this.getSubLayerClass("mesh",NE))(this.getSubLayerProps({id:"mesh"}),{data:eO,mesh:this.state.terrain,texture:i,_instanced:!1,getPosition:e=>[0,0,0],getColor:e,material:t,wireframe:r})}}TerrainLayer.defaultProps=tO,TerrainLayer.layerName="TerrainLayer";const iO=TerrainLayer,rO=e=>e.includes("{x}")&&(e.includes("{y}")||e.includes("{-y}"));var sO=n(31554),oO=n(67261);function aO(e,t,n){switch(e.type){case"Point":return function(e,t,n){const{positions:i}=e,r=cO(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:cO(i,r[0],r[1])}}const s=[];for(let e=0;e<r.length-1;e++){const t=cO(i,r[e],r[e+1]);s.push(t)}return{type:"MultiLineString",coordinates:s}}(e,t,n);case"Polygon":return lO(e,t,n);default:const i=e;throw new Error(`Unsupported geometry type: ${i?.type}`)}}function lO(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=cO(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=lO(e,r[t],r[t+1]).coordinates;o.push(n)}return{type:"MultiPolygon",coordinates:o}}function cO(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 AO(e,t){const n=t?.globalFeatureId;return void 0!==n?function(e,t){const n=uO(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 hO(e,n,r);n=r,i=s}}if(t===e.globalFeatureIds.value[n])return hO(e,n,e.featureIds.value.length)}throw new Error(`featureId:${t} not found`)}(e,n):function(e,t){const n=uO(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(hO(n,e,r)),e=r,i=s)}t.push(hO(n,e,n.featureIds.value.length))}return t}(n)}(e,t?.type)}function uO(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 hO(e,t,n){const i=aO(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}}const dO={Point:fO,MultiPoint:function(e,t,n){return pO(e,t,n)},LineString:gO,MultiLineString:function(e,t,n){return e.map(e=>gO(e,t,n))},Polygon:mO,MultiPolygon:function(e,t,n){return e.map(e=>mO(e,t,n))}};function fO([e,t],[n,i],r){const s=(0,xn.Cc)(n[0],i[0],e),o=(0,xn.Cc)(n[1],i[1],t);return r.unprojectFlat([s,o])}function pO(e,t,n){return e.map(e=>fO(e,t,n))}function gO(e,t,n){return pO(e,t,n)}function mO(e,t,n){return e.map(e=>pO(e,t,n))}const bO=["points","lines","polygons"];function _O(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=vO(e.properties,e=>e[t]===n,s,o):e.fields&&(a=vO(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 vO(e,t,n,i){for(let r=n;r<i;r++)if(t(e[r],r))return r;return-1}const yO={...lc.defaultProps,data:__,onDataLoad:{type:"function",value:null,optional:!0,compare:!1},uniqueIdProperty:"",highlightedFeatureId:null,loaders:[oO.f],binary:!0};class MVTLayer extends U_{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||/(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))/.test(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=y_(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:i}=e.tile.index,r=Math.pow(2,i),s=512/r,o=-s,a=512*t/r,l=512*(1-n/r),c=(new Rn.k).scale([s,o,1]);e.autoHighlight=!1,this.context.viewport.resolution||(e.modelMatrix=c,e.coordinateOrigin=[a,l,0],e.coordinateSystem=Mn.rf.CARTESIAN,e.extensions=[...e.extensions||[],new sO.A]);const A=super.renderSubLayers(e);return!this.state.binary||A instanceof lc||Ie.A.warn("renderSubLayers() must return GeoJsonLayer when using binary:true")(),A}_updateAutoHighlight(e){const{uniqueIdProperty:t}=this.props,{hoveredFeatureId:n,hoveredFeatureLayerName:i}=this.state,r=e.object;let s=null,o=null;r&&(s=xO(r,t),o=TO(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=AO(n,{globalFeatureId:t.index})}return t.object&&!this._isWGS84()&&(t.object=SO(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=EO(s);if(!(EO(t)||a))return-1;const l=a?s:t;return Array.isArray(o)?o.findIndex(e=>{const t=xO(e,r)===l,i=a||TO(e)===n;return t&&i}):o&&i?function(e,t,n,i){for(const r of bO){const s=e[r]&&_O(e[r],t,n,i);if(s>=0)return s}return-1}(o,r,l,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=xO(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&&function(e){return Number.isFinite(e.west)&&Number.isFinite(e.north)&&Number.isFinite(e.east)&&Number.isFinite(e.south)}(e)){const n=this.state.binary?AO(t.content):t.content;t._contentWGS84=n.map(t=>SO(t,e,this.context.viewport))}return t._contentWGS84}})})}}MVTLayer.layerName="MVTLayer",MVTLayer.defaultProps=yO;const wO=MVTLayer;function xO(e,t){return e.properties&&t?e.properties[t]:"id"in e?e.id:void 0}function TO(e){return e.properties?.layerName||null}function EO(e){return null!=e&&""!==e}function SO(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:dO[e.type](e.coordinates,i,n)}}(e.geometry,t,n);return i.coordinates}}),i}const CO="0123456789bcdefghjkmnpqrstuvwxyz",PO={};for(let e=0;e<32;e++)PO[CO.charAt(e)]=e;function RO(e){const[t,n,i,r]=function(e){let t,n=!0,i=90,r=-90,s=180,o=-180,a=0;for(let l=0,c=e.length;l<c;l++){const c=e[l].toLowerCase();a=PO[c];for(let e=4;e>=0;e--){const l=a>>e&1;n?(t=(s+o)/2,1===l?o=t:s=t):(t=(i+r)/2,1===l?r=t:i=t),n=!n}}return[r,o,i,s]}(e);return[r,i,r,t,n,t,n,i,r,i]}class GeohashLayer extends bu{indexToBounds(){const{data:e,getGeohash:t}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(e,n)=>RO(t(e,n))}}}GeohashLayer.layerName="GeohashLayer",GeohashLayer.defaultProps={getGeohash:{type:"accessor",value:e=>e.geohash}};const MO=GeohashLayer;var LO=n(63696);const IO="undefined"!=typeof window?LO.useLayoutEffect:LO.useEffect;function OO(e,t){for(;e;){if(e===t)return!0;e=Object.getPrototypeOf(e)}return!1}const BO={position:"absolute",zIndex:-1};function NO(e,t){if("function"==typeof e)return e(t);if(Array.isArray(e))return e.map(e=>NO(e,t));if(kO(e)){if(n=e,n.props?.mapStyle)return t.style=BO,(0,LO.cloneElement)(e,t);if(function(e){const t=e.type;return t&&t.deckGLViewProps}(e))return(0,LO.cloneElement)(e,t)}var n;return e}function kO(e){return LO.isValidElement(e)}function FO(e){if("function"==typeof e)return(0,LO.createElement)(View,{},e);if(Array.isArray(e))return e.map(FO);if(kO(e)){if(e.type===LO.Fragment)return FO(e.props.children);if(OO(e.type,View))return e}return e}const DO=(0,LO.createContext)();const UO={mixBlendMode:null};function VO(e){e.redrawReason&&(e.deck._drawLayers(e.redrawReason),e.redrawReason=null)}const zO=LO.forwardRef(function(e,t){const[n,i]=(0,LO.useState)(0),r=(0,LO.useRef)({control:null,version:n,forceUpdate:()=>i(e=>e+1)}),s=r.current,o=(0,LO.useRef)(null),a=(0,LO.useRef)(null),l=(0,LO.useMemo)(()=>function({children:e,layers:t=[],views:n}){const i=[],r=[],s={};return LO.Children.forEach(FO(e),e=>{if(kO(e)){const t=e.type;if(OO(t,Ts)){const n=function(e,t){const n={},i=e.defaultProps||{};for(const e in t)i[e]!==t[e]&&(n[e]=t[e]);return new e(n)}(t,e.props);r.push(n)}else i.push(e);if(OO(t,View)&&t!==View&&e.props.id){const n=new t(e.props);s[n.id]=n}}else e&&i.push(e)}),Object.keys(s).length>0&&(Array.isArray(n)?n.forEach(e=>{s[e.id]=e}):n&&(s[n.id]=n),n=Object.values(s)),{layers:t=r.length>0?[r,t]:t,children:i,views:n}}(e),[e.layers,e.views,e.children]);let c=!0;const A=t=>c&&e.viewState?(s.viewStateUpdateRequested=t,null):(s.viewStateUpdateRequested=null,e.onViewStateChange?.(t)),u=t=>{c?s.interactionStateUpdateRequested=t:(s.interactionStateUpdateRequested=null,e.onInteractionStateChange?.(t))},h=(0,LO.useMemo)(()=>{const t={widgets:[],...e,style:null,width:"100%",height:"100%",parent:o.current,canvas:a.current,layers:l.layers,onViewStateChange:A,onInteractionStateChange:u};return l.views&&(t.views=l.views),delete t._customRender,s.deck&&(s.deck.setProps(t),s.deck.isInitialized&&(s.lastRenderedViewports=s.deck.getViewports())),t},[e]);(0,LO.useEffect)(()=>{const t=e.Deck||lr;return s.deck=function(e,t,n){const i=new t({...n,_customRender:"webgpu"===n.deviceProps?.adapters?.[0]?.type?void 0:t=>{e.redrawReason=t;const n=i.getViewports();e.lastRenderedViewports!==n?e.forceUpdate():VO(e)}});return i}(s,t,{...h,parent:o.current,canvas:a.current}),()=>s.deck?.finalize()},[]),IO(()=>{VO(s);const{viewStateUpdateRequested:e,interactionStateUpdateRequested:t}=s;e&&A(e),t&&u(t),s.deck?.isInitialized&&s.deck.redraw("Initial render")}),(0,LO.useImperativeHandle)(t,()=>function(e){return{get deck(){return e.deck},pickObjectAsync:t=>e.deck.pickObjectAsync(t),pickObjectsAsync:t=>e.deck.pickObjectsAsync(t),pickObject:t=>e.deck.pickObject(t),pickMultipleObjects:t=>e.deck.pickMultipleObjects(t),pickObjects:t=>e.deck.pickObjects(t)}}(s),[]);const d=s.deck&&s.deck.isInitialized?s.deck.getViewports():void 0,{ContextProvider:f,width:p="100%",height:g="100%",id:m,style:b}=e,{containerStyle:_,canvasStyle:v}=(0,LO.useMemo)(()=>function({width:e,height:t,style:n}){const i={position:"absolute",zIndex:0,left:0,top:0,width:e,height:t},r={left:0,top:0};if(n)for(const e in n)e in UO?r[e]=n[e]:i[e]=n[e];return{containerStyle:i,canvasStyle:r}}({width:p,height:g,style:b}),[p,g,b]);if(!s.viewStateUpdateRequested&&s.lastRenderedViewports===d||s.version!==n){s.lastRenderedViewports=d,s.version=n;const e=function({children:e,deck:t,ContextProvider:n=DO.Provider}){const{viewManager:i}=t||{};if(!i||!i.views.length)return[];const r={},s=i.views[0].id;for(const t of e){let e=s,n=t;kO(t)&&OO(t.type,View)&&(e=t.props.id||s,n=t.props.children);const o=i.getViewport(e),a=i.getViewState(e);if(o){a.padding=o.padding;const{x:t,y:i,width:s,height:l}=o;n=NO(n,{x:t,y:i,width:s,height:l,viewport:o,viewState:a}),r[e]||(r[e]={viewport:o,children:[]}),r[e].children.push(n)}}return Object.keys(r).map(e=>{const{viewport:i,children:s}=r[e],{x:o,y:a,width:l,height:c}=i,A={position:"absolute",left:o,top:a,width:l,height:c},u=`view-${e}`,h=(0,LO.createElement)("div",{key:u,id:u,style:A},...s),d={deck:t,viewport:i,container:t.canvas.offsetParent,eventManager:t.eventManager,onViewStateChange:n=>{n.viewId=e,t._onViewStateChange(n)},widgets:[]},f=`view-${e}-context`;return(0,LO.createElement)(n,{key:f,value:d},h)})}({children:l.children,deck:s.deck,ContextProvider:f}),t=(0,LO.createElement)("canvas",{key:"canvas",id:m||"deckgl-overlay",ref:a,style:v}),i=(0,LO.createElement)("div",{key:"deck-events-root",className:"deck-events-root",style:{width:p,height:g}},[t,e]),r=(0,LO.createElement)("div",{key:"deck-widgets-root",className:"deck-widgets-root"});s.control=(0,LO.createElement)("div",{id:`${m||"deckgl"}-wrapper`,ref:o,style:_},[i,r])}return c=!1,s.control}),GO=zO;var jO,HO,WO,qO,KO,QO,XO,$O,ZO,YO,JO,eB,tB,nB,iB={},rB=[],sB=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,oB=Array.isArray;function aB(e,t){for(var n in t)e[n]=t[n];return e}function lB(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function cB(e,t,n,i,r){var s={type:e,props:t,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++WO,__i:-1,__u:0};return null==r&&null!=HO.vnode&&HO.vnode(s),s}function AB(e){return e.children}function uB(e,t){this.props=e,this.context=t}function hB(e,t){if(null==t)return e.__?hB(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?hB(e):null}function dB(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,i=[],r=[],s=aB({},t);s.__v=t.__v+1,HO.vnode&&HO.vnode(s),TB(e.__P,s,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,i,n??hB(t),!!(32&t.__u),r),s.__v=t.__v,s.__.__k[s.__i]=s,SB(i,s,r),t.__e=t.__=null,s.__e!=n&&fB(s)}}function fB(e){if(null!=(e=e.__)&&null!=e.__c)return e.__e=e.__c.base=null,e.__k.some(function(t){if(null!=t&&null!=t.__e)return e.__e=e.__c.base=t.__e}),fB(e)}function pB(e){(!e.__d&&(e.__d=!0)&&qO.push(e)&&!gB.__r++||KO!=HO.debounceRendering)&&((KO=HO.debounceRendering)||QO)(gB)}function gB(){try{for(var e,t=1;qO.length;)qO.length>t&&qO.sort(XO),e=qO.shift(),t=qO.length,dB(e)}finally{qO.length=gB.__r=0}}function mB(e,t,n,i,r,s,o,a,l,c,A){var u,h,d,f,p,g,m=i&&i.__k||rB,b=t.length;for(l=bB(n,t,m,l,b),u=0;u<b;u++)null!=(d=n.__k[u])&&(h=-1!=d.__i&&m[d.__i]||iB,d.__i=u,g=TB(e,d,h,r,s,o,a,l,c,A),f=d.__e,d.ref&&h.ref!=d.ref&&(h.ref&&PB(h.ref,null,d),A.push(d.ref,d.__c||f,d)),null==p&&null!=f&&(p=f),4&d.__u?(l=_B(d,l,e),h.__e&&(h.__e=null)):"function"==typeof d.type&&void 0!==g?l=g:f&&(l=f.nextSibling),d.__u&=-7);return n.__e=p,l}function bB(e,t,n,i,r){var s,o,a,l,c,A=n.length,u=A,h=0;for(e.__k=new Array(r),s=0;s<r;s++)null!=(o=t[s])&&"boolean"!=typeof o&&"function"!=typeof o?("string"==typeof o||"number"==typeof o||"bigint"==typeof o||o.constructor==String?o=e.__k[s]=cB(null,o,null,null,null):oB(o)?o=e.__k[s]=cB(AB,{children:o},null,null,null):void 0===o.constructor&&o.__b>0?o=e.__k[s]=cB(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[s]=o,l=s+h,o.__=e,o.__b=e.__b+1,a=null,-1!=(c=o.__i=vB(o,n,l,u))&&(u--,(a=n[c])&&(a.__u|=2)),null==a||null==a.__v?(-1==c&&(r>A?h--:r<A&&h++),"function"!=typeof o.type&&(o.__u|=4)):c!=l&&(c==l-1?h--:c==l+1?h++:(c>l?h--:h++,o.__u|=4))):e.__k[s]=null;if(u)for(s=0;s<A;s++)null!=(a=n[s])&&!(2&a.__u)&&(a.__e==i&&(i=hB(a)),RB(a,a));return i}function _B(e,t,n){var i,r;if("function"==typeof e.type){for(i=e.__k,r=0;i&&r<i.length;r++)i[r]&&(i[r].__=e,t=_B(i[r],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=hB(e)),t=n.insertBefore(e.__e,t||null));do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function vB(e,t,n,i){var r,s,o,a=e.key,l=e.type,c=t[n],A=null!=c&&!(2&c.__u);if(null===c&&null==a||A&&a==c.key&&l==c.type)return n;if(i>(A?1:0))for(r=n-1,s=n+1;r>=0||s<t.length;)if(null!=(c=t[o=r>=0?r--:s++])&&!(2&c.__u)&&a==c.key&&l==c.type)return o;return-1}function yB(e,t,n){"-"==t[0]?e.setProperty(t,n??""):e[t]=null==n?"":"number"!=typeof n||sB.test(t)?n:n+"px"}function wB(e,t,n,i,r){var s,o;e:if("style"==t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof i&&(e.style.cssText=i=""),i)for(t in i)n&&t in n||yB(e.style,t,"");if(n)for(t in n)i&&n[t]==i[t]||yB(e.style,t,n[t])}else if("o"==t[0]&&"n"==t[1])s=t!=(t=t.replace(JO,"$1")),o=t.toLowerCase(),t=o in e||"onFocusOut"==t||"onFocusIn"==t?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=n,n?i?n[YO]=i[YO]:(n[YO]=eB,e.addEventListener(t,s?nB:tB,s)):e.removeEventListener(t,s?nB:tB,s);else{if("http://www.w3.org/2000/svg"==r)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=n??"";break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==n?"":n))}}function xB(e){return function(t){if(this.l){var n=this.l[t.type+e];if(null==t[ZO])t[ZO]=eB++;else if(t[ZO]<n[YO])return;return n(HO.event?HO.event(t):t)}}}function TB(e,t,n,i,r,s,o,a,l,c){var A,u,h,d,f,p,g,m,b,_,v,y,w,x,T,E,S=t.type;if(void 0!==t.constructor)return null;128&n.__u&&(l=!!(32&n.__u),s=[a=t.__e=n.__e]),(A=HO.__b)&&A(t);e:if("function"==typeof S){u=o.length;try{if(b=t.props,_=S.prototype&&S.prototype.render,v=(A=S.contextType)&&i[A.__c],y=A?v?v.props.value:A.__:i,n.__c?m=(h=t.__c=n.__c).__=h.__E:(_?t.__c=h=new S(b,y):(t.__c=h=new uB(b,y),h.constructor=S,h.render=MB),v&&v.sub(h),h.state||(h.state={}),h.__n=i,d=h.__d=!0,h.__h=[],h._sb=[]),_&&null==h.__s&&(h.__s=h.state),_&&null!=S.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=aB({},h.__s)),aB(h.__s,S.getDerivedStateFromProps(b,h.__s))),f=h.props,p=h.state,h.__v=t,d)_&&null==S.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),_&&null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else{if(_&&null==S.getDerivedStateFromProps&&b!==f&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(b,y),t.__v==n.__v||!h.__e&&null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(b,h.__s,y)){t.__v!=n.__v&&(h.props=b,h.state=h.__s,h.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),rB.push.apply(h.__h,h._sb),h._sb=[],h.__h.length&&o.push(h),a=hB(n);break e}null!=h.componentWillUpdate&&h.componentWillUpdate(b,h.__s,y),_&&null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(f,p,g)})}if(h.context=y,h.props=b,h.__P=e,h.__e=!1,w=HO.__r,x=0,_)h.state=h.__s,h.__d=!1,w&&w(t),A=h.render(h.props,h.state,h.context),rB.push.apply(h.__h,h._sb),h._sb=[];else do{h.__d=!1,w&&w(t),A=h.render(h.props,h.state,h.context),h.state=h.__s}while(h.__d&&++x<25);h.state=h.__s,null!=h.getChildContext&&(i=aB(aB({},i),h.getChildContext())),_&&!d&&null!=h.getSnapshotBeforeUpdate&&(g=h.getSnapshotBeforeUpdate(f,p)),T=null!=A&&A.type===AB&&null==A.key?CB(A.props.children):A,a=mB(e,oB(T)?T:[T],t,n,i,r,s,o,a,l,c),h.base=t.__e,t.__u&=-161,h.__h.length&&o.push(h),m&&(h.__E=h.__=null)}catch(e){if(o.length=u,t.__v=null,l||null!=s){if(e.then){for(t.__u|=l?160:128;a&&8==a.nodeType&&a.nextSibling;)a=a.nextSibling;null!=s&&(s[s.indexOf(a)]=null),t.__e=a}else if(null!=s)for(E=s.length;E--;)lB(s[E])}else t.__e=n.__e;null==t.__k&&(t.__k=n.__k||[]),e.then||EB(t),HO.__e(e,t,n)}}else null==s&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):a=t.__e=function(e,t,n,i,r,s,o,a,l){var c,A,u,h,d,f,p,g=n.props||iB,m=t.props,b=t.type;if("svg"==b?r="http://www.w3.org/2000/svg":"math"==b?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),null!=s)for(c=0;c<s.length;c++)if((d=s[c])&&"setAttribute"in d==!!b&&(b?d.localName==b:3==d.nodeType)){e=d,s[c]=null;break}if(null==e){if(null==b)return document.createTextNode(m);e=document.createElementNS(r,b,m.is&&m),a&&(HO.__m&&HO.__m(t,s),a=!1),s=null}if(null==b)g===m||a&&e.data==m||(e.data=m);else{if(s="textarea"==b&&null!=m.defaultValue?null:s&&jO.call(e.childNodes),!a&&null!=s)for(g={},c=0;c<e.attributes.length;c++)g[(d=e.attributes[c]).name]=d.value;for(c in g)d=g[c],"dangerouslySetInnerHTML"==c?u=d:"children"==c||c in m||"value"==c&&"defaultValue"in m||"checked"==c&&"defaultChecked"in m||wB(e,c,null,d,r);for(c in m)d=m[c],"children"==c?h=d:"dangerouslySetInnerHTML"==c?A=d:"value"==c?f=d:"checked"==c?p=d:a&&"function"!=typeof d||g[c]===d||wB(e,c,d,g[c],r);if(A)a||u&&(A.__html==u.__html||A.__html==e.innerHTML)||(e.innerHTML=A.__html),t.__k=[];else if(u&&(e.innerHTML=""),mB("template"==t.type?e.content:e,oB(h)?h:[h],t,n,i,"foreignObject"==b?"http://www.w3.org/1999/xhtml":r,s,o,s?s[0]:n.__k&&hB(n,0),a,l),null!=s)for(c=s.length;c--;)lB(s[c]);a&&"textarea"!=b||(c="value","progress"==b&&null==f?e.removeAttribute("value"):null!=f&&(f!==e[c]||"progress"==b&&!f||"option"==b&&f!=g[c])&&wB(e,c,f,g[c],r),c="checked",null!=p&&p!=e[c]&&wB(e,c,p,g[c],r))}return e}(n.__e,t,n,i,r,s,o,l,c);return(A=HO.diffed)&&A(t),128&t.__u?void 0:a}function EB(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(EB))}function SB(e,t,n){for(var i=0;i<n.length;i++)PB(n[i],n[++i],n[++i]);HO.__c&&HO.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){HO.__e(e,t.__v)}})}function CB(e){return"object"!=typeof e||null==e||e.__b>0?e:oB(e)?e.map(CB):void 0!==e.constructor?null:aB({},e)}function PB(e,t,n){try{if("function"==typeof e){var i="function"==typeof e.__u;i&&e.__u(),i&&null==t||(e.__u=e(t))}else e.current=t}catch(e){HO.__e(e,n)}}function RB(e,t,n){var i,r;if(HO.unmount&&HO.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||PB(i,null,t)),null!=(i=e.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){HO.__e(e,t)}i.base=i.__P=i.__n=null}if(i=e.__k)for(r=0;r<i.length;r++)i[r]&&RB(i[r],t,n||"function"!=typeof e.type);n||lB(e.__e),e.__c=e.__=e.__e=void 0}function MB(e,t,n){return this.constructor(e,n)}function LB(e,t,n){var i,r,s,o;t==document&&(t=document.documentElement),HO.__&&HO.__(e,t),r=(i="function"==typeof n)?null:n&&n.__k||t.__k,s=[],o=[],TB(t,e=(!i&&n||t).__k=function(e,t,n){var i,r,s,o={};for(s in t)"key"==s?i=t[s]:"ref"==s?r=t[s]:o[s]=t[s];if(arguments.length>2&&(o.children=arguments.length>3?jO.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(s in e.defaultProps)void 0===o[s]&&(o[s]=e.defaultProps[s]);return cB(e,o,i,r,null)}(AB,null,[e]),r||iB,iB,t.namespaceURI,!i&&n?[n]:r?null:t.firstChild?jO.call(t.childNodes):null,s,!i&&n?n:r?r.__e:t.firstChild,i,o),SB(s,e,o),e.props.children=null}jO=rB.slice,HO={__e:function(e,t,n,i){for(var r,s,o;t=t.__;)if((r=t.__c)&&!r.__)try{if((s=r.constructor)&&null!=s.getDerivedStateFromError&&(r.setState(s.getDerivedStateFromError(e)),o=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(e,i||{}),o=r.__d),o)return r.__E=r}catch(t){e=t}throw e}},WO=0,uB.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=aB({},this.state),"function"==typeof e&&(e=e(aB({},n),this.props)),e&&aB(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),pB(this))},uB.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),pB(this))},uB.prototype.render=AB,qO=[],QO="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,XO=function(e,t){return e.__v.__b-t.__v.__b},gB.__r=0,$O=Math.random().toString(8),ZO="__d"+$O,YO="__a"+$O,JO=/(PointerCapture)$|Capture$/i,eB=0,tB=xB(!1),nB=xB(!0);var IB=0;Array.isArray;function OB(e,t,n,i,r,s){t||(t={});var o,a,l=t;if("ref"in l)for(a in l={},t)"ref"==a?o=t[a]:l[a]=t[a];var c={type:e,props:l,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--IB,__i:-1,__u:0,__source:r,__self:s};if("function"==typeof e&&(o=e.defaultProps))for(a in o)void 0===l[a]&&(l[a]=o[a]);return HO.vnode&&HO.vnode(c),c}const BB=e=>{const{children:t,orientation:n="horizontal"}=e;return OB("div",{className:`deck-widget-button-group ${n}`,children:t})};var NB,kB,FB,DB,UB=0,VB=[],zB=HO,GB=zB.__b,jB=zB.__r,HB=zB.diffed,WB=zB.__c,qB=zB.unmount,KB=zB.__;function QB(e,t){zB.__h&&zB.__h(kB,e,UB||t),UB=0;var n=kB.__H||(kB.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function XB(e){return UB=1,function(e,t,n){var i=QB(NB++,2);if(i.t=e,!i.__c&&(i.__=[n?n(t):aN(void 0,t),function(e){var t=i.__N?i.__N[0]:i.__[0],n=i.t(t,e);t!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=kB,!kB.__f)){var r=function(e,t,n){if(!i.__c.__H)return!0;var r=!1,o=i.__c.props!==e;if(i.__c.__H.__.some(function(e){if(e.__N){r=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),s){var a=s.call(this,e,t,n);return r?a||o:a}return!r||o};kB.__f=!0;var s=kB.shouldComponentUpdate,o=kB.componentWillUpdate;kB.componentWillUpdate=function(e,t,n){if(this.__e){var i=s;s=void 0,r(e,t,n),s=i}o&&o.call(this,e,t,n)},kB.shouldComponentUpdate=r}return i.__N||i.__}(aN,e)}function $B(e,t){var n=QB(NB++,3);!zB.__s&&oN(n.__H,t)&&(n.__=e,n.u=t,kB.__H.__h.push(n))}function ZB(e,t){var n=QB(NB++,4);!zB.__s&&oN(n.__H,t)&&(n.__=e,n.u=t,kB.__h.push(n))}function YB(e){return UB=5,JB(function(){return{current:e}},[])}function JB(e,t){var n=QB(NB++,7);return oN(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function eN(e,t){return UB=8,JB(function(){return e},t)}function tN(){for(var e;e=VB.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(rN),t.__h.some(sN),t.__h=[]}catch(n){t.__h=[],zB.__e(n,e.__v)}}}zB.__b=function(e){kB=null,GB&&GB(e)},zB.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),KB&&KB(e,t)},zB.__r=function(e){jB&&jB(e),NB=0;var t=(kB=e.__c).__H;t&&(FB===kB?(t.__h=[],kB.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(rN),t.__h.some(sN),t.__h=[],NB=0)),FB=kB},zB.diffed=function(e){HB&&HB(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==VB.push(t)&&DB===zB.requestAnimationFrame||((DB=zB.requestAnimationFrame)||iN)(tN)),t.__H.__.some(function(e){e.u&&(e.__H=e.u,e.u=void 0)})),FB=kB=null},zB.__c=function(e,t){t.some(function(e){try{e.__h.some(rN),e.__h=e.__h.filter(function(e){return!e.__||sN(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],zB.__e(n,e.__v)}}),WB&&WB(e,t)},zB.unmount=function(e){qB&&qB(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{rN(e)}catch(e){t=e}}),n.__H=void 0,t&&zB.__e(t,n.__v))};var nN="function"==typeof requestAnimationFrame;function iN(e){var t,n=function(){clearTimeout(i),nN&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(n,35);nN&&(t=requestAnimationFrame(n))}function rN(e){var t=kB,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),kB=t}function sN(e){var t=kB;e.__c=e.__(),kB=t}function oN(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function aN(e,t){return"function"==typeof t?t(e):t}function lN(e){if(!e)return;const t=`url("${e.replace(/"/g,"'")}")`;return{maskImage:t,WebkitMaskImage:t}}const cN=e=>{const{className:t="",style:n,color:i,icon:r,label:s,onClick:o,children:a}=e,l=JB(()=>{const e=lN(r);return i?{...e,backgroundColor:i}:e},[i,r]);return OB("div",{className:"deck-widget-button",style:n,children:OB("button",{className:`deck-widget-icon-button ${t}`,type:"button",onClick:o,title:s,children:a||OB("div",{className:"deck-widget-icon",style:l})})})};class ZoomWidget extends Widget{constructor(e={}){super(e),this.className="deck-widget-zoom",this.placement="top-left",this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){LB(OB(BB,{orientation:this.props.orientation,children:[OB(cN,{onClick:()=>this.handleZoomIn(),label:this.props.zoomInLabel,className:"deck-widget-zoom-in"}),OB(cN,{onClick:()=>this.handleZoomOut(),label:this.props.zoomOutLabel,className:"deck-widget-zoom-out"})]}),e)}isOrthographicView(e){const t=this.deck;return(t?.isInitialized&&t.getView(e))instanceof Fs}handleZoom(e,t){const n=this.getViewState(e),i={};if(this.isOrthographicView(e)){const{zoomAxis:r}=this.props,{zoomX:s,minZoomX:o,maxZoomX:a,zoomY:l,minZoomY:c,maxZoomY:A}=function({zoom:e=0,zoomX:t,zoomY:n,minZoom:i=-1/0,maxZoom:r=1/0,minZoomX:s=i,maxZoomX:o=r,minZoomY:a=i,maxZoomY:l=r}){return t=t??(Array.isArray(e)?e[0]:e),n=n??(Array.isArray(e)?e[1]:e),{zoomX:t,zoomY:n,minZoomX:s,minZoomY:a,maxZoomX:o,maxZoomY:l}}(n);let u,h;if("X"===r)u=AN(s+t,o,a),h=l;else if("Y"===r)u=s,h=AN(l+t,c,A);else{const e=AN(t,Math.max(o-s,c-l),Math.min(a-s,A-l));u=s+e,h=l+e}i.zoom=[u,h],i.zoomX=u,i.zoomY=h,this.props.onZoom?.({viewId:e,delta:t,zoom:"Y"===r?h:u,zoomX:u,zoomY:h})}else{const{zoom:r=0,minZoom:s,maxZoom:o}=n,a=AN(r+t,s,o);i.zoom=a,this.props.onZoom?.({viewId:e,delta:t,zoom:a})}const r={...n,...i};this.props.transitionDuration>0&&(r.transitionDuration=this.props.transitionDuration,r.transitionInterpolator="latitude"in r?new FlyToInterpolator:new LinearInterpolator({transitionProps:"zoomX"in i?["zoomX","zoomY"]:["zoom"]})),this.setViewState(e,r)}handleZoomIn(){for(const e of this.viewIds)this.handleZoom(e,1)}handleZoomOut(){for(const e of this.viewIds)this.handleZoom(e,-1)}}function AN(e,t,n){return e<t?t:e>n?n:e}ZoomWidget.defaultProps={...Widget.defaultProps,id:"zoom",placement:"top-left",orientation:"vertical",transitionDuration:200,zoomInLabel:"Zoom In",zoomOutLabel:"Zoom Out",zoomAxis:"all",viewId:null,onZoom:()=>{}};class ResetViewWidget extends Widget{constructor(e={}){super(e),this.className="deck-widget-reset-view",this.placement="top-left",this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){LB(OB(cN,{className:"deck-widget-reset-focus",label:this.props.label,onClick:this.handleClick.bind(this)}),e)}handleClick(){const e=this.props.initialViewState||this.deck?.props.initialViewState;this.resetViewState(e)}resetViewState(e){for(const t of this.viewIds){const n={...e?.[t]??e};this.props.onReset?.({viewId:t,viewState:n}),this.setViewState(t,n)}}}ResetViewWidget.defaultProps={...Widget.defaultProps,id:"reset-view",placement:"top-left",label:"Reset View",initialViewState:void 0,viewId:null,onReset:()=>{}};class GimbalWidget extends Widget{constructor(e={}){super(e),this.className="deck-widget-gimbal",this.placement="top-left",this.viewports={},this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){const t=this.viewId||Object.values(this.viewports)[0]?.id||"default-view",n=this.viewports[t],{rotationOrbit:i,rotationX:r}=this.getNormalizedRotation(n);LB(OB("div",{className:"deck-widget-button",style:{perspective:100,pointerEvents:"auto"},children:OB("button",{type:"button",onClick:()=>{for(const e of Object.values(this.viewports))this.resetOrbitView(e)},title:this.props.label,style:{position:"relative",width:26,height:26},children:[OB("svg",{className:"gimbal-outer-ring",width:"100%",height:"100%",viewBox:"0 0 26 26",style:{position:"absolute",top:0,left:0,transform:`rotateY(${i}deg)`},children:OB("circle",{cx:"13",cy:"13",r:"10",stroke:"var(--icon-gimbal-outer-color, rgb(68, 92, 204))",strokeWidth:this.props.strokeWidth,fill:"none"})}),OB("svg",{className:"gimbal-inner-ring",width:"100%",height:"100%",viewBox:"0 0 26 26",style:{position:"absolute",top:0,left:0,transform:`rotateX(${r}deg)`},children:OB("circle",{cx:"13",cy:"13",r:"7",stroke:"var(--icon-gimbal-inner-color, rgb(240, 92, 68))",strokeWidth:this.props.strokeWidth,fill:"none"})})]})}),e)}onViewportChange(e){this.viewports[e.id]=e,this.updateHTML()}resetOrbitView(e){const t=this.viewId||e?.id||"OrbitView",n=this.getViewState(t);if("rotationOrbit"in n||"rotationX"in n){this.props.onReset?.({viewId:t,rotationOrbit:0,rotationX:0});const e={...n,rotationOrbit:0,rotationX:0,transitionDuration:this.props.transitionDuration,transitionInterpolator:new LinearInterpolator({transitionProps:["rotationOrbit","rotationX"]})};this.setViewState(t,e)}}getNormalizedRotation(e){const t=this.viewId||e?.id||"OrbitView",n=this.getViewState(t),[i,r]=this.getRotation(n);return{rotationOrbit:uN(i),rotationX:uN(r)}}getRotation(e){return e&&("rotationOrbit"in e||"rotationX"in e)?[-(e.rotationOrbit||0),e.rotationX||0]:[0,0]}}function uN(e){let t=((e+180)%360+360)%360-180;const n=t-90;return Math.abs(n)<10&&(n<10?t=100:n>-10&&(t=80)),t}GimbalWidget.defaultProps={...Widget.defaultProps,id:"gimbal",placement:"top-left",viewId:null,label:"Gimbal",strokeWidth:1.5,transitionDuration:200,onReset:()=>{}};class CompassWidget extends Widget{constructor(e={}){super(e),this.className="deck-widget-compass",this.placement="top-left",this.viewports={},this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){const t=this.viewId||Object.values(this.viewports)[0]?.id,n=this.viewports[t],[i,r]=this.getRotation(n);LB(OB("div",{className:"deck-widget-button",style:{perspective:100},children:OB("button",{type:"button",onClick:()=>{for(const e of Object.values(this.viewports))this.handleCompassReset(e)},title:this.props.label,style:{transform:`rotateX(${r}deg)`},children:OB("svg",{fill:"none",width:"100%",height:"100%",viewBox:"0 0 26 26",children:OB("g",{transform:`rotate(${i},13,13)`,children:[OB("path",{d:"M10 13.0001L12.9999 5L15.9997 13.0001H10Z",fill:"var(--icon-compass-north-color, rgb(240, 92, 68))"}),OB("path",{d:"M16.0002 12.9999L13.0004 21L10.0005 12.9999H16.0002Z",fill:"var(--icon-compass-south-color, rgb(204, 204, 204))"})]})})})}),e)}onViewportChange(e){e.equals(this.viewports[e.id])||(this.viewports[e.id]=e,this.updateHTML())}getRotation(e){return e instanceof wn.A?[-e.bearing,e.pitch]:e instanceof Un?[0,Math.max(-80,Math.min(80,e.latitude))]:[0,0]}handleCompassReset(e){const t=this.viewId||e.id;if(e instanceof wn.A){const n=this.getViewState(t),i=0===this.getRotation(e)[0],r=0,s=i?0:e.pitch;this.props.onReset?.({viewId:t,bearing:r,pitch:s});const o={...n,bearing:r,...i?{pitch:s}:{},transitionDuration:this.props.transitionDuration,transitionInterpolator:new FlyToInterpolator};this.setViewState(t,o)}}}CompassWidget.defaultProps={...Widget.defaultProps,id:"compass",placement:"top-left",viewId:null,label:"Reset Compass",transitionDuration:200,onReset:()=>{}};class ScaleWidget extends Widget{constructor(e={}){super(e),this.className="deck-widget-scale",this.placement="bottom-left",this.scaleWidth=10,this.scaleValue=0,this.scaleText="",this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){const t=50;LB(OB("svg",{className:"deck-widget-scale",width:t+this.scaleWidth,height:30,style:{overflow:"visible",background:"transparent"},onClick:this.handleClick.bind(this),children:[OB("text",{x:55,y:"10",textAnchor:"end",alignmentBaseline:"middle",style:{fontSize:"16px",fill:"black",fontWeight:"bold",fontFamily:"sans-serif"},children:this.scaleText}),OB("line",{x1:t,y1:"15",x2:t+this.scaleWidth,y2:"15",stroke:"black",strokeWidth:"6"}),OB("line",{x1:t,y1:"15",x2:t,y2:5,stroke:"black",strokeWidth:"6"}),OB("line",{x1:t+this.scaleWidth,y1:"15",x2:t+this.scaleWidth,y2:5,stroke:"black",strokeWidth:"6"})]}),e)}onViewportChange(e){if(!("latitude"in e))return;const{latitude:t,zoom:n}=e,i=function(e,t){return 40075016.686*Math.cos(e*Math.PI/180)/Math.pow(2,t+8)}(t,n),{candidate:r,candidatePixels:s}=function(e){const t=100,n=200,i=(t+n)/2*e,r=Math.floor(Math.log10(i)),s=Math.pow(10,r),o=[1,2,5];let a=o[0]*s,l=a/e;for(let i=0;i<o.length;i++){const r=o[i]*s,c=r/e;if(c>=t&&c<=n){a=r,l=c;break}if(c>n){a=i>0?o[i-1]*s:r,l=a/e;break}i===o.length-1&&c<t&&(a=o[0]*s*10,l=a/e)}return{candidate:a,candidatePixels:l}}(i);this.scaleValue=r,this.scaleWidth=s,this.scaleText=r>=1e3?`${(r/1e3).toFixed(1)} km`:`${r} m`,this.updateHTML()}handleClick(){}}function hN(e){return"string"==typeof e?e:e.label}ScaleWidget.defaultProps={...Widget.defaultProps,id:"scale",placement:"bottom-left",label:"Scale",viewId:null};const dN=e=>{const[t,n]=XB(!1);return OB(fN,{...e,style:{...e.style,position:"absolute"},isOpen:t,onClose:()=>n(!1),trigger:OB("button",{className:"deck-widget-dropdown-button",onClick:()=>n(!t),children:OB("span",{className:"deck-widget-dropdown-icon "+(t?"open":"")})})})},fN=e=>{const t=YB(null);$B(()=>{const n=n=>{t.current&&!t.current.contains(n.target)&&e.onClose()};return document.addEventListener("mousedown",n),()=>{document.removeEventListener("mousedown",n)}},[]);return 0===e.menuItems.length?null:OB("div",{className:"deck-widget-dropdown-container",ref:t,children:[e.trigger,e.isOpen&&OB("ul",{className:"deck-widget-dropdown-menu",style:e.style,children:e.menuItems.map((t,n)=>{const i=function(e){return"string"==typeof e?e:e.value}(t),r=function(e){return"string"==typeof e?void 0:e.icon}(t);return OB("li",{className:"deck-widget-dropdown-item "+(i?"":"disabled"),onClick:()=>((t,n)=>{t&&("object"==typeof n&&n.onSelect?.(),e.onSelect?.(t),e.onClose())})(i,t),children:[r&&OB("span",{className:"deck-widget-dropdown-item-icon",style:lN(r)}),hN(t)]},n)})})]})},pN="deck-geocoder-history";class GeocoderHistory{constructor(e){this.addressText="",this.errorText="",this.addressHistory=[],this.props={maxEntries:5,...e},this.addressHistory=this.loadPreviousAddresses()}async geocode(e,t,n){this.errorText="",this.addressText=t;try{const i=await e.geocode(t,n);if(i)return this.storeAddress(this.addressText),i;this.errorText="Invalid address"}catch(e){this.errorText=`${e.message}`}return null}loadPreviousAddresses(){try{const e=window.localStorage.getItem(pN),t=e&&JSON.parse(e),n=Array.isArray(t)?t.filter(e=>"string"==typeof e):[];return n}catch{}return[]}storeAddress(e){const t=e.trim();if(!t||"current"===t)return;const n=[t,...this.addressHistory.filter(e=>e!==t)];this.addressHistory=n.slice(0,this.props.maxEntries);try{window.localStorage.setItem(pN,JSON.stringify(this.addressHistory))}catch{}}}const gN={name:"google",requiresApiKey:!0,async geocode(e,t){const n=encodeURIComponent(e),i=await vN(`https://maps.googleapis.com/maps/api/geocode/json?address=${n}&key=${t}`);if("OK"===i.status){const e=i.results.length>0&&i.results[0].geometry.location;return e?{longitude:e.lng,latitude:e.lat}:null}throw new Error(`Google Geocoder failed: ${i.status}`)}},mN={name:"google",requiresApiKey:!0,async geocode(e,t){const n=encodeURIComponent(e),i=await vN(`https://api.mapbox.com/geocoding/v5/mapbox.places/${n}.json?access_token=${t}`);if(Array.isArray(i.features)&&i.features.length>0){const e=i.features[0].center;if(Array.isArray(e)&&e.length>=2)return{longitude:e[0],latitude:e[1]}}return null}},bN={name:"opencage",requiresApiKey:!0,async geocode(e,t){const n=encodeURIComponent(e),i=await vN(`https://api.opencagedata.com/geocode/v1/json?q=${n}&key=${t}`);if(Array.isArray(i.results)&&i.results.length>0){const e=i.results[0].geometry;return{longitude:e.lng,latitude:e.lat}}return null}},_N={name:"current",requiresApiKey:!1,async geocode(){if(!navigator.geolocation)throw new Error("Geolocation not supported");return new Promise((e,t)=>{navigator.geolocation.getCurrentPosition(t=>{const{longitude:n,latitude:i}=t.coords;e({longitude:n,latitude:i})},e=>t(new Error(e.message)))})}};async function vN(e){let t;try{t=await fetch(e)}catch(t){throw new Error(`CORS error? ${t}. ${e}: `)}if(!t.ok)throw new Error(`${t.statusText}. ${e}: `);const n=await t.json();if(!n)throw new Error(`No data returned. ${e}`);return n}const yN={name:"coordinates",requiresApiKey:!1,placeholderLocation:"-122.45, 37.8 or 37°48'N, 122°27'W",geocode:async e=>function(e){const t=(e=e.trim()).split(/[,;]/).map(e=>e.trim());if(t.length<2)return null;const n=wN(t[0]),i=wN(t[1]);if(null===n||null===i)return null;if(Math.abs(n)>90&&Math.abs(i)>90)return null;if(Math.abs(n)>90)return{longitude:n,latitude:i};if(Math.abs(i)>90)return{longitude:i,latitude:n};return{latitude:n,longitude:i}}(e)||null};function wN(e){if((e=e.trim()).includes("°")||e.includes("'")||e.includes('"')){const t=function(e){const t=/(-?\d+)[°d]\s*(\d+)?['′m]?\s*(\d+(?:\.\d+)?)?[\"″s]?\s*([NSEW])?/i,n=e.match(t);if(!n)return NaN;const i=parseFloat(n[1])||0,r=parseFloat(n[2])||0,s=parseFloat(n[3])||0,o=n[4]||"",a=i<0?-1:1;let l=Math.abs(i)+r/60+s/3600;/[SW]/i.test(o)?l=-l:l*=a;return l}(e);return isNaN(t)?null:t}let t=1;/[SW]/i.test(e)&&(t=-1),e=e.replace(/[NSEW]/gi,"");const n=parseFloat(e);return isNaN(n)?null:t*n}const xN="current",TN={label:"Current location",value:xN,icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath d='M480-480q33 0 56.5-23.5T560-560q0-33-23.5-56.5T480-640q-33 0-56.5 23.5T400-560q0 33 23.5 56.5T480-480Zm0 294q122-112 181-203.5T720-552q0-109-69.5-178.5T480-800q-101 0-170.5 69.5T240-552q0 71 59 162.5T480-186Zm0 106Q319-217 239.5-334.5T160-552q0-150 96.5-239T480-880q127 0 223.5 89T800-552q0 100-79.5 217.5T480-80Z'/%3E%3C/svg%3E"};class GeocoderWidget extends Widget{constructor(e={}){super(e),this.className="deck-widget-geocoder",this.placement="top-left",this.geocodeHistory=new GeocoderHistory({}),this.addressText="",this.geocoder=yN,this.isGettingLocation=!1,this.setInput=e=>{this.addressText=e},this.handleKeyPress=e=>{"Enter"===e.key&&this.handleSubmit()},this.handleSelect=e=>{e===xN?this.getCurrentLocation():(this.setInput(e),this.handleSubmit())},this.handleSubmit=()=>{this.geocode(this.addressText)},this.getCurrentLocation=async()=>{this.isGettingLocation=!0,this.rootElement&&this.updateHTML();try{const e=await _N.geocode();e&&this.flyTo(e)}catch(e){this.geocodeHistory.errorText=e instanceof Error?e.message:"Location error"}finally{this.isGettingLocation=!1,this.rootElement&&this.updateHTML()}},this.geocode=async e=>{const t=await this.geocodeHistory.geocode(this.geocoder,this.addressText,this.props.apiKey);this.rootElement&&this.updateHTML(),t&&this.flyTo(t)},this.setProps(this.props)}setProps(e){if(this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,this.geocoder=function(e){switch(e.geocoder){case"google":return gN;case"mapbox":return mN;case"opencage":return bN;case"coordinates":return yN;case"custom":if(!e.customGeocoder)throw new Error("Custom geocoder is not defined");return e.customGeocoder;default:throw new Error(`Unknown geocoder: ${e.geocoder}`)}}(this.props),this.geocoder.requiresApiKey&&!this.props.apiKey)throw new Error(`API key is required for the ${this.geocoder.name} geocoder`);super.setProps(e)}onRenderHTML(e){const t=this.props._geolocation?[TN,...this.geocodeHistory.addressHistory]:[...this.geocodeHistory.addressHistory];LB(OB("div",{className:"deck-widget-geocoder",children:[OB("input",{className:"deck-widget-geocoder-input",type:"text",placeholder:this.isGettingLocation?"Finding your location...":this.geocoder.placeholderLocation??"Enter address or location",value:this.geocodeHistory.addressText,onInput:e=>this.setInput(e.target?.value||""),onKeyPress:this.handleKeyPress}),OB(dN,{menuItems:t,onSelect:this.handleSelect}),this.geocodeHistory.errorText&&OB("div",{className:"deck-widget-geocoder-error",children:this.geocodeHistory.errorText})]}),e)}flyTo(e){for(const t of this.viewIds){"longitude"in e&&"latitude"in e&&this.props.onGeocode?.({viewId:t,coordinates:{longitude:e.longitude,latitude:e.latitude,zoom:e.zoom}});const n={...this.getViewState(t),...e};this.props.transitionDuration>0&&(n.transitionDuration=this.props.transitionDuration,n.transitionInterpolator="latitude"in n?new FlyToInterpolator:new LinearInterpolator),this.setViewState(t,n)}}}GeocoderWidget.defaultProps={...Widget.defaultProps,id:"geocoder",viewId:null,placement:"top-left",label:"Geocoder",transitionDuration:200,geocoder:"coordinates",customGeocoder:yN,apiKey:"",_geolocation:!1,onGeocode:()=>{}};class FullscreenWidget extends Widget{constructor(e={}){super(e),this.className="deck-widget-fullscreen",this.placement="top-left",this.fullscreen=!1,this.setProps(this.props)}onAdd(){document.addEventListener("fullscreenchange",this.onFullscreenChange.bind(this))}onRemove(){document.removeEventListener("fullscreenchange",this.onFullscreenChange.bind(this))}onRenderHTML(e){const t=this.getFullscreen();LB(OB(cN,{onClick:()=>{this.handleClick().catch(e=>Ie.A.error(e)())},label:t?this.props.exitLabel:this.props.enterLabel,className:t?"deck-widget-fullscreen-exit":"deck-widget-fullscreen-enter"}),e)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}getContainer(){return this.props.container||this.deck?.props.parent||this.deck?.getCanvas()?.parentElement}getFullscreen(){return this.fullscreen}onFullscreenChange(){const e=document.fullscreenElement===this.getContainer();e!==this.fullscreen&&(this.fullscreen=e,this.props.onFullscreenChange?.(e),this.updateHTML())}async handleClick(){this.getFullscreen()?await this.exitFullscreen():await this.requestFullscreen()}async requestFullscreen(){const e=this.getContainer();e?.requestFullscreen?await e.requestFullscreen({navigationUI:"hide"}):this.togglePseudoFullscreen()}async exitFullscreen(){document.exitFullscreen?await document.exitFullscreen():this.togglePseudoFullscreen()}togglePseudoFullscreen(){this.getContainer()?.classList.toggle("deck-pseudo-fullscreen"),this.fullscreen=!this.fullscreen,this.props.onFullscreenChange?.(this.fullscreen),this.updateHTML()}}function EN(e){const t=[],n=e=>"views"in e;return function e(i){const r=t.length,s=i.minSplit??.05,o=i.maxSplit??.95,a=Math.min(Math.max(i.initialSplit??.5,s),o),l={id:r,orientation:i.orientation,views:i.views,split:a,editable:i.editable??!0,minSplit:s,maxSplit:o,x:0,y:0,width:0,height:0};return t.push(l),l.views=[n(i.views[0])?e(i.views[0]):i.views[0],n(i.views[1])?e(i.views[1]):i.views[1]],l}(e),t}function SN(e){const t=[];return function e(n,i,r,s,o){n.x=i,n.y=r,n.width=s,n.height=o;const a=i,l=r;let c=s,A=o,u=i,h=r,d=s,f=o;"horizontal"===n.orientation?(c=s*n.split,u=i+c,d=s-c):(A=o*n.split,h=r+A,f=o-A);const[p,g]=n.views;"views"in p?e(p,a,l,c,A):t.push(p.clone({x:`${a}%`,y:`${l}%`,width:`${c}%`,height:`${A}%`})),"views"in g?e(g,u,h,d,f):t.push(g.clone({x:`${u}%`,y:`${h}%`,width:`${d}%`,height:`${f}%`}))}(e,0,0,100,100),t}FullscreenWidget.defaultProps={...Widget.defaultProps,id:"fullscreen",placement:"top-left",viewId:null,enterLabel:"Enter Fullscreen",exitLabel:"Exit Fullscreen",container:void 0,onFullscreenChange:()=>{}};class SplitterWidget extends Widget{constructor(e){super(e),this.className="deck-widget-splitter",this.placement="fill",this.needsUpdate=!0,this.viewLayouts=EN(this.props.viewLayout)}setProps(e){e.viewLayout&&!(0,dn.b)(e.viewLayout,this.props.viewLayout,-1)&&(this.viewLayouts=EN(e.viewLayout),this.views=void 0),super.setProps(e)}onRedraw(){super.updateHTML()}updateHTML(){this.views||(this.views=SN(this.viewLayouts[0]),this.props.onChange(this.views.slice())),requestAnimationFrame(()=>{this.doUpdate()})}doUpdate(){if(this.deck){const e=this.deck.props.views;e&&e!==this.lastViews||this.lastViews===this.views||(this.lastViews=this.views,this.deck.setProps({views:this.views}))}}onChange(e,t){t.split=e,this.views=SN(this.viewLayouts[0]),this.props.onChange(this.views.slice()),this.doUpdate()}onRenderHTML(e){LB(OB(AB,{children:this.viewLayouts.map(e=>e.editable&&OB(CN,{...e,onChange:t=>this.onChange(t,e),onDragStart:()=>this.props.onDragStart(),onDragEnd:()=>this.props.onDragStart()}))}),e)}}function CN({orientation:e,x:t,y:n,width:i,height:r,split:s,minSplit:o,maxSplit:a,onChange:l,onDragStart:c,onDragEnd:A}){const[u,h]=XB(!1),d=YB(null);$B(()=>{if(!u)return;const t=t=>{if(!d.current)return;const n=d.current.getBoundingClientRect();let i;i="horizontal"===e?(t.clientX-n.left)/n.width:(t.clientY-n.top)/n.height,i=Math.min(Math.max(i,o),a),l?.(i)},n=()=>{A?.(),h(!1)};return document.addEventListener("pointermove",t),document.addEventListener("pointerup",n),document.addEventListener("pointerleave",n),()=>{document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",n),document.removeEventListener("pointerleave",n)}},[u]);return OB("div",{ref:d,style:{position:"absolute",top:`${n}%`,left:`${t}%`,width:`${i}%`,height:`${r}%`},children:OB("div",{className:`deck-widget-splitter-handle deck-widget-splitter-handle--${e} ${u?"active":""}`,style:"horizontal"===e?{left:100*s+"%"}:{top:100*s+"%"},onPointerDown:e=>{h(!0),c?.(),e.preventDefault()}})})}SplitterWidget.defaultProps={...Widget.defaultProps,id:"splitter-widget",viewLayout:void 0,onChange:()=>{},onDragStart:()=>{},onDragEnd:()=>{}};const PN=Math.min,RN=Math.max,MN=Math.round,LN=Math.floor,IN=e=>({x:e,y:e}),ON={left:"right",right:"left",bottom:"top",top:"bottom"};function BN(e,t,n){return RN(e,PN(t,n))}function NN(e,t){return"function"==typeof e?e(t):e}function kN(e){return e.split("-")[0]}function FN(e){return e.split("-")[1]}function DN(e){return"x"===e?"y":"x"}function UN(e){return"y"===e?"height":"width"}function VN(e){const t=e[0];return"t"===t||"b"===t?"y":"x"}function zN(e){return DN(VN(e))}function GN(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const jN=["left","right"],HN=["right","left"],WN=["top","bottom"],qN=["bottom","top"];function KN(e,t,n,i){const r=FN(e);let s=function(e,t,n){switch(e){case"top":case"bottom":return n?t?HN:jN:t?jN:HN;case"left":case"right":return t?WN:qN;default:return[]}}(kN(e),"start"===n,i);return r&&(s=s.map(e=>e+"-"+r),t&&(s=s.concat(s.map(GN)))),s}function QN(e){const t=kN(e);return ON[t]+e.slice(t.length)}function XN(e){return"number"!=typeof e?function(e){var t,n,i,r;return{top:null!=(t=e.top)?t:0,right:null!=(n=e.right)?n:0,bottom:null!=(i=e.bottom)?i:0,left:null!=(r=e.left)?r:0}}(e):{top:e,right:e,bottom:e,left:e}}function $N(e){const{x:t,y:n,width:i,height:r}=e;return{width:i,height:r,top:n,left:t,right:t+i,bottom:n+r,x:t,y:n}}function ZN(e,t,n){let{reference:i,floating:r}=e;const s=VN(t),o=zN(t),a=UN(o),l=kN(t),c="y"===s,A=i.x+i.width/2-r.width/2,u=i.y+i.height/2-r.height/2,h=i[a]/2-r[a]/2;let d;switch(l){case"top":d={x:A,y:i.y-r.height};break;case"bottom":d={x:A,y:i.y+i.height};break;case"right":d={x:i.x+i.width,y:u};break;case"left":d={x:i.x-r.width,y:u};break;default:d={x:i.x,y:i.y}}const f=FN(t);return f&&(d[o]+=h*("end"===f?1:-1)*(n&&c?-1:1)),d}async function YN(e,t){var n;void 0===t&&(t={});const{x:i,y:r,platform:s,rects:o,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:A="viewport",elementContext:u="floating",altBoundary:h=!1,padding:d=0}=NN(t,e),f=XN(d),p=a[h?"floating"===u?"reference":"floating":u],g=$N(await s.getClippingRect({element:null==(n=await(null==s.isElement?void 0:s.isElement(p)))||n?p:p.contextElement||await(null==s.getDocumentElement?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:A,strategy:l})),m="floating"===u?{x:i,y:r,width:o.floating.width,height:o.floating.height}:o.reference,b=await(null==s.getOffsetParent?void 0:s.getOffsetParent(a.floating)),_=await(null==s.isElement?void 0:s.isElement(b))&&await(null==s.getScale?void 0:s.getScale(b))||{x:1,y:1},v=$N(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:m,offsetParent:b,strategy:l}):m);return{top:(g.top-v.top+f.top)/_.y,bottom:(v.bottom-g.bottom+f.bottom)/_.y,left:(g.left-v.left+f.left)/_.x,right:(v.right-g.right+f.right)/_.x}}const JN=new Set(["left","top"]);function ek(){return"undefined"!=typeof window}function tk(e){return rk(e)?(e.nodeName||"").toLowerCase():"#document"}function nk(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function ik(e){var t;return null==(t=(rk(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function rk(e){return!!ek()&&(e instanceof Node||e instanceof nk(e).Node)}function sk(e){return!!ek()&&(e instanceof Element||e instanceof nk(e).Element)}function ok(e){return!!ek()&&(e instanceof HTMLElement||e instanceof nk(e).HTMLElement)}function ak(e){return!(!ek()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof nk(e).ShadowRoot)}function lk(e){const{overflow:t,overflowX:n,overflowY:i,display:r}=bk(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+n)&&"inline"!==r&&"contents"!==r}function ck(e){return/^(table|td|th)$/.test(tk(e))}function Ak(e){try{if(e.matches(":popover-open"))return!0}catch(e){}try{return e.matches(":modal")}catch(e){return!1}}const uk=/transform|translate|scale|rotate|perspective|filter/,hk=/paint|layout|strict|content/,dk=e=>!!e&&"none"!==e;let fk;function pk(e){const t=sk(e)?bk(e):e;return dk(t.transform)||dk(t.translate)||dk(t.scale)||dk(t.rotate)||dk(t.perspective)||!gk()&&(dk(t.backdropFilter)||dk(t.filter))||uk.test(t.willChange||"")||hk.test(t.contain||"")}function gk(){return null==fk&&(fk="undefined"!=typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),fk}function mk(e){return/^(html|body|#document)$/.test(tk(e))}function bk(e){return nk(e).getComputedStyle(e)}function _k(e){return sk(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function vk(e){if("html"===tk(e))return e;const t=e.assignedSlot||e.parentNode||ak(e)&&e.host||ik(e);return ak(t)?t.host:t}function yk(e){const t=vk(e);return mk(t)?(e.ownerDocument||e).body:ok(t)&&lk(t)?t:yk(t)}function wk(e,t,n){var i;void 0===t&&(t=[]),void 0===n&&(n=!0);const r=yk(e),s=r===(null==(i=e.ownerDocument)?void 0:i.body),o=nk(r);if(s){const e=xk(o);return t.concat(o,o.visualViewport||[],lk(r)?r:[],e&&n?wk(e):[])}return t.concat(r,wk(r,[],n))}function xk(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Tk(e){const t=bk(e);let n=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const r=ok(e),s=r?e.offsetWidth:n,o=r?e.offsetHeight:i,a=MN(n)!==s||MN(i)!==o;return a&&(n=s,i=o),{width:n,height:i,$:a}}function Ek(e){return sk(e)?e:e.contextElement}function Sk(e){const t=Ek(e);if(!ok(t))return IN(1);const n=t.getBoundingClientRect(),{width:i,height:r,$:s}=Tk(t);let o=(s?MN(n.width):n.width)/i,a=(s?MN(n.height):n.height)/r;return o&&Number.isFinite(o)||(o=1),a&&Number.isFinite(a)||(a=1),{x:o,y:a}}const Ck=IN(0);function Pk(e){const t=nk(e);return gk()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:Ck}function Rk(e,t,n,i){void 0===t&&(t=!1),void 0===n&&(n=!1);const r=e.getBoundingClientRect(),s=Ek(e);let o=IN(1);t&&(i?sk(i)&&(o=Sk(i)):o=Sk(e));const a=function(e,t,n){return void 0===t&&(t=!1),!!n&&t&&n===nk(e)}(s,n,i)?Pk(s):IN(0);let l=(r.left+a.x)/o.x,c=(r.top+a.y)/o.y,A=r.width/o.x,u=r.height/o.y;if(s&&i){const e=nk(s),t=sk(i)?nk(i):i;let n=e,r=xk(n);for(;r&&t!==n;){const e=Sk(r),t=r.getBoundingClientRect(),i=bk(r),s=t.left+(r.clientLeft+parseFloat(i.paddingLeft))*e.x,o=t.top+(r.clientTop+parseFloat(i.paddingTop))*e.y;l*=e.x,c*=e.y,A*=e.x,u*=e.y,l+=s,c+=o,n=nk(r),r=xk(n)}}return $N({width:A,height:u,x:l,y:c})}function Mk(e,t){const n=_k(e).scrollLeft;return t?t.left+n:Rk(ik(e)).left+n}function Lk(e,t){const n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Mk(e,n),y:n.top+t.scrollTop}}function Ik(e,t,n){let i;if("viewport"===t||"layoutViewport"===t)i=function(e,t,n){void 0===n&&(n="viewport");const i="layoutViewport"===n,r=nk(e),s=ik(e),o=r.visualViewport;let a=s.clientWidth,l=s.clientHeight,c=0,A=0;if(o){const e=!gk()||"fixed"===t;i?e||(c=-o.offsetLeft,A=-o.offsetTop):(a=o.width,l=o.height,e&&(c=o.offsetLeft,A=o.offsetTop))}if(Mk(s)<=0){const e=s.ownerDocument,t=e.body,n=getComputedStyle(t),i="CSS1Compat"===e.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,r=Math.abs(s.clientWidth-t.clientWidth-i),o="stable both-edges"===getComputedStyle(s).scrollbarGutter?r/2:r;o<=25&&(a-=o)}return{width:a,height:l,x:c,y:A}}(e,n,t);else if("document"===t)i=function(e){const t=_k(e),n=e.ownerDocument.body,i=RN(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),r=RN(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-t.scrollLeft+Mk(e);const o=-t.scrollTop;return"rtl"===bk(n).direction&&(s+=RN(e.clientWidth,n.clientWidth)-i),{width:i,height:r,x:s,y:o}}(ik(e));else if(sk(t))i=function(e,t){const n=Rk(e,!0,"fixed"===t),i=n.top+e.clientTop,r=n.left+e.clientLeft,s=Sk(e);return{width:e.clientWidth*s.x,height:e.clientHeight*s.y,x:r*s.x,y:i*s.y}}(t,n);else{const n=Pk(e);i={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return $N(i)}function Ok(e,t,n){const i=ok(t),r=ik(t),s="fixed"===n,o=Rk(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=IN(0);if((i||!s)&&(("body"!==tk(t)||lk(r))&&(a=_k(t)),i)){const e=Rk(t,!0,s,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}!i&&r&&(l.x=Mk(r));const c=!r||i||s?IN(0):Lk(r,a);return{x:o.left+a.scrollLeft-l.x-c.x,y:o.top+a.scrollTop-l.y-c.y,width:o.width,height:o.height}}function Bk(e){return"static"===bk(e).position}function Nk(e,t){if(!ok(e)||"fixed"===bk(e).position)return null;if(t)return t(e);let n=e.offsetParent;return ik(e)===n&&(n=n.ownerDocument.body),n}function kk(e,t){const n=nk(e);if(Ak(e))return n;if(!ok(e)){let t=vk(e);for(;t&&!mk(t);){if(sk(t)&&!Bk(t))return t;t=vk(t)}return n}let i=Nk(e,t);for(;i&&ck(i)&&Bk(i);)i=Nk(i,t);return i&&mk(i)&&Bk(i)&&!pk(i)?n:i||function(e){let t=vk(e);for(;ok(t)&&!mk(t);){if(pk(t))return t;if(Ak(t))return null;t=vk(t)}return null}(e)||n}const Fk={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:i,strategy:r}=e;const s="fixed"===r,o=ik(i),a=!!t&&Ak(t.floating);if(i===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=IN(1);const A=IN(0),u=ok(i);if((u||!s)&&(("body"!==tk(i)||lk(o))&&(l=_k(i)),u)){const e=Rk(i);c=Sk(i),A.x=e.x+i.clientLeft,A.y=e.y+i.clientTop}const h=!o||u||s?IN(0):Lk(o,l);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+A.x+h.x,y:n.y*c.y-l.scrollTop*c.y+A.y+h.y}},getDocumentElement:ik,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:i,strategy:r}=e;const s="clippingAncestors"===n?Ak(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let i=wk(e,[],!1).filter(e=>sk(e)&&"body"!==tk(e)),r=null;const s="fixed"===bk(e).position;let o=s?vk(e):e;for(;sk(o)&&!mk(o);){const e=bk(o),t=pk(o),n=r?r.position:s?"fixed":"";t||"fixed"!==n&&("absolute"!==n||"static"!==e.position)?r=e:i=i.filter(e=>e!==o),o=vk(o)}return t.set(e,i),i}(t,this._c):[].concat(n),o=[...s,i],a=Ik(t,o[0],r);let l=a.top,c=a.right,A=a.bottom,u=a.left;for(let e=1;e<o.length;e++){const n=Ik(t,o[e],r);l=RN(n.top,l),c=PN(n.right,c),A=PN(n.bottom,A),u=RN(n.left,u)}return{width:c-u,height:A-l,x:u,y:l}},getOffsetParent:kk,getElementRects:async function(e){const t=this.getOffsetParent||kk,n=this.getDimensions,i=await n(e.floating);return{reference:Ok(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}},getClientRects:function(e){return e.getClientRects?Array.from(e.getClientRects()):[]},getDimensions:function(e){const{width:t,height:n}=Tk(e);return{width:t,height:n}},getScale:Sk,isElement:sk,isRTL:function(e){return"rtl"===bk(e).direction}};function Dk(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Uk(e,t,n,i){void 0===i&&(i={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:o="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:l=!1}=i,c=Ek(e),A=r||s?[...c?wk(c):[],...t?wk(t):[]]:[];A.forEach(e=>{r&&e.addEventListener("scroll",n),s&&e.addEventListener("resize",n)});const u=c&&a?function(e,t,n){let i,r=null;const s=ik(e);function o(){var e;clearTimeout(i),null==(e=r)||e.disconnect(),r=null}function a(n,l){void 0===n&&(n=!1),void 0===l&&(l=1),o();const c=e.getBoundingClientRect(),{left:A,top:u,width:h,height:d}=c;if(n||t(),!h||!d)return;const f={rootMargin:-LN(u)+"px "+-LN(s.clientWidth-(A+h))+"px "+-LN(s.clientHeight-(u+d))+"px "+-LN(A)+"px",threshold:RN(0,PN(1,l))||1};let p=!0;function g(t){const n=t[0].intersectionRatio;if(!Dk(c,e.getBoundingClientRect()))return a();if(n!==l){if(!p)return a();n?a(!1,n):i=setTimeout(()=>{a(!1,1e-7)},1e3)}p=!1}try{r=new IntersectionObserver(g,{...f,root:s.ownerDocument})}catch(e){r=new IntersectionObserver(g,f)}r.observe(e)}const l=nk(e),c=()=>a(n);return l.addEventListener("resize",c),a(!0),()=>{l.removeEventListener("resize",c),o()}}(c,n,s):null;let h,d=-1,f=null;o&&(f=new ResizeObserver(e=>{let[i]=e;i&&i.target===c&&f&&t&&(f.unobserve(t),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var e;null==(e=f)||e.observe(t)})),n()}),c&&!l&&f.observe(c),t&&f.observe(t));let p=l?Rk(e):null;return l&&function t(){const i=Rk(e);p&&!Dk(p,i)&&n();p=i,h=requestAnimationFrame(t)}(),n(),()=>{var e;A.forEach(e=>{r&&e.removeEventListener("scroll",n),s&&e.removeEventListener("resize",n)}),null==u||u(),null==(e=f)||e.disconnect(),f=null,l&&cancelAnimationFrame(h)}}const Vk=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,i;const{x:r,y:s,placement:o,middlewareData:a}=t,l=await async function(e,t){const{placement:n,platform:i,elements:r}=e,s=await(null==i.isRTL?void 0:i.isRTL(r.floating)),o=kN(n),a=FN(n),l="y"===VN(n),c=JN.has(o)?-1:1,A=s&&l?-1:1,u=NN(t,e);let{mainAxis:h,crossAxis:d,alignmentAxis:f}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&"number"==typeof f&&(d="end"===a?-1*f:f),l?{x:d*A,y:h*c}:{x:h*c,y:d*A}}(t,e);return o===(null==(n=a.offset)?void 0:n.placement)&&null!=(i=a.arrow)&&i.alignmentOffset?{}:{x:r+l.x,y:s+l.y,data:{...l,placement:o}}}}},zk=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:i,placement:r,platform:s}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:l={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...c}=NN(e,t),A={x:n,y:i},u=await s.detectOverflow(t,c),h=VN(r),d=DN(h);let f=A[d],p=A[h];const g=(e,t)=>BN(t+u["y"===e?"top":"left"],t,t-u["y"===e?"bottom":"right"]);o&&(f=g(d,f)),a&&(p=g(h,p));const m=l.fn({...t,[d]:f,[h]:p});return{...m,data:{x:m.x-n,y:m.y-i,enabled:{[d]:o,[h]:a}}}}}},Gk=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,i;const{placement:r,middlewareData:s,rects:o,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:A=!0,crossAxis:u=!0,fallbackPlacements:h,fallbackStrategy:d="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:p=!0,...g}=NN(e,t);if(null!=(n=s.arrow)&&n.alignmentOffset)return{};const m=kN(r),b=VN(a),_=kN(a)===a,v=await(null==l.isRTL?void 0:l.isRTL(c.floating)),y=h||(_||!p?[QN(a)]:function(e){const t=QN(e);return[GN(e),t,GN(t)]}(a)),w="none"!==f;!h&&w&&y.push(...KN(a,p,f,v));const x=[a,...y],T=await l.detectOverflow(t,g),E=[];let S=(null==(i=s.flip)?void 0:i.overflows)||[];if(A&&E.push(T[m]),u){const e=function(e,t,n){void 0===n&&(n=!1);const i=FN(e),r=zN(e),s=UN(r);let o="x"===r?i===(n?"end":"start")?"right":"left":"start"===i?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=QN(o)),[o,QN(o)]}(r,o,v);E.push(T[e[0]],T[e[1]])}if(S=[...S,{placement:r,overflows:E}],!E.every(e=>e<=0)){var C,P;const e=((null==(C=s.flip)?void 0:C.index)||0)+1,t=x[e];if(t){if(!("alignment"===u&&b!==VN(t))||S.every(e=>VN(e.placement)!==b||e.overflows[0]>0))return{data:{index:e,overflows:S},reset:{placement:t}}}let n=null==(P=S.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:P.placement;if(!n)switch(d){case"bestFit":{var R;const e=null==(R=S.filter(e=>{if(w){const t=VN(e.placement);return t===b||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:R[0];e&&(n=e);break}case"initialPlacement":n=a}if(r!==n)return{reset:{placement:n}}}return{}}}},jk=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:i,placement:r,rects:s,platform:o,elements:a,middlewareData:l}=t,{element:c,padding:A=0}=NN(e,t)||{};if(null==c)return{};const u=XN(A),h={x:n,y:i},d=zN(r),f=UN(d),p=await o.getDimensions(c),g="y"===d,m=g?"top":"left",b=g?"bottom":"right",_=g?"clientHeight":"clientWidth",v=s.reference[f]+s.reference[d]-h[d]-s.floating[f],y=h[d]-s.reference[d],w=await(null==o.getOffsetParent?void 0:o.getOffsetParent(c));let x=w?w[_]:0;x&&await(null==o.isElement?void 0:o.isElement(w))||(x=a.floating[_]||s.floating[f]);const T=v/2-y/2,E=x/2-p[f]/2-1,S=PN(u[m],E),C=PN(u[b],E),P=x-p[f]-C,R=x/2-p[f]/2+T,M=BN(S,R,P),L=!l.arrow&&null!=FN(r)&&R!==M&&s.reference[f]/2-(R<S?S:C)-p[f]/2<0,I=L?R<S?R-S:R-P:0;return{[d]:h[d]+I,data:{[d]:M,centerOffset:R-M-I,...L&&{alignmentOffset:I}},reset:L}}}),Hk=(e,t,n)=>{const i=new Map,r=null!=n?n:{},s={...Fk,...r.platform,_c:i};return(async(e,t,n)=>{const{placement:i="bottom",strategy:r="absolute",middleware:s=[],platform:o}=n,a=o.detectOverflow?o:{...o,detectOverflow:YN},l=await(null==o.isRTL?void 0:o.isRTL(t));let c=await o.getElementRects({reference:e,floating:t,strategy:r}),{x:A,y:u}=ZN(c,i,l),h=i,d=0;const f={};for(let n=0;n<s.length;n++){const p=s[n];if(!p)continue;const{name:g,fn:m}=p,{x:b,y:_,data:v,reset:y}=await m({x:A,y:u,initialPlacement:i,placement:h,strategy:r,middlewareData:f,rects:c,platform:a,elements:{reference:e,floating:t}});A=null!=b?b:A,u=null!=_?_:u,f[g]={...f[g],...v},y&&d<50&&(d++,"object"==typeof y&&(y.placement&&(h=y.placement),y.rects&&(c=!0===y.rects?await o.getElementRects({reference:e,floating:t,strategy:r}):y.rects),({x:A,y:u}=ZN(c,h,l))),n=-1)}return{x:A,y:u,placement:h,strategy:r,middlewareData:f}})(e,t,{...r,platform:s})},Wk=({x:e,y:t,placement:n="right",offset:i=0,arrow:r=!1,arrowColor:s="white",children:o})=>{const a=YB(null),l=YB(null),c=YB(null),A=YB();return A.current=()=>{if(!a.current||!l.current)return;const e=Array.isArray(r)?r[0]:r||0,t=Array.isArray(r)?r[1]:r||0,o=i+Math.max(t,e),A=n.includes("-")?[Vk(o),Gk(),zk()]:[Vk(o),zk(),Gk()];c.current&&A.push(jk({element:c.current})),Hk(a.current,l.current,{placement:n,strategy:"fixed",middleware:A}).then(n=>{l.current&&Object.assign(l.current.style,{left:`${n.x}px`,top:`${n.y}px`});const i=n.middlewareData.arrow;if(i&&c.current){const r=function(e,t,n,i){const r={width:0,height:0,top:"",bottom:"",left:"",right:""};i.startsWith("bottom")?(r.borderLeft=e/2+"px solid transparent",r.borderRight=e/2+"px solid transparent",r.borderBottom=`${t}px solid ${n}`,r.borderTop="",r.top=-t+"px"):i.startsWith("top")?(r.borderLeft=e/2+"px solid transparent",r.borderRight=e/2+"px solid transparent",r.borderTop=`${t}px solid ${n}`,r.borderBottom="",r.bottom=-t+"px"):i.startsWith("right")?(r.borderTop=e/2+"px solid transparent",r.borderBottom=e/2+"px solid transparent",r.borderRight=`${t}px solid ${n}`,r.borderLeft="",r.left=-t+"px"):i.startsWith("left")&&(r.borderTop=e/2+"px solid transparent",r.borderBottom=e/2+"px solid transparent",r.borderLeft=`${t}px solid ${n}`,r.borderRight="",r.right=-t+"px");return r}(e,t,s,n.placement);r.transform=`translate(${i.x||0}px, ${i.y||0}px)`,Object.assign(c.current.style,r)}})},JB(()=>{A.current?.()},[e,t,n,r,i]),$B(()=>{const e=a.current,t=l.current;if(!e||!t)return;t.style.visibility="visible";const n=Uk(e,t,()=>A.current?.());return()=>{n()}},[]),OB("div",{style:{position:"absolute",left:e,top:t},ref:a,children:OB("div",{className:"deck-widget deck-widget-popover",style:{position:"fixed",visibility:"hidden",pointerEvents:"none"},ref:l,children:[Boolean(r)&&OB("div",{className:"deck-widget-popover-arrow",style:{position:"absolute"},ref:c}),o]})})};const qk=({text:e,html:t,element:n,...i})=>{const r=YB(null);return $B(()=>(r.current&&n&&r.current.append(n),()=>{n?.remove()}),[n]),OB("div",{ref:r,...i,dangerouslySetInnerHTML:t?{__html:t}:void 0,children:e})};class InfoWidget extends Widget{constructor(e){super(e),this.className="deck-widget-info",this.placement="fill",this.tooltip=null,this.setProps(this.props)}setProps(e){this.viewId=e.viewId??this.viewId,super.setProps(e)}onAdd({deck:e}){this.deck=e}onRemove(){this.rootElement&&LB(null,this.rootElement)}onViewportChange(e){this.viewport=e,this.updateHTML()}onHover(e){"hover"===this.props.mode&&(this.tooltip=this._getTooltip(e),this.updateHTML())}onClick(e){"click"===this.props.mode&&(this.tooltip=this._getTooltip(e),this.updateHTML())}_getTooltip(e){if(!this.props.getTooltip)return null;const t=this.props.getTooltip(e,this)??null;if(null===t)return null;const n="string"==typeof t?{text:t}:t,i=n.position||e.coordinate;return i?{position:i,text:"",html:"",element:null,className:"",style:{},...n}:null}onRenderHTML(e){if(!this.viewport||null===this.tooltip)return void LB(null,e);const t={...this.props.style,...this.tooltip.style},[n,i]=this.viewport.project(this.tooltip.position);LB(OB(Wk,{x:n,y:i,placement:this.props.placement,arrow:this.props.arrow,arrowColor:"var(--menu-background, #fff)",offset:this.props.offset,children:OB(qk,{className:`deck-widget-popup-content ${this.tooltip.className} ${this.props.className}`,style:t,html:this.tooltip.html,text:this.tooltip.text,element:this.tooltip.element})}),e)}}InfoWidget.defaultProps={...Widget.defaultProps,id:"info",viewId:null,mode:"hover",getTooltip:void 0,placement:"right",offset:10,arrow:10};class PopupWidget extends Widget{constructor(e){super(e),this.className="deck-widget-popup",this.placement="fill",this.setProps(this.props),this.isOpen=this.props.defaultIsOpen}setProps(e){this.viewId=e.viewId??this.viewId,super.setProps(e)}onAdd({deck:e}){this.deck=e}onRemove(){this.rootElement&&LB(null,this.rootElement)}onViewportChange(e){this.viewport=e,this.updateHTML()}onClick(){this.props.closeOnClickOutside&&this._setIsOpen(!1)}_setIsOpen(e){this.isOpen!==e&&(this.isOpen=e,this.props.onOpenChange?.(e),this.updateHTML())}onRenderHTML(e){if(!this.viewport)return void LB(null,e);const{marker:t,content:n,style:i}=this.props,[r,s]=this.viewport.project(this.props.position);LB(OB("div",{children:[t&&OB("div",{className:"deck-widget-popup-marker",style:{left:r,top:s},children:OB(qk,{...t,onClick:()=>this._setIsOpen(!0)})}),this.isOpen&&OB(Wk,{x:r,y:s,placement:this.props.placement,arrow:this.props.arrow,arrowColor:"var(--menu-background, #fff)",offset:this.props.offset,children:OB("div",{className:`deck-widget-popup-content ${this.props.className}`,style:i,children:[this.props.closeButton&&OB("div",{className:"deck-widget-popup-controls",style:{width:"100%",display:"flex",justifyContent:"end"},children:OB(cN,{className:"deck-widget-popup-close-button",onClick:()=>this._setIsOpen(!1)})}),OB(qk,{..."string"==typeof n?{text:n}:n})]})})]}),e)}}PopupWidget.defaultProps={...Widget.defaultProps,id:"info",viewId:null,position:[0,0],marker:null,defaultIsOpen:!0,content:"",placement:"right",offset:10,arrow:10,closeButton:!0,closeOnClickOutside:!1,onOpenChange:()=>{}};class ContextMenuWidget extends Widget{constructor(e){super(e),this.className="deck-widget-context-menu",this.placement="fill",this.menu=null,this.setProps(this.props)}onAdd({deck:e}){e.getCanvas()?.addEventListener("contextmenu",e=>this.handleContextMenu(e))}handleContextMenu(e){const t=e.target.getBoundingClientRect(),n=e.clientX-t.x,i=e.clientY-t.y,r=this.deck?.pickObject({x:n,y:i})||{x:n,y:i,picked:!1,layer:null,color:null,index:-1,pixelRatio:1},s=this.props.getMenuItems?.(r,this)||this.props.menuItems;this.menu=s.length>0?{items:s,pickInfo:r}:null,e.preventDefault(),this.updateHTML()}onRenderHTML(e){if(!this.menu)return void LB(null,e);const{items:t,pickInfo:n}=this.menu,i={pointerEvents:"auto",position:"static",...this.props.style};LB(OB(Wk,{x:n.x,y:n.y,placement:this.props.placement,arrow:this.props.arrow,arrowColor:"var(--menu-background, #fff)",offset:this.props.offset,children:OB(fN,{menuItems:t,onSelect:e=>this.props.onMenuItemSelected(e,n),style:i,isOpen:!0,onClose:()=>this.hide()})}),e)}hide(){this.menu=null,this.updateHTML()}}ContextMenuWidget.defaultProps={...Widget.defaultProps,id:"context",viewId:null,menuItems:[],getMenuItems:void 0,onMenuItemSelected:()=>{},placement:"bottom-start",offset:10,arrow:!1};const Kk={passive:!1},Qk=(e,t,n)=>e<t?t:e>n?n:e,Xk=(e,t)=>{if(!e||!e.firstElementChild)return[0,0];const n=e.firstElementChild.getBoundingClientRect();return t||t?[n.top,n.height]:[n.left,n.width]},$k=(e,t)=>"number"==typeof e&&!Number.isNaN(e)&&e>0?e:Math.max(1,t/10||1),Zk=(e,t)=>"number"==typeof e&&!Number.isNaN(e)&&e>0?e:Math.max(1,t||1);function Yk(e){const{className:t="",min:n,max:i,step:r,value:s,orientation:o,pageSize:a,stepButtons:l=!1,startButtonAriaLabel:c,endButtonAriaLabel:A,eventTarget:u,decorations:h=[],onChange:d}=e,f="horizontal"!==o,p=YB(null),g=YB(null),m=YB(null),b=YB(null),[_,v]=XB(0),y=i-n,w=Math.max(0,s[1]-s[0]),x=Math.max(0,y-w),T=Qk(s[0],n,n+x),{thumbLength:E,thumbOffset:S}=JB(()=>{if(_<=0||y<=0)return{thumbLength:0,thumbOffset:0};if(y<=w)return{thumbLength:1,thumbOffset:0};const e=w/y,t=Math.max(0,1-e),i=x<=0?0:Qk((T-n)/x,0,1);return{thumbLength:Math.max(0,Math.min(e,1)),thumbOffset:t*i}},[_,y,w,x,T,n]),C=eN(e=>{if(!d)return;const t=Qk(e,n,n+x);d([t,t+w])},[d,n,x,w]),P=eN(e=>{e.stopPropagation(),C(T-$k(r,y))},[C,T,r,y]),R=eN(e=>{e.stopPropagation(),C(T+$k(r,y))},[C,T,r,y]),M=eN(e=>{if(0!==e.button)return;const t=e.target;if("true"===t?.dataset.scrollbarThumb)return;const i=g.current;if(!i)return;e.preventDefault(),e.stopPropagation();const[r]=Xk(i,f),s=f?e.clientY-r:e.clientX-r,o=Math.max(1,1-E)*_,a=o<=0?0:Qk((s-E/2*_)/o,0,1);C(n+a*x)},[f,_,E,C,n,x]),L=eN(e=>{const t=b.current;if(!t||t.pointerId!==e.pointerId)return;const[n,i]=Xk(g.current,f),r=(f?e.clientY:e.clientX)-t.startCoord,s=t.startRatio+r/i,o=Qk(s*(t.max-t.min),0,t.maxStart)+t.min;C(o),e.preventDefault()},[C,f]),I=eN(e=>{const t=b.current;t&&t.pointerId===e.pointerId&&(b.current=null,m.current?.releasePointerCapture(e.pointerId),e.preventDefault())},[]),O=eN(e=>{switch(e.key){case"ArrowUp":case"ArrowLeft":(f&&"ArrowUp"===e.key||!f&&"ArrowLeft"===e.key)&&(C(T-$k(r,y)),e.preventDefault());break;case"ArrowDown":case"ArrowRight":(f&&"ArrowDown"===e.key||!f&&"ArrowRight"===e.key)&&(C(T+$k(r,y)),e.preventDefault());break;case"PageUp":C(T-Zk(a,w)),e.preventDefault();break;case"PageDown":C(T+Zk(a,w)),e.preventDefault();break;case"Home":C(n),e.preventDefault();break;case"End":C(n+x),e.preventDefault()}},[f,C,T,r,y,a,w,n,x]),B=eN(e=>{if(e.preventDefault(),e.stopPropagation(),0===x)return;let t=f?e.deltaY:e.deltaX;f||0!==t||(t=e.deltaY),e.deltaMode===WheelEvent.DOM_DELTA_LINE?t*=$k(r,y):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=Zk(a,w)),0!==t&&C(T+t)},[C,T,x,f,r,y,a,w]);ZB(()=>{v(Xk(g.current,f)[1])},[f]),ZB(()=>{const e=g.current;if(!e)return;const t=()=>{v(Xk(e,f)[1])};if(t(),"undefined"!=typeof ResizeObserver){const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()}return"undefined"!=typeof window?(window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)):void 0},[f]),$B(()=>{const e=u??p.current;if(e)return e.addEventListener("keydown",O),e.addEventListener("wheel",B,Kk),()=>{e.removeEventListener("keydown",O),e.removeEventListener("wheel",B,Kk)}},[u,O,B]);const N=JB(()=>!h.length||y<=0?[]:h.map((e,t)=>{const[i,r]=e.position,s=(i-n)/y,o=(r-n)/y,a=Math.round(1e3*s)/10,l=Math.max(0,Math.round(1e3*(o-s))/10);return OB("div",{className:"deck-widget-range__decoration",style:f?{left:"0",width:"100%",top:`${a}%`,height:`${l}%`}:{top:"0",height:"100%",left:`${a}%`,width:`${l}%`},children:e.element},`decoration-${t}`)}),[h,y,n,f]);return OB("div",{ref:p,tabIndex:0,role:"scrollbar","aria-valuemin":n,"aria-valuemax":n+x,"aria-valuenow":T,"aria-orientation":o,className:`${t} deck-widget-range deck-widget-range--${o} ${0===x?"deck-widget-range--disabled":""}`,children:[l&&OB("button",{type:"button",className:"deck-widget-range__button deck-widget-range__button--start","aria-label":c,disabled:T<=n,onClick:P,children:OB("span",{className:"deck-widget-icon"})}),OB("div",{className:"deck-widget-range__track",ref:g,onClick:M,children:[OB("div",{className:"deck-widget-range__decorations",children:N}),OB("div",{className:"deck-widget-range__thumb","data-scrollbar-thumb":"true",ref:m,style:f?{height:100*E+"%",top:100*S+"%"}:{width:100*E+"%",left:100*S+"%"},onPointerDown:e=>{if(0!==e.button)return;g.current&&(b.current={pointerId:e.pointerId,startCoord:f?e.clientY:e.clientX,startRatio:S,min:n,max:i,maxStart:x},e.currentTarget.setPointerCapture(e.pointerId),e.preventDefault(),e.stopPropagation())},onPointerMove:L,onPointerUp:I,onPointerCancel:I})]}),l&&OB("button",{type:"button",className:"deck-widget-range__button deck-widget-range__button--end","aria-label":A,disabled:T>=n+x,onClick:R,children:OB("span",{className:"deck-widget-icon"})})]})}const Jk=(e,t,n)=>e<t?t:e>n?n:e;class ScrollbarWidget extends Widget{constructor(e){const t={...ScrollbarWidget.defaultProps,...e};super(t),this.className="deck-widget-scrollbar",this.placement="fill",this.contentSize=0,this.viewportSize=0,this.scrollOffset=0,this.handleRangeChange=e=>{this.emitScroll(e[0])},this.viewId=t.viewId??null}onViewportChange(e){this.viewport=e,this.onRenderHTML()}onRenderHTML(){const e=this.rootElement;if(!e)return;e.dataset.placement=this.props.placement;const t=this.viewport;this.updateViewport(t);const n=this.getClampedOffset(),i=this.getWheelEventTarget(this.props.captureWheel?"global":"local"),r=this.getDecorations(t),s=this.isVertical(),o=this.props.startButtonAriaLabel??(s?"Scroll up":"Scroll left"),a=this.props.endButtonAriaLabel??(s?"Scroll down":"Scroll right");LB(OB(Yk,{min:0,max:Math.max(0,this.contentSize),step:this.getEffectiveStep(),pageSize:this.getEffectivePage(),value:[n,n+this.viewportSize],orientation:this.props.orientation,stepButtons:!0,startButtonAriaLabel:o,endButtonAriaLabel:a,eventTarget:i,decorations:r,onChange:this.handleRangeChange}),e)}onRemove(){this.rootElement&&LB(null,this.rootElement),super.onRemove()}getContentBounds(e){return this.props.contentBounds??this.deck?.getView(e)?.controller?.maxBounds??null}updateViewport(e){if(!e)return this.contentSize=0,this.scrollOffset=0,void(this.viewportSize=0);const t=this.getContentBounds(e.id),n=this.isVertical(),i=t?eF(t,e,n):[0,0];this.contentSize=i[1]-i[0],this.scrollOffset=-i[0],this.viewportSize=n?e.height:e.width}getDecorations(e){const{decorations:t=[]}=this.props;if(!e||0===t.length)return[];const n=this.getContentBounds(e.id);if(!n)return[];const i=this.isVertical(),[r]=eF(n,e,i);return t.map(t=>{const[n,s]=eF(t.contentBounds,e,i),o=t.onClick?e=>{const n=t.onClick?.(e);n&&(e.stopPropagation(),e.preventDefault())}:void 0;return{position:[n-r,s-r],element:OB("div",{style:{pointerEvents:o?"all":"none",width:"100%",height:"100%",backgroundColor:t.color},title:t.title,onClick:o})}})}getWheelEventTarget(e){return null===e?null:"local"===e?this.rootElement:this.deck?.props.parent||this.deck?.getCanvas()?.parentElement||this.rootElement}getMaxScroll(){return Math.max(0,this.contentSize-this.viewportSize)}getClampedOffset(){const e=this.getMaxScroll();return Jk(this.scrollOffset,0,e)}isVertical(){return"horizontal"!==this.props.orientation}getEffectiveStep(){return"number"!=typeof this.props.stepSize||Number.isNaN(this.props.stepSize)?Math.max(1,this.viewportSize/10||1):this.props.stepSize}getEffectivePage(){return"number"!=typeof this.props.pageSize||Number.isNaN(this.props.pageSize)?this.viewportSize:this.props.pageSize}emitScroll(e){const t=this.getMaxScroll(),n=Jk(Math.round(e),0,t),i=this.viewport;if(i&&n!==this.getClampedOffset()){const e=i.project(i.position);this.isVertical()?e[1]-=n-this.scrollOffset:e[0]-=n-this.scrollOffset;const{target:t}=i.panByPosition(i.position,e);this.deck._onViewStateChange({viewId:i.id,viewState:{...this.getViewState(i.id),target:t},interactionState:{}})}}}function eF(e,t,n){return e.map(([e,n])=>t.project([e,n,0])).reduce((e,[t,i])=>{const r=n?i:t;return e[0]=Math.min(e[0],r),e[1]=Math.max(e[1],r),e},[1/0,-1/0])}ScrollbarWidget.defaultProps={...Widget.defaultProps,contentBounds:null,placement:"top-right",viewId:null,orientation:"vertical",stepSize:null,pageSize:null,startButtonAriaLabel:"",endButtonAriaLabel:"",captureWheel:!1,decorations:[]};class IconWidget extends Widget{constructor(e){super(e),this.className="",this.placement="top-left",this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId,super.setProps(e)}onRenderHTML(e){const{className:t,style:n,icon:i,color:r,label:s,onClick:o}=this.props;LB(OB(cN,{className:t,style:n,color:r,icon:i,label:s,onClick:o}),e)}}IconWidget.defaultProps={...Widget.defaultProps,id:"icon",placement:"top-left",viewId:null,icon:"",label:"",color:"",onClick:void 0};class ToggleWidget extends Widget{constructor(e){super(e),this.className="deck-widget-toggle",this.placement="top-left",this._toggle=()=>{this.checked=!this.checked,this.props.onChange?.(this.checked),this.updateHTML()},this.checked=this.props.initialChecked,this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId,super.setProps(e)}onRenderHTML(e){const{className:t,style:n,icon:i,label:r,color:s,onIcon:o=i,onLabel:a=r,onColor:l=s}=this.props,c=this.checked;e.dataset.checked=String(c),LB(OB(cN,{className:t,style:n,icon:c?o:i,label:c?a:r,color:c?l:s,onClick:this._toggle}),e)}}ToggleWidget.defaultProps={...Widget.defaultProps,id:"icon",placement:"top-left",viewId:null,initialChecked:!1,icon:"",onIcon:void 0,label:"",onLabel:void 0,color:"",onColor:void 0,onChange:void 0};class SelectorWidget extends Widget{constructor(e){super(e),this.className="deck-widget-selector",this.placement="top-left",this.isOpen=!1,this._toggleMenu=()=>{this.isOpen?this.isOpen=!1:this.rootElement&&(this.isOpen={x:this.rootElement.offsetLeft,y:this.rootElement.offsetTop,placement:this.props.placement.includes("right")?"left-start":"right-start"}),this.updateHTML()},this._handleSelectMode=e=>{this.value=e,this.props.onChange(e),this.updateHTML()},this.value=this.props.initialValue,this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){const t=this.props.options.find(e=>e.value===this.value)??this.props.options[0];LB(OB("div",{children:[OB(cN,{icon:t.icon,label:t.label,onClick:this._toggleMenu}),this.isOpen&&OB(Wk,{...this.isOpen,children:OB(fN,{isOpen:!0,style:{pointerEvents:"auto",position:"static"},menuItems:this.props.options,onSelect:this._handleSelectMode,onClose:this._toggleMenu})})]}),e)}}SelectorWidget.defaultProps={...Widget.defaultProps,id:"view-selector",placement:"top-left",viewId:null,initialValue:"",options:[],onChange:()=>{}};class TimelineWidget extends Widget{getTime(){return this.props.time??this.currentTime}getPlaying(){return this.props.playing??this._playing}constructor(e={}){super(e),this.id="timeline",this.className="deck-widget-timeline",this.placement="fill",this._playing=!1,this.timerId=null,this.handlePlayPause=()=>{const e=!this.getPlaying();this.props.onPlayingChange?.(e),void 0===this.props.playing&&(e?this.play():this.stop())},this.handleTimeChange=([e])=>{this.props.onTimeChange(e),void 0===this.props.time&&(this.currentTime=e,this.props.timeline?.setTime(e),this.updateHTML())},this.tick=()=>{const{timeRange:[e,t],step:n,loop:i}=this.props;if(n>0){const r=this.getTime();let s=Math.round(r/n)*n+n;s>t&&(r<t?s=t:i?s=e:(s=t,this._playing=!1,this.props.onPlayingChange?.(!1))),this.props.onTimeChange(s),void 0===this.props.time&&(this.currentTime=s,this.props.timeline?.setTime(s)),this.updateHTML()}this._playing?this.timerId=window.setTimeout(this.tick,this.props.playInterval):this.timerId=null},this.currentTime=this.props.initialTime??this.props.timeRange[0];const t=this.props.time??this.currentTime;this.props.timeline?.setTime(t),this.setProps(this.props)}setProps(e){const{playing:t,time:n}=this.props;this.viewId=e.viewId??this.viewId,super.setProps(e),void 0!==e.time&&e.time!==n&&this.props.timeline?.setTime(e.time),void 0!==e.playing&&e.playing!==t&&(e.playing&&!this._playing?this._startTimer():!e.playing&&this._playing&&this._stopTimer())}onAdd(){this._playing=!1,this.timerId=null,this.props.autoPlay&&(void 0!==this.props.playing?this.props.onPlayingChange?.(!0):this.play())}onRemove(){this.stop()}onRenderHTML(e){const{timeRange:t,step:n,formatLabel:i}=this.props,r=this.getPlaying(),s=this.getTime();e.dataset.placement=this.props.placement,LB(OB("div",{className:"deck-widget-button-group",children:[OB(cN,r?{label:"Pause",className:"deck-widget-timeline-pause",onClick:this.handlePlayPause}:{label:"Play",className:"deck-widget-timeline-play",onClick:this.handlePlayPause}),OB(Yk,{min:t[0],max:t[1],orientation:"horizontal",step:n,value:[s,s],onChange:this.handleTimeChange,decorations:[{position:[s,s+n],element:OB("div",{className:"deck-widget-timeline-label deck-widget-timeline-label--current",children:i(s)})}]})]}),e)}play(){this._playing=!0;const{timeRange:[e,t]}=this.props;void 0===this.props.time&&this.getTime()>=t&&(this.currentTime=e,this.props.onTimeChange(e),this.props.timeline?.setTime(e)),this.updateHTML(),this.tick()}stop(){this._stopTimer(),this.updateHTML()}_startTimer(){this._playing=!0,this.tick()}_stopTimer(){this._playing=!1,null!==this.timerId&&(window.clearTimeout(this.timerId),this.timerId=null)}}TimelineWidget.defaultProps={...Widget.defaultProps,id:"timeline",placement:"bottom-left",viewId:null,timeline:null,timeRange:[0,100],step:1,initialTime:void 0,time:void 0,onTimeChange:()=>{},autoPlay:!1,loop:!1,playInterval:1e3,playing:void 0,onPlayingChange:()=>{},formatLabel:String};class ScreenshotWidget extends Widget{constructor(e={}){super(e),this.className="deck-widget-screenshot",this.placement="top-left",this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){LB(OB(cN,{className:"deck-widget-camera",label:this.props.label,onClick:this.handleClick.bind(this)}),e)}handleClick(){if(this.props.onCapture)return void this.props.onCapture(this);const e=this.captureScreenToDataURL(this.props.imageFormat);e&&this.downloadDataURL(e,this.props.filename)}captureScreenToDataURL(e){const t=this.deck?.getCanvas();return t?.toDataURL(e)}downloadDataURL(e,t){const n=document.createElement("a");n.href=e,n.download=t,n.click()}}ScreenshotWidget.defaultProps={...Widget.defaultProps,id:"screenshot",placement:"top-left",viewId:null,label:"Screenshot",filename:"screenshot.png",imageFormat:"image/png",onCapture:void 0};class ThemeWidget extends Widget{constructor(e={}){super(e),this.className="deck-widget-theme",this.placement="top-left",this.themeMode="dark",this.appliedTheme={},this.themeMode=this._getInitialThemeMode(),this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){const{lightModeLabel:t,darkModeLabel:n}=this.props,i=this.getThemeMode();this._applyTheme(i,e),LB(OB(cN,{onClick:this._handleClick.bind(this),label:"dark"===i?n:t,className:"dark"===i?"deck-widget-moon":"deck-widget-sun"}),e)}getThemeMode(){return this.props.themeMode??this.themeMode}_handleClick(){const e="dark"===this.getThemeMode()?"light":"dark";this.props.onThemeModeChange?.(e),void 0===this.props.themeMode&&(this.themeMode=e,this.updateHTML())}_applyTheme(e,t){const n="dark"===e?this.props.darkModeTheme:this.props.lightModeTheme;if((0,dn.b)(n,this.appliedTheme,1))return;const i=t.closest(".deck-widget-container");if(!i)return;Ui(i,n),this.appliedTheme=n;const r="dark"===e?this.props.darkModeLabel:this.props.lightModeLabel;Ie.A.log(1,`Switched theme to ${r}`,n)()}_getInitialThemeMode(){const{initialThemeMode:e}=this.props;return"auto"!==e?e:"undefined"==typeof window?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}}ThemeWidget.defaultProps={...Widget.defaultProps,id:"theme",placement:"top-left",viewId:null,lightModeLabel:"Light Mode",lightModeTheme:{"--widget-margin":"12px","--button-size":"28px","--button-corner-radius":"8px","--button-background":"rgba(255, 255, 255, 0.6)","--button-stroke":"rgba(255, 255, 255, 0.3)","--button-inner-stroke":"1px solid rgba(255, 255, 255, 0.6)","--button-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset","--button-backdrop-filter":"blur(4px)","--button-icon-idle":"rgba(97, 97, 102, 1)","--button-icon-hover":"rgba(24, 24, 26, 1)","--button-text":"rgb(24, 24, 26, 1)","--icon-compass-north-color":"rgb(240, 92, 68)","--icon-compass-south-color":"rgb(204, 204, 204)","--menu-gap":"4px","--menu-background":"rgba(255, 255, 255, 0.6)","--menu-backdrop-filter":"blur(4px)","--menu-border":"1px solid rgba(255, 255, 255, 0.6)","--menu-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset","--menu-text":"rgb(24, 24, 26, 1)","--menu-item-hover":"rgba(0, 0, 0, 0.08)","--range-step-button-size":"24px","--range-track-size":"16px","--range-thumb-size":"10px","--range-track-color":"rgba(215, 214, 229, 0.3)","--range-thumb-color":"rgba(97, 97, 102, 1)","--range-decoration-active-color":"rgba(255, 215, 0, 0.6)"},darkModeLabel:"Dark Mode",darkModeTheme:{"--widget-margin":"12px","--button-size":"28px","--button-corner-radius":"8px","--button-background":"rgba(18, 18, 20, 0.75)","--button-stroke":"rgba(18, 18, 20, 0.30)","--button-inner-stroke":"1px solid rgba(18, 18, 20, 0.75)","--button-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset","--button-backdrop-filter":"blur(4px)","--button-icon-idle":"rgba(158, 157, 168, 1)","--button-icon-hover":"rgba(215, 214, 229, 1)","--button-text":"rgb(215, 214, 229, 1)","--icon-compass-north-color":"rgb(240, 92, 68)","--icon-compass-south-color":"rgb(200, 199, 209)","--menu-gap":"4px","--menu-background":"rgba(18, 18, 20, 0.75)","--menu-backdrop-filter":"blur(4px)","--menu-border":"1px solid rgba(18, 18, 20, 0.75)","--menu-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset","--menu-text":"rgb(215, 214, 229, 1)","--menu-item-hover":"rgba(255, 255, 255, 0.1)","--range-step-button-size":"24px","--range-track-size":"16px","--range-thumb-size":"10px","--range-track-color":"rgba(24, 24, 26, 0.3)","--range-thumb-color":"rgba(158, 157, 168, 1)","--range-decoration-active-color":"rgba(255, 145, 0, 0.6)"},initialThemeMode:"auto",themeMode:void 0,onThemeModeChange:()=>{}};class LoadingWidget extends Widget{constructor(e={}){super(e),this.className="deck-widget-loading",this.placement="top-left",this.loading=!0,this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){LB(this.loading&&OB(cN,{className:"deck-widget-spinner",label:this.props.label,onClick:this.handleClick.bind(this)}),e)}onRedraw({layers:e}){const t=e.some(e=>!e.isLoaded);t!==this.loading&&(this.loading=t,this.props.onLoadingChange?.(t),this.updateHTML())}handleClick(){}}LoadingWidget.defaultProps={...Widget.defaultProps,id:"loading",placement:"top-left",viewId:null,label:"Loading layer data",onLoadingChange:()=>{}};const tF=e=>`${e.name}: ${e.count}`;function nF(e){return e<1e3?`${e.toFixed(2)}ms`:`${(e/1e3).toFixed(2)}s`}function iF(e){return`${(e/1e6).toFixed(1)} MB`}const rF={count:tF,averageTime:e=>`${e.name}: ${nF(e.getAverageTime())}`,totalTime:e=>`${e.name}: ${nF(e.time)}`,fps:e=>`${e.name}: ${Math.round(e.getHz())}fps`,memory:e=>`${e.name}: ${iF(e.count)}`};class StatsWidget extends Widget{getExpanded(){return this.props.expanded??this._expanded}constructor(e={}){super(e),this.className="deck-widget-stats",this.placement="top-left",this._counter=0,this._expanded=!1,this._toggleExpanded=()=>{const e=!this.getExpanded();this.props.onExpandedChange?.(e),void 0===this.props.expanded&&(this._expanded=e,this.updateHTML())},this._getFps=()=>Math.round(this.deck?.metrics.fps??0),this._formatters={...rF},this._resetOnUpdate={...this.props.resetOnUpdate},this._expanded=Boolean(e.initialExpanded),this.setProps(e)}setProps(e){if(this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,e.formatters)for(const t in e.formatters){const n=e.formatters[t];this._formatters[t]="string"==typeof n?rF[n]||tF:n}e.resetOnUpdate&&(this._resetOnUpdate={...e.resetOnUpdate}),super.setProps(e)}onRemove(){this.rootElement&&LB(null,this.rootElement)}onRenderHTML(e){if(!this.getExpanded())return void LB(OB(sF,{getFps:this._getFps,onClick:this._toggleExpanded}),e);const t=this._getStats(),n=this.props.title||("id"in t?t.id:null)||"Stats",i=this._getDeviceLabel(),r=[];t&&t.forEach(e=>{const t=this._getLines(e).split("\n");this._resetOnUpdate&&this._resetOnUpdate[e.name]&&e.reset(),t.forEach((t,n)=>{r.push(OB("div",{style:{whiteSpace:"pre"},children:t},`${e.name}-${n}`))})}),LB(OB("div",{className:"deck-widget-stats-container",style:{cursor:"default"},children:[OB("div",{className:"deck-widget-stats-header",style:{cursor:"pointer",pointerEvents:"auto"},onClick:this._toggleExpanded,children:[OB("b",{children:n}),i&&OB("span",{className:"deck-widget-stats-device",children:i}),OB("button",{className:"deck-widget-dropdown-button",children:OB("span",{className:"deck-widget-dropdown-icon open"})})]}),OB("div",{className:"deck-widget-stats-content",children:r})]}),e)}onRedraw(){if(this.getExpanded()){const e=Math.max(1,this.props.framesPerUpdate||1);this._counter++%e===0&&this.updateHTML()}}_getStats(){switch(this.props.type){case"deck":const e=this.deck?.metrics??{};return Object.entries(e);case"luma":return Array.from(qi.stats.stats.values())[0];case"device":const t=this.deck?.device,n=t?.statsManager.stats.values();return n?Array.from(n)[0]:[];case"custom":return this.props.stats;default:throw new Error(`Unknown stats type: ${this.props.type}`)}}_getDeviceLabel(){const e=this.deck?.device?.type;if(!e)return null;switch(e){case"webgpu":return"WebGPU";case"webgl":return"WebGL";default:return String(e)}}_getLines(e){if("count"in e){return(this._formatters[e.name]||this._formatters[e.type||""]||tF)(e)}const[t,n]=e,i=t.endsWith("Memory")?iF(n):t.includes("Time")?nF(n):`${n.toFixed(2)}`;return`${t}: ${i}`}}function sF({getFps:e,onClick:t}){const[n,i]=XB(e());return $B(()=>{const t=()=>{i(e()),n=requestAnimationFrame(t)};let n=requestAnimationFrame(t);return()=>{cancelAnimationFrame(n)}},[e]),OB(cN,{onClick:t,children:OB("div",{className:"text",children:["FPS",OB("br",{}),n]})})}StatsWidget.defaultProps={...Widget.defaultProps,type:"deck",placement:"top-left",viewId:null,initialExpanded:!1,stats:void 0,title:"Stats",framesPerUpdate:1,formatters:{},resetOnUpdate:{},id:"stats",expanded:void 0,onExpandedChange:()=>{}}}}]);
|
|
1
|
+
"use strict";(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([[489],{88361(e,t,s){s.r(t),s.d(t,{BitmapLayer:()=>i.A,CollisionFilteredTextLayer:()=>CollisionFilteredTextLayer,Deck:()=>l.A,FlyToInterpolator:()=>f.A,GeoJsonLayer:()=>p.A,LinearInterpolator:()=>d.A,MVTBasemapLayer:()=>MVTBasemapLayer,MapView:()=>u.A,OrthographicView:()=>h.A,PathLayer:()=>a.A,TileLayer:()=>n.A,WebMercatorViewport:()=>c.A,_Tileset2D:()=>o.TL,load:()=>r.H,updateLabelCollisions:()=>T});var r=s(22662),o=s(86772),i=s(83362),n=s(52337),a=s(56802),p=s(40618),l=s(33517),c=s(69502),u=s(75524),h=s(6299),d=s(70053),f=s(73281),y=s(91111),g=s(87590);const M=([e=0,t=0],s,r,o,i=0)=>{const n=i*Math.PI/180,a=Math.abs(Math.cos(n)),p=Math.abs(Math.sin(n)),l=(s*a+r*p)/2+4,c=(s*p+r*a)/2+4;if(!(e+l<0||e-l>o.width||t+c<0||t-c>o.height))return{left:e-l,right:e+l,top:t-c,bottom:t+c}},m=(e,t,s,r,o)=>{if(s.zoom<12)return;const{geometry:i}=e,n="LineString"===i.type?[i.coordinates]:"MultiLineString"===i.type?i.coordinates:[];let a;for(const i of n){const n=i.map(e=>({position:e,screen:t(e)}));let p=[];const l=()=>{const i=p.at(0),n=p.at(-1);if(!i||!n)return;const[l=0,c=0]=i.screen,[u=0,h=0]=n.screen,d=b(i.screen,n.screen,s);if(!d)return;const[f,y]=d,g=Math.hypot(u-l,h-c)*(y-f);if(g<r+8||g<=(a?.length??0))return;const m=(f+y)/2,x=i.position.map((e,t)=>e+((n.position[t]??e)-e)*m),[L=0,P=0]=x;if(L<0||L>=1||P<0||P>=1)return;let z=180*Math.atan2(c-h,u-l)/Math.PI;z>90&&(z-=180),z<-90&&(z+=180),M(t(x),r,1.2*o,s,z)&&(a={length:g,feature:{...e,geometry:{type:"Point",coordinates:x},properties:{...e.properties,labelAngle:z}}})};for(const e of n){const t=p.at(0),s=p.at(-1);if(t&&s){const[r=0,i=0]=t.screen,[n=0,a=0]=e.screen,c=n-r,u=a-i,h=Math.hypot(c,u);(!h||p.some(({screen:[e=0,t=0]})=>{const s=((e-r)*c+(t-i)*u)/h,n=Math.abs((e-r)*u-(t-i)*c)/h;return s<0||s>h||n>o/3}))&&(l(),p=[s])}p.push(e)}l()}return a?.feature},b=(e,t,s)=>{let r=0,o=1;for(const[i,n]of[s.width,s.height].entries()){const s=e[i]??0,a=(t[i]??0)-s;if(!a){if(s<0||s>n)return;continue}const p=-s/a,l=(n-s)/a;if(r=Math.max(r,Math.min(p,l)),o=Math.min(o,Math.max(p,l)),r>=o)return}return[r,o]};class MVTBasemapLayer extends y.A{static layerName="MVTBasemapLayer";renderLayers(){super.renderLayers();const{viewport:e}=this.context,{tileset:t}=this.state,s=[],r=[],o=[];for(const i of t?.tiles??[])for(const t of i.layers??[]){if(!t.id.endsWith("-labels")){r.push(t);continue}if(!i.isVisible)continue;s.push(t);const n=t=>z(t,i.index,e);for(const s of t.props.data){const r=(0,g.q4)(s);if(!r)continue;const i=(0,g.xY)(s),a=P(r)*i,p="Point"===s.geometry.type?s:m(s,n,e,a,i);if("Point"!==p?.geometry.type)continue;const l=M(n(p.geometry.coordinates),a,1.2*i,e,Number(p.properties?.labelAngle??0));l&&o.push({layerId:t.id,feature:p,bounds:l,size:i,text:r})}}o.sort((e,t)=>t.size-e.size||Number(t.feature.properties?.population??0)-Number(e.feature.properties?.population??0)||e.text.localeCompare(t.text)||e.bounds.left-t.bounds.left||e.bounds.top-t.bounds.top);const i=new Map;for(const{layerId:e,feature:t}of o){const s=i.get(e)??[];s.push(t),i.set(e,s)}return[r,s.map(e=>{const t=i.get(e.id)??[];return e.clone({data:t,_subLayerProps:{...e.props._subLayerProps,"points-text":{...e.props._subLayerProps?.["points-text"],getCollisionPriority:(e,{index:s})=>Number(t[s]?.properties?.population??0)}}})})]}}const x=document.createElement("canvas").getContext("2d");x.font=`${g.ts.weight} 64px ${g.ts.family}`;const L=new Map,P=e=>Array.from(e).reduce((e,t)=>{let s=L.get(t);return void 0===s&&(s=x.measureText(t).width/64,L.set(t,s)),e+s},0),z=(e,t,s)=>{const[r=0,o=0]=e,i=(t.x+r)/2**t.z*360-180,n=180*Math.atan(Math.sinh(Math.PI*(1-2*(t.y+o)/2**t.z)))/Math.PI;return s.project([i,n])};var w=s(65981);class CollisionFilteredTextLayer extends w.A{static layerName="CollisionFilteredTextLayer";static defaultProps={...w.A.defaultProps,collisionPriority:1,getCollisionPriority:{type:"accessor",value:0}};initializeState(){super.initializeState();const{deck:e,layerManager:t}=this.context;e&&C.set(e,t)}shouldUpdateState({changeFlags:e}){return e.somethingChanged}getLabelCandidates(){if(!this.props.visible)return[];const[e]=super.renderLayers();if(!e)return[];const{getBoundingRect:t,fontSize:s}=e.props,{viewport:r}=this.context,{getSize:o,getPosition:i,getAngle:n,getPixelOffset:a,sizeScale:p,sizeMinPixels:l,sizeMaxPixels:c}=this.props,u=this.props.data,h=[];return u.forEach((e,d)=>{const f={index:d,data:u,target:[]};if(!this.props.getText(e,f))return;const y=Math.max(l,Math.min(c,V(o,e,f)*p)),g=y/s,[m,b,x,L]=V(t,e,f),P=V(n,e,f),z=-P*Math.PI/180,w=(m+x/2)*g,T=(b+L/2)*g,[A,C]=V(a,e,f),[S=0,v=0]=this.project(Array.from(V(i,e,f))),I=M([S+A+w*Math.cos(z)-T*Math.sin(z),v+C+w*Math.sin(z)+T*Math.cos(z)],x*g,L*g,r,P);I&&h.push({layer:this,index:d,size:y,bounds:I,priority:V(this.props.getCollisionPriority,e,f)})}),h}setVisibleLabels(e){const t=A.get(this.state);t?.size===e.size&&[...e].every(([e,s])=>t.get(e)===s)||(A.set(this.state,e),this.setNeedsUpdate())}renderLayers(){const[,e]=super.renderLayers();if(!e)return[];const t=A.get(this.state);return[e.clone({getSize:(e,{index:s})=>t?.get(s)??0,sizeScale:1,sizeMinPixels:0,updateTriggers:{...e.props.updateTriggers,getSize:[t]}})]}}const T=e=>{const t=C.get(e),[s]=e.getViewports();if(!t||!s)return;for(const e of t.getLayers())e.activateViewport(s);t.updateLayers();const r=t.getLayers().filter(e=>e instanceof CollisionFilteredTextLayer),o=r.flatMap(e=>e.getLabelCandidates());o.sort((e,t)=>t.layer.props.collisionPriority-e.layer.props.collisionPriority||t.size-e.size||t.priority-e.priority);const i=new Map;for(const{layer:e,index:t,size:s}of(e=>{const t=[];return e.filter(({bounds:e})=>!t.some(t=>e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top)&&(t.push(e),!0))})(o)){const r=i.get(e)??new Map;r.set(t,s),i.set(e,r)}for(const e of r)e.setVisibleLabels(i.get(e)??new Map);t.updateLayers()},A=new WeakMap,C=new WeakMap,V=(e,t,s)=>"function"==typeof e?e(t,s):e}}]);
|