# Path: css2video/components/base.py
# class BaseComponent(object):
#     """A base component for other CSS components
# 
#     Public attributes:
#         - Dict: Dictionary form of the component
#     """
# 
#     def __init__(self, Dict):
#         super(BaseComponent, self).__init__()
#         self.Dict = Dict
# 
#     @classmethod
#     def from_dict(cls, Dict):
#         """Creates a component from dictionary"""
#         return cls(Dict=Dict)
# 
#     def to_dict(self):
#         """Returns the dictionary form of the component"""
#         return self.Dict
# 
#     def duplicate(self):
#         """Returns a duplicate of this component"""
#         return self.__class__(Dict=copy.deepcopy(self.Dict))
# 
# Path: css2video/components/rule.py
# class KeyframesRuleComponent(BaseComponent):
#     """A wrapper for CSS keyframes rule dictionary object"""
# 
#     def __init__(self, *args, **kwargs):
#         super(KeyframesRuleComponent, self).__init__(*args, **kwargs)
# 
#     @property
#     def name(self):
#         """Name of animation"""
#         return self.Dict.get('name')
# 
#     @property
#     def keyframe_properties(self):
#         """Keyframe properties of the animation"""
#         keyframe_properties = [
#             KeyframePropertiesComponent(k)
#             for k in self.Dict.get('keyframes', [])
#         ]
#         keyframe_properties.sort(key=lambda x: x.time_offset)
#         return keyframe_properties
# 
#     def get_property_sets(self, time_offset):
#         """For a given time offset, it returns the keyframe properties
#         before and after this time offset
# 
#         Args:
#             - time_offset: time offset in percentage
# 
#         Returns:
#             (props_1, props_2) where props_1 are properties before
#             the time offset and props_2 are properties after the time offset
#         """
#         set1 = set2 = None
#         for kfp in self.keyframe_properties:
#             if kfp.time_offset <= time_offset:
#                 set1 = kfp
# 
#         for kfp in self.keyframe_properties[::-1]:
#             if kfp.time_offset >= time_offset:
#                 set2 = kfp
#         return (set1, set2)
# 
# Path: css2video/components/rule.py
# class StyleRuleComponent(BaseComponent):
#     """A wrapper for CSS style rule dictionary object"""
# 
#     def __init__(self, *args, **kwargs):
#         super(StyleRuleComponent, self).__init__(*args, **kwargs)
# 
#     @property
#     def properties(self):
#         '''Returns all the properties as a dictionary'''
#         return {
#             p['property_name']: p['property_value']
#             for p in self.Dict.get('properties', [])
#         }
# 
#     def animation_properties(self):
#         '''Returns all the animation related properties as a dictionary'''
#         properties = {
#             'animation-name': '',
#             'animation-duration': 0,
#             'animation-delay': 0,
#             'animation-iteration-count': 1,
#             'animation-timing-function': 'ease'
#         }
#         for key in properties:
#             if self.properties.get(key):
#                 value = self.properties.get(key)
#                 properties[key] = value.get('value')
#         return properties
# 
#     def property_list(self):
#         '''Returns a list of property names'''
#         return [p['property_name'] for p in self.Dict.get('properties', [])]
# 
#     def add_property(self, name, value):
#         '''Add a new property and value'''
#         self.Dict['properties'].append({
#             'property_name': name,
#             'property_value': value
#         })


from .base import BaseComponent
from .rule import KeyframesRuleComponent
from .rule import StyleRuleComponent


class StyleSheetComponent(BaseComponent):
    """A wrapper from stylesheet dictionary object"""

    def __init__(self, *args, **kwargs):
        super(StyleSheetComponent, self).__init__(*args, **kwargs)

    @property
    def style_rules(self):
        """Returns the style components"""
        style_rules = filter(
            lambda x: x['type'] == 'style', self.Dict.get('rules', []))
        return [

# Path: css2video/components/base.py
# class BaseComponent(object):
#     """A base component for other CSS components
# 
#     Public attributes:
#         - Dict: Dictionary form of the component
#     """
# 
#     def __init__(self, Dict):
#         super(BaseComponent, self).__init__()
#         self.Dict = Dict
# 
#     @classmethod
#     def from_dict(cls, Dict):
#         """Creates a component from dictionary"""
#         return cls(Dict=Dict)
# 
#     def to_dict(self):
#         """Returns the dictionary form of the component"""
#         return self.Dict
# 
#     def duplicate(self):
#         """Returns a duplicate of this component"""
#         return self.__class__(Dict=copy.deepcopy(self.Dict))
# 
# Path: css2video/components/rule.py
# class KeyframesRuleComponent(BaseComponent):
#     """A wrapper for CSS keyframes rule dictionary object"""
# 
#     def __init__(self, *args, **kwargs):
#         super(KeyframesRuleComponent, self).__init__(*args, **kwargs)
# 
#     @property
#     def name(self):
#         """Name of animation"""
#         return self.Dict.get('name')
# 
#     @property
#     def keyframe_properties(self):
#         """Keyframe properties of the animation"""
#         keyframe_properties = [
#             KeyframePropertiesComponent(k)
#             for k in self.Dict.get('keyframes', [])
#         ]
#         keyframe_properties.sort(key=lambda x: x.time_offset)
#         return keyframe_properties
# 
#     def get_property_sets(self, time_offset):
#         """For a given time offset, it returns the keyframe properties
#         before and after this time offset
# 
#         Args:
#             - time_offset: time offset in percentage
# 
#         Returns:
#             (props_1, props_2) where props_1 are properties before
#             the time offset and props_2 are properties after the time offset
#         """
#         set1 = set2 = None
#         for kfp in self.keyframe_properties:
#             if kfp.time_offset <= time_offset:
#                 set1 = kfp
# 
#         for kfp in self.keyframe_properties[::-1]:
#             if kfp.time_offset >= time_offset:
#                 set2 = kfp
#         return (set1, set2)
# 
# Path: css2video/components/rule.py
# class StyleRuleComponent(BaseComponent):
#     """A wrapper for CSS style rule dictionary object"""
# 
#     def __init__(self, *args, **kwargs):
#         super(StyleRuleComponent, self).__init__(*args, **kwargs)
# 
#     @property
#     def properties(self):
#         '''Returns all the properties as a dictionary'''
#         return {
#             p['property_name']: p['property_value']
#             for p in self.Dict.get('properties', [])
#         }
# 
#     def animation_properties(self):
#         '''Returns all the animation related properties as a dictionary'''
#         properties = {
#             'animation-name': '',
#             'animation-duration': 0,
#             'animation-delay': 0,
#             'animation-iteration-count': 1,
#             'animation-timing-function': 'ease'
#         }
#         for key in properties:
#             if self.properties.get(key):
#                 value = self.properties.get(key)
#                 properties[key] = value.get('value')
#         return properties
# 
#     def property_list(self):
#         '''Returns a list of property names'''
#         return [p['property_name'] for p in self.Dict.get('properties', [])]
# 
#     def add_property(self, name, value):
#         '''Add a new property and value'''
#         self.Dict['properties'].append({
#             'property_name': name,
#             'property_value': value
#         })


# Path: css2video/components/stylesheet.py
from .base import BaseComponent
from .rule import KeyframesRuleComponent
from .rule import StyleRuleComponent



class StyleSheetComponent(BaseComponent):
    """A wrapper from stylesheet dictionary object"""

    def __init__(self, *args, **kwargs):
        super(StyleSheetComponent, self).__init__(*args, **kwargs)

    @property
    def style_rules(self):
        """Returns the style components"""
        style_rules = filter(
            lambda x: x['type'] == 'style', self.Dict.get('rules', []))
        return [

            StyleRuleComponent.from_dict(Dict=rule) for rule in style_rules