{"version":3,"sources":["../../../src/govuk/helpers/_colour.scss"],"names":[],"mappings":"AAAA,GAAG;AACH,wBAAwB;AACxB,GAAG;AACH,gBAAgB;AAChB,eAAe;AACf,gBAAgB;AAChB,kBAAkB;;AAElB,wCAAwC;AACxC,qCAAqC;AACrC,2CAA2C;AAC3C,8BAA8B;;AAE9B,gCAAgC;AAChC,EAAE;AACF,qEAAqE;AACrE,4EAA4E;AAC5E,4CAA4C;AAC5C,EAAE;AACF,4EAA4E;AAC5E,wBAAwB;AACxB,kFAAkF;AAClF,wBAAwB;AACxB,kDAAkD;AAClD,EAAE;AACF,0DAA0D;AAC1D,oBAAoB;AACpB,mCAAmC;AACnC,MAAM;AACN,EAAE;AACF,8CAA8C;AAC9C,oBAAoB;AACpB,wDAAwD;AACxD,MAAM;AACN,EAAE;AACF,8DAA8D;AAC9D,+EAA+E;AAC/E,2FAA2F;AAC3F,iBAAiB;;AAEjB;EACE,uEAAuE;EACvE,sDAAsD;EACtD,6DAA6D;EAC7D;IACE,qBAAqB;EACvB;;EAEA,4CAA4C;;EAE5C;IACE,kFAAkF;IAClF,mFAAmF;IACnF;MACE,iEAAiE;MACjE;QACE,6BAA6B;MAC/B;IACF;;IAEA,+EAA+E;EACjF;;EAEA,gGAAgG;EAChG;IACE,wBAAwB;EAC1B;;EAEA;IACE,2GAA2G;EAC7G;;EAEA,4CAA4C;;EAE5C;IACE,kHAAkH;EACpH;;EAEA,eAAe;AACjB;;AAEA;EACE,8DAA8D;;EAE9D;IACE,qDAAqD;IACrD,sDAAsD;;IAEtD,mHAAmH;;IAEnH;MACE;;;;;OAKC;IACH;;IAEA,6EAA6E;EAC/E;AACF;;AAEA,0BAA0B;AAC1B,EAAE;AACF,uEAAuE;AACvE,8EAA8E;AAC9E,0EAA0E;AAC1E,2EAA2E;AAC3E,oBAAoB;AACpB,EAAE;AACF,8CAA8C;AAC9C,uBAAuB;AACvB,+CAA+C;AAC/C,MAAM;AACN,EAAE;AACF,yDAAyD;AACzD,uBAAuB;AACvB,mDAAmD;AACnD,iDAAiD;AACjD,MAAM;AACN,EAAE;AACF,qEAAqE;AACrE,iBAAiB;AACjB,iCAAiC;AACjC;EACE,uEAAuE;EACvE,sDAAsD;EACtD,6DAA6D;EAC7D;IACE,qBAAqB;EACvB;;EAEA;IACE,0EAA0E;;IAE1E,iDAAiD;EACnD;;EAEA,gGAAgG;AAClG;;AAEA,0DAA0D;AAC1D,EAAE;AACF,0HAA0H;AAC1H,+BAA+B;AAC/B,6CAA6C;AAC7C,gDAAgD;AAChD,kBAAkB;AAClB;EACE,yDAAyD;EACzD;IACE,yBAAyB;EAC3B;;EAEA;IACE,+DAA+D;EACjE;;EAEA,yCAAyC;EACzC;IACE,oDAAoD;EACtD;;EAEA,mBAAmB;EACnB;IACE,+CAA+C;EACjD;;EAEA;IACE,uDAAuD;EACzD;;EAEA,+CAA+C;AACjD;;AAEA,+CAA+C;AAC/C,EAAE;AACF,2EAA2E;AAC3E,8EAA8E;AAC9E,6EAA6E;AAC7E,2EAA2E;AAC3E,0EAA0E;AAC1E,0EAA0E;AAC1E,oEAAoE;AACpE,EAAE;AACF,6DAA6D;AAC7D,wDAAwD;AACxD,iBAAiB;;AAEjB;EACE,yEAAyE;EACzE,8CAA8C;EAC9C;IACE,4EAA4E;EAC9E;;EAEA,yCAAyC;EACzC;IACE,gDAAgD;EAClD;;EAEA,iEAAiE;;EAEjE,kEAAkE;EAClE,sDAAsD;EACtD;IACE;;;KAGC;EACH;;EAEA;IACE,6CAA6C;EAC/C,EAAE;IACA,sCAAsC;EACxC;AACF","file":"_colour.scss","sourcesContent":["////\n/// @group helpers/colour\n////\n@use \"sass:list\";\n@use \"sass:map\";\n@use \"sass:meta\";\n@use \"sass:string\";\n\n@import \"../settings/colours-functional\";\n@import \"../settings/colours-palette\";\n@import \"../settings/colours-organisations\";\n@import \"../settings/warnings\";\n\n/// Get a colour from the palette\n///\n/// Before using this function, check if your use case is covered by a\n/// functional colour. For example, use `govuk-functional-colour(\"link\")` for\n/// links rather than `govuk-colour(\"blue\")`.\n///\n/// @param {String | Colour} $colour - Name of colour from the colour palette\n///   (`$_govuk-palette`)\n/// @param {String | Colour} $variant - Name of the variant from the colour palette\n///   (`$_govuk-palette`)\n/// @return {Colour} Representation of named colour\n///\n/// @example scss - Getting the primary variant of a colour\n///   .my-component {\n///     color: govuk-colour(\"blue\");\n///   }\n///\n/// @example scss - Getting a 50% shade of blue\n///   .my-component {\n///     color: govuk-colour(\"blue\", $variant: \"shade-50\")\n///   }\n///\n/// @throw if `$colour` is not a colour from the colour palette\n/// @throw if `$variant` is not a variant of the `$colour` in the colour palette\n/// @throw if the palette is misformatted and doesn't associate a colour or map to `$colour`\n/// @access public\n\n@function govuk-colour($colour, $variant: primary, $colours: $_govuk-palette) {\n  // Sass parses unquoted colours as colours, so we need to turn them into\n  // strings before looking them up in the colour palette\n  // https://sass-lang.com/documentation/values/strings#unquoted\n  @if meta.type-of($colour) != \"string\" {\n    $colour: \"#{$colour}\";\n  }\n\n  $colour-variants: map.get($colours, $colour);\n\n  @if not $colour-variants {\n    // To ease the transition between the brand palette and old GOV.UK Frontend colours\n    // we'll automatically convert old colour names into their equivalent in the palette\n    @if $colours == $_govuk-palette {\n      $corresponding-colour: _govuk-corresponding-brand-colour($colour);\n      @if $corresponding-colour {\n        @return $corresponding-colour;\n      }\n    }\n\n    @error \"Unknown colour `#{$colour}` (available colours: #{map.keys($colours)})\";\n  }\n\n  // Some colours may not have variants, if that's the case, we can return the colour straight away\n  @if meta.type-of($colour-variants) == \"color\" {\n    @return $colour-variants;\n  }\n\n  @if meta.type-of($colour-variants) != \"map\" {\n    @error \"Colour `#{$colour}` should either be a `map` or `color`, not a `#{meta.type-of($colour-variants)}`\";\n  }\n\n  $result: map.get($colour-variants, $variant);\n\n  @if not $result {\n    @error \"Unknown variant `#{$variant}` for colour `#{$colour}` (available variants: #{map.keys($colour-variants)})\";\n  }\n\n  @return $result;\n}\n\n@function _govuk-corresponding-brand-colour($colour) {\n  $pre-brand-colour: map.get($_govuk-pre-brand-colours, $colour);\n\n  @if $pre-brand-colour {\n    $corresponding-colour: list.nth($pre-brand-colour, 1);\n    $corresponding-variant: list.nth($pre-brand-colour, 2);\n\n    $corresponding-govuk-colour-call: 'govuk-colour(\"#{$corresponding-colour}\", $variant: \"#{$corresponding-variant}\")';\n\n    @if _should-warn(\"pre-brand-colour\") {\n      @warn _warning-text(\"pre-brand-colour\",\n        \"We've updated GOV.UK Frontend's colour palette. Use \" +\n        \"`#{$corresponding-govuk-colour-call}` instead of \" +\n        \"`govuk-colour(\\\"#{$colour}\\\")`. The `#{$colour}` colour is \" +\n        \"deprecated and we'll remove it in the next major version.\"\n      );\n    }\n\n    @return govuk-colour($corresponding-colour, $variant: $corresponding-variant);\n  }\n}\n\n/// Get a functional colour\n///\n/// @param {String|Colour} $colour - Name of the colour from the list of\n///   [functional colours](https://design-system.service.gov.uk/styles/colour/)\n/// @return {String} A reference to the functional colour's custom property\n///   wrapped in a var function, with the functional colour's hex value as a\n///   fallback value.\n///\n/// @example scss - Getting a functional colour\n///   .branded-element {\n///     color: govuk-functional-colour('brand');\n///   }\n///\n/// @example css - Output from getting a functional colour\n///   .branded-element {\n///     /* Assuming the 'brand' colour is hotpink */\n///     color: var(--govuk-brand-colour, hotpink);\n///   }\n///\n/// @throw if `$colour` is not an functional colour of GOV.UK Frontend\n/// @access public\n/// @see $govuk-functional-colours\n@function govuk-functional-colour($colour) {\n  // Sass parses unquoted colours as colours, so we need to turn them into\n  // strings before looking them up in the colour palette\n  // https://sass-lang.com/documentation/values/strings#unquoted\n  @if meta.type-of($colour) != \"string\" {\n    $colour: \"#{$colour}\";\n  }\n\n  @if map.has-key($govuk-functional-colours, $colour) {\n    $value: _govuk-resolve-colour(map.get($govuk-functional-colours, $colour));\n\n    @return var(--govuk-#{$colour}-colour, #{$value});\n  }\n\n  @error \"Unknown colour `#{$colour}` (available colours: #{map.keys($govuk-functional-colours)})\";\n}\n\n/// Resolves the given reference to a colour in the palette\n///\n/// @param {Map|Colour} $colour-reference - A map with the `name`, and optionally a `variant` for the colour in the palette\n/// @returns {Colour} The colour\n/// @throws if the `name` is present but falsy\n/// @throws if the `variant` is present but falsy\n/// @access private\n@function _govuk-resolve-colour($colour-reference) {\n  // If the reference is already a colour, return the colour\n  @if meta.type-of($colour-reference) == \"color\" {\n    @return $colour-reference;\n  }\n\n  @if not meta.type-of($colour-reference) == \"map\" {\n    @error 'Colour reference should be a Sass colour or a Sass map';\n  }\n\n  $name: map.get($colour-reference, \"name\");\n  @if not $name or $name == \"\" {\n    @error \"Colour reference `name` shouldn't be empty.\";\n  }\n\n  $variant: \"primary\";\n  @if map.has-key($colour-reference, \"variant\") {\n    $variant: map.get($colour-reference, \"variant\");\n  }\n\n  @if not $variant or $variant == \"\" {\n    @error \"Colour reference `variant` shouldn't be empty.\";\n  }\n\n  @return govuk-colour($name, $variant: $variant);\n}\n\n/// Get the colour for a government organisation\n///\n/// @param {String} $organisation - Organisation name, lowercase, hyphenated\n/// @param {Boolean} $contrast-safe [true] - By default a version of the colour\n///   will be returned which has a minimum 4.5:1 contrast ratio when used with\n///   white, as per the WCAG 2.1 Level AA guidelines. If you want to use the\n///   non-contrast safe version you can set this to `false` but your should\n///   ensure that you still meets contrast requirements for accessibility -\n///   for example, do not use the non-contrast safe version for text.\n///\n/// @return {Colour} Representation of colour for organisation\n/// @throw if `$organisation` is not a known organisation\n/// @access public\n\n@function govuk-organisation-colour($organisation, $contrast-safe: true) {\n  // Check if the $organisation exists in the aliases map. If so, change the\n  // value of $organisation to the aliased value.\n  @if map.has-key($_govuk_colours-organisations-aliases, $organisation) {\n    $organisation: map.get($_govuk_colours-organisations-aliases, $organisation);\n  }\n\n  // Check to see if the organisation exists\n  @if not map.has-key($govuk-colours-organisations, $organisation) {\n    @error \"Unknown organisation `#{$organisation}`\";\n  }\n\n  $org-colour: map.get($govuk-colours-organisations, $organisation);\n\n  // If the organisation has a deprecation message associated with it\n  // (e.g. it has ceased to exist) then output a warning.\n  @if map.has-key($org-colour, \"deprecation-message\") and _should-warn(\"organisation-colours\") {\n    @warn _warning-text(\n      \"organisation-colours\",\n      map.get($org-colour, \"deprecation-message\")\n    );\n  }\n\n  @if $contrast-safe and map.has-key($org-colour, \"contrast-safe\") {\n    @return map.get($org-colour, \"contrast-safe\");\n  } @else {\n    @return map.get($org-colour, \"colour\");\n  }\n}\n"]}
