import warnings
from enum import IntFlag
from typing import Optional, Union

from .. import xdr as stellar_xdr
from ..keypair import Keypair
from ..muxed_account import MuxedAccount
from ..signer import Signer
from ..strkey import StrKey
from ..type_checked import type_checked
from ..utils import raise_if_not_valid_ed25519_public_key
from .operation import Operation

__all__ = ["AuthorizationFlag", "SetOptions"]


class AuthorizationFlag(IntFlag):
    """Indicates which flags to set. For details about the flags,
    please refer to the `Control Access to an Asset - Flag <https://developers.stellar.org/docs/issuing-assets/control-asset-access/#flags>`__.
    """

    AUTHORIZATION_REQUIRED = 1
    AUTHORIZATION_REVOCABLE = 2
    AUTHORIZATION_IMMUTABLE = 4
    AUTHORIZATION_CLAWBACK_ENABLED = 8


@type_checked
class SetOptions(Operation):
    """The :class:`SetOptions` object, which represents a SetOptions operation
    on Stellar's network.

    This operation sets the options for an account.

    For more information on the signing options, please refer to the `multi-sig
    doc <https://developers.stellar.org/docs/glossary/multisig/>`_.

    When updating signers or other thresholds, the threshold of this operation
    is high.

    Threshold: Medium or High

    See `Set Options <https://developers.stellar.org/docs/start/list-of-operations/#set-options>`_ for more information.

    :param inflation_dest: Account of the inflation destination.
    :param clear_flags: Indicates which flags to clear. For details about the flags,
        please refer to the `Control Access to an Asset - Flag <https://developers.stellar.org/docs/issuing-assets/control-asset-access/#flags>`__.
        The `bit mask <https://en.wikipedia.org/wiki/Bit_field>`_ integer subtracts from the existing flags of the account.
        This allows for setting specific bits without knowledge of existing flags, you can also use
        :class:`stellar_sdk.operation.set_options.AuthorizationFlag`

        * AUTHORIZATION_REQUIRED = 1
        * AUTHORIZATION_REVOCABLE = 2
        * AUTHORIZATION_IMMUTABLE = 4