"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useProfilingPlugin = useProfilingPlugin; var _react = require("react"); var _common = require("@kbn/observability-plugin/common"); var _use_apm_plugin_context = require("../context/apm_plugin/use_apm_plugin_context"); /* * 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; you may not use this file except in compliance with the Elastic License * 2.0. */ function useProfilingPlugin() { var _plugins$profiling; const { plugins, core } = (0, _use_apm_plugin_context.useApmPluginContext)(); const isProfilingIntegrationEnabled = core.uiSettings.get(_common.apmEnableProfilingIntegration, false); const [isProfilingPluginInitialized, setIsProfilingPluginInitialized] = (0, _react.useState)(); (0, _react.useEffect)(() => { async function fetchIsProfilingSetup() { if (!plugins.profiling) { setIsProfilingPluginInitialized(false); return; } const resp = await plugins.profiling.hasSetup(); setIsProfilingPluginInitialized(resp); } fetchIsProfilingSetup(); }, [plugins.profiling]); return { isProfilingPluginInitialized, profilingLocators: isProfilingIntegrationEnabled && isProfilingPluginInitialized ? (_plugins$profiling = plugins.profiling) === null || _plugins$profiling === void 0 ? void 0 : _plugins$profiling.locators : undefined, isProfilingIntegrationEnabled }; }