{"version":3,"file":"templateSrv.mjs","sources":["../../../src/services/templateSrv.ts"],"sourcesContent":["import { ScopedVars, TimeRange, TypedVariableModel } from '@grafana/data';\n\n/**\n * Can be used to gain more information about an interpolation operation\n */\nexport interface VariableInterpolation {\n  /** The full matched expression including, example: ${varName.field:regex} */\n  match: string;\n  /** In the expression ${varName.field:regex} variableName is varName */\n  variableName: string;\n  /** In the expression ${varName.fields[0].name:regex} the fieldPath is fields[0].name */\n  fieldPath?: string;\n  /** In the expression ${varName:regex} the regex part is the format */\n  format?: string;\n  /** The formatted value of the variable expresion. Will equal match when variable not found or scopedVar was undefined or null **/\n  value: string;\n  // When value === match this will be true, meaning the variable was not found\n  found?: boolean;\n}\n\n/**\n * Via the TemplateSrv consumers get access to all the available template variables\n * that can be used within the current active dashboard.\n *\n * For a more in-depth description visit: https://grafana.com/docs/grafana/latest/reference/templating\n * @public\n */\nexport interface TemplateSrv {\n  /**\n   * List the dashboard variables\n   */\n  getVariables(): TypedVariableModel[];\n\n  /**\n   * Replace the values within the target string.  See also {@link InterpolateFunction}\n   *\n   * Note: interpolations array is being mutated by replace function by adding information about variables that\n   * have been interpolated during replacement. Variables that were specified in the target but not found in\n   * the list of available variables are also added to the array. See {@link VariableInterpolation} for more details.\n   *\n   * @param {VariableInterpolation[]} interpolations an optional map that is updated with interpolated variables\n   */\n  replace(\n    target?: string,\n    scopedVars?: ScopedVars,\n    format?: string | Function,\n    interpolations?: VariableInterpolation[]\n  ): string;\n\n  /**\n   * Checks if a target contains template variables.\n   */\n  containsTemplate(target?: string): boolean;\n\n  /**\n   * Update the current time range to be used when interpolating __from / __to variables.\n   */\n  updateTimeRange(timeRange: TimeRange): void;\n}\n\nlet singletonInstance: TemplateSrv;\n\n/**\n * Used during startup by Grafana to set the TemplateSrv so it is available\n * via the {@link getTemplateSrv} to the rest of the application.\n *\n * @internal\n */\nexport const setTemplateSrv = (instance: TemplateSrv) => {\n  singletonInstance = instance;\n};\n\n/**\n * Used to retrieve the {@link TemplateSrv} that can be used to fetch available\n * template variables.\n *\n * @public\n */\nexport const getTemplateSrv = (): TemplateSrv => singletonInstance;\n"],"names":[],"mappings":"AA4DA,IAAI,iBAAA;AAQS,MAAA,cAAA,GAAiB,CAAC,QAA0B,KAAA;AACvD,EAAoB,iBAAA,GAAA,QAAA;AACtB;AAQO,MAAM,iBAAiB,MAAmB;;;;"}