"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.UrlFormat = void 0; var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _i18n = require("@kbn/i18n"); var _lodash = require("lodash"); var _fieldTypes = require("@kbn/field-types"); var _utils = require("../utils"); var _field_format = require("../field_format"); var _types = require("../types"); /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ const templateMatchRE = /{{([\s\S]+?)}}/g; const allowedUrlSchemes = ['http://', 'https://']; const URL_TYPES = [{ kind: 'a', text: _i18n.i18n.translate('fieldFormats.url.types.link', { defaultMessage: 'Link' }) }, { kind: 'img', text: _i18n.i18n.translate('fieldFormats.url.types.img', { defaultMessage: 'Image' }) }, { kind: 'audio', text: _i18n.i18n.translate('fieldFormats.url.types.audio', { defaultMessage: 'Audio' }) }]; const DEFAULT_URL_TYPE = 'a'; /** @public */ class UrlFormat extends _field_format.FieldFormat { constructor(params) { super(params); (0, _defineProperty2.default)(this, "textConvert", value => this.formatLabel(value)); (0, _defineProperty2.default)(this, "htmlConvert", (rawValue, options = {}) => { const { field, hit } = options; const { parsedUrl } = this._params; const { basePath, pathname, origin } = parsedUrl || {}; const url = (0, _lodash.escape)(this.formatUrl(rawValue)); const label = (0, _lodash.escape)(this.formatLabel(rawValue, url)); switch (this.param('type')) { case 'audio': return `