{"version":3,"file":"time.mjs","sources":["../../../src/types/time.ts"],"sourcesContent":["import {\n  TimeZone as SchemaTimeZone,\n  TimeZoneBrowser as SchemaTimeZoneBrowser,\n  TimeZoneUtc as SchemaTimeZoneUtc,\n  defaultTimeZone,\n} from '@grafana/schema';\n\nimport { dateTime, DateTime } from '../datetime/moment_wrapper';\n\nexport interface RawTimeRange {\n  from: DateTime | string;\n  to: DateTime | string;\n}\n\nexport interface TimeRange {\n  from: DateTime;\n  to: DateTime;\n  raw: RawTimeRange;\n}\n\n/**\n * Type to describe relative time to now in seconds.\n * @internal\n */\nexport interface RelativeTimeRange {\n  from: number;\n  to: number;\n}\n\nexport interface AbsoluteTimeRange {\n  from: number;\n  to: number;\n}\n\nexport interface IntervalValues {\n  interval: string; // 10s,5m\n  intervalMs: number;\n}\n\nexport interface TimeOption {\n  from: string;\n  to: string;\n  display: string;\n  invalid?: boolean;\n  section?: number;\n}\n\n/** @deprecated use TimeZone from schema  */\nexport type TimeZone = SchemaTimeZone;\n\n/** @deprecated use TimeZoneBrowser from schema  */\nexport type TimeZoneBrowser = SchemaTimeZoneBrowser;\n\n/** @deprecated use TimeZoneUtc from schema  */\nexport type TimeZoneUtc = SchemaTimeZoneUtc;\n\n/** @deprecated use defaultTimeZone from schema  */\nexport const DefaultTimeZone = defaultTimeZone;\n\nexport interface TimeOptions {\n  [key: string]: TimeOption[];\n}\n\nexport type TimeFragment = string | DateTime;\n\nexport const TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';\n\nexport function getDefaultTimeRange(): TimeRange {\n  const now = dateTime();\n\n  return {\n    from: dateTime(now).subtract(6, 'hour'),\n    to: now,\n    raw: { from: 'now-6h', to: 'now' },\n  };\n}\n\n/**\n * Returns the default relative time range.\n *\n * @public\n */\nexport function getDefaultRelativeTimeRange(): RelativeTimeRange {\n  return {\n    from: 600,\n    to: 0,\n  };\n}\n\n/**\n * Simple helper to quickly create a TimeRange object either from string representations of a dateTime or directly\n * DateTime objects.\n */\nexport function makeTimeRange(from: DateTime | string, to: DateTime | string): TimeRange {\n  const fromDateTime = typeof from === 'string' ? dateTime(from) : from;\n  const toDateTime = typeof to === 'string' ? dateTime(to) : to;\n  return {\n    from: fromDateTime,\n    to: toDateTime,\n    raw: {\n      from: fromDateTime,\n      to: toDateTime,\n    },\n  };\n}\n"],"names":[],"mappings":";;;;AAyDO,MAAM,eAAA,GAAkB;AAQxB,MAAM,WAAA,GAAc;AAEpB,SAAS,mBAAA,GAAiC;AAC/C,EAAA,MAAM,MAAM,QAAA,EAAS;AAErB,EAAA,OAAO;AAAA,IACL,MAAM,QAAA,CAAS,GAAG,CAAA,CAAE,QAAA,CAAS,GAAG,MAAM,CAAA;AAAA,IACtC,EAAA,EAAI,GAAA;AAAA,IACJ,GAAA,EAAK,EAAE,IAAA,EAAM,QAAA,EAAU,IAAI,KAAA;AAAM,GACnC;AACF;AAOO,SAAS,2BAAA,GAAiD;AAC/D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,GAAA;AAAA,IACN,EAAA,EAAI;AAAA,GACN;AACF;AAMO,SAAS,aAAA,CAAc,MAAyB,EAAA,EAAkC;AACvF,EAAA,MAAM,eAAe,OAAO,IAAA,KAAS,QAAA,GAAW,QAAA,CAAS,IAAI,CAAA,GAAI,IAAA;AACjE,EAAA,MAAM,aAAa,OAAO,EAAA,KAAO,QAAA,GAAW,QAAA,CAAS,EAAE,CAAA,GAAI,EAAA;AAC3D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,YAAA;AAAA,IACN,EAAA,EAAI,UAAA;AAAA,IACJ,GAAA,EAAK;AAAA,MACH,IAAA,EAAM,YAAA;AAAA,MACN,EAAA,EAAI;AAAA;AACN,GACF;AACF;;;;"}