<script>

import VueSound from './VueSound.vue';

export default {
  props: ['data', 'type'],
  components: { VueSound, },
  computed: {
    termsDataDict: function() {
      let data = this.data.terms;
      let ret = Object({});
      for(let i = 0; i < data.length; i++) {
            if (!Array.isArray(ret[data[i].string1])) ret[data[i].string1] = []; 
            ret[data[i].string1].push(data[i]);         
      }
      return ret;
    }
  },

}
</script>

<template>

<div v-if="type == 0" class="border-b dark:border-slate-600 shadow-sm overflow-hidden my-8">
<div class="flex flex-col justify-center">
    <div class="overflow-x-auto sm:-mx-6 lg:-mx-8">
        <div class="inline-block py-2 min-w-full sm:px-6 lg:px-8">
            <div class="overflow-hidden shadow-md sm:rounded-lg flex justify-center">
                <table class="min-w-fit">
                    <thead class="bg-gray-100 dark:bg-gray-700">
                        <tr>
                            <th scope="col" class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400">
                                Výraz
                            </th>
                            <th scope="col" class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400">
                                Preklad
                            </th>
                            <th scope="col" class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400">
                                Člen
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr v-for="(t, i) in data.terms" :key="i" 
							class="border-b odd:bg-white even:bg-gray-50 odd:dark:bg-gray-800 even:dark:bg-gray-700 dark:border-gray-600">
                            <td class="py-4 px-6 text-sm font-medium text-gray-900 whitespace-nowrap dark:text-white">
                                {{ t.string1 }}
                            </td>
                            <td class="py-4 px-6 text-sm text-gray-500 whitespace-nowrap dark:text-gray-400">
                                {{ t.string2 }}
                            </td>
                            <td class="py-4 px-6 text-sm text-gray-500 whitespace-nowrap dark:text-gray-400">
                                {{ t.member }}
                            </td>
                        </tr>

                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>		
</div>

<div v-if="type == 1" class=" flex flex-col items-center justify-center mt-4">

<div class="bg-gray-100 dark:bg-gray-700 py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400 md:w-1/2 border-b dark:border-slate-600 shadow-sm overflow-hidden">
    <div class="text-lg grid place-items-center">
        Preklad
    </div>
</div>

<div class="md:w-1/2 sm:w-fit justify-center align-middle">
<div class="overflow-hidden shadow-md sm:rounded-lg  justify-center">
    <div v-for="(t, i) in termsDataDict" :key="i" class="border-b odd:bg-white even:bg-gray-50 p-2">
    <span class="text-sm font-medium text-gray-900 whitespace-nowrap dark:text-white">{{ i }} </span>
    <span v-if="t[0].pronunciations" class="mx-2">
        
        <span class="mx-1 text-sm font-bold" 
              v-bind:class="{ 'text-green-800': i == 0, 'text-blue-800': i == 1, 'text-red-800': i == 3 }" 
              v-for="(p,i) in t[0].pronunciations" :key="i">[{{ p.ipa }}] 
              <vue-sound :src="p.filename"></vue-sound>
              </span>  
    </span>
        <div class="px-10">
        <span v-for="(tt, n) in t" :key="n" class="text-sm text-gray-500  dark:text-gray-400">
            {{ tt.string2 }}<span v-if="n != t.length-1">, </span>
        </span>
        </div>
    </div>
</div> 
</div>
</div>

<div v-if="type == 2" class="border-b dark:border-slate-600 shadow-sm overflow-hidden my-8">
<div class="flex flex-col justify-center">
    <div class="overflow-x-auto sm:-mx-6 lg:-mx-8">
        <div class="inline-block py-2 min-w-full sm:px-6 lg:px-8">
            <div class="overflow-hidden shadow-md sm:rounded-lg flex justify-center">
                <table class="shadow-lg bg-white border-collapse">
                <thead class="bg-gray-100 dark:bg-gray-700">
                <tr class="bg-gray-100 dark:bg-gray-700">
                <th scope="col" class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400">písmeno</th>
                <th scope="col" class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400">PSP</th>
                <th scope="col" class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400">alt.</th>
                <th scope="col" class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400">IPA</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/B" title="B">B</a> b</td>
                <td class="border px-8 py-4">bé</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/b/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/C" title="C">C</a> c</td>
                <td class="border px-8 py-4">cé</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/t͡s/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/%C4%8C" title="Č">Č</a> č</td>
                <td class="border px-8 py-4">čé</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/t͡ʃ/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/D" title="D">D</a> d</td>
                <td class="border px-8 py-4">dé</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/d/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/%C4%8E" title="Ď">Ď</a> ď</td>
                <td class="border px-8 py-4">ďé</td>
                <td class="border px-8 py-4">mäkké dé</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/ɟ/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4">DZ dz</td>
                <td class="border px-8 py-4">dzé</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/d͡z/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4">DŽ dž</td>
                <td class="border px-8 py-4">džé</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/d͡ʒ/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/F" title="F">F</a> f</td>
                <td class="border px-8 py-4">ef</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/f/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/G" title="G">G</a> g</td>
                <td class="border px-8 py-4">gé</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/ɡ/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/H" title="H">H</a> h</td>
                <td class="border px-8 py-4">há</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/ɦ/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/CH" class="mw-disambig" title="CH">CH</a> ch</td>
                <td class="border px-8 py-4">chá</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/x/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/J" title="J">J</a> j</td>
                <td class="border px-8 py-4">jé</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/j/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/K" title="K">K</a> k</td>
                <td class="border px-8 py-4">ká</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/k/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/L" title="L">L</a> l</td>
                <td class="border px-8 py-4">el</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/l/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/%C4%B9" title="Ĺ">Ĺ</a> ĺ</td>
                <td class="border px-8 py-4">dlhé el</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/lː/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/%C4%BD" title="Ľ">Ľ</a> ľ</td>
                <td class="border px-8 py-4">eľ</td>
                <td class="border px-8 py-4">mäkké el</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/ʎ/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/M" title="M">M</a> m</td>
                <td class="border px-8 py-4">em</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/m/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/N" title="N">N</a> n</td>
                <td class="border px-8 py-4">en</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/n/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/%C5%87" title="Ň">Ň</a> ň</td>
                <td class="border px-8 py-4">eň</td>
                <td class="border px-8 py-4">mäkké en</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/ɲ/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/P" title="P">P</a> p</td>
                <td class="border px-8 py-4">pé</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/p/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/Q" title="Q">Q</a> q</td>
                <td class="border px-8 py-4">kvé</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/kv/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/R" title="R">R</a> r</td>
                <td class="border px-8 py-4">er</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/r/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/%C5%94" title="Ŕ">Ŕ</a> ŕ</td>
                <td class="border px-8 py-4">dlhé er</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/rː/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/S" title="S">S</a> s</td>
                <td class="border px-8 py-4">es</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/s/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/%C5%A0" title="Š">Š</a> š</td>
                <td class="border px-8 py-4">eš</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/ʃ/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/T" title="T">T</a> t</td>
                <td class="border px-8 py-4">té</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/t/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/%C5%A4" title="Ť">Ť</a> ť</td>
                <td class="border px-8 py-4">ťé</td>
                <td class="border px-8 py-4">mäkké té</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/c/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/V" title="V">V</a> v</td>
                <td class="border px-8 py-4">vé</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/v/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/W" title="W">W</a> w</td>
                <td class="border px-8 py-4">dvojité vé</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/v/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/X" title="X">X</a> x</td>
                <td class="border px-8 py-4">iks</td>
                <td class="border px-8 py-4">&nbsp;</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/ks/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/Z" title="Z">Z</a> z</td>
                <td class="border px-8 py-4">zé</td>
                <td class="border px-8 py-4">zet</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/z/</span></td>
                </tr>
                <tr>
                <td class="border px-8 py-4"><a href="/wiki/%C5%BD" title="Ž">Ž</a> ž</td>
                <td class="border px-8 py-4">žé</td>
                <td class="border px-8 py-4">žet</td>
                <td class="border px-8 py-4"><span title="Zápis v Medzinárodnej fonetickej abecede (IPA)" class="IPA">/ʒ/</span></td>
                </tr>
                </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
</div>
</template>