        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,


        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,


        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,


        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,


        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,


        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 Surface Pro 3",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestPixel4aInfeasibleWithReasonTask(
    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="Microsoft Surface Pro 3",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestPixel4aInfeasibleWithReasonTask(
    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="Pixel 4a",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestPixel4aInfeasibleTask(
    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="Pixel 4a",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestPixel4aInfeasibleTask(
    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="Pixel 4a",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4InfeasibleWithReasonTask(
    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="Pixel 4a",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

class DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4InfeasibleWithReasonTask(
    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="Windows Surface Pro 4",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4InfeasibleTask(
    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="Windows Surface Pro 4",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4InfeasibleTask(
    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="Windows Surface Pro 4",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

local_vars = locals().copy()

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


        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="Windows Surface Pro 4",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=True,
        )

class DashboardRetrieveIncidentAndMaxRequestWindowsSurfacePro4InfeasibleTask(
    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="Windows Surface Pro 4",
            question="max",
            dashboard_class=SingleChartMinMaxRetrievalTask,
            provide_reason=False,
        )

local_vars = locals().copy()

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


            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"


                        "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,
                )


teardown

                + 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,


from faker import Faker

fake = Faker()

from browsergym.workarena.tasks.navigation import AllMenuTask
from browsergym.workarena.tasks.send_chat_message import SendChatMessageGenericTask
from browsergym.workarena.tasks.service_catalog import (
    OrderDeveloperLaptopTask,
    OrderIpadMiniTask,
    OrderIpadProTask,
    OrderSalesLaptopTask,
    OrderStandardLaptopTask,
    OrderAppleWatchTask,
    OrderAppleMacBookPro15Task,
    OrderDevelopmentLaptopPCTask,
    OrderLoanerLaptopTask,
)

from .base import HumanEvalTask
from .filter_and_do import FilterAndDoTask

from ..base import AbstractServiceNowTask

from ...api.requested_items import create_requested_item
from ...api.user import create_user
from ...api.utils import db_delete_from_table, table_api_call
from ...config import (
    # Expected columns for the different lists
    EXPECTED_REQUESTED_ITEMS_COLUMNS_PATH,
)
from ...instance import SNowInstance

class FilterRequestedItemsAndOrderCatalogItemTask(FilterAndDoTask, HumanEvalTask):
    """Generic task to filter the requested items list to find what a given user has requested and order the same thing.
    Args:
    fixed_request_item: str
        The requested item to find and order.
    task_class: AbstractServiceNowTask
        The class of the task to order the item.
    """

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        fixed_request_item: str = None,
        order_task_class: AbstractServiceNowTask = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "module": "Requested Items",
                "application": "Self-Service",
            },
            level=level,
            protocol_name="",
        )
        self.fixed_request_item = fixed_request_item
        self.order_task_class = order_task_class
        # name of the user the item will be assigned to
        self.user_full_name = (
            fake.first_name()
            + "-"
            + fake.first_name()
            + " "
            + fake.last_name()
            + "-"
            + fake.last_name()
        )
        self.short_description = f"Order same item as {self.user_full_name}"
        self.task_description = f'{self.user_full_name} has recently requested an item from the service catalog. You need to order the same. Find what it is from the "Requested Items" list and order it from the service catalog. If possible, set the item\'s configuration to match the following: \n'
        self.created_user_sys_id = None  # sys_id of the user to assign the item to
        self.requested_item_sys_id = None  # sys_id of the requested item to order
        self.tasks = []

    def _setup_list(self) -> None:
        self.filter_config = {
            "list_url": "/now/nav/ui/classic/params/target/sc_req_item_list.do",
            "expected_fields_path": EXPECTED_REQUESTED_ITEMS_COLUMNS_PATH,
            "filter_columns": [
                "requested_for",
            ],
            "filter_kind": "AND",
            "filter_operators": ["contains"],
            "filter_values": [
                f"{self.user_full_name}",
            ],
        }
        # Create a new user to assign the item to
        first_name = self.user_full_name.split(" ")[0]
        last_name = self.user_full_name.split(" ")[1]
        _, _, self.created_user_sys_id = create_user(
            self.instance, first_name=first_name, last_name=last_name, random=self.random
        )
        # Create a new requested item to order
        self.requested_item_sys_id, _ = create_requested_item(
            self.instance,
            system_name=self.fixed_request_item,
            user_sys_id=self.created_user_sys_id,
        )
        self.tasks.append(
            # After the filter has been made and the information retrieved, navigate to the catalog
            AllMenuTask(
                instance=self.instance,
                fixed_config={
                    "module": "Service Catalog",
                    "application": "Self-Service",
                },
                used_in_level_2=True,
                is_validated=False,
            )
        )
        self.tasks.append(
            SendChatMessageGenericTask(
                instance=self.instance,
                message="a",
                answer_format="a",
                level=self.level,
                description=f"Clear the existing filters on the page. \n",
                is_validated=False,
                use_description_in_l3=True,
                used_in_level_2=True,
            )
        )
        order_task_config = self.random.choice(self.order_task_class.all_configs())
        # task to order the item
        item_order_task = self.order_task_class(
            seed=self.seed,
            instance=self.instance,
            fixed_config=order_task_config,
            used_in_level_2=True,
            is_validated=True,
            config_only_in_desc=True,
        )
        self.tasks.append(item_order_task)

    def teardown(self) -> None:
        # Delete the requested item and the user if they exist
        requested_item_exists = table_api_call(
            instance=self.instance,
            table="sc_req_item",
            params={"sysparm_query": f"sys_id={self.requested_item_sys_id}"},
        )["result"]
        if requested_item_exists:
            db_delete_from_table(
                instance=self.instance,
                table="sc_req_item",
                sys_id=self.requested_item_sys_id,
            )
        user_exists = table_api_call(
            instance=self.instance,
            table="sys_user",
            params={"sysparm_query": f"sys_id={self.created_user_sys_id}"},
        )["result"]
        if user_exists:
            db_delete_from_table(
                instance=self.instance,
                table="sys_user",
                sys_id=self.created_user_sys_id,
            )

        super().teardown()

class FilterRequestedItemsAndOrderDeveloperLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Developer Laptop (Mac)",
            level=level,
            order_task_class=OrderDeveloperLaptopTask,
        )

class FilterRequestedItemsAndOrderIpadMiniTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="iPad mini",
            level=level,
            order_task_class=OrderIpadMiniTask,
        )

class FilterRequestedItemsAndOrderIpadProTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="iPad pro",
            level=level,
            order_task_class=OrderIpadProTask,
        )

class FilterRequestedItemsAndOrderSalesLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Sales Laptop",
            level=level,
            order_task_class=OrderSalesLaptopTask,
        )

class FilterRequestedItemsAndOrderStandardLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Standard Laptop",
            level=level,
            order_task_class=OrderStandardLaptopTask,
        )

class FilterRequestedItemsAndOrderAppleWatchTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Apple Watch",
            level=level,
            order_task_class=OrderAppleWatchTask,
        )

class FilterRequestedItemsAndOrderAppleMacBookPro15Task(
    FilterRequestedItemsAndOrderCatalogItemTask
):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item='Apple MacBook Pro 15"',
            level=level,
            order_task_class=OrderAppleMacBookPro15Task,
        )

class FilterRequestedItemsAndOrderDevelopmentLaptopPCTask(
    FilterRequestedItemsAndOrderCatalogItemTask
):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Development Laptop (PC)",
            level=level,
            order_task_class=OrderDevelopmentLaptopPCTask,
        )

class FilterRequestedItemsAndOrderLoanerLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Notebook Computer Loaner",
            level=level,
            order_task_class=OrderLoanerLaptopTask,
        )

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 FilterRequestedItemsAndOrderCatalogItemTask
]


    OrderAppleMacBookPro15Task,
    OrderDevelopmentLaptopPCTask,
    OrderLoanerLaptopTask,
)

from .base import HumanEvalTask
from .filter_and_do import FilterAndDoTask

from ..base import AbstractServiceNowTask

from ...api.requested_items import create_requested_item
from ...api.user import create_user
from ...api.utils import db_delete_from_table, table_api_call
from ...config import (
    # Expected columns for the different lists
    EXPECTED_REQUESTED_ITEMS_COLUMNS_PATH,
)
from ...instance import SNowInstance

class FilterRequestedItemsAndOrderCatalogItemTask(FilterAndDoTask, HumanEvalTask):
    """Generic task to filter the requested items list to find what a given user has requested and order the same thing.
    Args:
    fixed_request_item: str
        The requested item to find and order.
    task_class: AbstractServiceNowTask
        The class of the task to order the item.
    """

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        fixed_request_item: str = None,
        order_task_class: AbstractServiceNowTask = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "module": "Requested Items",
                "application": "Self-Service",
            },
            level=level,
            protocol_name="",
        )
        self.fixed_request_item = fixed_request_item
        self.order_task_class = order_task_class
        # name of the user the item will be assigned to
        self.user_full_name = (
            fake.first_name()
            + "-"
            + fake.first_name()
            + " "
            + fake.last_name()
            + "-"
            + fake.last_name()
        )
        self.short_description = f"Order same item as {self.user_full_name}"
        self.task_description = f'{self.user_full_name} has recently requested an item from the service catalog. You need to order the same. Find what it is from the "Requested Items" list and order it from the service catalog. If possible, set the item\'s configuration to match the following: \n'
        self.created_user_sys_id = None  # sys_id of the user to assign the item to
        self.requested_item_sys_id = None  # sys_id of the requested item to order
        self.tasks = []

    def _setup_list(self) -> None:
        self.filter_config = {
            "list_url": "/now/nav/ui/classic/params/target/sc_req_item_list.do",
            "expected_fields_path": EXPECTED_REQUESTED_ITEMS_COLUMNS_PATH,
            "filter_columns": [
                "requested_for",
            ],
            "filter_kind": "AND",
            "filter_operators": ["contains"],
            "filter_values": [
                f"{self.user_full_name}",
            ],
        }
        # Create a new user to assign the item to
        first_name = self.user_full_name.split(" ")[0]
        last_name = self.user_full_name.split(" ")[1]
        _, _, self.created_user_sys_id = create_user(
            self.instance, first_name=first_name, last_name=last_name, random=self.random
        )
        # Create a new requested item to order
        self.requested_item_sys_id, _ = create_requested_item(
            self.instance,
            system_name=self.fixed_request_item,
            user_sys_id=self.created_user_sys_id,
        )
        self.tasks.append(
            # After the filter has been made and the information retrieved, navigate to the catalog
            AllMenuTask(
                instance=self.instance,
                fixed_config={
                    "module": "Service Catalog",
                    "application": "Self-Service",
                },
                used_in_level_2=True,
                is_validated=False,
            )
        )
        self.tasks.append(
            SendChatMessageGenericTask(
                instance=self.instance,
                message="a",
                answer_format="a",
                level=self.level,
                description=f"Clear the existing filters on the page. \n",
                is_validated=False,
                use_description_in_l3=True,
                used_in_level_2=True,
            )
        )
        order_task_config = self.random.choice(self.order_task_class.all_configs())
        # task to order the item
        item_order_task = self.order_task_class(
            seed=self.seed,
            instance=self.instance,
            fixed_config=order_task_config,
            used_in_level_2=True,
            is_validated=True,
            config_only_in_desc=True,
        )
        self.tasks.append(item_order_task)

    def teardown(self) -> None:
        # Delete the requested item and the user if they exist
        requested_item_exists = table_api_call(
            instance=self.instance,
            table="sc_req_item",
            params={"sysparm_query": f"sys_id={self.requested_item_sys_id}"},
        )["result"]
        if requested_item_exists:
            db_delete_from_table(
                instance=self.instance,
                table="sc_req_item",
                sys_id=self.requested_item_sys_id,
            )
        user_exists = table_api_call(
            instance=self.instance,
            table="sys_user",
            params={"sysparm_query": f"sys_id={self.created_user_sys_id}"},
        )["result"]
        if user_exists:
            db_delete_from_table(
                instance=self.instance,
                table="sys_user",
                sys_id=self.created_user_sys_id,
            )

        super().teardown()

class FilterRequestedItemsAndOrderDeveloperLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Developer Laptop (Mac)",
            level=level,
            order_task_class=OrderDeveloperLaptopTask,
        )


            db_delete_from_table(
                instance=self.instance,
                table="sc_req_item",
                sys_id=self.requested_item_sys_id,
            )
        user_exists = table_api_call(
            instance=self.instance,
            table="sys_user",
            params={"sysparm_query": f"sys_id={self.created_user_sys_id}"},
        )["result"]
        if user_exists:
            db_delete_from_table(
                instance=self.instance,
                table="sys_user",
                sys_id=self.created_user_sys_id,
            )

        super().teardown()

class FilterRequestedItemsAndOrderDeveloperLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Developer Laptop (Mac)",
            level=level,
            order_task_class=OrderDeveloperLaptopTask,
        )

class FilterRequestedItemsAndOrderIpadMiniTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="iPad mini",
            level=level,
            order_task_class=OrderIpadMiniTask,
        )


class FilterRequestedItemsAndOrderDeveloperLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Developer Laptop (Mac)",
            level=level,
            order_task_class=OrderDeveloperLaptopTask,
        )

class FilterRequestedItemsAndOrderIpadMiniTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="iPad mini",
            level=level,
            order_task_class=OrderIpadMiniTask,
        )

class FilterRequestedItemsAndOrderIpadProTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="iPad pro",
            level=level,
            order_task_class=OrderIpadProTask,
        )


FilterRequestedItemsAndOrderIpadProTask

class FilterRequestedItemsAndOrderIpadMiniTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="iPad mini",
            level=level,
            order_task_class=OrderIpadMiniTask,
        )

class FilterRequestedItemsAndOrderIpadProTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="iPad pro",
            level=level,
            order_task_class=OrderIpadProTask,
        )

class FilterRequestedItemsAndOrderSalesLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Sales Laptop",
            level=level,
            order_task_class=OrderSalesLaptopTask,
        )


class FilterRequestedItemsAndOrderIpadProTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="iPad pro",
            level=level,
            order_task_class=OrderIpadProTask,
        )

class FilterRequestedItemsAndOrderSalesLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Sales Laptop",
            level=level,
            order_task_class=OrderSalesLaptopTask,
        )

class FilterRequestedItemsAndOrderStandardLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Standard Laptop",
            level=level,
            order_task_class=OrderStandardLaptopTask,
        )


class FilterRequestedItemsAndOrderSalesLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Sales Laptop",
            level=level,
            order_task_class=OrderSalesLaptopTask,
        )

class FilterRequestedItemsAndOrderStandardLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Standard Laptop",
            level=level,
            order_task_class=OrderStandardLaptopTask,
        )

class FilterRequestedItemsAndOrderAppleWatchTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Apple Watch",
            level=level,
            order_task_class=OrderAppleWatchTask,
        )


class FilterRequestedItemsAndOrderStandardLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Standard Laptop",
            level=level,
            order_task_class=OrderStandardLaptopTask,
        )

class FilterRequestedItemsAndOrderAppleWatchTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Apple Watch",
            level=level,
            order_task_class=OrderAppleWatchTask,
        )

class FilterRequestedItemsAndOrderAppleMacBookPro15Task(
    FilterRequestedItemsAndOrderCatalogItemTask
):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item='Apple MacBook Pro 15"',
            level=level,
            order_task_class=OrderAppleMacBookPro15Task,
        )


class FilterRequestedItemsAndOrderAppleWatchTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Apple Watch",
            level=level,
            order_task_class=OrderAppleWatchTask,
        )

class FilterRequestedItemsAndOrderAppleMacBookPro15Task(
    FilterRequestedItemsAndOrderCatalogItemTask
):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item='Apple MacBook Pro 15"',
            level=level,
            order_task_class=OrderAppleMacBookPro15Task,
        )

class FilterRequestedItemsAndOrderDevelopmentLaptopPCTask(
    FilterRequestedItemsAndOrderCatalogItemTask
):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Development Laptop (PC)",
            level=level,
            order_task_class=OrderDevelopmentLaptopPCTask,
        )


class FilterRequestedItemsAndOrderAppleMacBookPro15Task(
    FilterRequestedItemsAndOrderCatalogItemTask
):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item='Apple MacBook Pro 15"',
            level=level,
            order_task_class=OrderAppleMacBookPro15Task,
        )

class FilterRequestedItemsAndOrderDevelopmentLaptopPCTask(
    FilterRequestedItemsAndOrderCatalogItemTask
):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Development Laptop (PC)",
            level=level,
            order_task_class=OrderDevelopmentLaptopPCTask,
        )

class FilterRequestedItemsAndOrderLoanerLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Notebook Computer Loaner",
            level=level,
            order_task_class=OrderLoanerLaptopTask,
        )


class FilterRequestedItemsAndOrderDevelopmentLaptopPCTask(
    FilterRequestedItemsAndOrderCatalogItemTask
):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Development Laptop (PC)",
            level=level,
            order_task_class=OrderDevelopmentLaptopPCTask,
        )

class FilterRequestedItemsAndOrderLoanerLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Notebook Computer Loaner",
            level=level,
            order_task_class=OrderLoanerLaptopTask,
        )

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 FilterRequestedItemsAndOrderCatalogItemTask
]


    FilterRequestedItemsAndOrderCatalogItemTask
):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Development Laptop (PC)",
            level=level,
            order_task_class=OrderDevelopmentLaptopPCTask,
        )

class FilterRequestedItemsAndOrderLoanerLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Notebook Computer Loaner",
            level=level,
            order_task_class=OrderLoanerLaptopTask,
        )

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 FilterRequestedItemsAndOrderCatalogItemTask
]


            protocol_name="",
        )
        self.fixed_request_item = fixed_request_item
        self.order_task_class = order_task_class
        # name of the user the item will be assigned to
        self.user_full_name = (
            fake.first_name()
            + "-"
            + fake.first_name()
            + " "
            + fake.last_name()
            + "-"
            + fake.last_name()
        )
        self.short_description = f"Order same item as {self.user_full_name}"
        self.task_description = f'{self.user_full_name} has recently requested an item from the service catalog. You need to order the same. Find what it is from the "Requested Items" list and order it from the service catalog. If possible, set the item\'s configuration to match the following: \n'
        self.created_user_sys_id = None  # sys_id of the user to assign the item to
        self.requested_item_sys_id = None  # sys_id of the requested item to order
        self.tasks = []

    def _setup_list(self) -> None:
        self.filter_config = {
            "list_url": "/now/nav/ui/classic/params/target/sc_req_item_list.do",
            "expected_fields_path": EXPECTED_REQUESTED_ITEMS_COLUMNS_PATH,
            "filter_columns": [
                "requested_for",
            ],
            "filter_kind": "AND",
            "filter_operators": ["contains"],
            "filter_values": [
                f"{self.user_full_name}",
            ],
        }
        # Create a new user to assign the item to
        first_name = self.user_full_name.split(" ")[0]
        last_name = self.user_full_name.split(" ")[1]
        _, _, self.created_user_sys_id = create_user(
            self.instance, first_name=first_name, last_name=last_name, random=self.random
        )
        # Create a new requested item to order
        self.requested_item_sys_id, _ = create_requested_item(
            self.instance,
            system_name=self.fixed_request_item,
            user_sys_id=self.created_user_sys_id,
        )
        self.tasks.append(
            # After the filter has been made and the information retrieved, navigate to the catalog
            AllMenuTask(
                instance=self.instance,
                fixed_config={
                    "module": "Service Catalog",
                    "application": "Self-Service",
                },
                used_in_level_2=True,
                is_validated=False,
            )
        )
        self.tasks.append(
            SendChatMessageGenericTask(
                instance=self.instance,
                message="a",
                answer_format="a",
                level=self.level,
                description=f"Clear the existing filters on the page. \n",
                is_validated=False,
                use_description_in_l3=True,
                used_in_level_2=True,
            )
        )
        order_task_config = self.random.choice(self.order_task_class.all_configs())
        # task to order the item
        item_order_task = self.order_task_class(
            seed=self.seed,
            instance=self.instance,
            fixed_config=order_task_config,
            used_in_level_2=True,
            is_validated=True,
            config_only_in_desc=True,
        )
        self.tasks.append(item_order_task)

    def teardown(self) -> None:
        # Delete the requested item and the user if they exist
        requested_item_exists = table_api_call(
            instance=self.instance,
            table="sc_req_item",
            params={"sysparm_query": f"sys_id={self.requested_item_sys_id}"},
        )["result"]
        if requested_item_exists:
            db_delete_from_table(
                instance=self.instance,
                table="sc_req_item",
                sys_id=self.requested_item_sys_id,
            )
        user_exists = table_api_call(
            instance=self.instance,
            table="sys_user",
            params={"sysparm_query": f"sys_id={self.created_user_sys_id}"},
        )["result"]
        if user_exists:


teardown

                answer_format="a",
                level=self.level,
                description=f"Clear the existing filters on the page. \n",
                is_validated=False,
                use_description_in_l3=True,
                used_in_level_2=True,
            )
        )
        order_task_config = self.random.choice(self.order_task_class.all_configs())
        # task to order the item
        item_order_task = self.order_task_class(
            seed=self.seed,
            instance=self.instance,
            fixed_config=order_task_config,
            used_in_level_2=True,
            is_validated=True,
            config_only_in_desc=True,
        )
        self.tasks.append(item_order_task)

    def teardown(self) -> None:
        # Delete the requested item and the user if they exist
        requested_item_exists = table_api_call(
            instance=self.instance,
            table="sc_req_item",
            params={"sysparm_query": f"sys_id={self.requested_item_sys_id}"},
        )["result"]
        if requested_item_exists:
            db_delete_from_table(
                instance=self.instance,
                table="sc_req_item",
                sys_id=self.requested_item_sys_id,
            )
        user_exists = table_api_call(
            instance=self.instance,
            table="sys_user",
            params={"sysparm_query": f"sys_id={self.created_user_sys_id}"},
        )["result"]
        if user_exists:
            db_delete_from_table(
                instance=self.instance,
                table="sys_user",
                sys_id=self.created_user_sys_id,
            )

        super().teardown()

class FilterRequestedItemsAndOrderDeveloperLaptopTask(FilterRequestedItemsAndOrderCatalogItemTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            fixed_request_item="Developer Laptop (Mac)",
            level=level,
            order_task_class=OrderDeveloperLaptopTask,
        )


import re

from faker import Faker
from typing import List, Tuple

fake = Faker()

from playwright.sync_api._generated import Page

from browsergym.workarena.tasks.send_chat_message import SendChatMessageForBudgetAllocationTask

from .base import HumanEvalTask
from .delete_record import DeleteExpenseLineKnapsack
from .filter_and_do import FilterAndDoTask
from .utils.knapsack import KnapsackInstanceGenarator

from ..base import AbstractServiceNowTask

from ...api.expense_line import create_expense_line
from ...api.utils import table_api_call, db_delete_from_table
from ...config import (
    # Expected columns for the different lists
    EXPECTED_EXPENSE_LINE_COLUMNS_PATH,
)
from ...instance import SNowInstance

class FilterExpensesAndAllocateInvestmentsTask(FilterAndDoTask):
    """Task to filter expenses and allocate investments.
    Args:
    num_expenses: list[int]
        The range to choose the number of expenses from
    budget: int
        The budget to allocate to the expenses
    mode: str
        Mode of generation. Choice of "random", "trivial", "single_item", "single_item_uniform", "n_items"
        - random: Randomly generate the instance and return it; guaranteed to have a unique optimal solution
        - trivial: Generate a trivial instance with all items fitting in the knapsack; return the instance
        - single_item: Generate an instance where the optimal solution has only one item
        - n_items: Generate an instance with all items having uniform weight and value; n items fitting in the knapsack
        - single_item_uniform: Generate an instance with all items having uniform weight and value; optimal solution has only one item and it can be any
    answer_format: str
        The type of answer to generate. Choice of total_return_only, total_return_and_investments, investments_only, cleanup, cleanup_and_return
    num_items_uniform: int
        The number of items to generate in the "n_items" mode
    """

    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        num_expenses: list[int] = [3, 4],
        budget: int = 150000,
        mode: str = "random",
        num_items_uniform: int = None,
        answer_format: str = None,
        level: int = 2,
    ) -> None:
        super().__init__(
            seed=seed,
            instance=instance,
            fixed_config=fixed_config,
            navigation_config={
                "module": "Expense Lines",
                "application": "Cost",
            },
            level=level,
            protocol_name="Maximizing total investment return",
        )
        self.num_expenses = self.random.randint(num_expenses[0], num_expenses[1] + 1)
        # In these settings, we need to vary the budget
        if mode in ["single_item_uniform", "n_items"]:
            min_budget = budget / 5
            max_budget = budget * 5
            self.budget = self.random.randint(min_budget, max_budget)
        else:
            self.budget = budget
        self.mode = mode
        self.answer_format = answer_format
        self.num_items_uniform = 1 if mode == "single_item_uniform" else num_items_uniform

        self.expense_hashtag = "#" + self.unique_id[:10]
        self.short_description = f"Allocate investments to maximize returns"
        self.expense_line_sys_ids = []
        self.expense_line_numbers = []
        self.correct_investments = (
            []
        )  # List of correct investments to check for in the chat messages
        self.incorrect_investments = (
            []
        )  # List of incorrect investments to check for in the chat messages
        self.potential_investments = None  # List of tuples (cost, return) of potential investments
        self.max_return = None  # Maximum return possible with optimal solution
        self.alternative_max_return_formats = (
            []
        )  # List of alternative formats for the maximum return to check for in the chat messages
        self.selected_investment_indices = (
            None  # Indices of the selected investments in the optimal solution
        )
        # flag to check if the investments are correctly selected and total return is correct
        self.investments_correctly_selected = False
        self.total_return_correct = False

    def _setup_list(self) -> None:
        self.filter_config = {
            "list_url": "/now/nav/ui/classic/params/target/fm_expense_line_list.do",
            "expected_fields_path": EXPECTED_EXPENSE_LINE_COLUMNS_PATH,
            "filter_columns": [
                "short_description",
            ],
            "filter_kind": "AND",
            "filter_operators": ["contains"],
            "filter_values": [
                f"{self.expense_hashtag}",
            ],
        }
        knapsack = KnapsackInstanceGenarator(
            random=self.random,
            num_items=self.num_expenses,
            max_capacity=self.budget,
            mode=self.mode,
            num_items_in_solution=self.num_items_uniform,
        )
        # investments is a list of tuples, where each tuple is (cost, return)
        self.potential_investments, self.max_return, self.selected_investment_indices = (
            knapsack.get_instance()
        )
        # Accepted answer formats for the maximum return
        self.alternative_max_return_formats = [
            str(self.max_return),  # No comma
            "{:,}".format(self.max_return),  # Comma as thousand separator
            "{:,}".format(self.max_return).replace(
                ",", ", "
            ),  # Comma as thousand separator with space after
            "{:,}".format(self.max_return).replace(",", " "),  # Space as thousand separator
        ]

        for i, investment in enumerate(self.potential_investments):
            expense_number = f"EXP-{i}{self.unique_id[:10]}"
            # Include the return inside the short description
            short_description = f"Build {fake.sentence(2)} - Return: {investment[1]}$ "
            expense_sys_id, expense_number = create_expense_line(
                instance=self.instance,
                amount=investment[0],
                number=expense_number,
                date=str(fake.date_this_year(before_today=True, after_today=False)),
                short_description=short_description,
                expense_hashtag=self.expense_hashtag,
                user_sys_id=self._base_user_sysid,
            )
            self.expense_line_sys_ids.append(expense_sys_id)
            self.expense_line_numbers.append(expense_number)

        # In this setting there is only one valid answer
        if self.mode in ["random", "trivial", "single_item"]:
            for i, investment in enumerate(self.potential_investments):
                if i in self.selected_investment_indices:
                    self.correct_investments.append(self.expense_line_numbers[i])
                else:
                    self.incorrect_investments.append(self.expense_line_numbers[i])
        # In this setting, many answers are possible, it's only a matter of respecting the number of items in the solution
        # We store values here just so the cheat function can work uniformly
        elif self.mode in ["n_items", "single_item_uniform"]:
            for i, investment in enumerate(self.potential_investments):
                if i < self.num_items_uniform:
                    self.correct_investments.append(self.expense_line_numbers[i])
                else:
                    self.incorrect_investments.append(self.expense_line_numbers[i])

    def validate(self, page: Page, chat_messages: List[str]) -> Tuple[float, bool, str, dict]:
        super().validate(page, chat_messages)

    def check_total_return(
        self, page: Page, chat_messages: List[str]
    ) -> Tuple[float, bool, str, dict]:
        """Simple check that validates that the total return is correct."""
        if self.total_return_correct:
            return (
                1,
                True,
                "That is correct, thank you!",
                {"message": "Correct total return."},
            )

        if chat_messages and chat_messages[-1]["role"] == "assistant":
            answer = chat_messages[-1]["message"]
        else:
            return (
                0,
                False,
                "",
                {"message": "The assistant did not provide an answer."},
            )
        for format in self.alternative_max_return_formats:
            if format in answer:
                self.total_return_correct = True
                return (
                    1,
                    True,
                    "That is correct, thank you!",
                    {"message": "Correct answer."},
                )

        return (
            0,
            False,
            "",
            {"message": "Incorrect answer."},
        )

    def check_correct_investments_sent_in_chat(
        self, page: Page, chat_messages: List[str]
    ) -> Tuple[float, bool, str, dict]:
        """Check that the correct investments have been selected and their numbers have been sent in the chat"""
        if not self.investments_correctly_selected:
            if chat_messages and chat_messages[-1]["role"] == "assistant":
                answer = chat_messages[-1]["message"]
            else:
                return (
                    0,
                    False,
                    "",
                    {"message": "The assistant did not provide an answer."},
                )

            # In these settings, there is only one valid answer
            if self.mode in ["random", "trivial", "single_item"]:
                # Check that the correct investments have been selected
                for investment in self.correct_investments:
                    if investment not in answer:
                        return (
                            0,
                            False,
                            "",
                            {"message": "Investment missing from selected list."},
                        )
                # Check that the incorrect investments have not been selected
                for investment in self.incorrect_investments:
                    if investment in answer:
                        return (
                            0,
                            False,
                            "",
                            {"message": "Incorrect investment selected."},
                        )
            # In those settings, many answers are possible, it's only a matter of respecting the number of items in the solution
            elif self.mode in ["n_items", "single_item_uniform"]:
                # Extract the expense line numbers from the answer
                pattern = r"EXP-\w+-\w+"
                matches = re.findall(pattern, answer)
                if len(matches) != self.num_items_uniform:
                    return (
                        0,
                        False,
                        "",
                        {"message": "Incorrect number of investments selected."},
                    )
            self.correct_investments_selected = True

        return (
            1,
            True,
            "That is correct, thank you!",
            {"message": "Correct investments selected."},
        )

    def check_only_right_investment_kept(
        self, page: Page, chat_messages: List[str]
    ) -> Tuple[float, bool, str, dict]:
        """Checks that only the expected investments were kept; i.e. the others were deleted"""
        for i, investment_sys_id in enumerate(self.expense_line_sys_ids):
            record_expected = i in self.selected_investment_indices
            record_exists = table_api_call(
                instance=self.instance,
                table="fm_expense_line",
                params={"sysparm_query": f"sys_id={investment_sys_id}"},
            )["result"]
            # Missing investment that should be kept
            if record_expected and not record_exists:
                return (
                    0,
                    True,
                    "",
                    {"message": "Expected investment has been deleted."},
                )
            # Unexpected investment that should be deleted
            if not record_expected and record_exists:
                return (
                    0,
                    False,
                    "",
                    {"message": "Unexpected investment is present."},
                )

        return (
            1,
            True,
            "That is correct, thank you!",
            {"message": "Correct investments kept."},
        )

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

class FilterExpensesAndFindTotalReturnTask(FilterExpensesAndAllocateInvestmentsTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: list[AbstractServiceNowTask] = None,
        num_expenses: list[int] = [3, 4],
        budget: int = 150000,
        mode: str = "random",
        answer_format: str = "total_return_only",
        num_items_uniform: int = 1,
        level: int = 2,
    ):
        super().__init__(
            seed,
            instance,
            fixed_config,
            num_expenses=num_expenses,
            budget=budget,
            mode=mode,
            num_items_uniform=num_items_uniform,
            answer_format=answer_format,
            level=level,
        )
        self.task_description = f'Follow protocol "{self.protocol_name}" (located in the "Company Protocols" knowledge base) to allocate investments to the expenses with short description containing {self.expense_hashtag} to maximize returns while fitting inside the budget of {self.budget}$. Give total return of selected investments only. '

    def _setup_list(self) -> None:
        super()._setup_list()
        self.tasks = [
            SendChatMessageForBudgetAllocationTask(
                instance=self.instance,
                message=f"The total value of the investments is {self.max_return}$",
                used_in_level_2=True,
                is_validated=False,
                budget=self.budget,
                answer_format=self.answer_format,
                level=self.level,
            )
        ]

    def validate(self, page: Page, chat_messages: List[str]) -> Tuple[float, bool, str, dict]:
        reward, done, message, info = self.check_total_return(page, chat_messages)
        if reward == 1 and done:
            return FilterAndDoTask.validate(self, page, chat_messages)
        else:
            return reward, done, message, info

class FilterRandomExpensesAndFindTotalReturnSmallTask(
    FilterExpensesAndFindTotalReturnTask, HumanEvalTask
):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: List[AbstractServiceNowTask] = None,
        level: int = 2,
    ):
        super().__init__(
            seed,
            instance,
            fixed_config,
            num_expenses=[3, 5],
            budget=150000,
            mode="random",
            level=level,
        )

class FilterRandomExpensesAndFindTotalReturnMediumTask(FilterExpensesAndFindTotalReturnTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: List[AbstractServiceNowTask] = None,
        level: int = 2,
    ):
        super().__init__(
            seed,
            instance,
            fixed_config,
            num_expenses=[6, 8],
            budget=150000,
            mode="random",
            level=level,
        )

class FilterRandomExpensesAndFindTotalReturnLargeTask(FilterExpensesAndFindTotalReturnTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: List[AbstractServiceNowTask] = None,
        level: int = 2,
    ):
        super().__init__(
            seed,
            instance,
            fixed_config,
            num_expenses=[9, 12],
            budget=150000,
            mode="random",
            level=level,
        )

class FilterTrivialExpensesAndFindTotalReturnSmallTask(
    FilterExpensesAndFindTotalReturnTask, HumanEvalTask
):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: List[AbstractServiceNowTask] = None,
        level: int = 2,
    ):
        super().__init__(
            seed,
            instance,
            fixed_config,
            num_expenses=[3, 5],
            budget=150000,
            mode="trivial",
            level=level,
        )

class FilterTrivialExpensesAndFindTotalReturnMediumTask(FilterExpensesAndFindTotalReturnTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: List[AbstractServiceNowTask] = None,
        level: int = 2,
    ):
        super().__init__(
            seed,
            instance,
            fixed_config,
            num_expenses=[6, 8],
            budget=150000,
            mode="trivial",
            level=level,
        )

class FilterTrivialExpensesAndFindTotalReturnLargeTask(FilterExpensesAndFindTotalReturnTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: List[AbstractServiceNowTask] = None,
        level: int = 2,
    ):
        super().__init__(
            seed,
            instance,
            fixed_config,
            num_expenses=[9, 12],
            budget=150000,
            mode="trivial",
            level=level,
        )

class FilterSingleItemExpensesAndFindTotalReturnSmallTask(
    FilterExpensesAndFindTotalReturnTask, HumanEvalTask
):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: List[AbstractServiceNowTask] = None,
        level: int = 2,
    ):
        super().__init__(
            seed,
            instance,
            fixed_config,
            num_expenses=[3, 5],
            budget=150000,
            mode="single_item",
            level=level,
        )

class FilterSingleItemExpensesAndFindTotalReturnMediumTask(FilterExpensesAndFindTotalReturnTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: List[AbstractServiceNowTask] = None,
        level: int = 2,
    ):
        super().__init__(
            seed,
            instance,
            fixed_config,
            num_expenses=[6, 8],
            budget=150000,
            mode="single_item",
            level=level,
        )

class FilterSingleItemExpensesAndFindTotalReturnLargeTask(FilterExpensesAndFindTotalReturnTask):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: List[AbstractServiceNowTask] = None,
        level: int = 2,
    ):
        super().__init__(
            seed,
            instance,
            fixed_config,
            num_expenses=[9, 12],
            budget=150000,
            mode="single_item",
            level=level,
        )

class FilterSingleItemUniformExpensesAndFindTotalReturnSmallTask(
    FilterExpensesAndFindTotalReturnTask, HumanEvalTask
):
    def __init__(
        self,
        seed: int,
        instance: SNowInstance = None,
        fixed_config: List[Abst
# ... truncated ...