import { Component, h, Host, Prop } from '@stencil/core';
const renderReference = (field, data) => {
  const imageSrc = field.imageField ? data[field.imageField] : undefined;
  const initialLetters = field.titleField
    ? data[field.titleField].split(' ').map(word => word[0]).join('')
    : undefined;
  return (h("abbr", { title: data[field.titleField] },
    h("dvn-image", { bordered: true, src: imageSrc, text: initialLetters })));
};
export class DvnFieldDisplayCellReference {
  render() {
    const { field } = this;
    const value = this.value || [];
    return (h(Host, null, Array.isArray(value)
      ? value.map(data => renderReference(field, data))
      : renderReference(field, value)));
  }
  static get is() { return "dvn-field-display-cell-reference"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["dvn-field-display-cell-reference.css"]
  }; }
  static get styleUrls() { return {
    "$": ["dvn-field-display-cell-reference.css"]
  }; }
  static get properties() { return {
    "value": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "any[]",
        "resolved": "any[]",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "field": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "ReferenceField",
        "resolved": "ReferenceField",
        "references": {
          "ReferenceField": {
            "location": "import",
            "path": "../reference-field"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    }
  }; }
}
