import { B as BaseField } from './BaseField-461b6d0c.js';
import { r as registerInterceptor, I as InterceptorConfig, a as InterceptorHandler } from './InterceptorHandler-6474bcf4.js';

class RawDataField extends BaseField {
  constructor(id, title, description, dataType = 'json') {
    super(id, 'raw-data');
    this.dataType = 'json';
    this.trimStringQuotes = false;
    this.id = id;
    this.title = title;
    this.description = description;
    this.dataType = dataType;
  }
  showPreview() {
    this.preview = true;
    return this;
  }
  getDisplayValue(value) {
    return value;
  }
  setDataType(dataType) {
    this.dataType = dataType;
    return this;
  }
  setTrimStringQuotes(shouldTrim) {
    this.trimStringQuotes = shouldTrim;
    return this;
  }
}
RawDataField.type = 'raw-data';

class ValidatorRegex extends InterceptorConfig {
  constructor(regex, message) {
    super('validatorAlphanumericChar');
    this.regexFlags = 'gm';
    this.regex = regex;
    this.message = message;
  }
}
ValidatorRegex.id = 'validatorAlphanumericChar';
class ValidatorRegexHandler extends InterceptorHandler {
  constructor(config) {
    super();
    this.config = config;
  }
  run(context, _, field, value) {
    if (typeof value === 'string' || value instanceof String) {
      if (!new RegExp(this.config.regex, this.config.regexFlags).test(value)) {
        const errorMessage = this.config.message || context.strings.interceptors.validatorRegex.message;
        return {
          error: errorMessage.replace('{title}', field.errorTitle || field.title),
          value,
        };
      }
    }
    return { value };
  }
}
registerInterceptor(ValidatorRegex.id, (config) => new ValidatorRegexHandler(config));

export { RawDataField as R, ValidatorRegex as V };
