'use strict';

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

var __chunk_1 = require('./chunk-cc325129.js');
var __chunk_2 = require('./chunk-d8f887e2.js');
var __chunk_4 = require('./chunk-db6c6598.js');
var __chunk_10 = require('./chunk-b21a051b.js');

//
var script = {
  name: 'VNavSubMenu',
  props: {
    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, {
        'is-expanded': this.isExpanded
      });
    },
    currentIcon: function currentIcon() {
      if (this.isExpanded) {
        return 'chevron-up';
      }

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

      this.isExpanded = true;
      setImmediate(this.addCloseHandlers);
    },
    handleClickOutsideOnce: function handleClickOutsideOnce(e) {
      if (e.type === 'click' || e.keyCode === 27) {
        this.isExpanded = false;
        this.removeCloseHandlers();
      }
    },
    addCloseHandlers: function addCloseHandlers() {
      document.body.addEventListener('click', this.handleClickOutsideOnce);
      window.addEventListener('keydown', this.handleClickOutsideOnce);
    },
    removeCloseHandlers: function removeCloseHandlers() {
      document.body.removeEventListener('click', this.handleClickOutsideOnce);
      window.removeEventListener('keydown', this.handleClickOutsideOnce);
    }
  },
  mixins: [__chunk_2.ThemeMixin],
  components: {
    SvgAtom: __chunk_4.SvgAtom,
    NavigationControlAtom: __chunk_10.NavigationControlAtom
  }
};

/* 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('section',{staticClass:"v-nav-sub-menu",class:_vm.vNavSubMenuCssClass},[_c('navigation-control-atom',{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',{ref:"list",staticClass:"v-nav-sub-menu-content"},[_vm._t("default")],2)],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 = __chunk_1.__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;
