{"version":3,"file":"mixins.mjs","sources":["../../../src/themes/mixins.ts"],"sourcesContent":["import tinycolor from 'tinycolor2';\n\nimport { GrafanaTheme, GrafanaTheme2 } from '@grafana/data';\n\nexport function cardChrome(theme: GrafanaTheme2): string {\n  return `\n    background: ${theme.colors.background.secondary};\n    &:hover {\n      background: ${hoverColor(theme.colors.background.secondary, theme)};\n    }\n    box-shadow: ${theme.components.panel.boxShadow};\n    border-radius: ${theme.shape.radius.default};\n`;\n}\n\nexport function hoverColor(color: string, theme: GrafanaTheme2): string {\n  return theme.isDark ? tinycolor(color).brighten(2).toString() : tinycolor(color).darken(2).toString();\n}\n\nexport function listItem(theme: GrafanaTheme2): string {\n  return `\n  background: ${theme.colors.background.secondary};\n  &:hover {\n    background: ${hoverColor(theme.colors.background.secondary, theme)};\n  }\n  box-shadow: ${theme.components.panel.boxShadow};\n  border-radius: ${theme.shape.radius.default};\n`;\n}\n\nexport function listItemSelected(theme: GrafanaTheme2): string {\n  return `\n    background: ${hoverColor(theme.colors.background.secondary, theme)};\n    color: ${theme.colors.text.maxContrast};\n`;\n}\n\nexport function mediaUp(breakpoint: string) {\n  return `only screen and (min-width: ${breakpoint})`;\n}\n\nconst isGrafanaTheme2 = (theme: GrafanaTheme | GrafanaTheme2): theme is GrafanaTheme2 => theme.hasOwnProperty('v1');\nexport const focusCss = (theme: GrafanaTheme | GrafanaTheme2) => {\n  const isTheme2 = isGrafanaTheme2(theme);\n  const firstColor = isTheme2 ? theme.colors.background.canvas : theme.colors.bodyBg;\n  const secondColor = isTheme2 ? theme.colors.primary.main : theme.colors.formFocusOutline;\n\n  return `\n  outline: 2px dotted transparent;\n  outline-offset: 2px;\n  box-shadow: 0 0 0 2px ${firstColor}, 0 0 0px 4px ${secondColor};\n  transition-property: outline, outline-offset, box-shadow;\n  transition-duration: 0.2s;\n  transition-timing-function: cubic-bezier(0.19, 1, 0.22, 1);`;\n};\n\nexport function getMouseFocusStyles(theme: GrafanaTheme | GrafanaTheme2) {\n  return {\n    outline: 'none',\n    boxShadow: `none`,\n  };\n}\n\nexport function getFocusStyles(theme: GrafanaTheme2) {\n  return {\n    outline: '2px dotted transparent',\n    outlineOffset: '2px',\n    boxShadow: `0 0 0 2px ${theme.colors.background.canvas}, 0 0 0px 4px ${theme.colors.primary.main}`,\n    transitionTimingFunction: `cubic-bezier(0.19, 1, 0.22, 1)`,\n    transitionDuration: '0.2s',\n    transitionProperty: 'outline, outline-offset, box-shadow',\n  };\n}\n\nexport function getButtonFocusStyles(theme: GrafanaTheme2) {\n  return {\n    ...getFocusStyles(theme),\n    transitionProperty: undefined,\n  };\n}\n\n// max-width is set up based on .grafana-tooltip class that's used in dashboard\nexport const getTooltipContainerStyles = (theme: GrafanaTheme2) => ({\n  overflow: 'hidden',\n  background: theme.colors.background.elevated,\n  boxShadow: theme.shadows.z2,\n  maxWidth: '800px',\n  padding: theme.spacing(1),\n  borderRadius: theme.shape.radius.default,\n  zIndex: theme.zIndex.tooltip,\n});\n\ninterface ExternalRadiusAdditionalOptions {\n  selfBorderWidth?: number;\n  childBorderRadius?: number;\n}\n/**\n * Calculates a border radius for an element, based on border radius of its child.\n *\n * @param theme\n * @param offset - The distance to offset from the child element, should be >= 0.\n * @param additionalOptions\n * @param additionalOptions.selfBorderWidth - The border width of the element itself (default: 1)\n * @param additionalOptions.childBorderRadius - The border radius of the child element (default: theme default radius)\n * @returns A CSS calc() expression that returns the relative external radius value\n */\nexport const getExternalRadius = (\n  theme: GrafanaTheme2,\n  offset: number,\n  additionalOptions: ExternalRadiusAdditionalOptions = {}\n) => {\n  const { selfBorderWidth = 1, childBorderRadius } = additionalOptions;\n\n  const childBorderRadiusPx = childBorderRadius !== undefined ? `${childBorderRadius}px` : theme.shape.radius.default;\n  return `calc(max(0px, ${childBorderRadiusPx} + ${offset}px + ${selfBorderWidth}px))`;\n};\n\ninterface InternalRadiusAdditionalOptions {\n  parentBorderWidth?: number;\n  parentBorderRadius?: number;\n}\n\n/**\n * Calculates a border radius for an element, based on border radius of its parent.\n *\n * @param theme\n * @param offset - The distance to offset from the parent element, should be >= 0.\n * @param additionalOptions\n * @param additionalOptions.parentBorderWidth - The border width of the parent element (default: 1)\n * @param additionalOptions.parentBorderRadius - The border radius of the parent element (default: theme default radius)\n * @returns A CSS calc() expression that returns the relative internal radius value\n */\nexport const getInternalRadius = (\n  theme: GrafanaTheme2,\n  offset: number,\n  additionalOptions: InternalRadiusAdditionalOptions = {}\n) => {\n  const { parentBorderWidth = 1, parentBorderRadius } = additionalOptions;\n\n  const parentBorderRadiusPx =\n    parentBorderRadius !== undefined ? `${parentBorderRadius}px` : theme.shape.radius.default;\n  return `calc(max(0px, ${parentBorderRadiusPx} - ${offset}px - ${parentBorderWidth}px))`;\n};\n"],"names":[],"mappings":";;;AAIO,SAAS,WAAW,KAAA,EAA8B;AACvD,EAAA,OAAO;AAAA,gBAAA,EACS,KAAA,CAAM,MAAA,CAAO,UAAA,CAAW,SAAS,CAAA;AAAA;AAAA,kBAAA,EAE/B,WAAW,KAAA,CAAM,MAAA,CAAO,UAAA,CAAW,SAAA,EAAW,KAAK,CAAC,CAAA;AAAA;AAAA,gBAAA,EAEtD,KAAA,CAAM,UAAA,CAAW,KAAA,CAAM,SAAS,CAAA;AAAA,mBAAA,EAC7B,KAAA,CAAM,KAAA,CAAM,MAAA,CAAO,OAAO,CAAA;AAAA,CAAA;AAE/C;AAEO,SAAS,UAAA,CAAW,OAAe,KAAA,EAA8B;AACtE,EAAA,OAAO,MAAM,MAAA,GAAS,SAAA,CAAU,KAAK,CAAA,CAAE,SAAS,CAAC,CAAA,CAAE,QAAA,EAAS,GAAI,UAAU,KAAK,CAAA,CAAE,MAAA,CAAO,CAAC,EAAE,QAAA,EAAS;AACtG;AAEO,SAAS,SAAS,KAAA,EAA8B;AACrD,EAAA,OAAO;AAAA,cAAA,EACO,KAAA,CAAM,MAAA,CAAO,UAAA,CAAW,SAAS,CAAA;AAAA;AAAA,gBAAA,EAE/B,WAAW,KAAA,CAAM,MAA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