import { _ as _typeof } from './typeof-6c6d8d7a.js';
import './es.array.concat-669570ef.js';
import { _ as _unsupportedIterableToArray } from './unsupportedIterableToArray-577176bf.js';
import './es.object.to-string-9e0d4e1d.js';
import './es.array.includes-d05e3b05.js';
import './es.string.includes-00e9ada6.js';
import './es.object.keys-9aa2f274.js';
import { i as i18n } from './i18n-ad4a7ece.js';
import { n as normalizeComponent } from './normalize-component-1b2cdbb6.js';

function _createForOfIteratorHelper(o, allowArrayLike) {
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];

  if (!it) {
    if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
      if (it) o = it;
      var i = 0;

      var F = function F() {};

      return {
        s: F,
        n: function n() {
          if (i >= o.length) return {
            done: true
          };
          return {
            done: false,
            value: o[i++]
          };
        },
        e: function e(_e) {
          throw _e;
        },
        f: F
      };
    }

    throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  }

  var normalCompletion = true,
      didErr = false,
      err;
  return {
    s: function s() {
      it = it.call(o);
    },
    n: function n() {
      var step = it.next();
      normalCompletion = step.done;
      return step;
    },
    e: function e(_e2) {
      didErr = true;
      err = _e2;
    },
    f: function f() {
      try {
        if (!normalCompletion && it["return"] != null) it["return"]();
      } finally {
        if (didErr) throw err;
      }
    }
  };
}

/**
 * Component to render data in p | ul | dt tags depending on field type 'data'
 */

var script = {
  name: 'BaseTextList',
  components: {
    BaseLink: function BaseLink() {
      return import('./BaseLink-8e5996fb.js').then(function (m) {
        return m.default || m;
      });
    }
  },
  mixins: [i18n],
  props: {
    /**
     * data structure for different rendered tags: <br>
     * p: { label: 'String|Object', data: 'String' } <br>
     * ul: { label: 'String|Object, data: ['String']}} <br>
     * dt: {<br>
     *  label: 'String|Object,<br>
     *  data: [{
     *    label: 'String|Object',
     *    value: 'String',
     *    url: 'String',
     *    additional: 'Object' }]}} or<br>
     * dt: {<br>
     *  label: 'String|Object,<br>
     *  data: {
     *    label: 'String|Object',
     *    value: 'String',
     *    url: 'String'
     *    additional: 'Object'}}}<br><br>
     *
     * label might be a string or a language object with ISO 639-1 as object properties
     *  (e.g. { en: 'x', de: 'y' })<br>
     *  additional property creates a tooltip and takes an object in the same format as
     *    data: label, value and url<br>
     * Note: for dt property 'url' will render 'value' as a link<br>
     */
    data: {
      type: Array,
      default: function _default() {
        return [];
      }
    },

    /**
     * render component as e.g.: 'h2' | 'h3'
     */
    renderLabelAs: {
      type: String,
      default: 'div'
    },

    /**
     * set margin-bottom for the label
     */
    labelMarginBottom: {
      type: Boolean,
      default: false
    },

    /**
     * render content in two columns
     */
    cols2: {
      type: Boolean,
      default: false
    },

    /**
     * set box height to auto
     */
    autoHeight: {
      type: Boolean,
      default: false
    },

    /**
     * specify how link element should be rendered - this needs to be a
     * valid vue link component (e.g. router-link, nuxt-link) and vue-router
     * is necessary
     */
    renderLinkAs: {
      type: String,
      default: 'router-link'
    },

    /**
     * specify how data-list (label, value) should be rendered:
     */
    listType: {
      type: String,
      default: 'horizontal',
      validate: function validate(val) {
        return ['horizontal', 'vertical'].includes(val);
      }
    }
  },
  methods: {
    /**
     * check if all array objects have a key label
     *
     * @param {array} data
     * @param {string} key
     * @returns {boolean}
     */
    containKeys: function containKeys(data, key) {
      // eslint-disable-next-line
      var _iterator = _createForOfIteratorHelper(data),
          _step;

      try {
        for (_iterator.s(); !(_step = _iterator.n()).done;) {
          var obj = _step.value;

          if (!Object.keys(obj).includes(key)) {
            return false;
          }
        }
      } catch (err) {
        _iterator.e(err);
      } finally {
        _iterator.f();
      }

      return true;
    }
  }
};

var __vue_script__ = script;
/* template */

var __vue_render__ = function __vue_render__() {
  var _vm = this;

  var _h = _vm.$createElement;

  var _c = _vm._self._c || _h;

  return _c('div', {
    class: ['base-text-list', {
      'base-text-list-2-cols': _vm.cols2,
      'base-text-list-2-cols-single-content': _vm.cols2 && _vm.data.length === 1 && typeof _vm.data[0].data === 'string'
    }]
  }, _vm._l(_vm.data, function (item, index) {
    return _c('div', {
      key: index,
      staticClass: "base-text-list-group"
    }, [item.label ? _c(_vm.renderLabelAs, {
      tag: "component",
      class: ['base-text-list-label', {
        'base-text-list-label-mb': _vm.labelMarginBottom
      }]
    }, [_vm._v("\n      " + _vm._s(_vm.getLangLabel(item.label)) + "\n    ")]) : _vm._e(), _vm._v(" "), typeof item.data === 'string' ? _c('p', {
      class: ['base-text-list-content', 'base-text-list-content-pre-line', {
        'base-text-list-2-cols': _vm.data.length === 1
      }]
    }, [_vm._v(_vm._s(item.data))]) : _typeof(item.data) === 'object' && typeof item.data[0] === 'string' ? _c('ul', {
      staticClass: "base-text-list-content"
    }, _vm._l(item.data, function (arrayItem, listIndex) {
      return _c('li', {
        key: listIndex
      }, [_vm._v("\n        " + _vm._s(arrayItem) + "\n      ")]);
    }), 0) : _typeof(item.data) === 'object' ? [!_vm.containKeys([].concat(item.data), 'label') ? [_c('div', {
      staticClass: "base-text-list-content"
    }, [_vm._l([].concat(item.data), function (objectItem, objectIndex) {
      return [_c('BaseLink', {
        key: objectIndex,
        attrs: {
          "source": objectItem.source,
          "tooltip": objectItem.additional,
          "type": objectItem.type,
          "url": objectItem.url,
          "value": objectItem.value
        },
        scopedSlots: _vm._u([{
          key: "tooltip",
          fn: function fn() {
            return [_vm._t("tooltip", null, {
              "data": objectItem.additional
            })];
          },
          proxy: true
        }], null, true)
      }), _vm._v(_vm._s(item.data.length && objectIndex !== item.data.length - 1 ? ', ' : '') + "\n            ")];
    })], 2)] : _vm._e(), _vm._v(" "), _vm.containKeys([].concat(item.data), 'label') ? [_typeof(item.data) === 'object' ? _c('dl', {
      class: ['base-text-list-content', 'base-text-list-content--' + _vm.listType]
    }, [_vm._l([].concat(item.data), function (objectItem, objectIndex) {
      return [_c('dt', {
        key: 'l' + objectIndex,
        staticClass: "base-text-list__content__label"
      }, [objectItem.label ? [_vm._v("\n                " + _vm._s(_vm.getLangLabel(objectItem.label)) + ":\n              ")] : _vm._e()], 2), _vm._v(" "), _c('dd', {
        key: 'v' + objectIndex,
        staticClass: "base-text-list__content__label base-text-list__content__value"
      }, [_c('BaseLink', {
        attrs: {
          "render-link-as": _vm.renderLinkAs,
          "source": objectItem.source,
          "tooltip": objectItem.additional,
          "type": objectItem.type,
          "url": objectItem.url,
          "value": objectItem.value
        }
      }, [_vm._t("tooltip")], 2)], 1)];
    })], 2) : _vm._e()] : _vm._e()] : _vm._e()], 2);
  }), 0);
};

var __vue_staticRenderFns__ = [];
/* style */

var __vue_inject_styles__ = undefined;
/* scoped */

var __vue_scope_id__ = "data-v-24ecdcec";
/* module identifier */

var __vue_module_identifier__ = undefined;
/* functional template */

var __vue_is_functional_template__ = false;
/* style inject */

/* style inject SSR */

/* style inject shadow dom */

var __vue_component__ = /*#__PURE__*/normalizeComponent({
  render: __vue_render__,
  staticRenderFns: __vue_staticRenderFns__
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);

var BaseTextList = __vue_component__;

export { BaseTextList as B };
