'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var normalizeComponent = require('./normalize-component-6fa50395.js');
var ThemeMixin = require('./ThemeMixin-a2f817cd.js');
var svgAtom = require('./svg-atom-d2541b7d.js');
var closeByKeyAtom = require('./close-by-key-atom-6ca8a461.js');
var outsideClickAtom = require('./outside-click-atom-166b80f4.js');
var controlAtom = require('./control-atom-8027f052.js');

var script = {
  name: 'VNavSubMenu',
  props: {
    skin: {
      type: String,
      default: 'primary',
      validator: function validator(value) {
        return ['primary', 'secondary'].includes(value);
      }
    },
    label: {
      type: String,
      required: true
    },
    items: {
      type: Array,
      default: function _default() {
        return [];
      }
    },
    activePathname: {
      type: String,
      default: null
    }
  },
  data: function data() {
    return {
      isExpanded: false
    };
  },
  computed: {
    vNavSubMenuCssClass: function vNavSubMenuCssClass() {
      return Object.assign(this.themeCssClass, ThemeMixin._defineProperty({
        'is-expanded': this.isExpanded
      }, "skin-".concat(this.skin), !!this.skin));
    },
    currentIcon: function currentIcon() {
      if (this.isExpanded) {
        return 'chevron-up';
      }

      return 'chevron-down';
    }
  },
  methods: {
    onClickOutside: function onClickOutside() {
      this.isExpanded = false;
    },
    onESCPress: function onESCPress() {
      this.isExpanded = false;
    },
    handleOpenContent: function handleOpenContent() {
      if (this.isExpanded) {
        this.isExpanded = false;
        return;
      }

      this.isExpanded = true;
      setTimeout(this.addCloseHandlers, 50);
    }
  },
  mixins: [ThemeMixin.ThemeMixin],
  components: {
    SvgAtom: svgAtom.SvgAtom,
    NavigationControlAtom: controlAtom.NavigationControlAtom,
    OutsideClickAtom: outsideClickAtom.OutsideClickAtom,
    CloseByKeyAtom: closeByKeyAtom.CloseByKeyAtom
  }
};

/* script */
const __vue_script__ = script;

/* template */
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('outside-click-atom',{on:{"click":_vm.onClickOutside}},[_c('close-by-key-atom',{on:{"close":_vm.onESCPress}},[_c('section',{staticClass:"v-nav-sub-menu",class:_vm.vNavSubMenuCssClass},[_c('navigation-control-atom',{attrs:{"skin":_vm.skin},on:{"click":_vm.handleOpenContent}},[_vm._v("\n        "+_vm._s(_vm.label)+"\n        "),_c('i',{staticClass:"v-nav-sub-menu-icon"},[_c('svg-atom',{attrs:{"name":_vm.currentIcon}})],1)]),_vm._v(" "),_c('section',{staticClass:"v-nav-sub-menu-content"},[_vm._t("default")],2)],1)])],1)};
var __vue_staticRenderFns__ = [];

  /* style */
  const __vue_inject_styles__ = undefined;
  /* scoped */
  const __vue_scope_id__ = undefined;
  /* module identifier */
  const __vue_module_identifier__ = undefined;
  /* functional template */
  const __vue_is_functional_template__ = false;
  /* style inject */
  
  /* style inject SSR */
  

  
  var VNavSubMenu = normalizeComponent.__vue_normalize__(
    { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
    __vue_inject_styles__,
    __vue_script__,
    __vue_scope_id__,
    __vue_is_functional_template__,
    __vue_module_identifier__,
    undefined,
    undefined
  );

exports.default = VNavSubMenu;
