"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ERROR_CODE = exports.OPT_OUT_COOKIE_EXPIRATION = exports.DEFAULT_COOKIE_EXPIRATION = exports.ExperimentType = exports.ViewActivationTypes = exports.REQUEST_CF_PROPERTY_NAME = exports.RequestCFPropertiesToLog = exports.RequestPropertiesToLog = exports.DebugOnlyKeys = exports.OptimizelyLogLevel = exports.WorkerHost = exports.FileName = exports.ValidS3Buckets = exports.DefaultCdnOrigin = exports.RequestType = exports.VisitorIdLocatorType = exports.EdgeQueryParams = exports.RequestQueryParameters = exports.OptimizelyRequestHeaders = exports.SESSION_LENGTH_MS = exports.OptimizelyCookies = exports.OptimizelyQueryParams = exports.OPTIMIZELY_EDGE_HOSTNAME = exports.DatafileVersion = exports.CACHE_TTL_SECONDS = void 0;
exports.CACHE_TTL_SECONDS = 60;
exports.DatafileVersion = {
    V4: '4',
};
exports.OPTIMIZELY_EDGE_HOSTNAME = 'optimizely-edge.com';
/**
 * Optimizely query params. All are prefixed with 'optimizely_'.
 *
 * This is a subset of the query params that are parsed and consumed by client directives:
 * https://github.com/optimizely/client-js/blob/c4d866cadfcac259f083f581604753fb5afef2b4/src/core/directive/index.js#L19
 *
 * Parameter usage:
 *
 * * `optimizely_disable` (DISABLE) Disables Optimizely if present
 * * `optimizely_p13n` (EDITOR_V2) Indicates running in v2 (Optimizely X) editor.
 * * `optimizely_x` (FORCE_VARIATIONS) Comma-separated list of Variation IDs to bucket.
 *      If set, overrides any variations the visitor is in "naturally".
 * * `optimizely_opt_out` (OPT_OUT) Opts visitor out of Optimizely (sets cookie to persist).
 * * `optimizely_token` (TOKEN) Auth token for current project to load preview (unpublished/archived/paused) data.
 *
 * @enum {String}
 */
exports.OptimizelyQueryParams = {
    DISABLE: 'optimizely_disable',
    EDITOR_V2: 'optimizely_p13n',
    FORCE_VARIATIONS: 'optimizely_x',
    LOG: 'optimizely_log',
    OPT_OUT: 'optimizely_opt_out',
    TOKEN: 'optimizely_token',
};
exports.OptimizelyCookies = {
    OEU_ID: 'optimizelyEndUserId',
    OPT_OUT: 'optimizelyOptOut',
    OPTIMIZELY_TOKEN: 'optimizelyToken',
    OPTIMIZELY_SESSION: 'optimizelySession',
};
exports.SESSION_LENGTH_MS = 30 * 60 * 1000; // 30 min
/**
 * Edge request headers.
 *
 * Parameter usage:
 *
 * * `X-Optimizely-Extend-Cookie-Lifetime` (EXTEND_COOKIE_LIFETIME) If set to false,
 *      we don't set the Optimizely End User ID cookie in the microsnippet (if it's already set).
 *
 * @enum {String}
 */
exports.OptimizelyRequestHeaders = {
    EXTEND_COOKIE_LIFETIME: 'X-Optimizely-Extend-Cookie-Lifetime',
};
/**
 * Edge request URL query parameters.
 *
 * Parameter usage:
 *
 * * `extend_cookie_lifetime` (EXTEND_COOKIE_LIFETIME) If set to false,
 *      we don't set the Optimizely End User ID cookie in the microsnippet (if it's already set).
 * * `cookie_expiration` (COOKIE_EXPIRATION) this value overwrite
 *      the DEFAULT_COOKIE_EXPIRATION value.
 * `cookie_domain` (COOKIE_DOMAIN) If a value is defined and a is valid
 *      cookie domain, it will be set as the cookie domain.
 * @enum {String}
 */
exports.RequestQueryParameters = {
    EXTEND_COOKIE_LIFETIME: 'extend_cookie_lifetime',
    COOKIE_EXPIRATION: 'cookie_expiration',
    COOKIE_DOMAIN: 'cookie_domain',
};
/**
 * Query parameters needed for Edge decider.
 *
 * Parameter usage:
 *
 * * `optimizely_manifest_bucket` (OPTIMIZELY_MANIFEST_BUCKET) Specifies S3 bucket from
 *   which to fetch web manifest
 * * `optimizely_bypass_log_sampling` (BYPASS_LOG_SAMPLING) Always log request to Honeycomb (undocumented).
 * * `optimizely_bust_cache` (BUST_CACHE) Control caching of downstream resources (undocumented).
 *
 * @enum {String}
 */
exports.EdgeQueryParams = {
    OPTIMIZELY_MANIFEST_BUCKET: 'optimizely_manifest_bucket',
    BYPASS_LOG_SAMPLING: 'optimizely_bypass_log_sampling',
    BUST_CACHE: 'optimizely_bust_cache',
};
exports.VisitorIdLocatorType = {
    COOKIE: 'cookie',
    PAGE_QUERY: 'query',
    JS_VARIABLE: 'js',
    LOCALSTORAGE: 'localStorage',
};
exports.RequestType = {
    DISABLE: 'DISABLE',
    EDITOR: 'EDITOR',
    PREVIEW: 'PREVIEW',
    STANDARD: 'STANDARD',
    OPT_OUT_VIA_COOKIE: 'OPT_OUT_VIA_COOKIE',
    OPT_OUT_VIA_QUERY_PARAM: 'OPT_OUT_VIA_QUERY_PARAM',
};
exports.DefaultCdnOrigin = 'https://cdn.optimizely.com';
/**
 * List of Valid S3 buckets from which we can fetch.
 * @type {{"optimizely-staging": string, "optimizely-dev": string}}
 */
exports.ValidS3Buckets = {
    'optimizely-staging': 'optimizely-staging',
    'optimizely-dev': 'optimizely-dev',
};
/**
 * FileName.
 * @type {{WEB_MANIFEST: string}}
 */
exports.FileName = {
    WEB_PROJECT_MANIFEST: 'web_manifest_project_v0.json',
};
/*
 * Hosts to use for the worker.
 */
exports.WorkerHost = {
    local: 'localhost:3000',
};
exports.OptimizelyLogLevel = {
    DEBUG: 'debug',
    ERROR: 'error',
    INFO: 'info',
    WARN: 'warn',
};
exports.DebugOnlyKeys = ['metadata', 'webManifestUrl'];
/**
 * These are the primitive properties that are passed to us in the request that we want to log into Honeycomb.
 * @array {String}
 */
exports.RequestPropertiesToLog = ['bodyUsed', 'method', 'redirect', 'url'];
/**
 * The request has a "cf" property that is an object itself containing properties that we want to log into Honeycomb.
 * These are the specific properties that we want to log.
 * @array {String}
 */
exports.RequestCFPropertiesToLog = [
    'asn',
    'city',
    'clientTcpRtt',
    'clientTrustScore',
    'colo',
    'continent',
    'country',
    'edgeRequestKeepAliveStatus',
    'httpProtocol',
    'isEUCountry',
    'regionCode',
    'requestPriority',
    'tlsCipher',
    'tlsVersion',
];
/**
 * This is the property name for the CF data on the request object.
 * @type {string}
 */
exports.REQUEST_CF_PROPERTY_NAME = 'cf';
exports.ViewActivationTypes = {
    immediate: 'immediate',
    URLChanged: 'url_changed',
    DOMChanged: 'dom_changed',
};
exports.ExperimentType = {
    EQUAL_PRIORITY: 'equal_priority',
    SINGLE_EXPERIMENT: 'single_experiment',
    MULTIVARIATE: 'multivariate',
};
/**
 * Until we support cookieExpiration, use 6 months (15552000 secs) for expiration of Optimizely cookies (default in tracking snippet)
 * https://github.com/optimizely/client-js/blob/2b25fa05fde9a03019e0081cd2849c921ec5eef6/src/core/stores/cookie_options.js#L20
 *
 */
exports.DEFAULT_COOKIE_EXPIRATION = 60 * 60 * 24 * 30 * 6;
/**
 * This is the expiration time (max age) for Opt Out cookies - 10 years (315360000 secs).
 */
exports.OPT_OUT_COOKIE_EXPIRATION = 60 * 60 * 24 * 365 * 10;
/**
 * This list of error codes need to be set to return a different http code because 400 or 500 doesn't allow to
 * execute the script in the browser/user side.
 *
 * This also will be reflected in the honeycomb dataset 'edge-decider-df' and in the cloudflare metrics
 */
exports.ERROR_CODE = {
    InputError: 240,
    DataError: 249,
    InternalError: 250, // Like 500,  Mostly raised when there is a issue with the webmanifest file.
};
exports.default = {
    CACHE_TTL_SECONDS: exports.CACHE_TTL_SECONDS,
    DatafileVersion: exports.DatafileVersion,
    DebugOnlyKeys: exports.DebugOnlyKeys,
    DEFAULT_COOKIE_EXPIRATION: exports.DEFAULT_COOKIE_EXPIRATION,
    DefaultCdnOrigin: exports.DefaultCdnOrigin,
    EdgeQueryParams: exports.EdgeQueryParams,
    OptimizelyCookies: exports.OptimizelyCookies,
    OptimizelyLogLevel: exports.OptimizelyLogLevel,
    OptimizelyQueryParams: exports.OptimizelyQueryParams,
    OptimizelyRequestHeaders: exports.OptimizelyRequestHeaders,
    OPTIMIZELY_EDGE_HOSTNAME: exports.OPTIMIZELY_EDGE_HOSTNAME,
    OPT_OUT_COOKIE_EXPIRATION: exports.OPT_OUT_COOKIE_EXPIRATION,
    RequestCFPropertiesToLog: exports.RequestCFPropertiesToLog,
    RequestPropertiesToLog: exports.RequestPropertiesToLog,
    RequestQueryParameters: exports.RequestQueryParameters,
    REQUEST_CF_PROPERTY_NAME: exports.REQUEST_CF_PROPERTY_NAME,
    RequestType: exports.RequestType,
    ValidS3Buckets: exports.ValidS3Buckets,
    ViewActivationTypes: exports.ViewActivationTypes,
    VisitorIdLocatorType: exports.VisitorIdLocatorType,
    WorkerHost: exports.WorkerHost,
    ERROR_CODE: exports.ERROR_CODE,
};
