{"version":3,"sources":["src/app/components/notification/notification.component.ts","src/app/components/notification/notification.component.html","src/app/constants/time.const.ts","node_modules/uuid/dist/esm-browser/stringify.js","node_modules/uuid/dist/esm-browser/rng.js","node_modules/uuid/dist/esm-browser/native.js","node_modules/uuid/dist/esm-browser/v4.js","src/app/components/notification/notification.service.ts"],"sourcesContent":["/**\n * Copyright (c) 2020-2024 by Bosch.IO GmbH\n *\n * http://www.bosch.io\n * All rights reserved,\n * also regarding any disposal, exploitation, reproduction,\n * editing, distribution, as well as in the event of\n * applications for industrial property rights.\n *\n * This software is the confidential and proprietary information\n * of Bosch.IO GmbH. You shall not disclose\n * such Confidential Information and shall use it only in\n * accordance with the terms of the license agreement you\n * entered into with Bosch.IO.\n */\nimport { Component, computed } from '@angular/core';\nimport { INotificationInfoExtended } from '@components/notification/notification.service';\nimport { AppStateService } from '@services/index';\n\nexport enum NotificationType {\n SUCCESS = '-success',\n ERROR = '-error',\n INFO = '-neutral',\n WARNING = '-warning',\n}\n@Component({\n selector: 'nal3d-notification',\n standalone: true,\n imports: [],\n templateUrl: './notification.component.html',\n styleUrl: './notification.component.scss',\n})\nexport class NotificationComponent {\n NotificationType = NotificationType;\n notifications = computed(() => this.appStateService.notifications());\n constructor(private appStateService: AppStateService) {}\n\n removeNotification(notification: INotificationInfoExtended) {\n const notifications = this.notifications().filter(\n (n) => n.id !== notification.id,\n );\n\n this.appStateService.notifications.set(notifications);\n }\n}\n","
\n @for (notification of notifications(); track notification.id) {\n \n \n
\n {{ notification.message }}\n
\n \n
\n }\n\n","/**\n * Copyright (c) 2020-2024 by Bosch.IO GmbH\n *\n * http://www.bosch.io\n * All rights reserved,\n * also regarding any disposal, exploitation, reproduction,\n * editing, distribution, as well as in the event of\n * applications for industrial property rights.\n *\n * This software is the confidential and proprietary information\n * of Bosch.IO GmbH. You shall not disclose\n * such Confidential Information and shall use it only in\n * accordance with the terms of the license agreement you\n * entered into with Bosch.IO.\n */\nexport const DEFAULT_NOTIFICATION_DISMISS_TIME_MS = 5000;\n","import validate from './validate.js';\n\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\nvar byteToHex = [];\nfor (var i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n //\n // Note to future-self: No, you can't remove the `toLowerCase()` call.\n // REF: https://github.com/uuidjs/uuid/pull/677#issuecomment-1757351351\n return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();\n}\nfunction stringify(arr, offset = 0) {\n var uuid = unsafeStringify(arr, offset);\n // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n return uuid;\n}\nexport default stringify;","// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\n\nvar getRandomValues;\nvar rnds8 = new Uint8Array(16);\nexport default function rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n return getRandomValues(rnds8);\n}","var randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default {\n randomUUID\n};","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n options = options || {};\n var rnds = options.random || (options.rng || rng)();\n\n // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80;\n\n // Copy bytes to buffer, if provided\n if (buf) {\n offset = offset || 0;\n for (var i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n return buf;\n }\n return unsafeStringify(rnds);\n}\nexport default v4;","/**\n * Copyright (c) 2020-2024 by Bosch.IO GmbH\n *\n * http://www.bosch.io\n * All rights reserved,\n * also regarding any disposal, exploitation, reproduction,\n * editing, distribution, as well as in the event of\n * applications for industrial property rights.\n *\n * This software is the confidential and proprietary information\n * of Bosch.IO GmbH. You shall not disclose\n * such Confidential Information and shall use it only in\n * accordance with the terms of the license agreement you\n * entered into with Bosch.IO.\n */\nimport { computed, Injectable, SecurityContext } from '@angular/core';\nimport { DomSanitizer } from '@angular/platform-browser';\nimport { NotificationType } from '@components/notification/notification.component';\nimport { DEFAULT_NOTIFICATION_DISMISS_TIME_MS } from '@constants/time.const';\nimport { AppStateService } from '@services/app-state.service';\nimport { v4 as uuidV4 } from 'uuid';\nexport interface INotificationInfo {\n type: NotificationType;\n message: string;\n messageIsHTML?: false;\n}\n\nexport interface INotificationInfoExtended extends INotificationInfo {\n id: string;\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class NotificationService {\n notifications = computed(() => this.appStateService.notifications());\n constructor(\n private appStateService: AppStateService,\n private domSanitizer: DomSanitizer,\n ) {}\n\n /**\n * Displays a notification message and adds it to the list of active notifications.\n *\n * @param messageInfo - Information about the message to display.\n * @param customDismissTime - (Optional) Custom dismissal time for the notification.\n */\n showNotification({\n messageInfo,\n customDismissTime,\n }: {\n messageInfo: INotificationInfo;\n customDismissTime?: number;\n }) {\n // Generate a unique ID for the notification.\n const id = uuidV4();\n\n // Get the current list of notifications.\n const currentNotifications = this.notifications();\n\n // Clone the message to prevent modification of the original.\n const modifiedMessage = { ...messageInfo };\n\n // If the message contains HTML, sanitize it to prevent XSS attacks.\n if (modifiedMessage.messageIsHTML) {\n modifiedMessage.message = this.domSanitizer.sanitize(\n SecurityContext.HTML,\n modifiedMessage.message,\n ) as string;\n }\n\n // Create a new list of notifications with the new notification added.\n const newNotificationList = [\n ...currentNotifications.slice(),\n { ...modifiedMessage, id },\n ];\n\n // Update the observable with the new list of notifications.\n this.updateNotificationList(newNotificationList);\n\n // Start a timer to dismiss the notification after a set time.\n this.startNotificationDismissTimer(id, customDismissTime);\n }\n\n /**\n * Starts a timer to dismiss a notification after a specified time.\n *\n * @param id - The ID of the notification to dismiss.\n * @param customDismissTime - (Optional) Custom dismissal time for the notification.\n */\n private startNotificationDismissTimer(\n id: string,\n customDismissTime?: number,\n ) {\n // Set a timeout to remove the notification from the list after the specified time.\n const timeout = setTimeout(() => {\n const currentNotifications = this.notifications();\n // Filter out the notification with the specified ID.\n const filteredNotifications = currentNotifications.filter(\n (n) => n.id !== id,\n );\n // Update the observable with the filtered list, effectively dismissing the notification.\n this.updateNotificationList(filteredNotifications);\n // Clear the timeout to prevent any further dismissal attempts.\n clearTimeout(timeout);\n }, customDismissTime || DEFAULT_NOTIFICATION_DISMISS_TIME_MS);\n }\n\n updateNotificationList(notifications: INotificationInfoExtended[]) {\n this.appStateService.notifications.set(notifications);\n }\n\n showError(message: string) {\n this.showNotification({\n messageInfo: {\n message,\n type: NotificationType.ERROR,\n },\n });\n }\n\n showSuccess(message: string) {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