# Path: craft_ai/errors.py
# class CraftAiDecisionError(CraftAiError):
#     """An error occured during the decision phase."""
# 
# class CraftAiNullDecisionError(CraftAiDecisionError):
#     """An error occured during the decision phase."""
# 
# Path: craft_ai/operators.py
# OPERATORS_V1 = {
#     "IS": "is",
#     "IN_INTERVAL": "[in[",
#     "GTE": ">=",
#     "LT": "<",
# }
# 
# OPERATORS_FUNCTION_V1 = {
#     OPERATORS_V1["IS"]: lambda context, value: context == value,
#     OPERATORS_V1["GTE"]: lambda context, value: safe_op(context, value, GTE),
#     OPERATORS_V1["LT"]: lambda context, value: safe_op(context, value, LT),
#     OPERATORS_V1["IN_INTERVAL"]: lambda context, value: safe_op(context, value[0], GTE)
#     and safe_op(context, value[1], LT)
#     if safe_op(value[0], value[1], LT)
#     else safe_op(context, value[0], GTE) or safe_op(context, value[1], LT),
# }
# 
# Path: craft_ai/types.py
# TYPES = {
#     "continuous": "continuous",
#     "enum": "enum",
#     "boolean": "boolean",
#     "timezone": "timezone",
#     "time_of_day": "time_of_day",
#     "day_of_week": "day_of_week",
#     "day_of_month": "day_of_month",
#     "month_of_year": "month_of_year",
# }
# 
# Path: craft_ai/timezones.py
# def is_timezone(value):
#     # Valid time zone range is -12:00 (-720 min) and +14:00 (+840 min)
#     # cf. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
#     if isinstance(value, int) and value <= 840 and value >= -720:
#         return True
#     if not isinstance(value, str):
#         return False
#     if value in TIMEZONES:
#         return True
#     result_reg_exp = _TIMEZONE_REGEX.match(value) is not None
#     return result_reg_exp


import numbers
from craft_ai.errors import CraftAiDecisionError, CraftAiNullDecisionError
from craft_ai.operators import (
    OPERATORS_V1 as OPERATORS,
    OPERATORS_FUNCTION_V1 as OPERATORS_FUNCTION,
)
from craft_ai.types import TYPES
from craft_ai.timezones import is_timezone


_DECISION_VERSION = "1.1.0"

_VALUE_VALIDATORS = {
    TYPES["continuous"]: lambda value: isinstance(value, numbers.Real),
    TYPES["enum"]: lambda value: isinstance(value, str),
    TYPES["timezone"]: lambda value: is_timezone(value),
    TYPES["time_of_day"]: lambda value: (
        isinstance(value, numbers.Real) and value >= 0 and value < 24
    ),

# Path: craft_ai/errors.py
# class CraftAiDecisionError(CraftAiError):
#     """An error occured during the decision phase."""
# 
# class CraftAiNullDecisionError(CraftAiDecisionError):
#     """An error occured during the decision phase."""
# 
# Path: craft_ai/operators.py
# OPERATORS_V1 = {
#     "IS": "is",
#     "IN_INTERVAL": "[in[",
#     "GTE": ">=",
#     "LT": "<",
# }
# 
# OPERATORS_FUNCTION_V1 = {
#     OPERATORS_V1["IS"]: lambda context, value: context == value,
#     OPERATORS_V1["GTE"]: lambda context, value: safe_op(context, value, GTE),
#     OPERATORS_V1["LT"]: lambda context, value: safe_op(context, value, LT),
#     OPERATORS_V1["IN_INTERVAL"]: lambda context, value: safe_op(context, value[0], GTE)
#     and safe_op(context, value[1], LT)
#     if safe_op(value[0], value[1], LT)
#     else safe_op(context, value[0], GTE) or safe_op(context, value[1], LT),
# }
# 
# Path: craft_ai/types.py
# TYPES = {
#     "continuous": "continuous",
#     "enum": "enum",
#     "boolean": "boolean",
#     "timezone": "timezone",
#     "time_of_day": "time_of_day",
#     "day_of_week": "day_of_week",
#     "day_of_month": "day_of_month",
#     "month_of_year": "month_of_year",
# }
# 
# Path: craft_ai/timezones.py
# def is_timezone(value):
#     # Valid time zone range is -12:00 (-720 min) and +14:00 (+840 min)
#     # cf. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
#     if isinstance(value, int) and value <= 840 and value >= -720:
#         return True
#     if not isinstance(value, str):
#         return False
#     if value in TIMEZONES:
#         return True
#     result_reg_exp = _TIMEZONE_REGEX.match(value) is not None
#     return result_reg_exp


# Path: craft_ai/interpreter_v1.py
import numbers
from craft_ai.errors import CraftAiDecisionError, CraftAiNullDecisionError
from craft_ai.operators import (
    OPERATORS_V1 as OPERATORS,
    OPERATORS_FUNCTION_V1 as OPERATORS_FUNCTION,
)
from craft_ai.types import TYPES
from craft_ai.timezones import is_timezone



_DECISION_VERSION = "1.1.0"

_VALUE_VALIDATORS = {
    TYPES["continuous"]: lambda value: isinstance(value, numbers.Real),
    TYPES["enum"]: lambda value: isinstance(value, str),
    TYPES["timezone"]: lambda value: is_timezone(value),
    TYPES["time_of_day"]: lambda value: (
        isinstance(value, numbers.Real) and value >= 0 and value < 24
    ),

    TYPES["day_of_week"]: lambda value: (