"""Contains the Layout class"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

from traitlets import Unicode, Instance
from .widget_core import CoreWidget


class Layout(CoreWidget):
    """Layout specification

    Defines a layout that can be expressed using CSS.  Supports a subset of
    https://developer.mozilla.org/en-US/docs/Web/CSS/Reference

    When a property is also accessible via a shorthand property, we only
    expose the shorthand.

    For example:
    - ``flex-grow``, ``flex-shrink`` and ``flex-basis`` are bound to ``flex``.
    - ``flex-wrap`` and ``flex-direction`` are bound to ``flex-flow``.
    - ``margin-[top/bottom/left/right]`` values are bound to ``margin``, etc.
    """

    _model_module = Unicode('jupyter-js-widgets').tag(sync=True)
    _view_module = Unicode('jupyter-js-widgets').tag(sync=True)
    _view_name = Unicode('LayoutView').tag(sync=True)
    _model_name = Unicode('LayoutModel').tag(sync=True)

    # Keys
    align_content = Unicode(None, allow_none=True).tag(sync=True)
    align_items = Unicode(None, allow_none=True).tag(sync=True)
    align_self = Unicode(None, allow_none=True).tag(sync=True)
    bottom = Unicode(None, allow_none=True).tag(sync=True)
    border = Unicode(None, allow_none=True).tag(sync=True)
    display = Unicode(None, allow_none=True).tag(sync=True)
    flex = Unicode(None, allow_none=True).tag(sync=True)
    flex_flow = Unicode(None, allow_none=True).tag(sync=True)
    height = Unicode(None, allow_none=True).tag(sync=True)
    justify_content = Unicode(None, allow_none=True).tag(sync=True)
    left = Unicode(None, allow_none=True).tag(sync=True)
    margin = Unicode(None, allow_none=True).tag(sync=True)
    max_height = Unicode(None, allow_none=True).tag(sync=True)
    max_width = Unicode(None, allow_none=True).tag(sync=True)
    min_height = Unicode(None, allow_none=True).tag(sync=True)
    min_width = Unicode(None, allow_none=True).tag(sync=True)
    overflow = Unicode(None, allow_none=True).tag(sync=True)
    overflow_x = Unicode(None, allow_none=True).tag(sync=True)
    overflow_y = Unicode(None, allow_none=True).tag(sync=True)
    order = Unicode(None, allow_none=True).tag(sync=True)
    padding = Unicode(None, allow_none=True).tag(sync=True)
    right = Unicode(None, allow_none=True).tag(sync=True)
    top = Unicode(None, allow_none=True).tag(sync=True)
    visibility = Unicode(None, allow_none=True).tag(sync=True)
    width = Unicode(None, allow_none=True).tag(sync=True)


class LayoutTraitType(Instance):

    klass = Layout

    def validate(self, obj, value):
        if isinstance(value, dict):
            return super(LayoutTraitType, self).validate(obj, Layout(**value))
        else:
            return super(LayoutTraitType, self).validate(obj, value)

@@ -167,17 +167,34 @@
 Instance
+, CaselessStrEnum
 %0A
-
 from .wi
@@ -222,16 +222,63 @@
 Widget%0A%0A
+CSS_PROPERTIES=%5B'inherit', 'initial', 'unset'%5D%0A
 %0Aclass L
@@ -1094,147 +1094,456 @@
 t = 
-Unicode(None, allow_none=True).tag(sync=True)%0A    align_items = Unicode(None, allow_none=True).tag(sync=True)%0A    align_self = Unicode(None
+CaselessStrEnum(%5B'flex-start', 'flex-end', 'center', 'space-between',%0A        'space-around', 'space-evenly', 'stretch'%5D + CSS_PROPERTIES, allow_none=True).tag(sync=True)%0A    align_items = CaselessStrEnum(%5B'flex-start', 'flex-end', 'center',%0A        'baseline', 'stretch'%5D + CSS_PROPERTIES, allow_none=True).tag(sync=True)%0A    align_self = CaselessStrEnum(%5B'auto', 'flex-start', 'flex-end',%0A        'center', 'baseline', 'stretch'%5D + CSS_PROPERTIES
 , al
@@ -1946,36 +1946,134 @@
 y_content = 
-Unicode(None
+CaselessStrEnum(%5B'flex-start', 'flex-end', 'center',%0A        'space-between', 'space-around'%5D + CSS_PROPERTIES
 , allow_none
@@ -2479,146 +2479,326 @@
 w = 
-Unicode(None, allow_none=True).tag(sync=True)%0A    overflow_x = Unicode(None, allow_none=True).tag(sync=True)%0A    overflow_y = Unicode(None
+CaselessStrEnum(%5B'visible', 'hidden', 'scroll', 'auto'%5D + CSS_PROPERTIES, allow_none=True).tag(sync=True)%0A    overflow_x = CaselessStrEnum(%5B'visible', 'hidden', 'scroll', 'auto'%5D + CSS_PROPERTIES, allow_none=True).tag(sync=True)%0A    overflow_y = CaselessStrEnum(%5B'visible', 'hidden', 'scroll', 'auto'%5D + CSS_PROPERTIES
 , al
@@ -3072,36 +3072,76 @@
 isibility = 
-Unicode(None
+CaselessStrEnum(%5B'visible', 'hidden'%5D+CSS_PROPERTIES
 , allow_none

Make various layout properties enums.