/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import { a as getConfig } from "./runtime.js";
const loggedDeprecations = /* @__PURE__ */ new Set();
const logLevels = {
  trace: 0,
  debug: 1,
  info: 2,
  warn: 4,
  error: 8,
  off: 10
};
function willLog(level) {
  return logLevels[level] >= logLevels[getConfig().logLevel];
}
function forwardToConsole(level, ...data) {
  if (!willLog(level)) {
    return;
  }
  const badgeTemplate = "%ccalcite";
  const badgeStyle = "background: #007AC2; color: #fff; border-radius: 4px; padding: 2px 4px;";
  console[level](badgeTemplate, badgeStyle, ...data);
}
let listFormatter;
const logger = {
  debug: (message) => forwardToConsole("debug", message),
  info: (message) => forwardToConsole("info", message),
  warn: (message) => forwardToConsole("warn", message),
  error: (message) => forwardToConsole("error", message),
  trace: (message) => forwardToConsole("trace", message),
  deprecated
};
function deprecated(context, { component, name, suggested, removalVersion }) {
  const key = `${context}:${context === "component" ? "" : component}${name}`;
  const removalVersionText = removalVersion === "future" ? `a future version` : `v${removalVersion}`;
  if (loggedDeprecations.has(key)) {
    return;
  }
  loggedDeprecations.add(key);
  let message = "";
  message = context === "component" ? `This component is deprecated and will be removed in ${removalVersionText}.` : `The [${name}] ${context} is deprecated and will be removed in ${removalVersionText}.`;
  if (suggested) {
    listFormatter = new Intl.ListFormat("en", { style: "long", type: "disjunction" });
    message += ` Use ${listFormatter.format([suggested].flat().map((suggestion) => `"${suggestion}"`))} instead.`;
  }
  const composed = `[${component.el.tagName.toLocaleLowerCase().slice("calcite-".length)}] - ${message}`;
  forwardToConsole("warn", composed);
}
export {
  logger as l
};
