'use strict';

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

const index = require('./index-ce58ddc5.js');
const utils = require('./utils-95d43da5.js');

const dvnFieldDisplayTextCss = "dvn-field-display-text{display:block;--line-count:0;overflow:hidden;display:-webkit-box;-webkit-line-clamp:var(--line-count);-webkit-box-orient:vertical;line-height:var(--line-height);min-height:calc(var(--line-count) * var(--line-height))}";

let DvnFieldDisplayText = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.meta = {};
  }
  render() {
    const { field, meta } = this;
    let value = this.value;
    // 0 means no limit
    const { lines = 0 } = meta;
    if (!value) {
      return (index.h(index.Host, { style: { '--line-count': lines } }, "-"));
    }
    if (field.inputType === 'url') {
      value = index.h("a", { href: value.startsWith('http') ? value : `http://${value}`, target: "_blank" }, value);
    }
    if (utils.hasLink(value)) {
      return (index.h(index.Host, { style: { '--line-count': lines }, innerHTML: utils.linkify(this.value) }));
    }
    if (field.format === 'markdown') {
      return (index.h(index.Host, { style: { '--line-count': lines } }, index.h("dvn-markdown", { content: value })));
    }
    return (index.h(index.Host, { style: { '--line-count': lines } }, value));
  }
};
DvnFieldDisplayText.style = dvnFieldDisplayTextCss;

exports.dvn_field_display_text = DvnFieldDisplayText;
