# Path: lib/utils/debug.py
# def Debug(classification, text):
#     if 'all' in print_classifications or classification in print_classifications:
#         print("ArcticTypescript: %s: %s" % (classification.ljust(8), text))
#     if classification not in possible_classifications:
#         print("ArcticTypescript: debug: got unknown debug message classification: %s. " \
#             "Consider adding this to possible_classifications" % classification)
#     sys.stdout.flush()
# 
# def max_calls(limit = 1500, name=""):
#     """Decorator which allows its wrapped function to be called `limit` times"""
#     def decorator(func):
#         # Disable limit:
#         return func
#         @wraps(func)
#         def wrapper(*args, **kwargs):
#             calls = getattr(wrapper, 'calls', 0)
#             calls += 1
#             setattr(wrapper, 'calls', calls)
#             fname = name if name != "" else func.__name__
# 
#             if calls == limit + 1:
#                 Debug('max_calls', "LIMIT !! ## !!: Fkt %s has %i calls, stop" % (fname, calls - 1))
# 
#             if calls >= limit + 1:
#                 return None
# 
#             Debug('max_calls', "CALL: Fkt %s has %i calls -> +1" % (fname, calls - 1))
# 
#             return func(*args, **kwargs)
#         setattr(wrapper, 'calls', 0)
#         return wrapper
#     return decorator


import sublime
from ..utils import max_calls, Debug
                overlap = (end - start)
                cell_overlap.append(overlap)

        if len(cell_overlap) != 0:
                cell_index = cell_overlap.index(max(cell_overlap))
                return adjacent_cells[cell_index]
        return None


    def duplicated_views(self,window,original_group,duplicating_group):
        original_views = window.views_in_group(original_group)
        original_buffers = [v.buffer_id() for v in original_views]
        potential_dupe_views = window.views_in_group(duplicating_group)
        dupe_views = []
        for pd in potential_dupe_views:
                if pd.buffer_id() in original_buffers:
                        dupe_views.append(pd)
        return dupe_views


    def cells_adjacent_to_cell_in_direction(self,cells,cell,direction):
        fn = None
        if direction == "up": fn = lambda orig, check: orig[YMIN] == check[YMAX]
        elif direction == "right": fn = lambda orig, check: orig[XMAX] == check[XMIN]
        elif direction == "down": fn = lambda orig, check: orig[YMAX] == check[YMIN]
        elif direction == "left": fn = lambda orig, check: orig[XMIN] == check[XMAX]
        if fn: return [c for c in cells if fn(cell, c)]
        return None



# Path: lib/utils/debug.py
# def Debug(classification, text):
#     if 'all' in print_classifications or classification in print_classifications:
#         print("ArcticTypescript: %s: %s" % (classification.ljust(8), text))
#     if classification not in possible_classifications:
#         print("ArcticTypescript: debug: got unknown debug message classification: %s. " \
#             "Consider adding this to possible_classifications" % classification)
#     sys.stdout.flush()
# 
# def max_calls(limit = 1500, name=""):
#     """Decorator which allows its wrapped function to be called `limit` times"""
#     def decorator(func):
#         # Disable limit:
#         return func
#         @wraps(func)
#         def wrapper(*args, **kwargs):
#             calls = getattr(wrapper, 'calls', 0)
#             calls += 1
#             setattr(wrapper, 'calls', calls)
#             fname = name if name != "" else func.__name__
# 
#             if calls == limit + 1:
#                 Debug('max_calls', "LIMIT !! ## !!: Fkt %s has %i calls, stop" % (fname, calls - 1))
# 
#             if calls >= limit + 1:
#                 return None
# 
#             Debug('max_calls', "CALL: Fkt %s has %i calls -> +1" % (fname, calls - 1))
# 
#             return func(*args, **kwargs)
#         setattr(wrapper, 'calls', 0)
#         return wrapper
#     return decorator


# Path: lib/display/Layout.py
import sublime
from ..utils import max_calls, Debug

                overlap = (end - start)
                cell_overlap.append(overlap)

        if len(cell_overlap) != 0:
                cell_index = cell_overlap.index(max(cell_overlap))
                return adjacent_cells[cell_index]
        return None


    def duplicated_views(self,window,original_group,duplicating_group):
        original_views = window.views_in_group(original_group)
        original_buffers = [v.buffer_id() for v in original_views]
        potential_dupe_views = window.views_in_group(duplicating_group)
        dupe_views = []
        for pd in potential_dupe_views:
                if pd.buffer_id() in original_buffers:
                        dupe_views.append(pd)
        return dupe_views


    def cells_adjacent_to_cell_in_direction(self,cells,cell,direction):
        fn = None
        if direction == "up": fn = lambda orig, check: orig[YMIN] == check[YMAX]
        elif direction == "right": fn = lambda orig, check: orig[XMAX] == check[XMIN]
        elif direction == "down": fn = lambda orig, check: orig[YMAX] == check[YMIN]
        elif direction == "left": fn = lambda orig, check: orig[XMIN] == check[XMAX]
        if fn: return [c for c in cells if fn(cell, c)]
        return None



    def opposite_direction(self,direction):