teardown

                    },
                )
            if (
                incident_response["assigned_to"]["value"]
                != agents_per_category_sys_ids[incident_response["category"]][
                    self.priorities[int(incident_response["priority"])]["agent_type"]
                ]
            ):
                return (
                    0,
                    False,
                    "",
                    {
                        "message": f"The incident {incident_config['number']} was assigned to an incorrect agent."
                    },
                )
        # Validate final_l3 tasks
        reward, done, message, info = super().validate(page, chat_messages)
        return reward, done, message, info

    def teardown(self) -> None:
        for incident in self.incident_configs:
            db_delete_from_table(
                instance=self.instance, table="incident", sys_id=incident["sys_id"]
            )

        for category in self.agents_per_category.values():
            for agent in category.values():
                db_delete_from_table(
                    instance=self.instance, table="sys_user", sys_id=agent["sys_id"]
                )

        return super().teardown()

class PriorityAssignmentSmallTask(PriorityAssignmentTask, HumanEvalTask):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 3,
    ) -> None:
        """
        Small version of priority assignment task.
        """
        super().__init__(
            instance=instance,
            level=level,
            num_categories=2,
            fixed_config=fixed_config,
            seed=0,
            prefix="PAS",


from faker import Faker

fake = Faker()

from playwright.sync_api._generated import Page

from .base import HumanEvalTask
from .filter_and_do import FilterAndDoTask

from ..mark_duplicate_problem import SetProblemAsDuplicateTask
from ..base import AbstractServiceNowTask

from ...api.problem import create_problem
from ...api.utils import db_delete_from_table, table_api_call
from ...config import (
    # Expected columns for the different lists
    EXPECTED_PROBLEM_COLUMNS_PATH,
)
from ...instance import SNowInstance

class FilterProblemsAndMarkDuplicatesTask(FilterAndDoTask):
    """Basic task to filter problems with a specific hashtag and mark them as duplicates."""

    def __init__(
        self,
        seed: int,
        extra_problems: int,
        navigation_config: dict,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config=navigation_config,
            level=level,
            protocol_name="Problem List Cleanup",
        )
        self.extra_problems = extra_problems  # Number of non-duplicates to create; total problems will be extra_problems + 2
        self.problem_priorities = [2, 2] + [
            1
        ] * extra_problems  # The first two problems will be duplicates with the same priority; the other ones will get top priority by default
        self.problem_sys_ids = []
        self.duplicate_problems = []

        self.problem_hashtag = "#SERIES-" + self.unique_id[:10]
        self.short_description = f"Clean-up your duplicate problems"
        self.task_description = f'Referring to company protocol "{self.protocol_name}" (located in the "Company Protocols" knowledge base) clean-up your problem list (problems assigned to you) by marking duplicate problems among those with hashtag {self.problem_hashtag}.'

    def _setup_list(self) -> None:
        duplicated_short_descripton = f"{fake.sentence(4)}"

        for i, priority in enumerate(self.problem_priorities):
            # The first two problems will have the same short description; the other ones will get random ones
            if i < 2:
                short_description = duplicated_short_descripton
            else:
                short_description = None

            problem_sys_id, problem_number = create_problem(
                instance=self.instance,
                problem_hashtag=self.problem_hashtag,
                priority=priority,
                user_sys_id=self._base_user_sysid,
                short_description=short_description,
                return_number=True,
            )
            self.problem_sys_ids.append(problem_sys_id)

            if i < 2:
                self.duplicate_problems.append({"number": problem_number, "sys_id": problem_sys_id})

        self.filter_config = {
            "list_url": "/now/nav/ui/classic/params/target/problem_list.do",
            "expected_fields_path": EXPECTED_PROBLEM_COLUMNS_PATH,
            "filter_columns": [
                "short_description",
            ],
            "filter_kind": "AND",
            "filter_operators": ["contains"],
            "filter_values": [
                f"{self.problem_hashtag}",
            ],
        }
        # the 'tasks' attribute needs to be defined by children classes

    def teardown(self) -> None:
        for problem_sys_id in self.problem_sys_ids:
            record_exists = table_api_call(
                instance=self.instance,
                table="problem",
                params={"sysparm_query": f"sys_id={problem_sys_id}"},
            )["result"]
            if record_exists:
                db_delete_from_table(
                    instance=self.instance,
                    table="problem",
                    sys_id=problem_sys_id,
                )
        super().teardown()

class BasicFilterProblemsAndMarkDuplicatesSmallTask(
    FilterProblemsAndMarkDuplicatesTask, HumanEvalTask
):
    """Basic task to filter problems with a specific hashtag and mark them as duplicates. This"""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 2,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "Assigned to me",
                "application": "Problem",
            },
            level=level,
        )

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                is_validated=True,
                used_in_level_2=True,
                goal_version="base",
                level=self.level,
            ),
        ]

class BasicFilterProblemsAndMarkDuplicatesMediumTask(FilterProblemsAndMarkDuplicatesTask):
    """Basic task to filter problems with a specific hashtag and mark them as duplicates. This"""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 4,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "Assigned to me",
                "application": "Problem",
            },
            level=level,
        )

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                is_validated=True,
                used_in_level_2=True,
                goal_version="base",
                level=self.level,
            ),
        ]

class BasicFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):
    """Basic task to filter problems with a specific hashtag and mark them as duplicates. This"""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 6,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "Assigned to me",
                "application": "Problem",
            },
            level=level,
        )

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                is_validated=True,
                used_in_level_2=True,
                goal_version="base",
                level=self.level,
            ),
        ]

class PriorityFilterProblemsAndMarkDuplicatesSmallTask(
    FilterProblemsAndMarkDuplicatesTask, HumanEvalTask
):
    """Task to filter problems with a specific hashtag and mark the least priority one as duplicate of the first."""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 2,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "All",
                "application": "Problem",
            },
            level=level,
        )
        self.problem_priorities = [1, 2] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=True,
                is_validated=True,
                used_in_level_2=True,
                goal_version="priority",
                level=self.level,
            ),
        ]

class PriorityFilterProblemsAndMarkDuplicatesMediumTask(FilterProblemsAndMarkDuplicatesTask):
    """Task to filter problems with a specific hashtag and mark the least priority one as duplicate of the first."""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 4,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "All",
                "application": "Problem",
            },
            level=level,
        )
        self.problem_priorities = [1, 2] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=True,
                is_validated=True,
                used_in_level_2=True,
                goal_version="priority",
                level=self.level,
            ),
        ]

class PriorityFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):
    """Task to filter problems with a specific hashtag and mark the least priority one as duplicate of the first."""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 6,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "All",
                "application": "Problem",
            },
            level=level,
        )
        self.problem_priorities = [1, 2] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=True,
                is_validated=True,
                used_in_level_2=True,
                goal_version="priority",
                level=self.level,
            ),
        ]

class HighPriorityFilterProblemsAndMarkDuplicatesSmallTask(
    FilterProblemsAndMarkDuplicatesTask, HumanEvalTask
):
    """Task to filter problems with a specific hashtag and mark high priority items as duplicates. As
    a top priority item is marked as duplicate, we have to add a comment to it.
    """

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 2,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "All",
                "application": "Problem",
            },
            level=level,
        )
        self.problem_priorities = [1, 1] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=False,
                is_validated=True,
                used_in_level_2=True,
                goal_version="high priority",
                level=self.level,
            ),
        ]

class HighPriorityFilterProblemsAndMarkDuplicatesMediumTask(FilterProblemsAndMarkDuplicatesTask):
    """Task to filter problems with a specific hashtag and mark high priority items as duplicates. As
    a top priority item is marked as duplicate, we have to add a comment to it.
    """

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 4,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "All",
                "application": "Problem",
            },
            level=level,
        )
        self.problem_priorities = [1, 1] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=False,
                is_validated=True,
                used_in_level_2=True,
                goal_version="high priority",
                level=self.level,
            ),
        ]

class HighPriorityFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):
    """Task to filter problems with a specific hashtag and mark high priority items as duplicates. As
    a top priority item is marked as duplicate, we have to add a comment to it.
    """

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 6,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "All",
                "application": "Problem",
            },
            level=level,
        )
        self.problem_priorities = [1, 1] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=False,
                is_validated=True,
                used_in_level_2=True,
                goal_version="high priority",
                level=self.level,
            ),
        ]

local_vars = locals().copy()

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


FilterProblemsAndMarkDuplicatesTask

fake = Faker()

from playwright.sync_api._generated import Page

from .base import HumanEvalTask
from .filter_and_do import FilterAndDoTask

from ..mark_duplicate_problem import SetProblemAsDuplicateTask
from ..base import AbstractServiceNowTask

from ...api.problem import create_problem
from ...api.utils import db_delete_from_table, table_api_call
from ...config import (
    # Expected columns for the different lists
    EXPECTED_PROBLEM_COLUMNS_PATH,
)
from ...instance import SNowInstance

class FilterProblemsAndMarkDuplicatesTask(FilterAndDoTask):
    """Basic task to filter problems with a specific hashtag and mark them as duplicates."""

    def __init__(
        self,
        seed: int,
        extra_problems: int,
        navigation_config: dict,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config=navigation_config,
            level=level,
            protocol_name="Problem List Cleanup",
        )
        self.extra_problems = extra_problems  # Number of non-duplicates to create; total problems will be extra_problems + 2
        self.problem_priorities = [2, 2] + [
            1
        ] * extra_problems  # The first two problems will be duplicates with the same priority; the other ones will get top priority by default
        self.problem_sys_ids = []
        self.duplicate_problems = []

        self.problem_hashtag = "#SERIES-" + self.unique_id[:10]
        self.short_description = f"Clean-up your duplicate problems"
        self.task_description = f'Referring to company protocol "{self.protocol_name}" (located in the "Company Protocols" knowledge base) clean-up your problem list (problems assigned to you) by marking duplicate problems among those with hashtag {self.problem_hashtag}.'

    def _setup_list(self) -> None:
        duplicated_short_descripton = f"{fake.sentence(4)}"

        for i, priority in enumerate(self.problem_priorities):
            # The first two problems will have the same short description; the other ones will get random ones
            if i < 2:
                short_description = duplicated_short_descripton
            else:
                short_description = None

            problem_sys_id, problem_number = create_problem(
                instance=self.instance,
                problem_hashtag=self.problem_hashtag,
                priority=priority,
                user_sys_id=self._base_user_sysid,
                short_description=short_description,
                return_number=True,
            )
            self.problem_sys_ids.append(problem_sys_id)

            if i < 2:
                self.duplicate_problems.append({"number": problem_number, "sys_id": problem_sys_id})

        self.filter_config = {
            "list_url": "/now/nav/ui/classic/params/target/problem_list.do",
            "expected_fields_path": EXPECTED_PROBLEM_COLUMNS_PATH,
            "filter_columns": [
                "short_description",
            ],
            "filter_kind": "AND",
            "filter_operators": ["contains"],
            "filter_values": [
                f"{self.problem_hashtag}",
            ],
        }
        # the 'tasks' attribute needs to be defined by children classes

    def teardown(self) -> None:
        for problem_sys_id in self.problem_sys_ids:
            record_exists = table_api_call(
                instance=self.instance,
                table="problem",
                params={"sysparm_query": f"sys_id={problem_sys_id}"},
            )["result"]
            if record_exists:
                db_delete_from_table(
                    instance=self.instance,
                    table="problem",
                    sys_id=problem_sys_id,
                )
        super().teardown()

class BasicFilterProblemsAndMarkDuplicatesSmallTask(
    FilterProblemsAndMarkDuplicatesTask, HumanEvalTask
):
    """Basic task to filter problems with a specific hashtag and mark them as duplicates. This"""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 2,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,


            ],
        }
        # the 'tasks' attribute needs to be defined by children classes

    def teardown(self) -> None:
        for problem_sys_id in self.problem_sys_ids:
            record_exists = table_api_call(
                instance=self.instance,
                table="problem",
                params={"sysparm_query": f"sys_id={problem_sys_id}"},
            )["result"]
            if record_exists:
                db_delete_from_table(
                    instance=self.instance,
                    table="problem",
                    sys_id=problem_sys_id,
                )
        super().teardown()

class BasicFilterProblemsAndMarkDuplicatesSmallTask(
    FilterProblemsAndMarkDuplicatesTask, HumanEvalTask
):
    """Basic task to filter problems with a specific hashtag and mark them as duplicates. This"""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 2,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "Assigned to me",
                "application": "Problem",
            },
            level=level,
        )

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                is_validated=True,
                used_in_level_2=True,
                goal_version="base",
                level=self.level,
            ),
        ]

class BasicFilterProblemsAndMarkDuplicatesMediumTask(FilterProblemsAndMarkDuplicatesTask):
    """Basic task to filter problems with a specific hashtag and mark them as duplicates. This"""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 4,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "Assigned to me",


            level=level,
        )

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                is_validated=True,
                used_in_level_2=True,
                goal_version="base",
                level=self.level,
            ),
        ]

class BasicFilterProblemsAndMarkDuplicatesMediumTask(FilterProblemsAndMarkDuplicatesTask):
    """Basic task to filter problems with a specific hashtag and mark them as duplicates. This"""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 4,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "Assigned to me",
                "application": "Problem",
            },
            level=level,
        )

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                is_validated=True,
                used_in_level_2=True,
                goal_version="base",
                level=self.level,
            ),
        ]

class BasicFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):
    """Basic task to filter problems with a specific hashtag and mark them as duplicates. This"""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 6,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "Assigned to me",


            level=level,
        )

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                is_validated=True,
                used_in_level_2=True,
                goal_version="base",
                level=self.level,
            ),
        ]

class BasicFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):
    """Basic task to filter problems with a specific hashtag and mark them as duplicates. This"""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 6,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "Assigned to me",
                "application": "Problem",
            },
            level=level,
        )

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                is_validated=True,
                used_in_level_2=True,
                goal_version="base",
                level=self.level,
            ),
        ]

class PriorityFilterProblemsAndMarkDuplicatesSmallTask(
    FilterProblemsAndMarkDuplicatesTask, HumanEvalTask
):
    """Task to filter problems with a specific hashtag and mark the least priority one as duplicate of the first."""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 2,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,


            level=level,
        )

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                is_validated=True,
                used_in_level_2=True,
                goal_version="base",
                level=self.level,
            ),
        ]

class PriorityFilterProblemsAndMarkDuplicatesSmallTask(
    FilterProblemsAndMarkDuplicatesTask, HumanEvalTask
):
    """Task to filter problems with a specific hashtag and mark the least priority one as duplicate of the first."""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 2,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "All",
                "application": "Problem",
            },
            level=level,
        )
        self.problem_priorities = [1, 2] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=True,
                is_validated=True,
                used_in_level_2=True,
                goal_version="priority",
                level=self.level,
            ),
        ]

class PriorityFilterProblemsAndMarkDuplicatesMediumTask(FilterProblemsAndMarkDuplicatesTask):
    """Task to filter problems with a specific hashtag and mark the least priority one as duplicate of the first."""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 4,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "All",


        self.problem_priorities = [1, 2] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=True,
                is_validated=True,
                used_in_level_2=True,
                goal_version="priority",
                level=self.level,
            ),
        ]

class PriorityFilterProblemsAndMarkDuplicatesMediumTask(FilterProblemsAndMarkDuplicatesTask):
    """Task to filter problems with a specific hashtag and mark the least priority one as duplicate of the first."""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 4,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "All",
                "application": "Problem",
            },
            level=level,
        )
        self.problem_priorities = [1, 2] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=True,
                is_validated=True,
                used_in_level_2=True,
                goal_version="priority",
                level=self.level,
            ),
        ]

class PriorityFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):
    """Task to filter problems with a specific hashtag and mark the least priority one as duplicate of the first."""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 6,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "All",


        self.problem_priorities = [1, 2] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=True,
                is_validated=True,
                used_in_level_2=True,
                goal_version="priority",
                level=self.level,
            ),
        ]

class PriorityFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):
    """Task to filter problems with a specific hashtag and mark the least priority one as duplicate of the first."""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 6,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "All",
                "application": "Problem",
            },
            level=level,
        )
        self.problem_priorities = [1, 2] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=True,
                is_validated=True,
                used_in_level_2=True,
                goal_version="priority",
                level=self.level,
            ),
        ]

class HighPriorityFilterProblemsAndMarkDuplicatesSmallTask(
    FilterProblemsAndMarkDuplicatesTask, HumanEvalTask
):
    """Task to filter problems with a specific hashtag and mark high priority items as duplicates. As
    a top priority item is marked as duplicate, we have to add a comment to it.
    """

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 2,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,


        self.problem_priorities = [1, 2] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=True,
                is_validated=True,
                used_in_level_2=True,
                goal_version="priority",
                level=self.level,
            ),
        ]

class HighPriorityFilterProblemsAndMarkDuplicatesSmallTask(
    FilterProblemsAndMarkDuplicatesTask, HumanEvalTask
):
    """Task to filter problems with a specific hashtag and mark high priority items as duplicates. As
    a top priority item is marked as duplicate, we have to add a comment to it.
    """

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 2,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "All",
                "application": "Problem",
            },
            level=level,
        )
        self.problem_priorities = [1, 1] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=False,
                is_validated=True,
                used_in_level_2=True,
                goal_version="high priority",
                level=self.level,
            ),
        ]

class HighPriorityFilterProblemsAndMarkDuplicatesMediumTask(FilterProblemsAndMarkDuplicatesTask):
    """Task to filter problems with a specific hashtag and mark high priority items as duplicates. As
    a top priority item is marked as duplicate, we have to add a comment to it.
    """

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 4,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,


        self.problem_priorities = [1, 1] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=False,
                is_validated=True,
                used_in_level_2=True,
                goal_version="high priority",
                level=self.level,
            ),
        ]

class HighPriorityFilterProblemsAndMarkDuplicatesMediumTask(FilterProblemsAndMarkDuplicatesTask):
    """Task to filter problems with a specific hashtag and mark high priority items as duplicates. As
    a top priority item is marked as duplicate, we have to add a comment to it.
    """

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 4,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "All",
                "application": "Problem",
            },
            level=level,
        )
        self.problem_priorities = [1, 1] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=False,
                is_validated=True,
                used_in_level_2=True,
                goal_version="high priority",
                level=self.level,
            ),
        ]

class HighPriorityFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):
    """Task to filter problems with a specific hashtag and mark high priority items as duplicates. As
    a top priority item is marked as duplicate, we have to add a comment to it.
    """

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 6,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,


        self.problem_priorities = [1, 1] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=False,
                is_validated=True,
                used_in_level_2=True,
                goal_version="high priority",
                level=self.level,
            ),
        ]

class HighPriorityFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):
    """Task to filter problems with a specific hashtag and mark high priority items as duplicates. As
    a top priority item is marked as duplicate, we have to add a comment to it.
    """

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 6,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "All",
                "application": "Problem",
            },
            level=level,
        )
        self.problem_priorities = [1, 1] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=False,
                is_validated=True,
                used_in_level_2=True,
                goal_version="high priority",
                level=self.level,
            ),
        ]

local_vars = locals().copy()

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


            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=False,
                is_validated=True,
                used_in_level_2=True,
                goal_version="high priority",
                level=self.level,
            ),
        ]

class HighPriorityFilterProblemsAndMarkDuplicatesLargeTask(FilterProblemsAndMarkDuplicatesTask):
    """Task to filter problems with a specific hashtag and mark high priority items as duplicates. As
    a top priority item is marked as duplicate, we have to add a comment to it.
    """

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 6,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "All",
                "application": "Problem",
            },
            level=level,
        )
        self.problem_priorities = [1, 1] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=False,
                is_validated=True,
                used_in_level_2=True,
                goal_version="high priority",
                level=self.level,
            ),
        ]

local_vars = locals().copy()


        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 6,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,
            navigation_config={
                "module": "All",
                "application": "Problem",
            },
            level=level,
        )
        self.problem_priorities = [1, 1] + [1] * extra_problems

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SetProblemAsDuplicateTask(
                instance=self.instance,
                fixed_config={
                    "target_problem": self.duplicate_problems[1],
                    "source_problem": self.duplicate_problems[0],
                },
                respect_problem_ordering=False,
                is_validated=True,
                used_in_level_2=True,
                goal_version="high priority",
                level=self.level,
            ),
        ]

local_vars = locals().copy()

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


teardown

            )
            self.problem_sys_ids.append(problem_sys_id)

            if i < 2:
                self.duplicate_problems.append({"number": problem_number, "sys_id": problem_sys_id})

        self.filter_config = {
            "list_url": "/now/nav/ui/classic/params/target/problem_list.do",
            "expected_fields_path": EXPECTED_PROBLEM_COLUMNS_PATH,
            "filter_columns": [
                "short_description",
            ],
            "filter_kind": "AND",
            "filter_operators": ["contains"],
            "filter_values": [
                f"{self.problem_hashtag}",
            ],
        }
        # the 'tasks' attribute needs to be defined by children classes

    def teardown(self) -> None:
        for problem_sys_id in self.problem_sys_ids:
            record_exists = table_api_call(
                instance=self.instance,
                table="problem",
                params={"sysparm_query": f"sys_id={problem_sys_id}"},
            )["result"]
            if record_exists:
                db_delete_from_table(
                    instance=self.instance,
                    table="problem",
                    sys_id=problem_sys_id,
                )
        super().teardown()

class BasicFilterProblemsAndMarkDuplicatesSmallTask(
    FilterProblemsAndMarkDuplicatesTask, HumanEvalTask
):
    """Basic task to filter problems with a specific hashtag and mark them as duplicates. This"""

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        extra_problems: int = 2,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            extra_problems=extra_problems,
            fixed_config=fixed_config,


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

from .dash_do_base import DashboardRetrieveIncidentAndDoInfeasibleTask, DashDoFinalTask
from .utils.infeasible_configs import get_infeasible_form_config

from ..base import AbstractServiceNowTask
from ..dashboard import SingleChartMinMaxRetrievalTask

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 CreateItemRequestTask

class DashboardRetrieveIncidentAndRequestItemInfeasibleTask(
    DashboardRetrieveIncidentAndDoInfeasibleTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        item: str = None,
        question: str = None,
        dashboard_class: AbstractServiceNowTask = None,
        provide_reason: bool = None,
    ) -> None:
        """
        Retrieve the best performing agent and request an item for them.
        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 item for the best performing employee from the list"
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            question=question,
            dashboard_class=dashboard_class,
            function=get_infeasible_form_config,
            provide_reason=provide_reason,
        )
        if not item:
            raise Exception("No item passed to assign")
        self.item = item
        self.task_description = ""
        self.short_description = (
            f"Order an {self.item} for the best performing employee from the list."
        )
        self.attribute_name = "assigned_to"  # Return full name
        self.filter_than = "greater"
        self.prefix = "IRI"

    def set_compositional_task(self) -> None:
        # The unique name for the user is created once the task is instantiated
        requested_items = table_api_call(
            instance=self.instance,
            table="sc_req_item",
            method="GET",
        )["result"]
        current_requested_items_numbers = [
            requested_item["number"] for requested_item in requested_items
        ]

        agent_full_names, agent_value_sysids = self.get_agent_values(
            self.attribute_name, self.filter_than
        )
        self.agent_value_sysids = agent_value_sysids

        requested_item_numbers = []

        for _ in range(len(agent_full_names)):
            requested_item_number = "RITM" + str(random.randint(1000000, 9999999))
            while (
                requested_item_number in current_requested_items_numbers
                or requested_item_number in requested_item_numbers
            ):
                requested_item_number = "RITM" + str(random.randint(1000000, 9999999))
            requested_item_numbers.append(requested_item_number)

        self.requested_item_numbers = requested_item_numbers

        create_item_request_subtasks = []

        for agent_full_name, requested_item_number in zip(agent_full_names, requested_item_numbers):
            request_item_config = {
                "fields": {
                    "number": "Number",
                    "cat_item": "Item",
                    "requested_for": "Requested for",
                    "quantity": "Quantity",
                },
                "task_fields": ["number", "cat_item", "requested_for", "quantity"],
                "template_record": {
                    "number": requested_item_number,
                    "cat_item": self.item,
                    "requested_for": agent_full_name,
                    "quantity": "1",
                },
                "infeasible_task_fields": ["number", "cat_item", "quantity"],
            }
            request_item_config, self.infeasible_reasons = self.function(
                config=request_item_config, random=self.random
            )
            create_item_request_subtask = [
                # Navigate to the item request list
                AllMenuTask(
                    instance=self.instance,
                    fixed_config={
                        "application": "Open Records",
                        "module": "Open Records > Items",
                        "url": "/now/nav/ui/classic/params/target/sc_req_item_list.do",
                    },
                    is_validated=False,
                    used_in_level_2=True,
                ),
                # Create an item request
                CreateItemRequestTask(
                    instance=self.instance,
                    fixed_config=request_item_config,
                    is_validated=False,
                    used_in_level_2=True,
                    check_record_created=False,
                ),
            ]
            create_item_request_subtasks += create_item_request_subtask

        self.compositional_task = create_item_request_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()
        if self.level == 3:
            self.task_description = (
                self.task_description
                + f"Value to retrieve: {self.description_mapping[self.question]} of all the incidents. Comparator: Greather than or equal to the value.\n"
                + f"Task: Request items with the following information: \n"
                + f"Item: {self.item}, Quantity: 1.\n"
                + f"Request the item for each of the agents mentioned above. You can use the item numbers: {self.requested_item_numbers}, one for each request."
            )

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

        if self.level == 2:
            goal = (
                self.task_description
                + f"1. Navigate to the CMDB reports and look for the report with the mentioned hashtag. \n"
                + f"2. Find the agents with number of incidents greater than or equal to the  {self.description_mapping[self.question]} of the incidents assigned to every one. \n"
                + f"3. Navigate to Open Records > Items. \n"
                + f"4. Create new item requests with the following field values:- 'Item: {self.item}, Quantity: 1' and assign them to each of the agents. You will create as many item requests as there are agents.\n"
                + f"You should use the following request numbers for each item request (one for each): {self.requested_item_numbers}."
            )

        return goal, info

    def teardown(self) -> None:
        for requested_item_number in self.requested_item_numbers:
            created_item_request_response = table_api_call(
                instance=self.instance,
                table="sc_req_item",
                params={
                    "sysparm_query": f"number={requested_item_number}",
                },
                method="GET",
            )["result"]
            if len(created_item_request_response) > 1:
                raise Exception("Multiple request items created")
            if len(created_item_request_response) == 1:
                created_item_request_sysid = created_item_request_response[0]["sys_id"]
                db_delete_from_table(
                    instance=self.instance,
                    table="sc_req_item",
                    sys_id=created_item_request_sysid,
                )
        return super().teardown()

class DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple Watch",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple Watch",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleWatch2InfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple Watch Series 2",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleWatch2InfeasibleTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple Watch Series 2",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleIpad3InfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple iPad 3",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleIpad3InfeasibleTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple iPad 3",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleIphone13proInfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple iPhone 13 pro",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleIphone13proInfeasibleTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple iPhone 13 pro",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleIphone13InfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple iPhone 13",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleIphone13InfeasibleTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple iPhone 13",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestGalaxyNote20InfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Galaxy Note 20",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestGalaxyNote20InfeasibleTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Galaxy Note 20",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestGoogleNexus7InfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Google Nexus 7",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestGoogleNexus7InfeasibleTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Google Nexus 7",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3InfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Microsoft Surface Pro 3",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestMicrosoftSurfacePro3InfeasibleTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Microsoft Su
# ... truncated ...


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

from .dash_do_base import DashboardRetrieveIncidentAndDoInfeasibleTask, DashDoFinalTask
from .utils.infeasible_configs import get_infeasible_form_config

from ..base import AbstractServiceNowTask
from ..dashboard import SingleChartMinMaxRetrievalTask

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 CreateItemRequestTask

class DashboardRetrieveIncidentAndRequestItemInfeasibleTask(
    DashboardRetrieveIncidentAndDoInfeasibleTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
        item: str = None,
        question: str = None,
        dashboard_class: AbstractServiceNowTask = None,
        provide_reason: bool = None,
    ) -> None:
        """
        Retrieve the best performing agent and request an item for them.
        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 item for the best performing employee from the list"
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            question=question,
            dashboard_class=dashboard_class,
            function=get_infeasible_form_config,
            provide_reason=provide_reason,
        )
        if not item:
            raise Exception("No item passed to assign")
        self.item = item
        self.task_description = ""
        self.short_description = (
            f"Order an {self.item} for the best performing employee from the list."
        )
        self.attribute_name = "assigned_to"  # Return full name
        self.filter_than = "greater"
        self.prefix = "IRI"

    def set_compositional_task(self) -> None:
        # The unique name for the user is created once the task is instantiated
        requested_items = table_api_call(
            instance=self.instance,
            table="sc_req_item",
            method="GET",
        )["result"]
        current_requested_items_numbers = [
            requested_item["number"] for requested_item in requested_items
        ]

        agent_full_names, agent_value_sysids = self.get_agent_values(
            self.attribute_name, self.filter_than
        )
        self.agent_value_sysids = agent_value_sysids

        requested_item_numbers = []

        for _ in range(len(agent_full_names)):
            requested_item_number = "RITM" + str(random.randint(1000000, 9999999))
            while (
                requested_item_number in current_requested_items_numbers
                or requested_item_number in requested_item_numbers
            ):
                requested_item_number = "RITM" + str(random.randint(1000000, 9999999))
            requested_item_numbers.append(requested_item_number)

        self.requested_item_numbers = requested_item_numbers

        create_item_request_subtasks = []

        for agent_full_name, requested_item_number in zip(agent_full_names, requested_item_numbers):
            request_item_config = {
                "fields": {
                    "number": "Number",
                    "cat_item": "Item",
                    "requested_for": "Requested for",
                    "quantity": "Quantity",
                },
                "task_fields": ["number", "cat_item", "requested_for", "quantity"],
                "template_record": {
                    "number": requested_item_number,
                    "cat_item": self.item,
                    "requested_for": agent_full_name,
                    "quantity": "1",
                },
                "infeasible_task_fields": ["number", "cat_item", "quantity"],
            }
            request_item_config, self.infeasible_reasons = self.function(
                config=request_item_config, random=self.random
            )
            create_item_request_subtask = [
                # Navigate to the item request list
                AllMenuTask(
                    instance=self.instance,
                    fixed_config={
                        "application": "Open Records",
                        "module": "Open Records > Items",
                        "url": "/now/nav/ui/classic/params/target/sc_req_item_list.do",
                    },
                    is_validated=False,
                    used_in_level_2=True,
                ),
                # Create an item request
                CreateItemRequestTask(
                    instance=self.instance,
                    fixed_config=request_item_config,
                    is_validated=False,
                    used_in_level_2=True,
                    check_record_created=False,
                ),
            ]
            create_item_request_subtasks += create_item_request_subtask

        self.compositional_task = create_item_request_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()
        if self.level == 3:
            self.task_description = (
                self.task_description
                + f"Value to retrieve: {self.description_mapping[self.question]} of all the incidents. Comparator: Greather than or equal to the value.\n"
                + f"Task: Request items with the following information: \n"
                + f"Item: {self.item}, Quantity: 1.\n"
                + f"Request the item for each of the agents mentioned above. You can use the item numbers: {self.requested_item_numbers}, one for each request."
            )

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

        if self.level == 2:
            goal = (
                self.task_description
                + f"1. Navigate to the CMDB reports and look for the report with the mentioned hashtag. \n"
                + f"2. Find the agents with number of incidents greater than or equal to the  {self.description_mapping[self.question]} of the incidents assigned to every one. \n"
                + f"3. Navigate to Open Records > Items. \n"
                + f"4. Create new item requests with the following field values:- 'Item: {self.item}, Quantity: 1' and assign them to each of the agents. You will create as many item requests as there are agents.\n"
                + f"You should use the following request numbers for each item request (one for each): {self.requested_item_numbers}."
            )

        return goal, info

    def teardown(self) -> None:
        for requested_item_number in self.requested_item_numbers:
            created_item_request_response = table_api_call(
                instance=self.instance,
                table="sc_req_item",
                params={
                    "sysparm_query": f"number={requested_item_number}",
                },
                method="GET",
            )["result"]
            if len(created_item_request_response) > 1:
                raise Exception("Multiple request items created")
            if len(created_item_request_response) == 1:
                created_item_request_sysid = created_item_request_response[0]["sys_id"]
                db_delete_from_table(
                    instance=self.instance,
                    table="sc_req_item",
                    sys_id=created_item_request_sysid,
                )
        return super().teardown()

class DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,


            created_item_request_response = table_api_call(
                instance=self.instance,
                table="sc_req_item",
                params={
                    "sysparm_query": f"number={requested_item_number}",
                },
                method="GET",
            )["result"]
            if len(created_item_request_response) > 1:
                raise Exception("Multiple request items created")
            if len(created_item_request_response) == 1:
                created_item_request_sysid = created_item_request_response[0]["sys_id"]
                db_delete_from_table(
                    instance=self.instance,
                    table="sc_req_item",
                    sys_id=created_item_request_sysid,
                )
        return super().teardown()

class DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple Watch",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,


        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple Watch",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleWatchInfeasibleTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple Watch",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleWatch2InfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,


        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple Watch",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleWatch2InfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple Watch Series 2",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleWatch2InfeasibleTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,


        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple Watch Series 2",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleWatch2InfeasibleTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple Watch Series 2",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleIpad3InfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,


        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple Watch Series 2",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleIpad3InfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple iPad 3",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleIpad3InfeasibleTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,


        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple iPad 3",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleIpad3InfeasibleTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple iPad 3",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleIphone13proInfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,


        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple iPad 3",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleIphone13proInfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple iPhone 13 pro",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleIphone13proInfeasibleTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,


        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple iPhone 13 pro",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleIphone13proInfeasibleTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple iPhone 13 pro",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleIphone13InfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,


        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple iPhone 13 pro",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleIphone13InfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple iPhone 13",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleIphone13InfeasibleTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,


        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple iPhone 13",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestAppleIphone13InfeasibleTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,
            item="Apple iPhone 13",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestGalaxyNote20InfeasibleWithReasonTask(
    DashboardRetrieveIncidentAndRequestItemInfeasibleTask, DashDoFinalTask
):
    def __init__(
        self,
        instance: SNowInstance = None,
        seed: int = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        """
        Retrieve the best performing agent and request an apple watch for them.
        """
        super().__init__(
            instance=instance,
            seed=seed,
            fixed_config=fixed_config,
            level=level,