NavigateAndOrderIpadMiniTask

        short_description: str
            A short description of the task to be completed. "Order an iPad Pro"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Self-Service",
                "module": "Service Catalog",
            },
            level=level,
            task=OrderIpadProTask(
                seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True
            ),
        )
        self.task_description = "Order an iPad Pro from the service catalog with the required configuration if applicable. \n"
        self.short_description = "Order an iPad Pro from the service catalog"

class NavigateAndOrderIpadMiniTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Navigate to the service catalog item list page and order an iPad Mini.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Order an iPad Mini"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Self-Service",
                "module": "Service Catalog",
            },
            level=level,
            task=OrderIpadMiniTask(
                seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True
            ),
        )
        self.task_description = "Order an iPad Mini from the service catalog with the required configuration if applicable. \n"
        self.short_description = "Order an iPad Mini from the service catalog"

class NavigateAndOrderAppleWatchTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Navigate to the service catalog item list page and order an Apple Watch.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Order an Apple Watch"
        """


NavigateAndOrderAppleWatchTask

        short_description: str
            A short description of the task to be completed. "Order an iPad Mini"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Self-Service",
                "module": "Service Catalog",
            },
            level=level,
            task=OrderIpadMiniTask(
                seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True
            ),
        )
        self.task_description = "Order an iPad Mini from the service catalog with the required configuration if applicable. \n"
        self.short_description = "Order an iPad Mini from the service catalog"

class NavigateAndOrderAppleWatchTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Navigate to the service catalog item list page and order an Apple Watch.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Order an Apple Watch"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Self-Service",
                "module": "Service Catalog",
            },
            level=level,
            task=OrderAppleWatchTask(
                seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True
            ),
        )
        self.task_description = "Order an Apple Watch from the service catalog with the required configuration if applicable. \n"
        self.short_description = "Order an Apple Watch from the service catalog"

class NavigateAndOrderAppleMacBookPro15Task(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Navigate to the service catalog item list page and order an Apple MacBook Pro 15".

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Order an Apple MacBook Pro 15"
        """


        short_description: str
            A short description of the task to be completed. "Order an Apple Watch"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Self-Service",
                "module": "Service Catalog",
            },
            level=level,
            task=OrderAppleWatchTask(
                seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True
            ),
        )
        self.task_description = "Order an Apple Watch from the service catalog with the required configuration if applicable. \n"
        self.short_description = "Order an Apple Watch from the service catalog"

class NavigateAndOrderAppleMacBookPro15Task(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Navigate to the service catalog item list page and order an Apple MacBook Pro 15".

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Order an Apple MacBook Pro 15"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Self-Service",
                "module": "Service Catalog",
            },
            level=level,
            task=OrderAppleMacBookPro15Task(
                seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True
            ),
        )
        self.task_description = 'Order an Apple MacBook Pro 15" from the service catalog with the required configuration if applicable. \n'
        self.short_description = 'Order an Apple MacBook Pro 15" from the service catalog'

class NavigateAndOrderDevelopmentLaptopPCTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Navigate to the service catalog item list page and order a development laptop PC.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Order a development laptop PC"
        """


NavigateAndOrderDevelopmentLaptopPCTask

        short_description: str
            A short description of the task to be completed. "Order an Apple MacBook Pro 15"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Self-Service",
                "module": "Service Catalog",
            },
            level=level,
            task=OrderAppleMacBookPro15Task(
                seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True
            ),
        )
        self.task_description = 'Order an Apple MacBook Pro 15" from the service catalog with the required configuration if applicable. \n'
        self.short_description = 'Order an Apple MacBook Pro 15" from the service catalog'

class NavigateAndOrderDevelopmentLaptopPCTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Navigate to the service catalog item list page and order a development laptop PC.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Order a development laptop PC"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Self-Service",
                "module": "Service Catalog",
            },
            level=level,
            task=OrderDevelopmentLaptopPCTask(
                seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True
            ),
        )
        self.task_description = "Order a development laptop PC from the service catalog with the required configuration if applicable. \n"
        self.short_description = "Order a development laptop PC from the service catalog"

class NavigateAndOrderLoanerLaptopTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Navigate to the service catalog item list page and order a loaner laptop.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Order a loaner laptop"
        """


NavigateAndOrderLoanerLaptopTask

        short_description: str
            A short description of the task to be completed. "Order a development laptop PC"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Self-Service",
                "module": "Service Catalog",
            },
            level=level,
            task=OrderDevelopmentLaptopPCTask(
                seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True
            ),
        )
        self.task_description = "Order a development laptop PC from the service catalog with the required configuration if applicable. \n"
        self.short_description = "Order a development laptop PC from the service catalog"

class NavigateAndOrderLoanerLaptopTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Navigate to the service catalog item list page and order a loaner laptop.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Order a loaner laptop"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Self-Service",
                "module": "Service Catalog",
            },
            level=level,
            task=OrderLoanerLaptopTask(
                seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True
            ),
        )
        self.task_description = "Order a loaner laptop from the service catalog with the required configuration if applicable. \n"
        self.short_description = "Order a loaner laptop from the service catalog"

class NavigateAndFilterAssetListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "alm_asset",
    ) -> None:
        """
        Navigate to the user list page and filter the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Filter the asset list"


NavigateAndFilterAssetListTask

        short_description: str
            A short description of the task to be completed. "Order a loaner laptop"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Self-Service",
                "module": "Service Catalog",
            },
            level=level,
            task=OrderLoanerLaptopTask(
                seed=seed, instance=instance, used_in_level_2=(level == 2), is_validated=True
            ),
        )
        self.task_description = "Order a loaner laptop from the service catalog with the required configuration if applicable. \n"
        self.short_description = "Order a loaner laptop from the service catalog"

class NavigateAndFilterAssetListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "alm_asset",
    ) -> None:
        """
        Navigate to the user list page and filter the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Filter the asset list"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Asset",
                "module": "Portfolios > All Assets",
            },
            level=level,
            task=FilterAssetListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Filter the asset list - in Asset > Portflios > All Assets - based on specific criteria. \n"
        self.short_description = "Filter the asset list."
        self.list_name = list_name

class NavigateAndFilterUserListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "user",
    ) -> None:
        """
        Navigate to the user list page and filter the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Filter the user list"


NavigateAndFilterUserListTask

            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Asset",
                "module": "Portfolios > All Assets",
            },
            level=level,
            task=FilterAssetListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Filter the asset list - in Asset > Portflios > All Assets - based on specific criteria. \n"
        self.short_description = "Filter the asset list."
        self.list_name = list_name

class NavigateAndFilterUserListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "user",
    ) -> None:
        """
        Navigate to the user list page and filter the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Filter the user list"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Organization",
                "module": "Users",
            },
            level=level,
            task=FilterUserListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Filter the user list based on specific criteria. \n"
        self.short_description = "Filter the user list."
        self.list_name = list_name

class NavigateAndFilterIncidentListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "incident",
    ) -> None:
        """
        Navigate to the incident list page and filter the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Filter the incident list"


NavigateAndFilterIncidentListTask

            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Organization",
                "module": "Users",
            },
            level=level,
            task=FilterUserListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Filter the user list based on specific criteria. \n"
        self.short_description = "Filter the user list."
        self.list_name = list_name

class NavigateAndFilterIncidentListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "incident",
    ) -> None:
        """
        Navigate to the incident list page and filter the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Filter the incident list"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Service Desk",
                "module": "Incidents",
            },
            level=level,
            task=FilterIncidentListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Filter the incident list based on specific criteria. \n"
        self.short_description = "Filter the incident list."
        self.list_name = list_name

class NavigateAndFilterChangeRequestListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "change_request",
    ) -> None:
        """
        Navigate to the change request list page and filter the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Filter the change request list"


NavigateAndFilterChangeRequestListTask

            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Service Desk",
                "module": "Incidents",
            },
            level=level,
            task=FilterIncidentListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Filter the incident list based on specific criteria. \n"
        self.short_description = "Filter the incident list."
        self.list_name = list_name

class NavigateAndFilterChangeRequestListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "change_request",
    ) -> None:
        """
        Navigate to the change request list page and filter the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Filter the change request list"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Change",
                "module": "All",
            },
            level=level,
            task=FilterChangeRequestListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Filter the change request list based on specific criteria. \n"
        self.short_description = "Filter the change request list."
        self.list_name = list_name

class NavigateAndFilterHardwareListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "hardware_asset",
    ) -> None:
        """
        Navigate to the hardware asset list page and filter the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Filter the hardware asset list"


NavigateAndFilterHardwareListTask

            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Change",
                "module": "All",
            },
            level=level,
            task=FilterChangeRequestListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Filter the change request list based on specific criteria. \n"
        self.short_description = "Filter the change request list."
        self.list_name = list_name

class NavigateAndFilterHardwareListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "hardware_asset",
    ) -> None:
        """
        Navigate to the hardware asset list page and filter the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Filter the hardware asset list"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Asset",
                "module": "Portfolios > Hardware Assets",
            },
            level=level,
            task=FilterHardwareListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Filter the hardware asset list based on specific criteria. \n"
        self.short_description = "Filter the hardware asset list."
        self.list_name = list_name

class NavigateAndFilterServiceCatalogItemListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "service_catalog_item",
    ) -> None:
        """
        Navigate to the service catalog item list page and filter the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Filter the service catalog item list"


            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Asset",
                "module": "Portfolios > Hardware Assets",
            },
            level=level,
            task=FilterHardwareListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Filter the hardware asset list based on specific criteria. \n"
        self.short_description = "Filter the hardware asset list."
        self.list_name = list_name

class NavigateAndFilterServiceCatalogItemListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "service_catalog_item",
    ) -> None:
        """
        Navigate to the service catalog item list page and filter the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Filter the service catalog item list"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Service Catalog",
                "module": "Catalog Definitions > Maintain Items",
            },
            level=level,
            task=FilterServiceCatalogItemListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = (
            "Filter the service catalog item list based on specific criteria. \n"
        )
        self.short_description = "Filter the service catalog item list."
        self.list_name = list_name

class NavigateAndSortAssetListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "alm_asset",
    ) -> None:
        """
        Navigate to the user list page and sort the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Sort the asset list"


NavigateAndSortAssetListTask

            navigation_config={
                "application": "Service Catalog",
                "module": "Catalog Definitions > Maintain Items",
            },
            level=level,
            task=FilterServiceCatalogItemListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = (
            "Filter the service catalog item list based on specific criteria. \n"
        )
        self.short_description = "Filter the service catalog item list."
        self.list_name = list_name

class NavigateAndSortAssetListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "alm_asset",
    ) -> None:
        """
        Navigate to the user list page and sort the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Sort the asset list"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Asset",
                "module": "Portfolios > All Assets",
            },
            level=level,
            task=SortAssetListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Sort the asset list - in Asset > Portflios > All Assets - based on specific criteria. \n"
        self.short_description = "Sort the asset list."
        self.list_name = list_name

class NavigateAndSortUserListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "user",
    ) -> None:
        """
        Navigate to the user list page and sort the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Sort the user list"


NavigateAndSortUserListTask

            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Asset",
                "module": "Portfolios > All Assets",
            },
            level=level,
            task=SortAssetListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Sort the asset list - in Asset > Portflios > All Assets - based on specific criteria. \n"
        self.short_description = "Sort the asset list."
        self.list_name = list_name

class NavigateAndSortUserListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "user",
    ) -> None:
        """
        Navigate to the user list page and sort the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Sort the user list"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Organization",
                "module": "Users",
            },
            level=level,
            task=SortUserListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Sort the user list based on specific criteria. \n"
        self.short_description = "Sort the user list."
        self.list_name = list_name

class NavigateAndSortIncidentListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "incident",
    ) -> None:
        """
        Navigate to the incident list page and sort the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Sort the incident list"


NavigateAndSortIncidentListTask

            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Organization",
                "module": "Users",
            },
            level=level,
            task=SortUserListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Sort the user list based on specific criteria. \n"
        self.short_description = "Sort the user list."
        self.list_name = list_name

class NavigateAndSortIncidentListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "incident",
    ) -> None:
        """
        Navigate to the incident list page and sort the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Sort the incident list"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Service Desk",
                "module": "Incidents",
            },
            level=level,
            task=SortIncidentListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Sort the incident list based on specific criteria. \n"
        self.short_description = "Sort the incident list."
        self.list_name = list_name

class NavigateAndSortChangeRequestListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "change_request",
    ) -> None:
        """
        Navigate to the change request list page and sort the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Sort the change request list"


NavigateAndSortChangeRequestListTask

            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Service Desk",
                "module": "Incidents",
            },
            level=level,
            task=SortIncidentListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Sort the incident list based on specific criteria. \n"
        self.short_description = "Sort the incident list."
        self.list_name = list_name

class NavigateAndSortChangeRequestListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "change_request",
    ) -> None:
        """
        Navigate to the change request list page and sort the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Sort the change request list"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Change",
                "module": "All",
            },
            level=level,
            task=SortChangeRequestListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Sort the change request list based on specific criteria. \n"
        self.short_description = "Sort the change request list."
        self.list_name = list_name

class NavigateAndSortHardwareListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "hardware_asset",
    ) -> None:
        """
        Navigate to the hardware asset list page and sort the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Sort the hardware asset list"


NavigateAndSortHardwareListTask

            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Change",
                "module": "All",
            },
            level=level,
            task=SortChangeRequestListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Sort the change request list based on specific criteria. \n"
        self.short_description = "Sort the change request list."
        self.list_name = list_name

class NavigateAndSortHardwareListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "hardware_asset",
    ) -> None:
        """
        Navigate to the hardware asset list page and sort the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Sort the hardware asset list"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Asset",
                "module": "Portfolios > Hardware Assets",
            },
            level=level,
            task=SortHardwareListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Sort the hardware asset list based on specific criteria. \n"
        self.short_description = "Sort the hardware asset list."
        self.list_name = list_name

class NavigateAndSortServiceCatalogItemListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "service_catalog_item",
    ) -> None:
        """
        Navigate to the service catalog item list page and sort the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Sort the service catalog item list"


            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Asset",
                "module": "Portfolios > Hardware Assets",
            },
            level=level,
            task=SortHardwareListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Sort the hardware asset list based on specific criteria. \n"
        self.short_description = "Sort the hardware asset list."
        self.list_name = list_name

class NavigateAndSortServiceCatalogItemListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "service_catalog_item",
    ) -> None:
        """
        Navigate to the service catalog item list page and sort the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Sort the service catalog item list"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Service Catalog",
                "module": "Catalog Definitions > Maintain Items",
            },
            level=level,
            task=SortServiceCatalogItemListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Sort the service catalog item list based on specific criteria. \n"
        self.short_description = "Sort the service catalog item list."
        self.list_name = list_name

local_vars = locals().copy()

__TASKS__ = [
    var
    for var in local_vars.values()
    if isinstance(var, type) and issubclass(var, NavigateAndDoTask) and var is not NavigateAndDoTask
]

NAVIGATE_AND_CREATE_TASKS = [
    NavigateAndCreateUserTask,
    NavigateAndCreateIncidentTask,
    NavigateAndCreateChangeRequestTask,
    NavigateAndCreateProblemTask,
    NavigateAndCreateHardwareAssetTask,
]
NAVIGATE_AND_ORDER_TASKS = [
    NavigateAndOrderStandardLaptopTask,
    NavigateAndOrderSalesLaptopTask,


            fixed_config=fixed_config,
            navigation_config={
                "application": "Asset",
                "module": "Portfolios > Hardware Assets",
            },
            level=level,
            task=SortHardwareListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Sort the hardware asset list based on specific criteria. \n"
        self.short_description = "Sort the hardware asset list."
        self.list_name = list_name

class NavigateAndSortServiceCatalogItemListTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        list_name: str = "service_catalog_item",
    ) -> None:
        """
        Navigate to the service catalog item list page and sort the list based on a specific criteria.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Sort the service catalog item list"
        """
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "application": "Service Catalog",
                "module": "Catalog Definitions > Maintain Items",
            },
            level=level,
            task=SortServiceCatalogItemListTask(
                seed=seed,
                instance=instance,
                used_in_level_2=(level == 2),
                is_validated=True,
                list_name=list_name,
            ),
        )
        self.task_description = "Sort the service catalog item list based on specific criteria. \n"
        self.short_description = "Sort the service catalog item list."
        self.list_name = list_name

local_vars = locals().copy()

__TASKS__ = [
    var
    for var in local_vars.values()
    if isinstance(var, type) and issubclass(var, NavigateAndDoTask) and var is not NavigateAndDoTask
]

NAVIGATE_AND_CREATE_TASKS = [
    NavigateAndCreateUserTask,
    NavigateAndCreateIncidentTask,
    NavigateAndCreateChangeRequestTask,
    NavigateAndCreateProblemTask,
    NavigateAndCreateHardwareAssetTask,
]
NAVIGATE_AND_ORDER_TASKS = [
    NavigateAndOrderStandardLaptopTask,
    NavigateAndOrderSalesLaptopTask,


        task_description: str
            The start of the task description to be completed. Provided by the child class.
        short_description: str
            A short description of the task to be completed. "Create a new user". Provided by the child class.
        """
        assert level in [2, 3], "Level must be either 2 or 3"
        self.level = level
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            level=level,
        )
        self.used_in_level_2 = self.level == 2
        self.task = task
        self.task_description = None
        self.short_description = None
        # Get the navigation configuration; there is only one configuration for each application and module combo
        self.navigation_config = navigation_config

    def setup_goal(self, page: Page) -> tuple[str, dict]:
        config = self.fixed_config if self.fixed_config else self._get_config()
        goal, info = super().setup_goal(page=page, config=config)

        return goal, info

    def _get_config(self) -> list[AbstractServiceNowTask]:

        config = [
            # Navigate to the task start page
            AllMenuTask(
                instance=self.instance,
                fixed_config=self.navigation_config,
                is_validated=False,
                used_in_level_2=True,
                has_description=True,
            ),
            self.task,
        ]

        return config

class NavigateAndCreateUserTask(NavigateAndDoTask):
    def __init__(


        self.level = level
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            level=level,
        )
        self.used_in_level_2 = self.level == 2
        self.task = task
        self.task_description = None
        self.short_description = None
        # Get the navigation configuration; there is only one configuration for each application and module combo
        self.navigation_config = navigation_config

    def setup_goal(self, page: Page) -> tuple[str, dict]:
        config = self.fixed_config if self.fixed_config else self._get_config()
        goal, info = super().setup_goal(page=page, config=config)

        return goal, info

    def _get_config(self) -> list[AbstractServiceNowTask]:

        config = [
            # Navigate to the task start page
            AllMenuTask(
                instance=self.instance,
                fixed_config=self.navigation_config,
                is_validated=False,
                used_in_level_2=True,
                has_description=True,
            ),
            self.task,
        ]

        return config

class NavigateAndCreateUserTask(NavigateAndDoTask):
    def __init__(
        self,
        seed: int = None,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Navigate to the user list page and create a new user.

        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create a new user"
        """


import random
from playwright.sync_api._generated import Page
from typing import Tuple

from .dash_do_base import DashboardRetrieveIncidentAndDoTask, DashDoFinalTask

from ..base import AbstractServiceNowTask
from ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask

from ...api.utils import table_api_call, db_delete_from_table
from ...instance import SNowInstance

from browsergym.workarena.tasks.navigation import AllMenuTask
from browsergym.workarena.tasks.form import CreateIncidentTask

class DashboardRetrieveIncidentAndCreateIncidentTask(DashboardRetrieveIncidentAndDoTask):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        question: str = None,
        dashboard_class: AbstractServiceNowTask = None,
    ) -> None:
        """
        Retrieve the worst performing employee and create an incident to assign them a probation course.
        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"
        """
        self.filter_than = "lesser"
        self.attribute_name = "assigned_to"
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            question=question,
            dashboard_class=dashboard_class,
        )
        self.prefix = "DCI"

    def set_compositional_task(self) -> None:
        # The unique name for the user is created once the task is instantiated
        base_user = table_api_call(
            instance=self.instance,
            table="sys_user",
            params={
                "sysparm_query": f"sys_id={self._base_user_sysid}",
            },
        )["result"][0]
        self.user_name = base_user["first_name"] + " " + base_user["last_name"]

        agent_full_names, agent_value_sysids = self.get_agent_values(
            self.attribute_name, self.filter_than
        )
        self.agent_value_sysids = agent_value_sysids
        incident_numbers = []
        for _ in range(len(agent_full_names)):
            incident_number = "INC" + str(random.randint(1000000, 9999999))
            while (
                incident_number in self.all_incident_numbers or incident_number in incident_numbers
            ):
                incident_number = "INC" + str(random.randint(1000000, 9999999))
            incident_numbers.append(incident_number)

        self.incident_numbers = incident_numbers

        create_incident_subtasks = []

        for agent_full_name, incident_number in zip(agent_full_names, incident_numbers):
            self.incident_short_description = "Compulsory training for employee in probation"
            incident_config = {
                "fields": {
                    "caller_id": "Caller",
                    "category": "Category",
                    "short_description": "Short description",
                    "impact": "Impact",
                    "number": "Number",
                    "urgency": "Urgency",
                    "assigned_to": "Assigned to",
                },
                "task_fields": [
                    "caller_id",
                    "category",
                    "short_description",
                    "impact",
                    "number",
                    "urgency",
                    "assigned_to",
                ],
                "template_record": {
                    "caller_id": self.user_name,
                    "category": "Inquiry / Help",
                    "short_description": self.incident_short_description,
                    "impact": "1 - High",
                    "number": incident_number,
                    "urgency": "1 - High",
                    "assigned_to": agent_full_name,
                },
            }

            create_incident_subtask = [
                # Navigate to the incident list
                AllMenuTask(
                    instance=self.instance,
                    fixed_config={
                        "application": "Service Desk",
                        "module": "Incidents",
                        "url": "/now/nav/ui/classic/params/target/incident_list.do",
                    },
                    is_validated=False,
                    used_in_level_2=True,
                ),
                # Create an incident
                CreateIncidentTask(
                    instance=self.instance,
                    fixed_config=incident_config,
                    is_validated=False,
                    used_in_level_2=True,
                    check_record_created=False,
                ),
            ]
            create_incident_subtasks += create_incident_subtask

        self.compositional_task = create_incident_subtasks

    def setup_goal(self, page: Page) -> tuple[str, dict]:
        self.create_report()
        self.set_compositional_task()
        config = self.fixed_config if self.fixed_config else self._get_config()
        incident_numbers_string = ", ".join(self.incident_numbers)

        if self.level == 3:
            self.task_description = (
                self.task_description
                + f"\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Using this value, retrieve agents that have less than or equal number of incidents assigned to them compared to this value.\n"
                + f"\t   For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\n\n"
                + f"\t - Task: For each agent that fits the above criteria, create an 'incident' with the following information (only fill these fields and the 'incident number' from below) and assign it to them using the 'Assigned to' field: \n"
                + f"\t\t Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation', Caller: '{self.user_name}'. Make sure to use an 'incident number' from the list as described below.\n"
                + f"\t   Importantly, you should override the default incident numbers in the form and instead use one incident number from the following list for each incident you create: {incident_numbers_string}.\n\n"
                + f"Note that you will create as many incidents as there are agents matching the above criteria.\n"
                + f"\t   For example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' new incidents here, one assigned to each agent. \n\n"
            )

        goal, info = super().setup_goal(page=page, config=config)

        if self.level == 2:
            goal = (
                self.short_description
                + f"\n1. Navigate to the Reports > View/Run page. \n"
                + f"\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\n"
                + f"\n3. Find the agents with a number of incidents assigned less than or equal to the {self.description_mapping[self.question]} of the number of assigned incidents across agents. For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\n"
                + f"\n4. Navigate to Service Desk > Incidents. \n"
                + f"\n5. You have to create new 'incidents' from this page for all the agents based on the above criteria. Only fill the following fields when creating a new incident:- Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation', Caller: '{self.user_name}' and 'assign' them to each agent using the 'Assigned to' field.\n\n"
                + f"Importantly, you should override the default incident numbers in the form and instead use one incident number from the following list for each incident you create: {incident_numbers_string}.\n"
                + f"Note that you will create as many incidents as there are agents matching the above criteria."
                + "\nFor example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' new incidents here, one assigned to each agent. \n"
            )

        return goal, info

    def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:
        fixed_template_record = {
            "short_description": "Compulsory training for employee in probation",
            "impact": "1",
            "urgency": "1",
        }
        for incident_number in self.incident_numbers:
            created_incident_response = table_api_call(
                instance=self.instance,
                table="incident",
                params={
                    "sysparm_query": f"number={incident_number}",
                    "sysparm_fields": "assigned_to,impact,urgency,short_description,description",
                },
                method="GET",
            )["result"]
            if len(created_incident_response) == 0:
                return (
                    0,
                    False,
                    "",
                    {"message": f"No incident created with number {incident_number}."},
                )
            elif len(created_incident_response) > 1:
                return (
                    0,
                    False,
                    "",
                    {"message": f"Multiple incidents created with number {incident_number}."},
                )
            created_incident_response = created_incident_response[0]
            if created_incident_response["assigned_to"]["value"] not in self.agent_value_sysids:
                return (
                    0,
                    False,
                    "",
                    {"message": f"Incident {incident_number} assigned to a random agent."},
                )

            for key, value in fixed_template_record.items():
                if str(created_incident_response[key]).lower() != str(value).lower():
                    return (
                        0,
                        False,
                        "",
                        {
                            "message": f"Incident {incident_number} assigned incorrect value to field {key}."
                        },
                    )

        for agent_sysid in self.agent_value_sysids:
            created_incident_response = table_api_call(
                instance=self.instance,
                table="incident",
                params={
                    "sysparm_query": f"assigned_to={agent_sysid}^short_description={self.incident_short_description}",
                    "sysparm_fields": "assigned_to",
                },
                method="GET",
            )["result"]
            if len(created_incident_response) == 0:
                return (
                    0,
                    False,
                    "",
                    {
                        "message": f"No incident assigned to agent {self.agents[agent_sysid]['user_name']}."
                    },
                )
            elif len(created_incident_response) > 1:
                return (
                    0,
                    False,
                    "",
                    {
                        "message": f"Multiple incidents assigned to agent {self.agents[agent_sysid]['user_name']}."
                    },
                )
        reward, done, message, info = super().validate(page, chat_messages)
        return reward, done, message, info

    def teardown(self) -> None:
        for incident_number in self.incident_numbers:
            created_incident_response = table_api_call(
                instance=self.instance,
                table="incident",
                params={
                    "sysparm_query": f"number={incident_number}",
                },
                method="GET",
            )["result"]
            if len(created_incident_response) > 1:
                raise Exception("Multiple incidents created")
            if len(created_incident_response) == 1:
                created_incident_sysid = created_incident_response[0]["sys_id"]
                db_delete_from_table(
                    instance=self.instance,
                    table="incident",
                    sys_id=created_incident_sysid,
                )

        return super().teardown()

class DashboardRetrieveIncidentAndMinCreateIncidentTask(
    DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the worst performing employee and create an incident to assign them a probation course.
        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            question="min",
            dashboard_class=SingleChartMinMaxRetrievalTask,
        )

class DashboardRetrieveIncidentAndMeanCreateIncidentTask(
    DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the worst performing employee and create an incident to assign them a probation course.
        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            question="mean",
            dashboard_class=SingleChartMeanMedianModeRetrievalTask,
        )

class DashboardRetrieveIncidentAndMedianCreateIncidentTask(
    DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the worst performing employee and create an incident to assign them a probation course.
        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            question="median",
            dashboard_class=SingleChartMeanMedianModeRetrievalTask,
        )

class DashboardRetrieveIncidentAndModeCreateIncidentTask(
    DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the worst performing employee and create an incident to assign them a probation course.
        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            question="mode",
            dashboard_class=SingleChartMeanMedianModeRetrievalTask,
        )

local_vars = locals().copy()

__TASKS__ = [
    var
    for var in local_vars.values()
    if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask
]

DASH_AND_CREATE_INCIDENT = [
    DashboardRetrieveIncidentAndMinCreateIncidentTask,
]
DASH_COMPUTE_AND_CREATE_INCIDENT = [
    DashboardRetrieveIncidentAndMeanCreateIncidentTask,
    DashboardRetrieveIncidentAndMedianCreateIncidentTask,
    DashboardRetrieveIncidentAndModeCreateIncidentTask,
]


import random
from playwright.sync_api._generated import Page
from typing import Tuple

from .dash_do_base import DashboardRetrieveIncidentAndDoTask, DashDoFinalTask

from ..base import AbstractServiceNowTask
from ..dashboard import SingleChartMinMaxRetrievalTask, SingleChartMeanMedianModeRetrievalTask

from ...api.utils import table_api_call, db_delete_from_table
from ...instance import SNowInstance

from browsergym.workarena.tasks.navigation import AllMenuTask
from browsergym.workarena.tasks.form import CreateIncidentTask

class DashboardRetrieveIncidentAndCreateIncidentTask(DashboardRetrieveIncidentAndDoTask):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        question: str = None,
        dashboard_class: AbstractServiceNowTask = None,
    ) -> None:
        """
        Retrieve the worst performing employee and create an incident to assign them a probation course.
        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"
        """
        self.filter_than = "lesser"
        self.attribute_name = "assigned_to"
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            question=question,
            dashboard_class=dashboard_class,
        )
        self.prefix = "DCI"

    def set_compositional_task(self) -> None:
        # The unique name for the user is created once the task is instantiated
        base_user = table_api_call(
            instance=self.instance,
            table="sys_user",
            params={
                "sysparm_query": f"sys_id={self._base_user_sysid}",
            },
        )["result"][0]
        self.user_name = base_user["first_name"] + " " + base_user["last_name"]

        agent_full_names, agent_value_sysids = self.get_agent_values(
            self.attribute_name, self.filter_than
        )
        self.agent_value_sysids = agent_value_sysids
        incident_numbers = []
        for _ in range(len(agent_full_names)):
            incident_number = "INC" + str(random.randint(1000000, 9999999))
            while (
                incident_number in self.all_incident_numbers or incident_number in incident_numbers
            ):
                incident_number = "INC" + str(random.randint(1000000, 9999999))
            incident_numbers.append(incident_number)

        self.incident_numbers = incident_numbers

        create_incident_subtasks = []

        for agent_full_name, incident_number in zip(agent_full_names, incident_numbers):
            self.incident_short_description = "Compulsory training for employee in probation"
            incident_config = {
                "fields": {
                    "caller_id": "Caller",
                    "category": "Category",
                    "short_description": "Short description",
                    "impact": "Impact",
                    "number": "Number",
                    "urgency": "Urgency",
                    "assigned_to": "Assigned to",
                },
                "task_fields": [
                    "caller_id",
                    "category",
                    "short_description",
                    "impact",
                    "number",
                    "urgency",
                    "assigned_to",
                ],
                "template_record": {
                    "caller_id": self.user_name,
                    "category": "Inquiry / Help",
                    "short_description": self.incident_short_description,
                    "impact": "1 - High",
                    "number": incident_number,
                    "urgency": "1 - High",
                    "assigned_to": agent_full_name,
                },
            }

            create_incident_subtask = [
                # Navigate to the incident list
                AllMenuTask(
                    instance=self.instance,
                    fixed_config={
                        "application": "Service Desk",
                        "module": "Incidents",
                        "url": "/now/nav/ui/classic/params/target/incident_list.do",
                    },
                    is_validated=False,
                    used_in_level_2=True,
                ),
                # Create an incident
                CreateIncidentTask(
                    instance=self.instance,
                    fixed_config=incident_config,
                    is_validated=False,
                    used_in_level_2=True,
                    check_record_created=False,
                ),
            ]
            create_incident_subtasks += create_incident_subtask

        self.compositional_task = create_incident_subtasks

    def setup_goal(self, page: Page) -> tuple[str, dict]:
        self.create_report()
        self.set_compositional_task()
        config = self.fixed_config if self.fixed_config else self._get_config()
        incident_numbers_string = ", ".join(self.incident_numbers)

        if self.level == 3:
            self.task_description = (
                self.task_description
                + f"\t - Please retrieve the '{self.description_mapping[self.question]}' value of the number of incidents assigned across agents. Using this value, retrieve agents that have less than or equal number of incidents assigned to them compared to this value.\n"
                + f"\t   For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\n\n"
                + f"\t - Task: For each agent that fits the above criteria, create an 'incident' with the following information (only fill these fields and the 'incident number' from below) and assign it to them using the 'Assigned to' field: \n"
                + f"\t\t Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation', Caller: '{self.user_name}'. Make sure to use an 'incident number' from the list as described below.\n"
                + f"\t   Importantly, you should override the default incident numbers in the form and instead use one incident number from the following list for each incident you create: {incident_numbers_string}.\n\n"
                + f"Note that you will create as many incidents as there are agents matching the above criteria.\n"
                + f"\t   For example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' new incidents here, one assigned to each agent. \n\n"
            )

        goal, info = super().setup_goal(page=page, config=config)

        if self.level == 2:
            goal = (
                self.short_description
                + f"\n1. Navigate to the Reports > View/Run page. \n"
                + f"\n2. Given the title of the report, search for it on this page. The report shows the number of 'incidents' assigned to an 'agent'.\n"
                + f"\n3. Find the agents with a number of incidents assigned less than or equal to the {self.description_mapping[self.question]} of the number of assigned incidents across agents. For example, if you were asked to find the 'mean' or 'average' for a case where there are 4 agents assigned 1,2,3,2 incidents respectively, the mean would be 2. The list of agents required for solving the following task would be all the agents that have less than or equal to 2 assigned incidents.\n"
                + f"\n4. Navigate to Service Desk > Incidents. \n"
                + f"\n5. You have to create new 'incidents' from this page for all the agents based on the above criteria. Only fill the following fields when creating a new incident:- Category: 'Inquiry / Help', Impact: '1 - High', Urgency: '1 - High', Short description: 'Compulsory training for employee in probation', Caller: '{self.user_name}' and 'assign' them to each agent using the 'Assigned to' field.\n\n"
                + f"Importantly, you should override the default incident numbers in the form and instead use one incident number from the following list for each incident you create: {incident_numbers_string}.\n"
                + f"Note that you will create as many incidents as there are agents matching the above criteria."
                + "\nFor example, consider the above case and say you have 3 agents with less than or equal to 2 incidents assigned to them in the chart. You will be creating '3' new incidents here, one assigned to each agent. \n"
            )

        return goal, info

    def validate(self, page: Page, chat_messages: list[str]) -> Tuple[float, bool, str, dict]:
        fixed_template_record = {
            "short_description": "Compulsory training for employee in probation",
            "impact": "1",
            "urgency": "1",
        }
        for incident_number in self.incident_numbers:
            created_incident_response = table_api_call(
                instance=self.instance,
                table="incident",
                params={
                    "sysparm_query": f"number={incident_number}",
                    "sysparm_fields": "assigned_to,impact,urgency,short_description,description",
                },
                method="GET",
            )["result"]
            if len(created_incident_response) == 0:
                return (
                    0,
                    False,
                    "",
                    {"message": f"No incident created with number {incident_number}."},
                )
            elif len(created_incident_response) > 1:
                return (
                    0,
                    False,
                    "",
                    {"message": f"Multiple incidents created with number {incident_number}."},
                )
            created_incident_response = created_incident_response[0]
            if created_incident_response["assigned_to"]["value"] not in self.agent_value_sysids:
                return (
                    0,
                    False,
                    "",
                    {"message": f"Incident {incident_number} assigned to a random agent."},
                )

            for key, value in fixed_template_record.items():
                if str(created_incident_response[key]).lower() != str(value).lower():
                    return (
                        0,
                        False,
                        "",
                        {
                            "message": f"Incident {incident_number} assigned incorrect value to field {key}."
                        },
                    )

        for agent_sysid in self.agent_value_sysids:
            created_incident_response = table_api_call(
                instance=self.instance,
                table="incident",
                params={
                    "sysparm_query": f"assigned_to={agent_sysid}^short_description={self.incident_short_description}",
                    "sysparm_fields": "assigned_to",
                },
                method="GET",
            )["result"]
            if len(created_incident_response) == 0:
                return (
                    0,
                    False,
                    "",
                    {
                        "message": f"No incident assigned to agent {self.agents[agent_sysid]['user_name']}."
                    },
                )
            elif len(created_incident_response) > 1:
                return (
                    0,
                    False,
                    "",
                    {
                        "message": f"Multiple incidents assigned to agent {self.agents[agent_sysid]['user_name']}."
                    },
                )
        reward, done, message, info = super().validate(page, chat_messages)
        return reward, done, message, info

    def teardown(self) -> None:
        for incident_number in self.incident_numbers:
            created_incident_response = table_api_call(
                instance=self.instance,
                table="incident",
                params={
                    "sysparm_query": f"number={incident_number}",
                },
                method="GET",
            )["result"]
            if len(created_incident_response) > 1:
                raise Exception("Multiple incidents created")
            if len(created_incident_response) == 1:
                created_incident_sysid = created_incident_response[0]["sys_id"]
                db_delete_from_table(
                    instance=self.instance,
                    table="incident",
                    sys_id=created_incident_sysid,
                )

        return super().teardown()

class DashboardRetrieveIncidentAndMinCreateIncidentTask(
    DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the worst performing employee and create an incident to assign them a probation course.
        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"


                instance=self.instance,
                table="incident",
                params={
                    "sysparm_query": f"number={incident_number}",
                },
                method="GET",
            )["result"]
            if len(created_incident_response) > 1:
                raise Exception("Multiple incidents created")
            if len(created_incident_response) == 1:
                created_incident_sysid = created_incident_response[0]["sys_id"]
                db_delete_from_table(
                    instance=self.instance,
                    table="incident",
                    sys_id=created_incident_sysid,
                )

        return super().teardown()

class DashboardRetrieveIncidentAndMinCreateIncidentTask(
    DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the worst performing employee and create an incident to assign them a probation course.
        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            question="min",
            dashboard_class=SingleChartMinMaxRetrievalTask,
        )

class DashboardRetrieveIncidentAndMeanCreateIncidentTask(
    DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the worst performing employee and create an incident to assign them a probation course.
        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"


    ) -> None:
        """
        Retrieve the worst performing employee and create an incident to assign them a probation course.
        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            question="min",
            dashboard_class=SingleChartMinMaxRetrievalTask,
        )

class DashboardRetrieveIncidentAndMeanCreateIncidentTask(
    DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the worst performing employee and create an incident to assign them a probation course.
        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            question="mean",
            dashboard_class=SingleChartMeanMedianModeRetrievalTask,
        )

class DashboardRetrieveIncidentAndMedianCreateIncidentTask(
    DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the worst performing employee and create an incident to assign them a probation course.
        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"


    ) -> None:
        """
        Retrieve the worst performing employee and create an incident to assign them a probation course.
        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            question="mean",
            dashboard_class=SingleChartMeanMedianModeRetrievalTask,
        )

class DashboardRetrieveIncidentAndMedianCreateIncidentTask(
    DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the worst performing employee and create an incident to assign them a probation course.
        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            question="median",
            dashboard_class=SingleChartMeanMedianModeRetrievalTask,
        )

class DashboardRetrieveIncidentAndModeCreateIncidentTask(
    DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the worst performing employee and create an incident to assign them a probation course.
        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"


    ) -> None:
        """
        Retrieve the worst performing employee and create an incident to assign them a probation course.
        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            question="median",
            dashboard_class=SingleChartMeanMedianModeRetrievalTask,
        )

class DashboardRetrieveIncidentAndModeCreateIncidentTask(
    DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the worst performing employee and create an incident to assign them a probation course.
        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            question="mode",
            dashboard_class=SingleChartMeanMedianModeRetrievalTask,
        )

local_vars = locals().copy()

__TASKS__ = [
    var
    for var in local_vars.values()
    if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask
]

DASH_AND_CREATE_INCIDENT = [
    DashboardRetrieveIncidentAndMinCreateIncidentTask,
]
DASH_COMPUTE_AND_CREATE_INCIDENT = [
    DashboardRetrieveIncidentAndMeanCreateIncidentTask,
    DashboardRetrieveIncidentAndMedianCreateIncidentTask,
    DashboardRetrieveIncidentAndModeCreateIncidentTask,
]


        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            question="median",
            dashboard_class=SingleChartMeanMedianModeRetrievalTask,
        )

class DashboardRetrieveIncidentAndModeCreateIncidentTask(
    DashboardRetrieveIncidentAndCreateIncidentTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the worst performing employee and create an incident to assign them a probation course.
        Attributes:
        -----------
        task_description: str
            The start of the task description to be completed.
        short_description: str
            A short description of the task to be completed. "Create an incident for the worst performing employee from the list"
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            question="mode",
            dashboard_class=SingleChartMeanMedianModeRetrievalTask,
        )

local_vars = locals().copy()

__TASKS__ = [
    var
    for var in local_vars.values()
    if isinstance(var, type) and issubclass(var, DashDoFinalTask) and var is not DashDoFinalTask
]

DASH_AND_CREATE_INCIDENT = [
    DashboardRetrieveIncidentAndMinCreateIncidentTask,
]
DASH_COMPUTE_AND_CREATE_INCIDENT = [
    DashboardRetrieveIncidentAndMeanCreateIncidentTask,
    DashboardRetrieveIncidentAndMedianCreateIncidentTask,
    DashboardRetrieveIncidentAndModeCreateIncidentTask,
]