function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
import { getAttributeProps } from './parse';
/* -----------------------------------
 *
 * Async
 *
 * -------------------------------- */

function getAsyncComponent(component, tagName) {
  return component.then(function (response) {
    return getComponentResult(response, tagName);
  });
}

/* -----------------------------------
 *
 * Result
 *
 * -------------------------------- */

function getComponentResult(response, tagName) {
  var result = void 0;
  if (typeof response === 'function') {
    return response;
  }
  if (_typeof(response) === 'object') {
    result = response[getNameFromTag(tagName)] || void 0;
  }
  return result;
}

/* -----------------------------------
 *
 * Element
 *
 * -------------------------------- */

function getElementTag(tagName) {
  var result = tagName.toLowerCase();
  if (result.indexOf('-') < 0) {
    result = 'component-' + result;
  }
  return result;
}

/* -----------------------------------
 *
 * Tag
 *
 * -------------------------------- */

function getNameFromTag(value) {
  value = value.toLowerCase();
  return value.replace(/(^\w|-\w)/g, function (item) {
    return item.replace(/-/, '').toUpperCase();
  });
}

/* -----------------------------------
 *
 * Attributes
 *
 * -------------------------------- */

function getElementAttributes() {
  var _this$__options$attri = this.__options.attributes,
    attributes = _this$__options$attri === void 0 ? [] : _this$__options$attri;
  var result = {};
  if (!this.hasAttributes()) {
    return result;
  }
  return getAttributeProps(this.attributes, attributes);
}

/* -----------------------------------
 *
 * Export
 *
 * -------------------------------- */

export { getElementTag, getElementAttributes, getAsyncComponent };