<script lang="ts">
  export let toc: string;
  export let full: boolean = false;

  import { tocs as map } from '$lib/stores/tocMap';

  let text: string;

  $: {
    if (full) {
      text = map.get(toc.toLowerCase()) || toc;
    } else {
      text = toc;
    }
  }
</script>

<span class={toc.toLocaleLowerCase()}>{text}</span>

<style>
  span {
    padding: 4px;
    border-radius: 5px;
    border-style: solid;
    border-width: 1px;
    background-color: white;
    color: black;
  }
  .gw {
    /* GWR */
    background-color: #07352d;
    color: white;
    border-color: #041d18;
  }
  .sw,
  .il {
    /* SWR & Island Line */
    background-color: rgb(17, 23, 23);
    color: white;
  }
  .nt {
    /* Northern */
    background-color: rgb(38, 34, 98);
    color: white;
  }
  .aw {
    /* TfW */
    background-color: red;
    color: white;
  }
  .cc {
    /* c2c */
    background-color: rgb(168, 25, 127);
    color: white;
  }
  .cs {
    /* Caledonian Sleeper */
    background-color: #033c3c;
    color: white;
  }
  .ch {
    /* Chiltern Railways */
    background-color: white;
    color: blue;
  }
  .xc {
    /* CrossCountry */
    background-color: rgb(76, 18, 58);
    color: white;
  }
  .em {
    /* EMR */
    background-color: rgb(69, 29, 69);
    color: white;
  }
  .es {
    /* Eurostar */
    background-color: rgb(13, 13, 98);
    color: yellow;
  }
  .zz {
    /* Freight, Charters, etc */
    background-color: rgba(255, 255, 255, 0);
    color: white;
  }
  .ht {
    /* Hull Trains */
    background-color: rgb(160, 0, 136);
    color: rgb(19, 19, 173);
  }
  .gn {
    /* GTR Great Northern */
    background-color: rgb(79, 0, 128);
    color: white;
  }
  .tl {
    /* GTR Thameslink */
    background-color: rgb(191, 25, 183);
    color: white;
  }
  .gc {
    /* Grand Central */
    background-color: rgb(40, 40, 40);
    color: rgb(219, 123, 5);
  }
  .le,
  .ga {
    /*Greater Anglia */
    background-color: rgb(122, 124, 154);
    color: rgb(151, 0, 0);
    border-color: red;
  }
  .hx {
    /* Heathrow Express */
    background-color: rgb(181, 142, 211);
    color: black;
  }
  .ls {
    /* Locomotive Services Limited */
    background-color: white;
    color: black;
  }
  .lm {
    /* West Midlands Railway */
    background-color: rgb(120, 120, 120);
    border-color: rgb(230, 150, 0);
    color: white;
  }
  .lo {
    /*London Overground */
    background-color: rgb(231, 150, 0);
    color: rgb(0, 0, 210);
  }
  .lt {
    /* London Underground (when on Network Rail Metals) */
    background-color: rgb(203, 17, 17);
    color: rgb(0, 0, 210);
  }
  .me {
    /* Merseyrail */
    background-color: rgb(229, 229, 16);
    color: rgb(96, 96, 96);
  }
  .lr {
    /* NR On-Track Machines */
    background-color: yellow;
    color: black;
  }
  .tw {
    /* Tyne & Wear Metro (when on Network Rail Metals) */
    background-color: rgb(212, 169, 0);
    color: black;
  }
  .sr {
    /* ScotRail */
    background-color: rgb(16, 16, 200);
    color: white;
  }
  .sj {
    /* South Yorkshire (Sheffield) SuperTram (When on network rail metals) */
    background-color: rgb(255, 185, 56);
    color: rgb(58, 58, 255);
  }
  .se {
    /* Southeastern */
    background-color: darkblue;
    color: rgb(107, 152, 207);
  }
  .sn {
    /* GTR (Southern) */
    background-color: rgb(11, 74, 11);
    color: rgb(231, 231, 188);
  }
  .xr {
    /* Elizabeth Line (EastWest CrossRail) */
    background-color: rgb(91, 0, 171);
    color: rgb(207, 207, 255);
  }
  .tp {
    /* TransPennine Express */
    background-color: rgb(197, 130, 238);
    color: rgb(0, 98, 226);
  }
  .vt {
    /* Avanti West Coast */
    background-color: rgb(37, 37, 86);
    color: rgb(230, 96, 0);
  }
  .gr {
    /* LNER */
    background-color: rgb(202, 0, 0);
    color: white;
  }
  .wc {
    /* West Coast Railway (Spot Hire/Charter) */
    background-color: maroon;
    color: rgb(225, 190, 92);
  }
  .ty {
    /* Vintage Trains (Tour Operator) */
    background-color: green;
    color: white;
  }
  .ld {
    /* Lumo */
    background-color: whitesmoke;
    color: blue;
  }
  .so {
    /* Rail Adventure */
    background-color: rgb(93, 93, 93);
    color: rgb(93, 195, 93);
  }
  .ln {
    /* Grand Union Trains */
    background-color: rgb(89, 89, 89);
    color: white;
  }
  .uk {
    background-color: whitesmoke;
    color: black;
  }
</style>
