# generated by datamodel-codegen:
#   filename:  core/user_match.json
#   timestamp: 2026-02-23T01:56:40+00:00

from __future__ import annotations

from typing import Annotated

from adcp.types.base import AdCPBaseModel
from pydantic import ConfigDict, Field, RootModel

from ..enums import uid_type
from . import ext as ext_1


class Uid(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    type: Annotated[uid_type.UidType, Field(description='Universal ID type')]
    value: Annotated[str, Field(description='Universal ID value')]


class UserMatch1(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    click_id: Annotated[
        str | None,
        Field(description='Platform click identifier (fbclid, gclid, ttclid, ScCid, etc.)'),
    ] = None
    click_id_type: Annotated[
        str | None,
        Field(description='Type of click identifier (e.g. fbclid, gclid, ttclid, msclkid, ScCid)'),
    ] = None
    client_ip: Annotated[
        str | None, Field(description='Client IP address for probabilistic matching')
    ] = None
    client_user_agent: Annotated[
        str | None, Field(description='Client user agent string for probabilistic matching')
    ] = None
    ext: ext_1.ExtensionObject | None = None
    hashed_email: Annotated[
        str | None,
        Field(
            description='SHA-256 hash of lowercase, trimmed email address. Buyer must normalize before hashing: lowercase, trim whitespace.',
            pattern='^[a-f0-9]{64}$',
        ),
    ] = None
    hashed_phone: Annotated[
        str | None,
        Field(
            description='SHA-256 hash of E.164-formatted phone number (e.g. +12065551234). Buyer must normalize to E.164 before hashing.',
            pattern='^[a-f0-9]{64}$',
        ),
    ] = None
    uids: Annotated[
        list[Uid], Field(description='Universal ID values for user matching', min_length=1)
    ]


class UserMatch2(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    click_id: Annotated[
        str | None,
        Field(description='Platform click identifier (fbclid, gclid, ttclid, ScCid, etc.)'),
    ] = None
    click_id_type: Annotated[
        str | None,
        Field(description='Type of click identifier (e.g. fbclid, gclid, ttclid, msclkid, ScCid)'),
    ] = None
    client_ip: Annotated[
        str | None, Field(description='Client IP address for probabilistic matching')
    ] = None
    client_user_agent: Annotated[
        str | None, Field(description='Client user agent string for probabilistic matching')
    ] = None
    ext: ext_1.ExtensionObject | None = None
    hashed_email: Annotated[
        str,
        Field(
            description='SHA-256 hash of lowercase, trimmed email address. Buyer must normalize before hashing: lowercase, trim whitespace.',
            pattern='^[a-f0-9]{64}$',
        ),
    ]
    hashed_phone: Annotated[
        str | None,
        Field(
            description='SHA-256 hash of E.164-formatted phone number (e.g. +12065551234). Buyer must normalize to E.164 before hashing.',
            pattern='^[a-f0-9]{64}$',
        ),
    ] = None
    uids: Annotated[
        list[Uid] | None, Field(description='Universal ID values for user matching', min_length=1)
    ] = None


class UserMatch3(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    click_id: Annotated[
        str | None,
        Field(description='Platform click identifier (fbclid, gclid, ttclid, ScCid, etc.)'),
    ] = None
    click_id_type: Annotated[
        str | None,
        Field(description='Type of click identifier (e.g. fbclid, gclid, ttclid, msclkid, ScCid)'),
    ] = None
    client_ip: Annotated[
        str | None, Field(description='Client IP address for probabilistic matching')
    ] = None
    client_user_agent: Annotated[
        str | None, Field(description='Client user agent string for probabilistic matching')
    ] = None
    ext: ext_1.ExtensionObject | None = None
    hashed_email: Annotated[
        str | None,
        Field(
            description='SHA-256 hash of lowercase, trimmed email address. Buyer must normalize before hashing: lowercase, trim whitespace.',
            pattern='^[a-f0-9]{64}$',
        ),
    ] = None
    hashed_phone: Annotated[
        str,
        Field(
            description='SHA-256 hash of E.164-formatted phone number (e.g. +12065551234). Buyer must normalize to E.164 before hashing.',
            pattern='^[a-f0-9]{64}$',
        ),
    ]
    uids: Annotated[
        list[Uid] | None, Field(description='Universal ID values for user matching', min_length=1)
    ] = None


class UserMatch4(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    click_id: Annotated[
        str, Field(description='Platform click identifier (fbclid, gclid, ttclid, ScCid, etc.)')
    ]
    click_id_type: Annotated[
        str | None,
        Field(description='Type of click identifier (e.g. fbclid, gclid, ttclid, msclkid, ScCid)'),
    ] = None
    client_ip: Annotated[
        str | None, Field(description='Client IP address for probabilistic matching')
    ] = None
    client_user_agent: Annotated[
        str | None, Field(description='Client user agent string for probabilistic matching')
    ] = None
    ext: ext_1.ExtensionObject | None = None
    hashed_email: Annotated[
        str | None,
        Field(
            description='SHA-256 hash of lowercase, trimmed email address. Buyer must normalize before hashing: lowercase, trim whitespace.',
            pattern='^[a-f0-9]{64}$',
        ),
    ] = None
    hashed_phone: Annotated[
        str | None,
        Field(
            description='SHA-256 hash of E.164-formatted phone number (e.g. +12065551234). Buyer must normalize to E.164 before hashing.',
            pattern='^[a-f0-9]{64}$',
        ),
    ] = None
    uids: Annotated[
        list[Uid] | None, Field(description='Universal ID values for user matching', min_length=1)
    ] = None


class UserMatch5(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    click_id: Annotated[
        str | None,
        Field(description='Platform click identifier (fbclid, gclid, ttclid, ScCid, etc.)'),
    ] = None
    click_id_type: Annotated[
        str | None,
        Field(description='Type of click identifier (e.g. fbclid, gclid, ttclid, msclkid, ScCid)'),
    ] = None
    client_ip: Annotated[str, Field(description='Client IP address for probabilistic matching')]
    client_user_agent: Annotated[
        str, Field(description='Client user agent string for probabilistic matching')
    ]
    ext: ext_1.ExtensionObject | None = None
    hashed_email: Annotated[
        str | None,
        Field(
            description='SHA-256 hash of lowercase, trimmed email address. Buyer must normalize before hashing: lowercase, trim whitespace.',
            pattern='^[a-f0-9]{64}$',
        ),
    ] = None
    hashed_phone: Annotated[
        str | None,
        Field(
            description='SHA-256 hash of E.164-formatted phone number (e.g. +12065551234). Buyer must normalize to E.164 before hashing.',
            pattern='^[a-f0-9]{64}$',
        ),
    ] = None
    uids: Annotated[
        list[Uid] | None, Field(description='Universal ID values for user matching', min_length=1)
    ] = None


class UserMatch(RootModel[UserMatch1 | UserMatch2 | UserMatch3 | UserMatch4 | UserMatch5]):
    root: Annotated[
        UserMatch1 | UserMatch2 | UserMatch3 | UserMatch4 | UserMatch5,
        Field(
            description='User identifiers for attribution matching. Supports universal IDs, hashed identifiers, click IDs, and probabilistic matching.',
            title='User Match',
        ),
    ]
