"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.replaceBlockedKeywords = exports.converter = exports.WINDOW = exports.TRIGGER_TYPE = exports.SELECTOR = exports.SECURITY_CONSTANTS = exports.SCHEDULE_TYPE = exports.REPORT_TYPE = exports.REPORT_STATE = exports.REPORT_DEFINITION_STATUS = exports.INTERVAL = exports.GLOBAL_BASIC_COUNTER = exports.FORMAT = exports.EXTRA_HEADERS = exports.DELIVERY_TYPE = exports.DELIVERY_CHANNEL = exports.DEFAULT_ROLLING_COUNTER = exports.DEFAULT_REPORT_HEADER = exports.DEFAULT_MAX_SIZE = exports.DATA_REPORT_CONFIG = exports.CHROMIUM_PATH = exports.CAPACITY = exports.ALLOWED_HOSTS = void 0;

var _showdown = _interopRequireDefault(require("showdown"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/*
 * Copyright OpenSearch Contributors
 * SPDX-License-Identifier: Apache-2.0
 */
let FORMAT;
exports.FORMAT = FORMAT;

(function (FORMAT) {
  FORMAT["pdf"] = "pdf";
  FORMAT["png"] = "png";
  FORMAT["csv"] = "csv";
})(FORMAT || (exports.FORMAT = FORMAT = {}));

let REPORT_STATE;
exports.REPORT_STATE = REPORT_STATE;

(function (REPORT_STATE) {
  REPORT_STATE["created"] = "Created";
  REPORT_STATE["error"] = "Error";
  REPORT_STATE["pending"] = "Pending";
  REPORT_STATE["shared"] = "Shared";
})(REPORT_STATE || (exports.REPORT_STATE = REPORT_STATE = {}));

let REPORT_DEFINITION_STATUS;
exports.REPORT_DEFINITION_STATUS = REPORT_DEFINITION_STATUS;

(function (REPORT_DEFINITION_STATUS) {
  REPORT_DEFINITION_STATUS["active"] = "Active";
  REPORT_DEFINITION_STATUS["disabled"] = "Disabled";
})(REPORT_DEFINITION_STATUS || (exports.REPORT_DEFINITION_STATUS = REPORT_DEFINITION_STATUS = {}));

let DELIVERY_CHANNEL;
exports.DELIVERY_CHANNEL = DELIVERY_CHANNEL;

(function (DELIVERY_CHANNEL) {
  DELIVERY_CHANNEL["email"] = "Email";
  DELIVERY_CHANNEL["slack"] = "Slack";
  DELIVERY_CHANNEL["chime"] = "Chime";
  DELIVERY_CHANNEL["opensearchDashboards"] = "OpenSearch Dashboards user";
})(DELIVERY_CHANNEL || (exports.DELIVERY_CHANNEL = DELIVERY_CHANNEL = {}));

let SCHEDULE_TYPE;
exports.SCHEDULE_TYPE = SCHEDULE_TYPE;

(function (SCHEDULE_TYPE) {
  SCHEDULE_TYPE["recurring"] = "Recurring";
  SCHEDULE_TYPE["cron"] = "Cron based";
})(SCHEDULE_TYPE || (exports.SCHEDULE_TYPE = SCHEDULE_TYPE = {}));

let REPORT_TYPE;
exports.REPORT_TYPE = REPORT_TYPE;

(function (REPORT_TYPE) {
  REPORT_TYPE["savedSearch"] = "Saved search";
  REPORT_TYPE["dashboard"] = "Dashboard";
  REPORT_TYPE["visualization"] = "Visualization";
  REPORT_TYPE["notebook"] = "Notebook";
})(REPORT_TYPE || (exports.REPORT_TYPE = REPORT_TYPE = {}));

let DATA_REPORT_CONFIG;
exports.DATA_REPORT_CONFIG = DATA_REPORT_CONFIG;

(function (DATA_REPORT_CONFIG) {
  DATA_REPORT_CONFIG["excelDateFormat"] = "MM/DD/YYYY h:mm:ss.SSS a";
})(DATA_REPORT_CONFIG || (exports.DATA_REPORT_CONFIG = DATA_REPORT_CONFIG = {}));

let TRIGGER_TYPE;
exports.TRIGGER_TYPE = TRIGGER_TYPE;

(function (TRIGGER_TYPE) {
  TRIGGER_TYPE["schedule"] = "Schedule";
  TRIGGER_TYPE["onDemand"] = "On demand";
})(TRIGGER_TYPE || (exports.TRIGGER_TYPE = TRIGGER_TYPE = {}));

let DELIVERY_TYPE;
exports.DELIVERY_TYPE = DELIVERY_TYPE;

(function (DELIVERY_TYPE) {
  DELIVERY_TYPE["opensearchDashboardsUser"] = "OpenSearch Dashboards user";
  DELIVERY_TYPE["channel"] = "Channel";
})(DELIVERY_TYPE || (exports.DELIVERY_TYPE = DELIVERY_TYPE = {}));

let SELECTOR; // https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-request-from-size.html

exports.SELECTOR = SELECTOR;

(function (SELECTOR) {
  SELECTOR["dashboard"] = "#dashboardViewport";
  SELECTOR["visualization"] = ".visEditor__content";
  SELECTOR["notebook"] = ".euiPageBody";
})(SELECTOR || (exports.SELECTOR = SELECTOR = {}));

const DEFAULT_MAX_SIZE = 10000;
exports.DEFAULT_MAX_SIZE = DEFAULT_MAX_SIZE;
const DEFAULT_REPORT_HEADER = '<h1>OpenSearch Dashboards Reports</h1>';
exports.DEFAULT_REPORT_HEADER = DEFAULT_REPORT_HEADER;
const SECURITY_CONSTANTS = {
  TENANT_LOCAL_STORAGE_KEY: 'opendistro::security::tenant::show_popup'
};
exports.SECURITY_CONSTANTS = SECURITY_CONSTANTS;
const EXTRA_HEADERS = ['cookie', 'x-proxy-user', 'x-proxy-roles', 'x-forwarded-for'];
exports.EXTRA_HEADERS = EXTRA_HEADERS;
const converter = new _showdown.default.Converter({
  tables: true,
  simplifiedAutoLink: true,
  strikethrough: true,
  tasklists: true,
  noHeaderId: true
});
exports.converter = converter;
const BLOCKED_KEYWORD = 'BLOCKED_KEYWORD';
const ipv4Regex = /(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):([1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])/g;
const ipv6Regex = /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/g;
const localhostRegex = /localhost:([1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])/g;
const iframeRegex = /iframe/g;
const ALLOWED_HOSTS = /^(0|0.0.0.0|127.0.0.1|localhost|(.*\.)?(opensearch.org|aws.a2z.com))$/;
exports.ALLOWED_HOSTS = ALLOWED_HOSTS;

const replaceBlockedKeywords = htmlString => {
  // replace <ipv4>:<port>
  htmlString = htmlString.replace(ipv4Regex, BLOCKED_KEYWORD); // replace ipv6 addresses

  htmlString = htmlString.replace(ipv6Regex, BLOCKED_KEYWORD); // replace iframe keyword

  htmlString = htmlString.replace(iframeRegex, BLOCKED_KEYWORD); // replace localhost:<port>

  htmlString = htmlString.replace(localhostRegex, BLOCKED_KEYWORD);
  return htmlString;
};

exports.replaceBlockedKeywords = replaceBlockedKeywords;
const CHROMIUM_PATH = `${__dirname}/../../../.chromium/headless_shell`;
/**
 * Metric constants
 */

exports.CHROMIUM_PATH = CHROMIUM_PATH;
const WINDOW = 3600;
exports.WINDOW = WINDOW;
const INTERVAL = 60;
exports.INTERVAL = INTERVAL;
const CAPACITY = WINDOW / INTERVAL * 2;
exports.CAPACITY = CAPACITY;
const GLOBAL_BASIC_COUNTER = {
  report: {
    create: {
      total: 0
    },
    create_from_definition: {
      total: 0
    },
    download: {
      total: 0
    },
    list: {
      total: 0
    },
    info: {
      total: 0
    }
  },
  report_definition: {
    create: {
      total: 0
    },
    list: {
      total: 0
    },
    info: {
      total: 0
    },
    update: {
      total: 0
    },
    delete: {
      total: 0
    }
  },
  report_source: {
    list: {
      total: 0
    }
  },
  dashboard: {
    pdf: {
      download: {
        total: 0
      }
    },
    png: {
      download: {
        total: 0
      }
    }
  },
  visualization: {
    pdf: {
      download: {
        total: 0
      }
    },
    png: {
      download: {
        total: 0
      }
    }
  },
  notebook: {
    pdf: {
      download: {
        count: 0
      }
    },
    png: {
      download: {
        count: 0
      }
    }
  },
  saved_search: {
    csv: {
      download: {
        total: 0
      }
    }
  }
};
exports.GLOBAL_BASIC_COUNTER = GLOBAL_BASIC_COUNTER;
const DEFAULT_ROLLING_COUNTER = {
  report: {
    create: {
      count: 0,
      system_error: 0,
      user_error: 0
    },
    create_from_definition: {
      count: 0,
      system_error: 0,
      user_error: 0
    },
    download: {
      count: 0,
      system_error: 0,
      user_error: 0
    },
    list: {
      count: 0,
      system_error: 0,
      user_error: 0
    },
    info: {
      count: 0,
      system_error: 0,
      user_error: 0
    }
  },
  report_definition: {
    create: {
      count: 0,
      system_error: 0,
      user_error: 0
    },
    list: {
      count: 0,
      system_error: 0,
      user_error: 0
    },
    info: {
      count: 0,
      system_error: 0,
      user_error: 0
    },
    update: {
      count: 0,
      system_error: 0,
      user_error: 0
    },
    delete: {
      count: 0,
      system_error: 0,
      user_error: 0
    }
  },
  report_source: {
    list: {
      count: 0,
      system_error: 0,
      user_error: 0
    }
  },
  dashboard: {
    pdf: {
      download: {
        count: 0
      }
    },
    png: {
      download: {
        count: 0
      }
    }
  },
  visualization: {
    pdf: {
      download: {
        count: 0
      }
    },
    png: {
      download: {
        count: 0
      }
    }
  },
  notebook: {
    pdf: {
      download: {
        count: 0
      }
    },
    png: {
      download: {
        count: 0
      }
    }
  },
  saved_search: {
    csv: {
      download: {
        count: 0
      }
    }
  }
};
exports.DEFAULT_ROLLING_COUNTER = DEFAULT_ROLLING_COUNTER;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 17308 characters]