#  Copyright (c) yibocat 2025 All Rights Reserved
#  Python: 3.12.7
#  Date: 2025/8/18 18:23
#  Author: yibow
#  Email: yibocat@yeah.net
#  Software: AxisFuzzy


from typing import Any, Optional, Dict, List, Tuple, Union

import numpy as np

from .base import FuzznumStrategy


class Fuzznum:
    # --- 核心属性 ---
    __array_priority__: float
    mtype: str
    q: int
    md: Optional[float]
    nmd: Optional[float]

    # --- 核心、与 mtype 无关的方法 ---
    def __init__(self, mtype: Optional[str] = ..., q: Optional[int] = ...) -> None: ...
    def create(self, **kwargs: Any) -> 'Fuzznum': ...
    def copy(self) -> 'Fuzznum': ...
    def get_strategy_instance(self) -> FuzznumStrategy: ...
    def get_strategy_attributes_dict(self) -> Dict[str, Any]: ...
    def get_info(self) -> Dict[str, Any]: ...
    def validate_state(self) -> Dict[str, Any]: ...
    def to_dict(self) -> Dict[str, Any]: ...
    @classmethod
    def from_dict(cls, data: Dict[str, Any]) -> 'Fuzznum': ...

    # --- NumPy 兼容属性 ---
    @property
    def shape(self) -> Tuple[()]: ...
    @property
    def ndim(self) -> int: ...
    @property
    def size(self) -> int: ...
    @property
    def score(self) -> float: ...
    @property
    def acc(self) -> float: ...
    @property
    def ind(self) -> float: ...

    # --- Mixin 系统注入的通用方法 (mtype-agnostic) ---
    def reshape(self, *shape: int) -> Fuzzarray: ...
    def flatten(self) -> Fuzzarray: ...
    def squeeze(self, axis: Union[int, Tuple[int, ...], None] = ...) -> 'Fuzznum': ...
    def ravel(self) -> Fuzzarray: ...
    def transpose(self, *axes) -> 'Fuzznum': ...
    @property
    def T(self) -> 'Fuzznum': ...
    def broadcast_to(self, *shape: int) -> Fuzzarray: ...
    def item(self, *args) -> 'Fuzznum': ...
    def append(self,
               item: Union['Fuzznum', Fuzzarray, List['Fuzznum']],
               axis: Optional[int] = ...,
               inplace: bool = ...) -> Union[Fuzzarray, None]: ...
    def pop(self, index: int = ..., inplace: bool = ...) -> Union['Fuzznum', Tuple['Fuzznum', Fuzzarray], None]: ...

    # --- Extension 系统注入的方法 (mtype-specific but common API) ---
    # 我们在这里声明它们，但返回类型是 Any，因为具体实现依赖 mtype
    def distance(self, other: 'Fuzzarray', *args: Any, **kwargs: Any) -> Union[np.ndarray, float]: ...
    def sum(self, axis: Optional[int] = ...) -> Any: ...
    def mean(self, axis: Optional[int] = ...) -> Any: ...
    def max(self, axis: Optional[int] = ...) -> Any: ...
    def min(self, axis: Optional[int] = ...) -> Any: ...
    def prod(self, axis: Optional[int] = ...) -> Any: ...
    def var(self, axis: Optional[int] = ...) -> Any: ...
    def std(self, axis: Optional[int] = ...) -> Any: ...

    def __getstate__(self) -> Dict[str, Any]: ...
    def __setstate__(self, state: Dict[str, Any]) -> None: ...

    # 动态委托：允许外部 strategy / extension 注入任意属性或方法
    def __getattr__(self, name: str) -> Any: ...
    def __getattribute__(self, name: str) -> Any: ...

    # 常见算术/比较操作（返回类型为 Any，运行时由 dispatcher 决定）
    def __add__(self, other: Any) -> Any: ...
    def __radd__(self, other: Any) -> Any: ...
    def __sub__(self, other: Any) -> Any: ...
    def __mul__(self, other: Any) -> Any: ...
    def __rmul__(self, other: Any) -> Any: ...
    def __truediv__(self, other: Any) -> Any: ...
    def __pow__(self, power: Any, modulo: Optional[Any] = None) -> Any: ...

    def __gt__(self, other: Any) -> Any: ...
    def __lt__(self, other: Any) -> Any: ...
    def __ge__(self, other: Any) -> Any: ...
    def __le__(self, other: Any) -> Any: ...
    def __eq__(self, other: Any) -> Any: ...
    def __ne__(self, other: Any) -> Any: ...

    def __and__(self, other: Any) -> Any: ...
    def __or__(self, other: Any) -> Any: ...
    def __invert__(self) -> Any: ...
    def __lshift__(self, other: Any) -> Any: ...
    def __rshift__(self, other: Any) -> Any: ...
    def __xor__(self, other: Any) -> Any: ...
    def equivalent(self, other: Any) -> Any: ...

    # 表示与格式
    def __repr__(self) -> str: ...
    def __str__(self) -> str: ...
    def __bool__(self) -> bool: ...
    def __format__(self, format_spec: str) -> str: ...

def fuzznum(values: tuple = None,
            mtype: Optional[str] = None,
            q: Optional[int] = None,
            **kwargs: Any) -> Fuzznum: ...

# 确保 Fuzzarray 类型在此处可用
from .fuzzarray import Fuzzarray
