@import "../settings/colours-palette";
@import "../settings/colours-organisations";

////
/// @group helpers/colour
////

/// Get colour
///
/// @param {String} $colour - Name of colour from the colour palette
///   (`$govuk-colours`)
/// @return {Colour} Representation of named colour
/// @throw if `$colour` is not a colour from the colour palette
/// @access public

@function govuk-colour($colour) {
  $colour: quote($colour);

  @if not map-has-key($govuk-colours, $colour) {
    @error "Unknown colour `#{$colour}`";
  }

  @return map-get($govuk-colours, $colour);
}

/// Get the colour for a government organisation
///
/// @param {String} $organisation - Organisation name, lowercase, hyphenated
/// @param {Boolean} $websafe [true] - By default a 'websafe' version of the
///   colour will be returned which meets contrast requirements . If you want to
///   use the non-websafe version you can set this to `false` but your should
///   ensure that you still meets contrast requirements for accessibility - for
///   example, don't use the non-websafe version for text.
///
/// @return {Colour} Representation of colour for organisation
/// @throw if `$organisation` is not a known organisation
/// @access public

@function govuk-organisation-colour($organisation, $websafe: true) {
  @if not map-has-key($govuk-colours-organisations, $organisation) {
    @error "Unknown organisation `#{$organisation}`";
  }

  $org-colour: map-get($govuk-colours-organisations, $organisation);

  @if ($websafe and map-has-key($org-colour, colour-websafe)) {
    @return map-get($org-colour, colour-websafe);
  } @else {
    @return map-get($org-colour, colour);
  }
}
