# Path: sitetree/compat.py
# TOKEN_BLOCK = TokenType.BLOCK
# 
# Path: sitetree/templatetags/sitetree.py
# @register.tag
# def sitetree_tree(parser, token):
#     """Parses sitetree tag parameters.
# 
#     Two notation types are possible:
#         1. Two arguments:
#            {% sitetree_tree from "mytree" %}
#            Used to render tree for "mytree" site tree.
# 
#         2. Four arguments:
#            {% sitetree_tree from "mytree" template "sitetree/mytree.html" %}
#            Used to render tree for "mytree" site tree using specific
#            template "sitetree/mytree.html"
# 
#     """
#     tokens = token.split_contents()
#     use_template = detect_clause(parser, 'template', tokens)
#     tokens_num = len(tokens)
# 
#     if tokens_num in (3, 5):
#         tree_alias = parser.compile_filter(tokens[2])
#         return sitetree_treeNode(tree_alias, use_template)
#     else:
#         raise template.TemplateSyntaxError(
#             '%r tag requires two arguments. E.g. {%% sitetree_tree from "mytree" %%}.' % tokens[0])
# 
# Path: sitetree/utils.py
# def get_tree_model() -> Type['TreeBase']:
#     """Returns the Tree model, set for the project."""
#     return get_model_class('MODEL_TREE')
# 
# def get_tree_item_model() -> Type['TreeItemBase']:
#     """Returns the TreeItem model, set for the project."""
#     return get_model_class('MODEL_TREE_ITEM')
# 
# Path: sitetree/settings.py
# ITEMS_FIELD_ROOT_ID: str = getattr(settings, 'SITETREE_ITEMS_FIELD_ROOT_ID', '')


from typing import Optional
from django import template
from django.template.base import Parser, Token
from django.forms import ChoiceField
from django.utils.safestring import mark_safe
from .compat import TOKEN_BLOCK
from .templatetags.sitetree import sitetree_tree
from .utils import get_tree_model, get_tree_item_model
from .settings import ITEMS_FIELD_ROOT_ID
    from .models import TreeItemBase, TreeBase  # noqa



if False:  # pragma: nocover


MODEL_TREE_CLASS = get_tree_model()
MODEL_TREE_ITEM_CLASS = get_tree_item_model()



# Path: sitetree/compat.py
# TOKEN_BLOCK = TokenType.BLOCK
# 
# Path: sitetree/templatetags/sitetree.py
# @register.tag
# def sitetree_tree(parser, token):
#     """Parses sitetree tag parameters.
# 
#     Two notation types are possible:
#         1. Two arguments:
#            {% sitetree_tree from "mytree" %}
#            Used to render tree for "mytree" site tree.
# 
#         2. Four arguments:
#            {% sitetree_tree from "mytree" template "sitetree/mytree.html" %}
#            Used to render tree for "mytree" site tree using specific
#            template "sitetree/mytree.html"
# 
#     """
#     tokens = token.split_contents()
#     use_template = detect_clause(parser, 'template', tokens)
#     tokens_num = len(tokens)
# 
#     if tokens_num in (3, 5):
#         tree_alias = parser.compile_filter(tokens[2])
#         return sitetree_treeNode(tree_alias, use_template)
#     else:
#         raise template.TemplateSyntaxError(
#             '%r tag requires two arguments. E.g. {%% sitetree_tree from "mytree" %%}.' % tokens[0])
# 
# Path: sitetree/utils.py
# def get_tree_model() -> Type['TreeBase']:
#     """Returns the Tree model, set for the project."""
#     return get_model_class('MODEL_TREE')
# 
# def get_tree_item_model() -> Type['TreeItemBase']:
#     """Returns the TreeItem model, set for the project."""
#     return get_model_class('MODEL_TREE_ITEM')
# 
# Path: sitetree/settings.py
# ITEMS_FIELD_ROOT_ID: str = getattr(settings, 'SITETREE_ITEMS_FIELD_ROOT_ID', '')


# Path: sitetree/fields.py
from typing import Optional
from django import template
from django.template.base import Parser, Token
from django.forms import ChoiceField
from django.utils.safestring import mark_safe
from .compat import TOKEN_BLOCK
from .templatetags.sitetree import sitetree_tree
from .utils import get_tree_model, get_tree_item_model
from .settings import ITEMS_FIELD_ROOT_ID
    from .models import TreeItemBase, TreeBase  # noqa




if False:  # pragma: nocover


MODEL_TREE_CLASS = get_tree_model()
MODEL_TREE_ITEM_CLASS = get_tree_item_model()



class TreeItemChoiceField(ChoiceField):