(function () {
    'use strict';

    angular
        .module('contestacaoApp')
        .directive('sidebarInner', sidebarInner);

    sidebarInner.$inject = ['$timeout', '__env', '$q'];

    /* @ngInject */
    function sidebarInner($timeout, __env, $q) {
        let directive = {
            restrict: 'E',
            replace: true,
            templateUrl: __env.appPath + 'scripts/components/sidebar-inner/sidebar-inner.directive.html',
            link: link,
            scope: false
        };

        return directive;

        function link(scope, element, attrs) {
            //exports
            angular.extend(scope.vm, {
                openSidebarInner: openSidebarInner,
                closeSidebarInner: closeSidebarInner
            });

            scope.vm.sidebarInnerOpen = false;
            scope.vm.sidebarInnerComponent = {};

            function openSidebarInner(headerText, innerContent, closeAction) {
                scope.vm.sidebarInnerComponent.headerText = headerText;
                scope.vm.sidebarInnerComponent.innerContent = innerContent;
                scope.vm.sidebarInnerComponent.closeAction = closeAction;
                return $timeout(() => { return $q.resolve() }, 400);
            }

            function closeSidebarInner() {
                return $timeout(() => {
                    scope.vm.sidebarInnerComponent.headerText = null;
                    scope.vm.sidebarInnerComponent.innerContent = null;
                    return $q.resolve()
                }, 400);
            }

        }
    }
})();

