<commit_before>/*
    Utilities to parse params supplied as a map. Values can be defined in terms of
    other values, with modifications. For example:

    @include ag-register-params((
        a: ag-derived(b, $times: c, $plus: 2),
        b: 4,
        c: 10
    ));
    @debug ag-param(a); // outputs 42
*/

// Define a derived parameter. Derived values are lazily evaluated. This function is
// sugar for defining a data structure to record the derived value's parameters.
@function ag-derived(
    $reference-name,
    $times: null,
    $divide: null,
    $plus: null,
    $minus: null,
    $opacity: null,
    $lighten: null,
    $darken: null, 
    $mix: null
) {
    $derived: (
        "--ag-is-derived-value": true,
        "reference-name": $reference-name
    );
    @if $times != null {
        $derived: map-merge($derived, ("times": $times));
    }
    @if $divide != null {
        $derived: map-merge($derived, ("divide": $divide));
    }
    @if $plus != null {
        $derived: map-merge($derived, ("plus": $plus));
    }
    @if $minus != null {
        $derived: map-merge($derived, ("minus": $minus));
    }
    @if $opacity != null {
        $derived: map-merge($derived, ("opacity": $opacity));
    }
    @if $lighten != null {
        $derived: map-merge($derived, ("lighten": $lighten));
    }
    @if $darken != null {
        $derived: map-merge($derived, ("darken": $darken));
    }
    @if $mix != null {
        $derived: map-merge($derived, ("mix": $mix));
    }
    @return $derived;
}

// global map of params used by ag-param()
$-ag-params: null !default;

// Register a params map globally so that it can be used by ag-param($name)
@mixin ag-register-params($params) {
    $params: -ag-require-type($params, "map", "$params argument");
    $-ag-params: $params !global;
}

// Use a parameter in SCSS, e.g. `color: ag-param(foreground-color)`
@function ag-param($name) {
    $resolved: ag-param-unchecked($name);
    @if str-index(inspect($resolved), "ag-derived(") != null {
        @error "#{$name} param contains a ag-derived() as a CSS function call expression. This means that you have tried to use ag-derived() before the function is defined - you need to include the file that defines it.";
    }
    @if type-of($resolved) == map {
        @error "ag-param(#{$name}) resolved to a map, which is not valid CSS: #{inspect($resolved)}";
    }
    @each $part in $resolved {
        @if type-of($part) == map {
            @error "ag-param(#{$name}) resolved to a list containing a map, which is not valid CSS: #{str-slice(inspect($resolved), 0, 1000)}";
        }
    }
    @return $resolved;
}

// Like ag-param, but allow map values
@function ag-param-unchecked($name) {
    @if $-ag-params == null {
        @error "ag-param() called before ag-register-params";
    }
    @if str-index($name, "--internal-") == 1 {
        // internal vars are returned without ag-derived resolution or validation that the var exists
        @return map-get($-ag-params, $name);
    }
    @if not map-has-key($-ag-params, $name) {
        @error "ag-param(#{$name}): no such parameter";
    }
    @return -ag-resolve-param-name($-ag-params, $name);
}

// Merge params supplied to a theme with the defaults, optionally validate, and register
// the resulting map globally for use with ag-param()
//
// $params: params supplied by the derived theme
// $defaults: values for params not in $params
@function ag-process-theme-variables($params, $defaults) {
    $params: -ag-require-type($params, map, "$params argument to ag-process-theme-variables");
    // Derived themes can add params, and those new params would trigger validation errors when
    // passed to the base theme, so don't re-validate params that have already been validated
    @if not map-has-key($params, "--ag-already-validated") {
        @each $key in map-keys($params) {
            @if not map-has-key($defaults, $key) and str-index($key, "--internal-") != 1 {
                @warn "Unrecognised param \"#{$key}\"";
            }
        }
    }
    $params: map-merge($defaults, $params);
    $params: map-merge($params, ("--ag-already-validated": true));
    $-ag-params: $params !global;
    @return $params;
}

$ag-not-defined: "--ag-not-defined" !default;

// used in legacy var importers, see e.g. ag-theme-base-legacy-vars.scss for example
@function ag-merge-legacy-var($params, $param-name, $value-or-not-defined, $allowed) {
    @if index($allowed, $param-name) == null {
        @error "Invalid param to merge: #{$param-name}";
    }
    @if $value-or-not-defined == $ag-not-defined {
        @return $params;
    }
    @return map-merge($params, ($param-name: $value-or-not-defined));
}

//<commit_msg>RTI-61 - allow overiding subset of theme icons<commit_after>/*
    Utilities to parse params supplied as a map. Values can be defined in terms of
    other values, with modifications. For example:

    @include ag-register-params((
        a: ag-derived(b, $times: c, $plus: 2),
        b: 4,
        c: 10
    ));
    @debug ag-param(a); // outputs 42
*/

// Define a derived parameter. Derived values are lazily evaluated. This function is
// sugar for defining a data structure to record the derived value's parameters.
@function ag-derived(
    $reference-name,
    $times: null,
    $divide: null,
    $plus: null,
    $minus: null,
    $opacity: null,
    $lighten: null,
    $darken: null, 
    $mix: null
) {
    $derived: (
        "--ag-is-derived-value": true,
        "reference-name": $reference-name
    );
    @if $times != null {
        $derived: map-merge($derived, ("times": $times));
    }
    @if $divide != null {
        $derived: map-merge($derived, ("divide": $divide));
    }
    @if $plus != null {
        $derived: map-merge($derived, ("plus": $plus));
    }
    @if $minus != null {
        $derived: map-merge($derived, ("minus": $minus));
    }
    @if $opacity != null {
        $derived: map-merge($derived, ("opacity": $opacity));
    }
    @if $lighten != null {
        $derived: map-merge($derived, ("lighten": $lighten));
    }
    @if $darken != null {
        $derived: map-merge($derived, ("darken": $darken));
    }
    @if $mix != null {
        $derived: map-merge($derived, ("mix": $mix));
    }
    @return $derived;
}

// global map of params used by ag-param()
$-ag-params: null !default;

// Register a params map globally so that it can be used by ag-param($name)
@mixin ag-register-params($params) {
    $params: -ag-require-type($params, "map", "$params argument");
    $-ag-params: $params !global;
}

// Use a parameter in SCSS, e.g. `color: ag-param(foreground-color)`
@function ag-param($name) {
    $resolved: ag-param-unchecked($name);
    @if str-index(inspect($resolved), "ag-derived(") != null {
        @error "#{$name} param contains a ag-derived() as a CSS function call expression. This means that you have tried to use ag-derived() before the function is defined - you need to include the file that defines it.";
    }
    @if type-of($resolved) == map {
        @error "ag-param(#{$name}) resolved to a map, which is not valid CSS: #{inspect($resolved)}";
    }
    @each $part in $resolved {
        @if type-of($part) == map {
            @error "ag-param(#{$name}) resolved to a list containing a map, which is not valid CSS: #{str-slice(inspect($resolved), 0, 1000)}";
        }
    }
    @return $resolved;
}

// Like ag-param, but allow map values
@function ag-param-unchecked($name) {
    @if $-ag-params == null {
        @error "ag-param() called before ag-register-params";
    }
    @if str-index($name, "--internal-") == 1 {
        // internal vars are returned without ag-derived resolution or validation that the var exists
        @return map-get($-ag-params, $name);
    }
    @if not map-has-key($-ag-params, $name) {
        @error "ag-param(#{$name}): no such parameter";
    }
    @return -ag-resolve-param-name($-ag-params, $name);
}

// Merge params supplied to a theme with the defaults, optionally validate, and register
// the resulting map globally for use with ag-param()
//
// $params: params supplied by the derived theme
// $defaults: values for params not in $params
@function ag-process-theme-variables($params, $defaults) {
    $params: -ag-require-type($params, map, "$params argument to ag-process-theme-variables");
    // Derived themes can add params, and those new params would trigger validation errors when
    // passed to the base theme, so don't re-validate params that have already been validated
    @if not map-has-key($params, "--ag-already-validated") {
        @each $key in map-keys($params) {
            @if not map-has-key($defaults, $key) and str-index($key, "--internal-") != 1 {
                @warn "Unrecognised param \"#{$key}\"";
            }
        }
    }
    @if map-get($params, "icons-font-codes") and map-get($defaults, "icons-font-codes") {
        $merged-codes: map-merge(map-get($defaults, "icons-font-codes"), map-get($params, "icons-font-codes"));
        $params: map-merge($params, ("icons-font-codes": $merged-codes));
    }
    $params: map-merge($defaults, $params);
    $params: map-merge($params, ("--ag-already-validated": true));
    $-ag-params: $params !global;
    @return $params;
}

$ag-not-defined: "--ag-not-defined" !default;

// used in legacy var importers, see e.g. ag-theme-base-legacy-vars.scss for example
@function ag-merge-legacy-var($params, $param-name, $value-or-not-defined, $allowed) {
    @if index($allowed, $param-name) == null {
        @error "Invalid param to merge: #{$param-name}";
    }
    @if $value-or-not-defined == $ag-not-defined {
        @return $params;
    }
    @return map-merge($params, ($param-name: $value-or-not-defined));
}

//
{'fraction_non_alphanumeric': 0.16651267836977723, 'fraction_numerical': 0.002874448208602813, 'mean_word_length': 2.7833009708737864, 'pattern_counts': {'":': 23, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5935144', 'n_tokens_mistral': 3167, 'n_tokens_neox': 3052, 'n_words': 939}