from __future__ import annotations

from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar, cast

from attrs import define as _attrs_define
from attrs import field as _attrs_field

from ..types import UNSET, Unset

if TYPE_CHECKING:
    from ..models.types_payroll_api_mapping_source import TypesPayrollAPIMappingSource


T = TypeVar("T", bound="TypesPayrollAPIMapping")


@_attrs_define
class TypesPayrollAPIMapping:
    """
    Attributes:
        ee_pre_tax (list[TypesPayrollAPIMappingSource] | Unset):
        ee_roth (list[TypesPayrollAPIMappingSource] | Unset):
        er_match (list[TypesPayrollAPIMappingSource] | Unset):
        er_non_elective (list[TypesPayrollAPIMappingSource] | Unset):
        er_qaca_match (list[TypesPayrollAPIMappingSource] | Unset):
        er_safe_harbor_match (list[TypesPayrollAPIMappingSource] | Unset):
        er_safe_harbor_non_elective (list[TypesPayrollAPIMappingSource] | Unset):
        hpi_compensation (list[TypesPayrollAPIMappingSource] | Unset):
        ignore (list[str] | Unset): Fields to ignore - if there is a new field that's not in this list, we will flag for
            review
        plan (str | Unset): For each field, we take the sum of all sources
        plan_compensation (list[TypesPayrollAPIMappingSource] | Unset):
        prevailing_wage (list[TypesPayrollAPIMappingSource] | Unset):
        statutory_compensation (list[TypesPayrollAPIMappingSource] | Unset): This is the base salary
    """

    ee_pre_tax: list[TypesPayrollAPIMappingSource] | Unset = UNSET
    ee_roth: list[TypesPayrollAPIMappingSource] | Unset = UNSET
    er_match: list[TypesPayrollAPIMappingSource] | Unset = UNSET
    er_non_elective: list[TypesPayrollAPIMappingSource] | Unset = UNSET
    er_qaca_match: list[TypesPayrollAPIMappingSource] | Unset = UNSET
    er_safe_harbor_match: list[TypesPayrollAPIMappingSource] | Unset = UNSET
    er_safe_harbor_non_elective: list[TypesPayrollAPIMappingSource] | Unset = UNSET
    hpi_compensation: list[TypesPayrollAPIMappingSource] | Unset = UNSET
    ignore: list[str] | Unset = UNSET
    plan: str | Unset = UNSET
    plan_compensation: list[TypesPayrollAPIMappingSource] | Unset = UNSET
    prevailing_wage: list[TypesPayrollAPIMappingSource] | Unset = UNSET
    statutory_compensation: list[TypesPayrollAPIMappingSource] | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        ee_pre_tax: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.ee_pre_tax, Unset):
            ee_pre_tax = []
            for ee_pre_tax_item_data in self.ee_pre_tax:
                ee_pre_tax_item = ee_pre_tax_item_data.to_dict()
                ee_pre_tax.append(ee_pre_tax_item)

        ee_roth: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.ee_roth, Unset):
            ee_roth = []
            for ee_roth_item_data in self.ee_roth:
                ee_roth_item = ee_roth_item_data.to_dict()
                ee_roth.append(ee_roth_item)

        er_match: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.er_match, Unset):
            er_match = []
            for er_match_item_data in self.er_match:
                er_match_item = er_match_item_data.to_dict()
                er_match.append(er_match_item)

        er_non_elective: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.er_non_elective, Unset):
            er_non_elective = []
            for er_non_elective_item_data in self.er_non_elective:
                er_non_elective_item = er_non_elective_item_data.to_dict()
                er_non_elective.append(er_non_elective_item)

        er_qaca_match: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.er_qaca_match, Unset):
            er_qaca_match = []
            for er_qaca_match_item_data in self.er_qaca_match:
                er_qaca_match_item = er_qaca_match_item_data.to_dict()
                er_qaca_match.append(er_qaca_match_item)

        er_safe_harbor_match: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.er_safe_harbor_match, Unset):
            er_safe_harbor_match = []
            for er_safe_harbor_match_item_data in self.er_safe_harbor_match:
                er_safe_harbor_match_item = er_safe_harbor_match_item_data.to_dict()
                er_safe_harbor_match.append(er_safe_harbor_match_item)

        er_safe_harbor_non_elective: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.er_safe_harbor_non_elective, Unset):
            er_safe_harbor_non_elective = []
            for er_safe_harbor_non_elective_item_data in self.er_safe_harbor_non_elective:
                er_safe_harbor_non_elective_item = er_safe_harbor_non_elective_item_data.to_dict()
                er_safe_harbor_non_elective.append(er_safe_harbor_non_elective_item)

        hpi_compensation: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.hpi_compensation, Unset):
            hpi_compensation = []
            for hpi_compensation_item_data in self.hpi_compensation:
                hpi_compensation_item = hpi_compensation_item_data.to_dict()
                hpi_compensation.append(hpi_compensation_item)

        ignore: list[str] | Unset = UNSET
        if not isinstance(self.ignore, Unset):
            ignore = self.ignore

        plan = self.plan

        plan_compensation: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.plan_compensation, Unset):
            plan_compensation = []
            for plan_compensation_item_data in self.plan_compensation:
                plan_compensation_item = plan_compensation_item_data.to_dict()
                plan_compensation.append(plan_compensation_item)

        prevailing_wage: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.prevailing_wage, Unset):
            prevailing_wage = []
            for prevailing_wage_item_data in self.prevailing_wage:
                prevailing_wage_item = prevailing_wage_item_data.to_dict()
                prevailing_wage.append(prevailing_wage_item)

        statutory_compensation: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.statutory_compensation, Unset):
            statutory_compensation = []
            for statutory_compensation_item_data in self.statutory_compensation:
                statutory_compensation_item = statutory_compensation_item_data.to_dict()
                statutory_compensation.append(statutory_compensation_item)

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if ee_pre_tax is not UNSET:
            field_dict["ee_pre_tax"] = ee_pre_tax
        if ee_roth is not UNSET:
            field_dict["ee_roth"] = ee_roth
        if er_match is not UNSET:
            field_dict["er_match"] = er_match
        if er_non_elective is not UNSET:
            field_dict["er_non_elective"] = er_non_elective
        if er_qaca_match is not UNSET:
            field_dict["er_qaca_match"] = er_qaca_match
        if er_safe_harbor_match is not UNSET:
            field_dict["er_safe_harbor_match"] = er_safe_harbor_match
        if er_safe_harbor_non_elective is not UNSET:
            field_dict["er_safe_harbor_non_elective"] = er_safe_harbor_non_elective
        if hpi_compensation is not UNSET:
            field_dict["hpi_compensation"] = hpi_compensation
        if ignore is not UNSET:
            field_dict["ignore"] = ignore
        if plan is not UNSET:
            field_dict["plan"] = plan
        if plan_compensation is not UNSET:
            field_dict["plan_compensation"] = plan_compensation
        if prevailing_wage is not UNSET:
            field_dict["prevailing_wage"] = prevailing_wage
        if statutory_compensation is not UNSET:
            field_dict["statutory_compensation"] = statutory_compensation

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.types_payroll_api_mapping_source import TypesPayrollAPIMappingSource

        d = dict(src_dict)
        _ee_pre_tax = d.pop("ee_pre_tax", UNSET)
        ee_pre_tax: list[TypesPayrollAPIMappingSource] | Unset = UNSET
        if _ee_pre_tax is not UNSET:
            ee_pre_tax = []
            for ee_pre_tax_item_data in _ee_pre_tax:
                ee_pre_tax_item = TypesPayrollAPIMappingSource.from_dict(ee_pre_tax_item_data)

                ee_pre_tax.append(ee_pre_tax_item)

        _ee_roth = d.pop("ee_roth", UNSET)
        ee_roth: list[TypesPayrollAPIMappingSource] | Unset = UNSET
        if _ee_roth is not UNSET:
            ee_roth = []
            for ee_roth_item_data in _ee_roth:
                ee_roth_item = TypesPayrollAPIMappingSource.from_dict(ee_roth_item_data)

                ee_roth.append(ee_roth_item)

        _er_match = d.pop("er_match", UNSET)
        er_match: list[TypesPayrollAPIMappingSource] | Unset = UNSET
        if _er_match is not UNSET:
            er_match = []
            for er_match_item_data in _er_match:
                er_match_item = TypesPayrollAPIMappingSource.from_dict(er_match_item_data)

                er_match.append(er_match_item)

        _er_non_elective = d.pop("er_non_elective", UNSET)
        er_non_elective: list[TypesPayrollAPIMappingSource] | Unset = UNSET
        if _er_non_elective is not UNSET:
            er_non_elective = []
            for er_non_elective_item_data in _er_non_elective:
                er_non_elective_item = TypesPayrollAPIMappingSource.from_dict(er_non_elective_item_data)

                er_non_elective.append(er_non_elective_item)

        _er_qaca_match = d.pop("er_qaca_match", UNSET)
        er_qaca_match: list[TypesPayrollAPIMappingSource] | Unset = UNSET
        if _er_qaca_match is not UNSET:
            er_qaca_match = []
            for er_qaca_match_item_data in _er_qaca_match:
                er_qaca_match_item = TypesPayrollAPIMappingSource.from_dict(er_qaca_match_item_data)

                er_qaca_match.append(er_qaca_match_item)

        _er_safe_harbor_match = d.pop("er_safe_harbor_match", UNSET)
        er_safe_harbor_match: list[TypesPayrollAPIMappingSource] | Unset = UNSET
        if _er_safe_harbor_match is not UNSET:
            er_safe_harbor_match = []
            for er_safe_harbor_match_item_data in _er_safe_harbor_match:
                er_safe_harbor_match_item = TypesPayrollAPIMappingSource.from_dict(er_safe_harbor_match_item_data)

                er_safe_harbor_match.append(er_safe_harbor_match_item)

        _er_safe_harbor_non_elective = d.pop("er_safe_harbor_non_elective", UNSET)
        er_safe_harbor_non_elective: list[TypesPayrollAPIMappingSource] | Unset = UNSET
        if _er_safe_harbor_non_elective is not UNSET:
            er_safe_harbor_non_elective = []
            for er_safe_harbor_non_elective_item_data in _er_safe_harbor_non_elective:
                er_safe_harbor_non_elective_item = TypesPayrollAPIMappingSource.from_dict(
                    er_safe_harbor_non_elective_item_data
                )

                er_safe_harbor_non_elective.append(er_safe_harbor_non_elective_item)

        _hpi_compensation = d.pop("hpi_compensation", UNSET)
        hpi_compensation: list[TypesPayrollAPIMappingSource] | Unset = UNSET
        if _hpi_compensation is not UNSET:
            hpi_compensation = []
            for hpi_compensation_item_data in _hpi_compensation:
                hpi_compensation_item = TypesPayrollAPIMappingSource.from_dict(hpi_compensation_item_data)

                hpi_compensation.append(hpi_compensation_item)

        ignore = cast(list[str], d.pop("ignore", UNSET))

        plan = d.pop("plan", UNSET)

        _plan_compensation = d.pop("plan_compensation", UNSET)
        plan_compensation: list[TypesPayrollAPIMappingSource] | Unset = UNSET
        if _plan_compensation is not UNSET:
            plan_compensation = []
            for plan_compensation_item_data in _plan_compensation:
                plan_compensation_item = TypesPayrollAPIMappingSource.from_dict(plan_compensation_item_data)

                plan_compensation.append(plan_compensation_item)

        _prevailing_wage = d.pop("prevailing_wage", UNSET)
        prevailing_wage: list[TypesPayrollAPIMappingSource] | Unset = UNSET
        if _prevailing_wage is not UNSET:
            prevailing_wage = []
            for prevailing_wage_item_data in _prevailing_wage:
                prevailing_wage_item = TypesPayrollAPIMappingSource.from_dict(prevailing_wage_item_data)

                prevailing_wage.append(prevailing_wage_item)

        _statutory_compensation = d.pop("statutory_compensation", UNSET)
        statutory_compensation: list[TypesPayrollAPIMappingSource] | Unset = UNSET
        if _statutory_compensation is not UNSET:
            statutory_compensation = []
            for statutory_compensation_item_data in _statutory_compensation:
                statutory_compensation_item = TypesPayrollAPIMappingSource.from_dict(statutory_compensation_item_data)

                statutory_compensation.append(statutory_compensation_item)

        types_payroll_api_mapping = cls(
            ee_pre_tax=ee_pre_tax,
            ee_roth=ee_roth,
            er_match=er_match,
            er_non_elective=er_non_elective,
            er_qaca_match=er_qaca_match,
            er_safe_harbor_match=er_safe_harbor_match,
            er_safe_harbor_non_elective=er_safe_harbor_non_elective,
            hpi_compensation=hpi_compensation,
            ignore=ignore,
            plan=plan,
            plan_compensation=plan_compensation,
            prevailing_wage=prevailing_wage,
            statutory_compensation=statutory_compensation,
        )

        types_payroll_api_mapping.additional_properties = d
        return types_payroll_api_mapping

    @property
    def additional_keys(self) -> list[str]:
        return list(self.additional_properties.keys())

    def __getitem__(self, key: str) -> Any:
        return self.additional_properties[key]

    def __setitem__(self, key: str, value: Any) -> None:
        self.additional_properties[key] = value

    def __delitem__(self, key: str) -> None:
        del self.additional_properties[key]

    def __contains__(self, key: str) -> bool:
        return key in self.additional_properties
