// @svizzle/time_region_value v0.5.0 - © 2021 nestauk (https://www.nesta.org.uk/)
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global["@svizzle/time_region_value/Index"] = factory());
})(this, (function () { 'use strict';

function noop() { }
function run(fn) {
    return fn();
}
function blank_object() {
    return Object.create(null);
}
function run_all(fns) {
    fns.forEach(run);
}
function is_function(thing) {
    return typeof thing === 'function';
}
function safe_not_equal(a, b) {
    return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
}
function is_empty(obj) {
    return Object.keys(obj).length === 0;
}
function subscribe(store, ...callbacks) {
    if (store == null) {
        return noop;
    }
    const unsub = store.subscribe(...callbacks);
    return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
}
function component_subscribe(component, store, callback) {
    component.$$.on_destroy.push(subscribe(store, callback));
}
function append(target, node) {
    target.appendChild(node);
}
function append_styles(target, style_sheet_id, styles) {
    const append_styles_to = get_root_for_style(target);
    if (!append_styles_to.getElementById(style_sheet_id)) {
        const style = element('style');
        style.id = style_sheet_id;
        style.textContent = styles;
        append_stylesheet(append_styles_to, style);
    }
}
function get_root_for_style(node) {
    if (!node)
        return document;
    const root = node.getRootNode ? node.getRootNode() : node.ownerDocument;
    if (root && root.host) {
        return root;
    }
    return node.ownerDocument;
}
function append_stylesheet(node, style) {
    append(node.head || node, style);
}
function insert(target, node, anchor) {
    target.insertBefore(node, anchor || null);
}
function detach(node) {
    node.parentNode.removeChild(node);
}
function destroy_each(iterations, detaching) {
    for (let i = 0; i < iterations.length; i += 1) {
        if (iterations[i])
            iterations[i].d(detaching);
    }
}
function element(name) {
    return document.createElement(name);
}
function svg_element(name) {
    return document.createElementNS('http://www.w3.org/2000/svg', name);
}
function text(data) {
    return document.createTextNode(data);
}
function space() {
    return text(' ');
}
function empty() {
    return text('');
}
function listen(node, event, handler, options) {
    node.addEventListener(event, handler, options);
    return () => node.removeEventListener(event, handler, options);
}
function attr(node, attribute, value) {
    if (value == null)
        node.removeAttribute(attribute);
    else if (node.getAttribute(attribute) !== value)
        node.setAttribute(attribute, value);
}
function children(element) {
    return Array.from(element.childNodes);
}
function set_data(text, data) {
    data = '' + data;
    if (text.wholeText !== data)
        text.data = data;
}
let crossorigin;
function is_crossorigin() {
    if (crossorigin === undefined) {
        crossorigin = false;
        try {
            if (typeof window !== 'undefined' && window.parent) {
                void window.parent.document;
            }
        }
        catch (error) {
            crossorigin = true;
        }
    }
    return crossorigin;
}
function add_resize_listener(node, fn) {
    const computed_style = getComputedStyle(node);
    if (computed_style.position === 'static') {
        node.style.position = 'relative';
    }
    const iframe = element('iframe');
    iframe.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; ' +
        'overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;');
    iframe.setAttribute('aria-hidden', 'true');
    iframe.tabIndex = -1;
    const crossorigin = is_crossorigin();
    let unsubscribe;
    if (crossorigin) {
        iframe.src = "data:text/html,<script>onresize=function(){parent.postMessage(0,'*')}</script>";
        unsubscribe = listen(window, 'message', (event) => {
            if (event.source === iframe.contentWindow)
                fn();
        });
    }
    else {
        iframe.src = 'about:blank';
        iframe.onload = () => {
            unsubscribe = listen(iframe.contentWindow, 'resize', fn);
        };
    }
    append(node, iframe);
    return () => {
        if (crossorigin) {
            unsubscribe();
        }
        else if (unsubscribe && iframe.contentWindow) {
            unsubscribe();
        }
        detach(iframe);
    };
}
let current_component;
function set_current_component(component) {
    current_component = component;
}
function get_current_component() {
    if (!current_component)
        throw new Error('Function called outside component initialization');
    return current_component;
}
function onMount(fn) {
    get_current_component().$$.on_mount.push(fn);
}
const dirty_components = [];
const binding_callbacks = [];
const render_callbacks = [];
const flush_callbacks = [];
const resolved_promise = Promise.resolve();
let update_scheduled = false;
function schedule_update() {
    if (!update_scheduled) {
        update_scheduled = true;
        resolved_promise.then(flush);
    }
}
function add_render_callback(fn) {
    render_callbacks.push(fn);
}
let flushing = false;
const seen_callbacks = new Set();
function flush() {
    if (flushing)
        return;
    flushing = true;
    do {
        for (let i = 0; i < dirty_components.length; i += 1) {
            const component = dirty_components[i];
            set_current_component(component);
            update(component.$$);
        }
        set_current_component(null);
        dirty_components.length = 0;
        while (binding_callbacks.length)
            binding_callbacks.pop()();
        for (let i = 0; i < render_callbacks.length; i += 1) {
            const callback = render_callbacks[i];
            if (!seen_callbacks.has(callback)) {
                seen_callbacks.add(callback);
                callback();
            }
        }
        render_callbacks.length = 0;
    } while (dirty_components.length);
    while (flush_callbacks.length) {
        flush_callbacks.pop()();
    }
    update_scheduled = false;
    flushing = false;
    seen_callbacks.clear();
}
function update($$) {
    if ($$.fragment !== null) {
        $$.update();
        run_all($$.before_update);
        const dirty = $$.dirty;
        $$.dirty = [-1];
        $$.fragment && $$.fragment.p($$.ctx, dirty);
        $$.after_update.forEach(add_render_callback);
    }
}
const outroing = new Set();
function transition_in(block, local) {
    if (block && block.i) {
        outroing.delete(block);
        block.i(local);
    }
}
function mount_component(component, target, anchor, customElement) {
    const { fragment, on_mount, on_destroy, after_update } = component.$$;
    fragment && fragment.m(target, anchor);
    if (!customElement) {
        add_render_callback(() => {
            const new_on_destroy = on_mount.map(run).filter(is_function);
            if (on_destroy) {
                on_destroy.push(...new_on_destroy);
            }
            else {
                run_all(new_on_destroy);
            }
            component.$$.on_mount = [];
        });
    }
    after_update.forEach(add_render_callback);
}
function destroy_component(component, detaching) {
    const $$ = component.$$;
    if ($$.fragment !== null) {
        run_all($$.on_destroy);
        $$.fragment && $$.fragment.d(detaching);
        $$.on_destroy = $$.fragment = null;
        $$.ctx = [];
    }
}
function make_dirty(component, i) {
    if (component.$$.dirty[0] === -1) {
        dirty_components.push(component);
        schedule_update();
        component.$$.dirty.fill(0);
    }
    component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31));
}
function init(component, options, instance, create_fragment, not_equal, props, append_styles, dirty = [-1]) {
    const parent_component = current_component;
    set_current_component(component);
    const $$ = component.$$ = {
        fragment: null,
        ctx: null,
        props,
        update: noop,
        not_equal,
        bound: blank_object(),
        on_mount: [],
        on_destroy: [],
        on_disconnect: [],
        before_update: [],
        after_update: [],
        context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
        callbacks: blank_object(),
        dirty,
        skip_bound: false,
        root: options.target || parent_component.$$.root
    };
    append_styles && append_styles($$.root);
    let ready = false;
    $$.ctx = instance
        ? instance(component, options.props || {}, (i, ret, ...rest) => {
            const value = rest.length ? rest[0] : ret;
            if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
                if (!$$.skip_bound && $$.bound[i])
                    $$.bound[i](value);
                if (ready)
                    make_dirty(component, i);
            }
            return ret;
        })
        : [];
    $$.update();
    ready = true;
    run_all($$.before_update);
    $$.fragment = create_fragment ? create_fragment($$.ctx) : false;
    if (options.target) {
        if (options.hydrate) {
            const nodes = children(options.target);
            $$.fragment && $$.fragment.l(nodes);
            nodes.forEach(detach);
        }
        else {
            $$.fragment && $$.fragment.c();
        }
        if (options.intro)
            transition_in(component.$$.fragment);
        mount_component(component, options.target, options.anchor, options.customElement);
        flush();
    }
    set_current_component(parent_component);
}
class SvelteComponent {
    $destroy() {
        destroy_component(this, 1);
        this.$destroy = noop;
    }
    $on(type, callback) {
        const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
        callbacks.push(callback);
        return () => {
            const index = callbacks.indexOf(callback);
            if (index !== -1)
                callbacks.splice(index, 1);
        };
    }
    $set($$props) {
        if (this.$$set && !is_empty($$props)) {
            this.$$.skip_bound = true;
            this.$$set($$props);
            this.$$.skip_bound = false;
        }
    }
}

const isServerSide = typeof window === 'undefined';
const isClientSide = !isServerSide;

/**
* @overview lamb - A lightweight, and docile, JavaScript library to help embracing functional programming.
* @author Andrea Scartabelli <andrea.scartabelli@gmail.com>
* @version 0.60.0
* @module lamb
* @license MIT
*/
var __ = {};
function areSVZ (a, b) {
    return a !== a ? b !== b : a === b;
}
function binary (fn) {
    return function (a, b) {
        return fn.call(this, a, b);
    };
}
function clamp (n, min, max) {
    n = +n;
    min = +min;
    max = +max;
    if (min > max) {
        return NaN;
    } else {
        return n < min ? min : n > max ? max : n;
    }
}
function partial (fn, args) {
    return function () {
        if (!Array.isArray(args)) {
            return fn.apply(this, arguments);
        }
        var lastIdx = 0;
        var newArgs = [];
        var argsLen = args.length;
        for (var i = 0, boundArg; i < argsLen; i++) {
            boundArg = args[i];
            newArgs[i] = boundArg === __ ? arguments[lastIdx++] : boundArg;
        }
        for (var len = arguments.length; lastIdx < len; lastIdx++) {
            newArgs[i++] = arguments[lastIdx];
        }
        return fn.apply(this, newArgs);
    };
}
function _makePartial3 (fn, shouldAritize) {
    return function (a, b) {
        var f = shouldAritize && arguments.length !== 2 ? binary(fn) : fn;
        return partial(f, [__, a, b]);
    };
}
function identity (value) {
    return value;
}
function compose (a, b) {
    return arguments.length ? function () {
        return a.call(this, b.apply(this, arguments));
    } : identity;
}
var MAX_ARRAY_LENGTH = 4294967295;
function _toArrayLength (value) {
    return clamp(value, 0, MAX_ARRAY_LENGTH) >>> 0;
}
function forEach (arrayLike, iteratee) {
    for (var i = 0, len = _toArrayLength(arrayLike.length); i < len; i++) {
        iteratee(arrayLike[i], i, arrayLike);
    }
}
var generic = Function.bind.bind(Function.call);
function isNull (value) {
    return value === null;
}
function isUndefined (value) {
    return value === void 0;
}
function isNil (value) {
    return isNull(value) || isUndefined(value);
}
function _curry2 (fn, isRightCurry) {
    return function (a) {
        return function (b) {
            return isRightCurry ? fn.call(this, b, a) : fn.call(this, a, b);
        };
    };
}
function map (arrayLike, iteratee) {
    var len = _toArrayLength(arrayLike.length);
    var result = Array(len);
    for (var i = 0; i < len; i++) {
        result[i] = iteratee(arrayLike[i], i, arrayLike);
    }
    return result;
}
var mapWith = _curry2(map, true);
function _makeReducer (step) {
    return function (arrayLike, accumulator, initialValue) {
        var len = _toArrayLength(arrayLike.length);
        var idx = step === 1 ? 0 : len - 1;
        var nCalls;
        var result;
        if (arguments.length === 3) {
            nCalls = len;
            result = initialValue;
        } else {
            if (len === 0) {
                throw new TypeError("Reduce of empty array-like with no initial value");
            }
            result = arrayLike[idx];
            idx += step;
            nCalls = len - 1;
        }
        for (; nCalls--; idx += step) {
            result = accumulator(result, arrayLike[idx], idx, arrayLike);
        }
        return result;
    };
}
var reduce = _makeReducer(1);
var reduceWith = _makePartial3(reduce, true);
function _toInteger (value) {
    var n = +value;
    if (n !== n) {
        return 0;
    } else if (n % 1 === 0) {
        return n;
    } else {
        return Math.floor(Math.abs(n)) * (n < 0 ? -1 : 1);
    }
}
function slice (arrayLike, start, end) {
    var len = _toArrayLength(arrayLike.length);
    var begin = _toInteger(start);
    var upTo = _toInteger(end);
    if (begin < 0) {
        begin = begin < -len ? 0 : begin + len;
    }
    if (upTo < 0) {
        upTo = upTo < -len ? 0 : upTo + len;
    } else if (upTo > len) {
        upTo = len;
    }
    var resultLen = upTo - begin;
    var result = resultLen > 0 ? Array(resultLen) : [];
    for (var i = 0; i < resultLen; i++) {
        result[i] = arrayLike[begin + i];
    }
    return result;
}
var objectProtoToString = Object.prototype.toString;
function type (value) {
    return objectProtoToString.call(value).slice(8, -1);
}
function appendTo (arrayLike, value) {
    return slice(arrayLike, 0, arrayLike.length).concat([value]);
}
function isIn (arrayLike, value) {
    var result = false;
    for (var i = 0, len = arrayLike.length; i < len; i++) {
        if (areSVZ(value, arrayLike[i])) {
            result = true;
            break;
        }
    }
    return result;
}
function _groupWith (makeValue) {
    return function (arrayLike, iteratee) {
        var result = {};
        var len = arrayLike.length;
        for (var i = 0, element, key; i < len; i++) {
            element = arrayLike[i];
            key = iteratee(element, i, arrayLike);
            result[key] = makeValue(result[key], element);
        }
        return result;
    };
}
function filter (arrayLike, predicate) {
    var len = arrayLike.length;
    var result = [];
    for (var i = 0; i < len; i++) {
        predicate(arrayLike[i], i, arrayLike) && result.push(arrayLike[i]);
    }
    return result;
}
function not (predicate) {
    return function () {
        return !predicate.apply(this, arguments);
    };
}
function uniquesBy (iteratee) {
    return function (arrayLike) {
        var result = [];
        for (var i = 0, len = arrayLike.length, seen = [], value; i < len; i++) {
            value = iteratee(arrayLike[i], i, arrayLike);
            if (!isIn(seen, value)) {
                seen.push(value);
                result.push(arrayLike[i]);
            }
        }
        return result;
    };
}
function dropFrom (arrayLike, n) {
    return slice(arrayLike, n, arrayLike.length);
}
var drop = _curry2(dropFrom, true);
var filterWith = _curry2(filter, true);
function flatMap (array, iteratee) {
    return reduce(array, function (result, el, idx, arr) {
        var v = iteratee(el, idx, arr);
        if (!Array.isArray(v)) {
            v = [v];
        }
        for (var i = 0, len = v.length, rLen = result.length; i < len; i++) {
            result[rLen + i] = v[i];
        }
        return result;
    }, []);
}
var flatMapWith = _curry2(flatMap, true);
function _flatten (array, isDeep, output, idx) {
    for (var i = 0, len = array.length, value, j, vLen; i < len; i++) {
        value = array[i];
        if (!Array.isArray(value)) {
            output[idx++] = value;
        } else if (isDeep) {
            _flatten(value, true, output, idx);
            idx = output.length;
        } else {
            vLen = value.length;
            output.length += vLen;
            for (j = 0; j < vLen; j++) {
                output[idx++] = value[j];
            }
        }
    }
    return output;
}
var _makeArrayFlattener = _curry2(function (isDeep, array) {
    return Array.isArray(array) ? _flatten(array, isDeep, [], 0) : slice(array, 0, array.length);
});
var flatten = _makeArrayFlattener(true);
function _toNaturalIndex (idx, len) {
    idx = _toInteger(idx);
    return idx >= -len && idx < len ? idx < 0 ? idx + len : idx : NaN;
}
function getIndex (arrayLike, index) {
    var idx = _toNaturalIndex(index, _toArrayLength(arrayLike.length));
    return idx === idx ? arrayLike[idx] : void 0;
}
var getAt = _curry2(getIndex, true);
var head = getAt(0);
var index = _groupWith(function (a, b) {
    return b;
});
var indexBy = _curry2(index, true);
function join (arrayLike, separator) {
    return map(arrayLike, String).join(String(separator));
}
var joinWith = _curry2(join, true);
var last = getAt(-1);
function _argsToArrayFrom (idx) {
    return function () {
        var argsLen = arguments.length || idx;
        var len = argsLen - idx;
        var result = Array(len);
        for (var i = 0; i < len; i++) {
            result[i] = arguments[i + idx];
        }
        return result;
    };
}
var list = _argsToArrayFrom(0);
function getIn (obj, key) {
    return obj[key];
}
var getKey$1 = _curry2(getIn, true);
var pluck = compose(mapWith, getKey$1);
function reverse (arrayLike) {
    var len = _toArrayLength(arrayLike.length);
    var result = Array(len);
    for (var i = 0, ofs = len - 1; i < len; i++) {
        result[i] = arrayLike[ofs - i];
    }
    return result;
}
function _compareWith (criteria) {
    return function (a, b) {
        var len = criteria.length;
        var criterion = criteria[0];
        var result = criterion.compare(a.value, b.value);
        for (var i = 1; result === 0 && i < len; i++) {
            criterion = criteria[i];
            result = criterion.compare(a.value, b.value);
        }
        if (result === 0) {
            result = a.index - b.index;
        }
        return criterion.isDescending ? -result : result;
    };
}
function _comparer (a, b) {
    var result = 0;
    if (typeof a !== typeof b) {
        a = String(a);
        b = String(b);
    }
    if (!areSVZ(a, b)) {
        result = a > b || a !== a ? 1 : -1;
    }
    return result;
}
function _sorter (reader, isDescending, comparer) {
    if (typeof reader !== "function" || reader === identity) {
        reader = null;
    }
    if (typeof comparer !== "function") {
        comparer = _comparer;
    }
    return {
        isDescending: isDescending === true,
        compare: function (a, b) {
            if (reader) {
                a = reader(a);
                b = reader(b);
            }
            return comparer(a, b);
        }
    };
}
function _makeCriterion (criterion) {
    return criterion && typeof criterion.compare === "function" ? criterion : _sorter(criterion);
}
function _makeCriteria (sorters) {
    return sorters && sorters.length ? map(sorters, _makeCriterion) : [_sorter()];
}
function sort (arrayLike, sorters) {
    var criteria = _makeCriteria(sorters);
    var len = _toArrayLength(arrayLike.length);
    var result = Array(len);
    for (var i = 0; i < len; i++) {
        result[i] = { value: arrayLike[i], index: i };
    }
    result.sort(_compareWith(criteria));
    for (i = 0; i < len; i++) {
        result[i] = result[i].value;
    }
    return result;
}
var sorterDesc = partial(_sorter, [__, true, __]);
var sortWith = _curry2(sort, true);
function transpose (arrayLike) {
    var minLen = MAX_ARRAY_LENGTH;
    var len = _toArrayLength(arrayLike.length);
    if (len === 0) {
        return [];
    }
    for (var j = 0, elementLen; j < len; j++) {
        elementLen = _toArrayLength(arrayLike[j].length);
        if (elementLen < minLen) {
            minLen = elementLen;
        }
    }
    var result = Array(minLen);
    for (var i = 0, el; i < minLen; i++) {
        el = result[i] = Array(len);
        for (j = 0; j < len; j++) {
            el[j] = arrayLike[j][i];
        }
    }
    return result;
}
function _makeTypeErrorFor (value, desiredType) {
    return new TypeError("Cannot convert " + type(value).toLowerCase() + " to " + desiredType);
}
function pipe (functions) {
    if (!Array.isArray(functions)) {
        throw _makeTypeErrorFor(functions, "array");
    }
    var len = functions.length;
    return len ? function () {
        var result = functions[0].apply(this, arguments);
        for (var i = 1; i < len; i++) {
            result = functions[i].call(this, result);
        }
        return result;
    } : identity;
}
function unionBy (iteratee) {
    return pipe([binary(list), flatMapWith(drop(0)), uniquesBy(iteratee)]);
}
unionBy(identity);
function zip (a, b) {
    return transpose([a, b]);
}
function application (fn, args) {
    return fn.apply(this, Object(args));
}
var apply = _curry2(application);
var applyTo = _curry2(application, true);
function collect (functions) {
    if (!Array.isArray(functions)) {
        throw _makeTypeErrorFor(functions, "array");
    }
    return function () {
        return map(functions, applyTo(arguments));
    };
}
function _checkPredicates (checkAll) {
    return function (predicates) {
        if (!Array.isArray(predicates)) {
            throw _makeTypeErrorFor(predicates, "array");
        }
        return function () {
            for (var i = 0, len = predicates.length, result; i < len; i++) {
                result = predicates[i].apply(this, arguments);
                if (checkAll && !result) {
                    return false;
                } else if (!checkAll && result) {
                    return true;
                }
            }
            return checkAll;
        };
    };
}
var allOf = _checkPredicates(true);
function areSame (a, b) {
    return a === 0 && b === 0 ? 1 / a === 1 / b : areSVZ(a, b);
}
function gt (a, b) {
    return a > b;
}
var is = _curry2(areSame);
var isGT = _curry2(gt, true);
function sum (a, b) {
    return a + b;
}
function divide (a, b) {
    return a / b;
}
function _forceToNumber (value) {
    var n = +value;
    return n === n ? n : 0;
}
function range (start, limit, step) {
    start = _forceToNumber(start);
    limit = _forceToNumber(limit);
    step = arguments.length === 3 ? _forceToNumber(step) : 1;
    if (step === 0) {
        return limit === start ? [] : [start];
    }
    var len = Math.max(Math.ceil((limit - start) / step), 0);
    var result = Array(len);
    for (var i = 0, last = start; i < len; i++) {
        result[i] = last;
        last += step;
    }
    return result;
}
var _isOwnEnumerable = generic(Object.prototype.propertyIsEnumerable);
function _safeEnumerables (obj) {
    var result = [];
    for (var key in obj) {
        result.push(key);
    }
    return result;
}
function _isEnumerable (obj, key) {
    return key in Object(obj) && (_isOwnEnumerable(obj, key) || ~_safeEnumerables(obj).indexOf(key));
}
function _getPathKey (target, key, includeNonEnumerables) {
    if (includeNonEnumerables && key in Object(target) || _isEnumerable(target, key)) {
        return key;
    }
    var n = +key;
    var len = target && target.length;
    return n >= -len && n < len ? n < 0 ? n + len : n : void 0;
}
function _getPathInfo (obj, parts, walkNonEnumerables) {
    if (isNil(obj)) {
        throw _makeTypeErrorFor(obj, "object");
    }
    var target = obj;
    var i = -1;
    var len = parts.length;
    var key;
    while (++i < len) {
        key = _getPathKey(target, parts[i], walkNonEnumerables);
        if (isUndefined(key)) {
            break;
        }
        target = target[key];
    }
    return i === len ? { isValid: true, target: target } : { isValid: false, target: void 0 };
}
function _toPathParts (path, separator) {
    return String(path).split(separator || ".");
}
function getPathIn (obj, path, separator) {
    return _getPathInfo(obj, _toPathParts(path, separator), true).target;
}
var _unsafeKeyListFrom = _curry2(function (getKeys, obj) {
    if (isNil(obj)) {
        throw _makeTypeErrorFor(obj, "object");
    }
    return getKeys(obj);
});
var enumerables = _unsafeKeyListFrom(_safeEnumerables);
function fromPairs (pairsList) {
    var result = {};
    forEach(pairsList, function (pair) {
        result[pair[0]] = pair[1];
    });
    return result;
}
var getPath = _makePartial3(getPathIn);
function has (obj, key) {
    if (typeof obj !== "object" && !isUndefined(obj)) {
        obj = Object(obj);
    }
    return key in obj;
}
generic(Object.prototype.hasOwnProperty);
var _safeKeys = compose(Object.keys, Object);
var keys = _unsafeKeyListFrom(_safeKeys);
function mapValues (source, fn) {
    if (isNil(source)) {
        throw _makeTypeErrorFor(source, "object");
    }
    var result = {};
    for (var key in source) {
        result[key] = fn(source[key], key, source);
    }
    return result;
}
var mapValuesWith = _curry2(mapValues, true);
function _merge (getKeys, a, b) {
    return reduce([a, b], function (result, source) {
        forEach(getKeys(source), function (key) {
            result[key] = source[key];
        });
        return result;
    }, {});
}
var merge = partial(_merge, [enumerables]);
var _keyToPairIn = _curry2(function (obj, key) {
    return [key, obj[key]];
});
var _pairsFrom = _curry2(function (getKeys, obj) {
    return map(getKeys(obj), _keyToPairIn(obj));
});
var _valuesFrom = _curry2(function (getKeys, obj) {
    return map(getKeys(obj), function (key) {
        return obj[key];
    });
});
var pairs = _pairsFrom(enumerables);
function pickIf (predicate) {
    return function (source) {
        if (isNil(source)) {
            throw _makeTypeErrorFor(source, "object");
        }
        var result = {};
        for (var key in source) {
            if (predicate(source[key], key, source)) {
                result[key] = source[key];
            }
        }
        return result;
    };
}
var values = _valuesFrom(enumerables);
_makePartial3(generic(String.prototype.replace));
binary(generic(String.prototype.split));
generic(String.prototype.search);
function isType (typeName) {
    return function (value) {
        return type(value) === typeName;
    };
}

const subscriber_queue = [];
function readable(value, start) {
    return {
        subscribe: writable(value, start).subscribe
    };
}
function writable(value, start = noop) {
    let stop;
    const subscribers = new Set();
    function set(new_value) {
        if (safe_not_equal(value, new_value)) {
            value = new_value;
            if (stop) {
                const run_queue = !subscriber_queue.length;
                for (const subscriber of subscribers) {
                    subscriber[1]();
                    subscriber_queue.push(subscriber, value);
                }
                if (run_queue) {
                    for (let i = 0; i < subscriber_queue.length; i += 2) {
                        subscriber_queue[i][0](subscriber_queue[i + 1]);
                    }
                    subscriber_queue.length = 0;
                }
            }
        }
    }
    function update(fn) {
        set(fn(value));
    }
    function subscribe(run, invalidate = noop) {
        const subscriber = [run, invalidate];
        subscribers.add(subscriber);
        if (subscribers.size === 1) {
            stop = start(set) || noop;
        }
        run(value);
        return () => {
            subscribers.delete(subscriber);
            if (subscribers.size === 0) {
                stop();
                stop = null;
            }
        };
    }
    return { set, update, subscribe };
}
function derived(stores, fn, initial_value) {
    const single = !Array.isArray(stores);
    const stores_array = single
        ? [stores]
        : stores;
    const auto = fn.length < 2;
    return readable(initial_value, (set) => {
        let inited = false;
        const values = [];
        let pending = 0;
        let cleanup = noop;
        const sync = () => {
            if (pending) {
                return;
            }
            cleanup();
            const result = fn(single ? values[0] : values, set);
            if (auto) {
                set(result);
            }
            else {
                cleanup = is_function(result) ? result : noop;
            }
        };
        const unsubscribers = stores_array.map((store, i) => subscribe(store, (value) => {
            values[i] = value;
            pending &= ~(1 << i);
            if (inited) {
                sync();
            }
        }, () => {
            pending |= (1 << i);
        }));
        inited = true;
        sync();
        return function stop() {
            run_all(unsubscribers);
            cleanup();
        };
    });
}

function linear(domain, range) {
    var d0 = domain[0];
    var r0 = range[0];
    var m = (range[1] - r0) / (domain[1] - d0);
    return Object.assign(function (num) {
        return r0 + (num - d0) * m;
    }, {
        inverse: function () { return linear(range, domain); }
    });
}

const isArray = isType('Array');
const isNotNaN = not(isNaN);
const isNotNil = not(isNil);
const isFunction = isType('Function');
const isNumber = isType('Number');
allOf([
	isNotNil,
	obj => obj.then && isFunction(obj.then)
]);
const isValidNumber = allOf([isNumber, isNotNaN]);
pipe([Number, isValidNumber]);
pipe([parseFloat, isValidNumber]);

const concat = generic(Array.prototype.concat);

const mergeWith = fn => (a, b) => reduce(
	pairs(b),
	(obj, [bKey, bValue]) => {
		obj[bKey] = has(obj, bKey) ? fn(obj[bKey], bValue) : bValue;
		return obj;
	},
	merge({}, a)
);

const reduceTo = ctor => fn => reduceWith(fn, new ctor());

const reduceFromEmptyArray = reduceTo(Array);
reduceTo(Object);

const getKey = getKey$1('key');
const getValue = getKey$1('value');

collect([head, last]);
const inclusiveRange = ([start, end, step = 1]) => {
	if (start === end) {
		return isUndefined(start) ? [] : [start];
	}
	const range$1 = range(start, end, step);
	return range$1.length === 0 || last(range$1) + step > end
		? range$1
		: appendTo(range$1, end);
};
sortWith([getValue, getKey]);
sortWith([
	getValue,
	sorterDesc(getKey)
]);
sortWith([
	sorterDesc(getValue),
	getKey
]);
sortWith([
	sorterDesc(getValue),
	sorterDesc(getKey)
]);

const getLength = getKey$1('length');

const arraySumWith = accessor => reduceWith((acc, item) => {
	const value = accessor(item);
	return acc + (isNumber(value) ? value : 0);
}, 0);

const toFloatOrIdentity = x => {
	const parsed = parseFloat(x);
	return isValidNumber(parsed) ? parsed : x;
};

const makeArrayTransformer = fnArr => pipe([
	partial(zip, [fnArr, __]),
	mapWith(([fn, arg]) => fn(arg))
]);

const sliceString = generic(String.prototype.slice);
generic(String.prototype.trim);

const sliceStringAt = arr => partial(sliceString, [__, ...arr]);

const arrayMax = apply(Math.max);
const arrayMin = apply(Math.min);
const arraySum = reduceWith(sum, 0);
pipe([
	collect([arraySum, getLength]),
	apply(divide),
]);
pipe([
	collect([arraySumWith(getValue), getLength]),
	apply(divide),
]);

const joinWithBlank = joinWith(' ');

const is0 = is(0);
const is1 = is(1);
const isGT0 = isGT(0);
const isGT1 = isGT(1);

pipe([getLength, is0]);
const isIterableNotEmpty = pipe([getLength, isGT0]);
pipe([getLength, is1]);
pipe([getLength, isGT1]);

const pairToKeyValueObject = ([key, value]) => ({key, value});

mapValuesWith(toFloatOrIdentity);
mergeWith(sum);
mergeWith(merge);
mergeWith(concat);
mergeWith(appendTo);
const pickIfTruthy = pickIf(identity);
pipe([
	pairs,
	mapWith(reverse),
	fromPairs
]);

pipe([values, apply(concat)]);
pipe([
	pairs,
	filterWith(pipe([
		last,
		allOf([isArray, isIterableNotEmpty])
	])),
	reduceFromEmptyArray((acc, [key, values]) => {
		const props = values.map(value => ({[key]: value}));
		return acc.length === 0
			? props
			: flatMap(
				props,
				prop => acc.map(obj => merge(obj, prop))
			);
	})
]);
pipe([
	pairs,
	mapWith(pairToKeyValueObject)
]);
const getTruthyValuesKeys = pipe([pickIfTruthy, keys]);

/* ../ui/src/sensors/screen/ScreenSensor.svelte generated by Svelte v3.44.2 */

const _screen = writable();

const _groups = writable([]);
const _lookup = writable({});
const makeIndicatorsLookup = pipe([
	pluck('indicators'),
	flatten,
	indexBy(getPath('schema.value.id')),
]);
_groups.subscribe(groups => {
	_lookup.set(makeIndicatorsLookup(groups));
});
const getYearExtent = pipe([
	pluck('indicators'),
	flatten,
	pluck('year_extent'),
	transpose,
	makeArrayTransformer([arrayMin, arrayMax]),
]);
const _yearExtent = derived(_groups, getYearExtent);
derived(_yearExtent, inclusiveRange);

const _isSmallScreen = derived(
	_screen,
	s => s && (s.sizes.small && !s.sizes.medium)
);
derived(_screen, s => s?.classes);
const smallSafety = {left: 40, right: 40};
const largeSafety = {left: 120, right: 80};
const _safety = derived(
	_isSmallScreen,
	isSmall => isSmall ? smallSafety : largeSafety
);
const _timelineHeight = writable(0);
const _timelineWidth = writable(0);
const _timelineLayout = derived([
	_safety,
	_timelineHeight,
	_timelineWidth,
	_yearExtent,
], ([safety, height, width, yearExtent]) => {
	const padding = 10;
	const fontSize = Math.min(height / 4, 14);
	const radius = Math.min(height / 8, 7);
	const fullExtent = [
		padding + radius,
		width - padding - radius
	];
	const fullScaleX = linear(yearExtent, fullExtent);
	const start = fullExtent[0] + safety.left;
	const end = fullExtent[1] - safety.right;
	const scaleX = linear(yearExtent, [start, end]);
	const step = scaleX(start + 1) - scaleX(start);
	const doShortenYears = step < 3 * fontSize;
	const y1 = height / 3;
	const y2 = (height + y1 + radius) / 2;
	const ym = height / 2;
	return {
		doShortenYears,
		end,
		fontSize,
		fullScaleX,
		height,
		radius,
		scaleX,
		start,
		width,
		y1,
		y2,
		ym,
	}
});

const makeClasses = pipe([getTruthyValuesKeys, joinWithBlank]);

const activate = id => mapValuesWith((value, key) => key === id);
const defaultViews = {
	barchart: false,
	distribution: true,
	info: false,
	map: false,
	settings: false,
	sidebar: false,
	trends: false,
};
const _views = writable(defaultViews);
const showView = id => _views.update(activate(id));
derived(_views, makeClasses);
const defaultRoutes = {
	Id: false,
	IdYear: false,
	Index: true,
};
const _routes = writable(defaultRoutes);
const setRoute = id => _routes.update(activate(id));
derived(
	[_isSmallScreen, _views],
	([isSmall, views]) => isSmall && (views.info || views.settings)
);
const _hrefBase = writable('');

const _selectedYear = writable();
const resetSelectedYear = () => _selectedYear.set();

const shortenYear = pipe([String, sliceStringAt([2, 4])]);

const makeURL = (base, id, year) => {
	let url = year
		? `${base}/${id}/${year}`
		: `${base}/${id}`;
	if (isClientSide) {
		const {protocol, host} = location;
		url = new URL(url, `${protocol}//${host}`).toString();
	}
	return url;
};

/* src/routes/index.svelte generated by Svelte v3.44.2 */

function add_css(target) {
	append_styles(target, "svelte-yz4j7q", ".time_region_value_Index.svelte-yz4j7q.svelte-yz4j7q{height:100%;width:100%;padding:var(--dimPadding) var(--dimPadding) 0 var(--dimPadding)}.time_region_value_Index.svelte-yz4j7q header.svelte-yz4j7q{height:var(--dimHeaderHeightShort)}.time_region_value_Index.svelte-yz4j7q .timedist.svelte-yz4j7q{height:calc(100% - var(--dimHeaderHeightShort));width:100%;overflow-y:auto}.group.svelte-yz4j7q.svelte-yz4j7q{margin-top:1rem}svg.svelte-yz4j7q .xref line.svelte-yz4j7q{stroke:var(--colorLightgrey);stroke-dasharray:2 2}svg.svelte-yz4j7q .xref text.svelte-yz4j7q{stroke:none;fill:var(--colorRef);dominant-baseline:hanging;text-anchor:middle;font-size:10px}svg.svelte-yz4j7q .indicatorsrange line.svelte-yz4j7q{stroke:var(--colorBlack);stroke-width:0.7;pointer-events:none}svg.svelte-yz4j7q .indicatorsrange text.svelte-yz4j7q{stroke:none;fill:var(--colorRef);dominant-baseline:middle;text-anchor:middle;pointer-events:none}svg.svelte-yz4j7q .indicatorsrange text.bkg.svelte-yz4j7q{stroke:var(--colorWhite);stroke-width:5}svg.svelte-yz4j7q .indicatorsrange circle.svelte-yz4j7q{fill-opacity:1;fill:var(--colorWhite);stroke:var(--colorBlack);stroke-width:1.5;cursor:pointer}");
}

function get_each_context(ctx, list, i) {
	const child_ctx = ctx.slice();
	child_ctx[12] = list[i].description;
	child_ctx[13] = list[i].indicators;
	child_ctx[14] = list[i].label;
	return child_ctx;
}

function get_each_context_1(ctx, list, i) {
	const child_ctx = ctx.slice();
	child_ctx[17] = list[i].availableYears;
	child_ctx[18] = list[i].title;
	child_ctx[19] = list[i].schema;
	child_ctx[20] = list[i].year_extent;
	child_ctx[22] = i;
	return child_ctx;
}

function get_each_context_2(ctx, list, i) {
	const child_ctx = ctx.slice();
	child_ctx[23] = list[i];
	return child_ctx;
}

function get_each_context_3(ctx, list, i) {
	const child_ctx = ctx.slice();
	child_ctx[23] = list[i];
	return child_ctx;
}

// (56:5) {#if width || isServerSide}
function create_if_block(ctx) {
	let svg;
	let each0_anchor;
	let svg_height_value;
	let each_value_3 = /*$_yearRange*/ ctx[7];
	let each_blocks_1 = [];

	for (let i = 0; i < each_value_3.length; i += 1) {
		each_blocks_1[i] = create_each_block_3(get_each_context_3(ctx, each_value_3, i));
	}

	let each_value_1 = /*indicators*/ ctx[13];
	let each_blocks = [];

	for (let i = 0; i < each_value_1.length; i += 1) {
		each_blocks[i] = create_each_block_1(get_each_context_1(ctx, each_value_1, i));
	}

	return {
		c() {
			svg = svg_element("svg");

			for (let i = 0; i < each_blocks_1.length; i += 1) {
				each_blocks_1[i].c();
			}

			each0_anchor = empty();

			for (let i = 0; i < each_blocks.length; i += 1) {
				each_blocks[i].c();
			}

			attr(svg, "width", /*width*/ ctx[3]);
			attr(svg, "height", svg_height_value = 4 * gap + /*layout*/ ctx[2].fontSize + /*vStep*/ ctx[5] * /*indicators*/ ctx[13].length);
			attr(svg, "class", "svelte-yz4j7q");
		},
		m(target, anchor) {
			insert(target, svg, anchor);

			for (let i = 0; i < each_blocks_1.length; i += 1) {
				each_blocks_1[i].m(svg, null);
			}

			append(svg, each0_anchor);

			for (let i = 0; i < each_blocks.length; i += 1) {
				each_blocks[i].m(svg, null);
			}
		},
		p(ctx, dirty) {
			if (dirty & /*layout, $_yearRange, gap, vStep, $_groups, shortenYearFn*/ 244) {
				each_value_3 = /*$_yearRange*/ ctx[7];
				let i;

				for (i = 0; i < each_value_3.length; i += 1) {
					const child_ctx = get_each_context_3(ctx, each_value_3, i);

					if (each_blocks_1[i]) {
						each_blocks_1[i].p(child_ctx, dirty);
					} else {
						each_blocks_1[i] = create_each_block_3(child_ctx);
						each_blocks_1[i].c();
						each_blocks_1[i].m(svg, each0_anchor);
					}
				}

				for (; i < each_blocks_1.length; i += 1) {
					each_blocks_1[i].d(1);
				}

				each_blocks_1.length = each_value_3.length;
			}

			if (dirty & /*vStep, $_groups, makeURL, $_hrefBase, layout, gap*/ 356) {
				each_value_1 = /*indicators*/ ctx[13];
				let i;

				for (i = 0; i < each_value_1.length; i += 1) {
					const child_ctx = get_each_context_1(ctx, each_value_1, i);

					if (each_blocks[i]) {
						each_blocks[i].p(child_ctx, dirty);
					} else {
						each_blocks[i] = create_each_block_1(child_ctx);
						each_blocks[i].c();
						each_blocks[i].m(svg, null);
					}
				}

				for (; i < each_blocks.length; i += 1) {
					each_blocks[i].d(1);
				}

				each_blocks.length = each_value_1.length;
			}

			if (dirty & /*width*/ 8) {
				attr(svg, "width", /*width*/ ctx[3]);
			}

			if (dirty & /*layout, vStep, $_groups*/ 100 && svg_height_value !== (svg_height_value = 4 * gap + /*layout*/ ctx[2].fontSize + /*vStep*/ ctx[5] * /*indicators*/ ctx[13].length)) {
				attr(svg, "height", svg_height_value);
			}
		},
		d(detaching) {
			if (detaching) detach(svg);
			destroy_each(each_blocks_1, detaching);
			destroy_each(each_blocks, detaching);
		}
	};
}

// (69:9) {#if indicators.length > 1}
function create_if_block_1(ctx) {
	let line;
	let line_y__value;

	return {
		c() {
			line = svg_element("line");
			attr(line, "y1", gap);
			attr(line, "y2", line_y__value = gap + /*vStep*/ ctx[5] * /*indicators*/ ctx[13].length);
			attr(line, "class", "svelte-yz4j7q");
		},
		m(target, anchor) {
			insert(target, line, anchor);
		},
		p(ctx, dirty) {
			if (dirty & /*vStep, $_groups*/ 96 && line_y__value !== (line_y__value = gap + /*vStep*/ ctx[5] * /*indicators*/ ctx[13].length)) {
				attr(line, "y2", line_y__value);
			}
		},
		d(detaching) {
			if (detaching) detach(line);
		}
	};
}

// (63:7) {#each $_yearRange as year}
function create_each_block_3(ctx) {
	let g;
	let text_1;
	let t_value = /*shortenYearFn*/ ctx[4](/*year*/ ctx[23]) + "";
	let t;
	let text_1_font_size_value;
	let text_1_y_value;
	let g_transform_value;
	let if_block = /*indicators*/ ctx[13].length > 1 && create_if_block_1(ctx);

	return {
		c() {
			g = svg_element("g");
			if (if_block) if_block.c();
			text_1 = svg_element("text");
			t = text(t_value);
			attr(text_1, "font-size", text_1_font_size_value = /*layout*/ ctx[2].fontSize);
			attr(text_1, "y", text_1_y_value = 2 * gap + /*vStep*/ ctx[5] * /*indicators*/ ctx[13].length + /*layout*/ ctx[2].fontSize / 2);
			attr(text_1, "class", "svelte-yz4j7q");
			attr(g, "class", "xref");
			attr(g, "transform", g_transform_value = "translate(" + /*layout*/ ctx[2].scaleX(/*year*/ ctx[23]) + ",0)");
		},
		m(target, anchor) {
			insert(target, g, anchor);
			if (if_block) if_block.m(g, null);
			append(g, text_1);
			append(text_1, t);
		},
		p(ctx, dirty) {
			if (/*indicators*/ ctx[13].length > 1) {
				if (if_block) {
					if_block.p(ctx, dirty);
				} else {
					if_block = create_if_block_1(ctx);
					if_block.c();
					if_block.m(g, text_1);
				}
			} else if (if_block) {
				if_block.d(1);
				if_block = null;
			}

			if (dirty & /*shortenYearFn, $_yearRange*/ 144 && t_value !== (t_value = /*shortenYearFn*/ ctx[4](/*year*/ ctx[23]) + "")) set_data(t, t_value);

			if (dirty & /*layout*/ 4 && text_1_font_size_value !== (text_1_font_size_value = /*layout*/ ctx[2].fontSize)) {
				attr(text_1, "font-size", text_1_font_size_value);
			}

			if (dirty & /*vStep, $_groups, layout*/ 100 && text_1_y_value !== (text_1_y_value = 2 * gap + /*vStep*/ ctx[5] * /*indicators*/ ctx[13].length + /*layout*/ ctx[2].fontSize / 2)) {
				attr(text_1, "y", text_1_y_value);
			}

			if (dirty & /*layout, $_yearRange*/ 132 && g_transform_value !== (g_transform_value = "translate(" + /*layout*/ ctx[2].scaleX(/*year*/ ctx[23]) + ",0)")) {
				attr(g, "transform", g_transform_value);
			}
		},
		d(detaching) {
			if (detaching) detach(g);
			if (if_block) if_block.d();
		}
	};
}

// (112:9) {#each availableYears as year}
function create_each_block_2(ctx) {
	let a;
	let circle;
	let circle_cx_value;
	let circle_r_value;
	let a_aria_label_value;
	let a_href_value;

	return {
		c() {
			a = svg_element("a");
			circle = svg_element("circle");
			attr(circle, "cx", circle_cx_value = /*layout*/ ctx[2].scaleX(/*year*/ ctx[23]));
			attr(circle, "r", circle_r_value = /*layout*/ ctx[2].radius);
			attr(circle, "class", "svelte-yz4j7q");
			attr(a, "aria-label", a_aria_label_value = /*year*/ ctx[23]);
			attr(a, "href", a_href_value = makeURL(/*$_hrefBase*/ ctx[8], /*schema*/ ctx[19].value.id, /*year*/ ctx[23]));
			attr(a, "rel", "prefetch");
		},
		m(target, anchor) {
			insert(target, a, anchor);
			append(a, circle);
		},
		p(ctx, dirty) {
			if (dirty & /*layout, $_groups*/ 68 && circle_cx_value !== (circle_cx_value = /*layout*/ ctx[2].scaleX(/*year*/ ctx[23]))) {
				attr(circle, "cx", circle_cx_value);
			}

			if (dirty & /*layout*/ 4 && circle_r_value !== (circle_r_value = /*layout*/ ctx[2].radius)) {
				attr(circle, "r", circle_r_value);
			}

			if (dirty & /*$_groups*/ 64 && a_aria_label_value !== (a_aria_label_value = /*year*/ ctx[23])) {
				attr(a, "aria-label", a_aria_label_value);
			}

			if (dirty & /*$_hrefBase, $_groups*/ 320 && a_href_value !== (a_href_value = makeURL(/*$_hrefBase*/ ctx[8], /*schema*/ ctx[19].value.id, /*year*/ ctx[23]))) {
				attr(a, "href", a_href_value);
			}
		},
		d(detaching) {
			if (detaching) detach(a);
		}
	};
}

// (87:7) {#each indicators as {availableYears, title, schema, year_extent}
function create_each_block_1(ctx) {
	let g;
	let text0;
	let t0_value = /*title*/ ctx[18] + "";
	let t0;
	let text0_x_value;
	let text0_dy_value;
	let text0_font_size_value;
	let text1;
	let t1_value = /*title*/ ctx[18] + "";
	let t1;
	let text1_x_value;
	let text1_dy_value;
	let text1_font_size_value;
	let line;
	let line_x__value;
	let line_x__value_1;
	let g_transform_value;
	let each_value_2 = /*availableYears*/ ctx[17];
	let each_blocks = [];

	for (let i = 0; i < each_value_2.length; i += 1) {
		each_blocks[i] = create_each_block_2(get_each_context_2(ctx, each_value_2, i));
	}

	return {
		c() {
			g = svg_element("g");
			text0 = svg_element("text");
			t0 = text(t0_value);
			text1 = svg_element("text");
			t1 = text(t1_value);
			line = svg_element("line");

			for (let i = 0; i < each_blocks.length; i += 1) {
				each_blocks[i].c();
			}

			attr(text0, "class", "bkg svelte-yz4j7q");
			attr(text0, "x", text0_x_value = (/*layout*/ ctx[2].scaleX(/*year_extent*/ ctx[20][0]) + /*layout*/ ctx[2].scaleX(/*year_extent*/ ctx[20][1])) / 2);
			attr(text0, "dy", text0_dy_value = -(/*layout*/ ctx[2].fontSize + gap));
			attr(text0, "font-size", text0_font_size_value = /*layout*/ ctx[2].fontSize);
			attr(text1, "x", text1_x_value = (/*layout*/ ctx[2].scaleX(/*year_extent*/ ctx[20][0]) + /*layout*/ ctx[2].scaleX(/*year_extent*/ ctx[20][1])) / 2);
			attr(text1, "dy", text1_dy_value = -(/*layout*/ ctx[2].fontSize + gap));
			attr(text1, "font-size", text1_font_size_value = /*layout*/ ctx[2].fontSize);
			attr(text1, "class", "svelte-yz4j7q");
			attr(line, "x1", line_x__value = /*layout*/ ctx[2].scaleX(/*year_extent*/ ctx[20][0]) + /*layout*/ ctx[2].radius);
			attr(line, "x2", line_x__value_1 = /*layout*/ ctx[2].scaleX(/*year_extent*/ ctx[20][1]) - /*layout*/ ctx[2].radius);
			attr(line, "class", "svelte-yz4j7q");
			attr(g, "class", "indicatorsrange");
			attr(g, "transform", g_transform_value = "translate(0," + /*vStep*/ ctx[5] * (/*y*/ ctx[22] + 1) + ")");
		},
		m(target, anchor) {
			insert(target, g, anchor);
			append(g, text0);
			append(text0, t0);
			append(g, text1);
			append(text1, t1);
			append(g, line);

			for (let i = 0; i < each_blocks.length; i += 1) {
				each_blocks[i].m(g, null);
			}
		},
		p(ctx, dirty) {
			if (dirty & /*$_groups*/ 64 && t0_value !== (t0_value = /*title*/ ctx[18] + "")) set_data(t0, t0_value);

			if (dirty & /*layout, $_groups*/ 68 && text0_x_value !== (text0_x_value = (/*layout*/ ctx[2].scaleX(/*year_extent*/ ctx[20][0]) + /*layout*/ ctx[2].scaleX(/*year_extent*/ ctx[20][1])) / 2)) {
				attr(text0, "x", text0_x_value);
			}

			if (dirty & /*layout*/ 4 && text0_dy_value !== (text0_dy_value = -(/*layout*/ ctx[2].fontSize + gap))) {
				attr(text0, "dy", text0_dy_value);
			}

			if (dirty & /*layout*/ 4 && text0_font_size_value !== (text0_font_size_value = /*layout*/ ctx[2].fontSize)) {
				attr(text0, "font-size", text0_font_size_value);
			}

			if (dirty & /*$_groups*/ 64 && t1_value !== (t1_value = /*title*/ ctx[18] + "")) set_data(t1, t1_value);

			if (dirty & /*layout, $_groups*/ 68 && text1_x_value !== (text1_x_value = (/*layout*/ ctx[2].scaleX(/*year_extent*/ ctx[20][0]) + /*layout*/ ctx[2].scaleX(/*year_extent*/ ctx[20][1])) / 2)) {
				attr(text1, "x", text1_x_value);
			}

			if (dirty & /*layout*/ 4 && text1_dy_value !== (text1_dy_value = -(/*layout*/ ctx[2].fontSize + gap))) {
				attr(text1, "dy", text1_dy_value);
			}

			if (dirty & /*layout*/ 4 && text1_font_size_value !== (text1_font_size_value = /*layout*/ ctx[2].fontSize)) {
				attr(text1, "font-size", text1_font_size_value);
			}

			if (dirty & /*layout, $_groups*/ 68 && line_x__value !== (line_x__value = /*layout*/ ctx[2].scaleX(/*year_extent*/ ctx[20][0]) + /*layout*/ ctx[2].radius)) {
				attr(line, "x1", line_x__value);
			}

			if (dirty & /*layout, $_groups*/ 68 && line_x__value_1 !== (line_x__value_1 = /*layout*/ ctx[2].scaleX(/*year_extent*/ ctx[20][1]) - /*layout*/ ctx[2].radius)) {
				attr(line, "x2", line_x__value_1);
			}

			if (dirty & /*$_groups, makeURL, $_hrefBase, layout*/ 324) {
				each_value_2 = /*availableYears*/ ctx[17];
				let i;

				for (i = 0; i < each_value_2.length; i += 1) {
					const child_ctx = get_each_context_2(ctx, each_value_2, i);

					if (each_blocks[i]) {
						each_blocks[i].p(child_ctx, dirty);
					} else {
						each_blocks[i] = create_each_block_2(child_ctx);
						each_blocks[i].c();
						each_blocks[i].m(g, null);
					}
				}

				for (; i < each_blocks.length; i += 1) {
					each_blocks[i].d(1);
				}

				each_blocks.length = each_value_2.length;
			}

			if (dirty & /*vStep*/ 32 && g_transform_value !== (g_transform_value = "translate(0," + /*vStep*/ ctx[5] * (/*y*/ ctx[22] + 1) + ")")) {
				attr(g, "transform", g_transform_value);
			}
		},
		d(detaching) {
			if (detaching) detach(g);
			destroy_each(each_blocks, detaching);
		}
	};
}

// (51:3) {#each $_groups as {description, indicators, label}}
function create_each_block(ctx) {
	let li;
	let h2;
	let t0_value = /*label*/ ctx[14] + "";
	let t0;
	let t1;
	let p;
	let t2_value = /*description*/ ctx[12] + "";
	let t2;
	let t3;
	let t4;
	let if_block = (/*width*/ ctx[3] || isServerSide) && create_if_block(ctx);

	return {
		c() {
			li = element("li");
			h2 = element("h2");
			t0 = text(t0_value);
			t1 = space();
			p = element("p");
			t2 = text(t2_value);
			t3 = space();
			if (if_block) if_block.c();
			t4 = space();
			attr(li, "class", "group svelte-yz4j7q");
		},
		m(target, anchor) {
			insert(target, li, anchor);
			append(li, h2);
			append(h2, t0);
			append(li, t1);
			append(li, p);
			append(p, t2);
			append(li, t3);
			if (if_block) if_block.m(li, null);
			append(li, t4);
		},
		p(ctx, dirty) {
			if (dirty & /*$_groups*/ 64 && t0_value !== (t0_value = /*label*/ ctx[14] + "")) set_data(t0, t0_value);
			if (dirty & /*$_groups*/ 64 && t2_value !== (t2_value = /*description*/ ctx[12] + "")) set_data(t2, t2_value);

			if (/*width*/ ctx[3] || isServerSide) {
				if (if_block) {
					if_block.p(ctx, dirty);
				} else {
					if_block = create_if_block(ctx);
					if_block.c();
					if_block.m(li, t4);
				}
			} else if (if_block) {
				if_block.d(1);
				if_block = null;
			}
		},
		d(detaching) {
			if (detaching) detach(li);
			if (if_block) if_block.d();
		}
	};
}

function create_fragment(ctx) {
	let div1;
	let header;
	let t1;
	let div0;
	let ul;
	let div0_resize_listener;
	let each_value = /*$_groups*/ ctx[6];
	let each_blocks = [];

	for (let i = 0; i < each_value.length; i += 1) {
		each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
	}

	return {
		c() {
			div1 = element("div");
			header = element("header");
			header.innerHTML = `<h1>Indicators</h1>`;
			t1 = space();
			div0 = element("div");
			ul = element("ul");

			for (let i = 0; i < each_blocks.length; i += 1) {
				each_blocks[i].c();
			}

			attr(header, "class", "svelte-yz4j7q");
			attr(div0, "class", "timedist svelte-yz4j7q");
			add_render_callback(() => /*div0_elementresize_handler*/ ctx[11].call(div0));
			attr(div1, "class", "time_region_value_Index svelte-yz4j7q");
		},
		m(target, anchor) {
			insert(target, div1, anchor);
			append(div1, header);
			append(div1, t1);
			append(div1, div0);
			append(div0, ul);

			for (let i = 0; i < each_blocks.length; i += 1) {
				each_blocks[i].m(ul, null);
			}

			div0_resize_listener = add_resize_listener(div0, /*div0_elementresize_handler*/ ctx[11].bind(div0));
		},
		p(ctx, [dirty]) {
			if (dirty & /*width, gap, layout, vStep, $_groups, makeURL, $_hrefBase, $_yearRange, shortenYearFn, isServerSide*/ 508) {
				each_value = /*$_groups*/ ctx[6];
				let i;

				for (i = 0; i < each_value.length; i += 1) {
					const child_ctx = get_each_context(ctx, each_value, i);

					if (each_blocks[i]) {
						each_blocks[i].p(child_ctx, dirty);
					} else {
						each_blocks[i] = create_each_block(child_ctx);
						each_blocks[i].c();
						each_blocks[i].m(ul, null);
					}
				}

				for (; i < each_blocks.length; i += 1) {
					each_blocks[i].d(1);
				}

				each_blocks.length = each_value.length;
			}
		},
		i: noop,
		o: noop,
		d(detaching) {
			if (detaching) detach(div1);
			destroy_each(each_blocks, detaching);
			div0_resize_listener();
		}
	};
}

const gap = 7;

function instance($$self, $$props, $$invalidate) {
	let layout;
	let vStep;
	let shortenYearFn;
	let $_isSmallScreen;
	let $_timelineLayout;

	let $_groups,
		$$unsubscribe__groups = noop,
		$$subscribe__groups = () => ($$unsubscribe__groups(), $$unsubscribe__groups = subscribe(_groups, $$value => $$invalidate(6, $_groups = $$value)), _groups);

	let $_yearRange,
		$$unsubscribe__yearRange = noop,
		$$subscribe__yearRange = () => ($$unsubscribe__yearRange(), $$unsubscribe__yearRange = subscribe(_yearRange, $$value => $$invalidate(7, $_yearRange = $$value)), _yearRange);

	let $_hrefBase;
	component_subscribe($$self, _isSmallScreen, $$value => $$invalidate(9, $_isSmallScreen = $$value));
	component_subscribe($$self, _timelineLayout, $$value => $$invalidate(10, $_timelineLayout = $$value));
	component_subscribe($$self, _hrefBase, $$value => $$invalidate(8, $_hrefBase = $$value));
	$$self.$$.on_destroy.push(() => $$unsubscribe__groups());
	$$self.$$.on_destroy.push(() => $$unsubscribe__yearRange());
	let { _groups = null } = $$props;
	$$subscribe__groups();
	let { _yearRange = null } = $$props;
	$$subscribe__yearRange();

	/* init */
	onMount(() => {
		resetSelectedYear();
		setRoute('Index');
		showView('distribution');
	});

	/* local vars */
	// bound
	let width;

	function div0_elementresize_handler() {
		width = this.clientWidth;
		$$invalidate(3, width);
	}

	$$self.$$set = $$props => {
		if ('_groups' in $$props) $$subscribe__groups($$invalidate(0, _groups = $$props._groups));
		if ('_yearRange' in $$props) $$subscribe__yearRange($$invalidate(1, _yearRange = $$props._yearRange));
	};

	$$self.$$.update = () => {
		if ($$self.$$.dirty & /*$_timelineLayout*/ 1024) {
			$$invalidate(2, layout = $_timelineLayout);
		}

		if ($$self.$$.dirty & /*layout*/ 4) {
			$$invalidate(5, vStep = 2 * layout.radius + 3 * gap + layout.fontSize);
		}

		if ($$self.$$.dirty & /*$_isSmallScreen*/ 512) {
			$$invalidate(4, shortenYearFn = $_isSmallScreen ? shortenYear : identity);
		}
	};

	return [
		_groups,
		_yearRange,
		layout,
		width,
		shortenYearFn,
		vStep,
		$_groups,
		$_yearRange,
		$_hrefBase,
		$_isSmallScreen,
		$_timelineLayout,
		div0_elementresize_handler
	];
}

class Routes extends SvelteComponent {
	constructor(options) {
		super();
		init(this, options, instance, create_fragment, safe_not_equal, { _groups: 0, _yearRange: 1 }, add_css);
	}
}

return Routes;

}));
