/*
 * Application Insights JavaScript Web SDK - Basic, 2.8.19-nightly.240329-02
 * Copyright (c) Microsoft and contributors. All rights reserved.
 */


import dynamicProto from "@microsoft/dynamicproto-js";
import { Sender } from "@microsoft/applicationinsights-channel-js";
import { DEFAULT_BREEZE_PATH, parseConnectionString } from "@microsoft/applicationinsights-common";
import { AppInsightsCore, isNullOrUndefined, proxyFunctions, throwError } from "@microsoft/applicationinsights-core-js";
import { _DYN_CONNECTION_STRING, _DYN_DIAGNOSTIC_LOG_INTER0, _DYN_INSTRUMENTATION_KEY } from "./__DynamicConstants";
/**
 * @export
 * @class ApplicationInsights
 */
var ApplicationInsights = /** @class */ (function () {
    /**
     * Creates an instance of ApplicationInsights.
     * @param {IConfiguration & IConfig} config
     * @memberof ApplicationInsights
     */
    function ApplicationInsights(config) {
        var core = new AppInsightsCore();
        // initialize the queue and config in case they are undefined
        if (isNullOrUndefined(config) ||
            (isNullOrUndefined(config[_DYN_INSTRUMENTATION_KEY /* @min:%2einstrumentationKey */]) && isNullOrUndefined(config[_DYN_CONNECTION_STRING /* @min:%2econnectionString */]))) {
            throwError("Invalid input configuration");
        }
        dynamicProto(ApplicationInsights, this, function (_self) {
            if (config[_DYN_CONNECTION_STRING /* @min:%2econnectionString */]) {
                var cs = parseConnectionString(config[_DYN_CONNECTION_STRING /* @min:%2econnectionString */]);
                var ingest = cs.ingestionendpoint;
                config.endpointUrl = ingest ? (ingest + DEFAULT_BREEZE_PATH) : config.endpointUrl; // only add /v2/track when from connectionstring
                config[_DYN_INSTRUMENTATION_KEY /* @min:%2einstrumentationKey */] = cs.instrumentationkey || config[_DYN_INSTRUMENTATION_KEY /* @min:%2einstrumentationKey */];
            }
            _self.config = config;
            _initialize();
            _self.initialize = _initialize;
            _self.getSKUDefaults = function () {
                _self.config[_DYN_DIAGNOSTIC_LOG_INTER0 /* @min:%2ediagnosticLogInterval */] =
                    _self.config[_DYN_DIAGNOSTIC_LOG_INTER0 /* @min:%2ediagnosticLogInterval */] && _self.config[_DYN_DIAGNOSTIC_LOG_INTER0 /* @min:%2ediagnosticLogInterval */] > 0 ? _self.config[_DYN_DIAGNOSTIC_LOG_INTER0 /* @min:%2ediagnosticLogInterval */] : 10000;
            };
            _self.getSKUDefaults();
            proxyFunctions(_self, core, [
                "track",
                "flush",
                "pollInternalLogs",
                "stopPollingInternalLogs",
                "unload",
                "getPlugin",
                "addPlugin",
                "evtNamespace",
                "addUnloadCb"
            ]);
            function _initialize() {
                core.initialize(_self.config, [new Sender()]);
                core.pollInternalLogs();
            }
        });
    }
// Removed Stub for ApplicationInsights.prototype.initialize.
// Removed Stub for ApplicationInsights.prototype.track.
// Removed Stub for ApplicationInsights.prototype.flush.
// Removed Stub for ApplicationInsights.prototype.pollInternalLogs.
// Removed Stub for ApplicationInsights.prototype.stopPollingInternalLogs.
// Removed Stub for ApplicationInsights.prototype.getSKUDefaults.
// Removed Stub for ApplicationInsights.prototype.unload.
// Removed Stub for ApplicationInsights.prototype.getPlugin.
// Removed Stub for ApplicationInsights.prototype.addPlugin.
// Removed Stub for ApplicationInsights.prototype.evtNamespace.
// Removed Stub for ApplicationInsights.prototype.addUnloadCb.
    // This is a workaround for an IE8 bug when using dynamicProto() with classes that don't have any
    // non-dynamic functions or static properties/functions when using uglify-js to minify the resulting code.
    // this will be removed when ES3 support is dropped.
    ApplicationInsights.__ieDyn=1;

    return ApplicationInsights;
}());
export { ApplicationInsights };
export { AppInsightsCore, CoreUtils, arrForEach, _InternalMessageId, isNullOrUndefined, throwError, proxyFunctions } from "@microsoft/applicationinsights-core-js";
export { SeverityLevel } from "@microsoft/applicationinsights-common";
export { Sender } from "@microsoft/applicationinsights-channel-js";
//# sourceMappingURL=index.js.map