import { r as registerInstance, h, H as Host } from './index-b7735e0d.js';

const dvnFieldDisplayReferenceCss = ".sc-dvn-field-display-reference-h{display:-ms-flexbox;display:flex;overflow:auto}";

const renderReference = (field, data, meta) => {
  var _a;
  const imageSrc = field.imageField ? data[field.imageField] : undefined;
  const initialLetters = field.titleField
    ? (_a = data[field.titleField]) === null || _a === void 0 ? void 0 : _a.split(' ').map(word => word[0]).join('')
    : undefined;
  const title = data[field.titleField];
  if (meta.showTitle) {
    return (h("dvn-info-summary", { title: title, leaned: true }, h("dvn-image", { slot: "media", bordered: true, leaned: true, src: imageSrc, text: initialLetters })));
  }
  return (h("abbr", { title: title, style: { border: 'none', textDecoration: 'none' } }, h("dvn-image", { bordered: true, src: imageSrc, text: initialLetters })));
};
let DvnFieldDisplayReference = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.meta = {};
  }
  render() {
    const { field, meta } = this;
    const value = this.value || [];
    return (h(Host, null, Array.isArray(value)
      ? value.map(data => renderReference(field, data, meta))
      : renderReference(field, value, meta)));
  }
};
DvnFieldDisplayReference.style = dvnFieldDisplayReferenceCss;

export { DvnFieldDisplayReference as dvn_field_display_reference };
