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with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var TTmobile = (function (exports) {\n  \"use strict\";\n\n  const host = \"https://api.tt-mobile.ch/\";\n  // const host = \"http://localhost:3020/\";\n\n  function renderTable(clubs, element, options) {\n    const html = `\n      <thead>${renderTableHead()}</thead>\n      <tbody>\n        ${clubs.map((row) => renderTableRow(row, options)).join(\"\")}\n      </tbody>`;\n    element.innerHTML = html;\n  }\n\n  function clubName(teamName) {\n    const parts = teamName.split(\" \");\n    if (/[IVX]+$/.test(parts[parts.length - 1])) {\n      return parts.slice(0, -1).join(\" \");\n    }\n    return parts.join(\" \");\n  }\n\n  function renderTableRow(row, options) {\n    const match = options.highlight && row.name.includes(options.highlight);\n    const logoSize = options.logoSize || \"50px\";\n    return `\n      <tr>\n        <td>${row.rank}</td>\n        <td>\n          <img class=\"tt-mobile-logo\"\n            style=\"max-width: ${logoSize}; max-height: ${logoSize}; border-radius: 5px;\"\n            src=\"${host}logo/?name=${clubName(row.name)}\" />\n        </td>\n        <td>\n          <a target=\"_blank\" href=\"https://tt-mobile.ch/team/${encodeURIComponent(\n            row.href,\n          )}\">\n            ${match ? highlight(row.name) : row.name}\n          </a>\n        </td>\n        <td>${row.nrOfGames}</td>\n        <td>${row.games}</td>\n        <td>${row.balance}</td>\n        <td>${row.score}</td>\n      </tr>`;\n  }\n\n  function highlight(name) {\n    return \"<strong>\".concat(name, \"</strong>\");\n  }\n\n  function renderTableHead() {\n    return `<tr>\n      <th></th>\n      <th></th>\n      <th>Mannschaft</th>\n      <th>Beg.</th>\n      <th>Spiele</th>\n      <th>+/-</th>\n      <th>Punkte</th>\n    </tr>`;\n  }\n\n  function renderTeam(data, element, options) {\n    const showPlayers = options.showPlayers !== false;\n    const teamHtml = showPlayers\n      ? `\n      <table class=\"tt-team-players\">\n        <tbody>\n          ${data.players.map((row) => renderTeamRow(row, options)).join(\"\")}\n        </tbody>\n      </table>`\n      : \"\";\n    const divider =\n      showPlayers && options.showSchedule ? \"<hr class='tt-team-divider'>\" : \"\";\n    const teamScheduleHtml = options.showSchedule\n      ? `\n      <table class=\"tt-team-schedule\">\n        <tbody>\n          ${data.games\n            .map((game) => renderTeamScheduleRow(game, options))\n            .join(\"\")}\n        </tbody>\n      </table>\n    `\n      : \"\";\n    element.innerHTML = teamHtml + divider + teamScheduleHtml;\n  }\n\n  function renderTeamScheduleRow(row, options) {\n    const logoSize = options.logoSize || \"50px\";\n    return `\n      <tr>\n        <td>${row.date}, ${row.time}</td>\n        <td>${row.isHome ? \"Zuhause\" : \"Auswärts\"}</td>\n        <td>\n          <img class=\"tt-mobile-logo\"\n            style=\"max-width: ${logoSize}; max-height: ${logoSize}; border-radius: 5px;\"\n            src=\"${host}logo/?name=${clubName(row.opponent)}\" />\n        </td>\n        <td>${row.opponent}</td>\n        <td>${wrapResult(row.href, row.result)}</td>\n      </tr>\n    `;\n  }\n\n  function renderTeamRow(row, options) {\n    return `\n      <tr>\n        <td>\n          <a target=\"_blank\" href=\"https://tt-mobile.ch/player/${encodeURIComponent(\n            row.href,\n          )}\">${row.name}</a>\n        </td>\n        <td>${row.classification}</td>\n        <td>${row.balance}</td>\n      </tr>`;\n  }\n\n  function renderSchedule(data, element, options) {\n    if (\n      options.variant == \"responsive\" &&\n      !(\"container\" in document.documentElement.style)\n    ) {\n      import(\"https://unpkg.com/container-query-polyfill@^0.2.0\");\n    }\n\n    const mobileStyles = `\n      .tt-time { display: none; }\n      .tt-result { display: none; }\n      .tt-game {\n        display: grid;\n        grid-template-columns: 2fr 40px 3fr 1fr;\n        grid-template-areas:\n          \"league logo-home  home  result-home\"\n          \"league logo-guest guest result-guest\";\n        grid-gap: 4px;\n        margin-bottom: 1rem;\n      }`;\n\n    const desktopStyles = `\n      .tt-time { display: block; }\n      .tt-result { width: 45px; display: block; }\n      .tt-result-home { display: none; }\n      .tt-result-guest { display: none; }\n\n      .tt-home { text-align: right; }\n      .tt-game {\n        display: grid;\n        grid-template-columns: 2fr 0.5fr 3fr 40px 0.5fr 40px 3fr;\n        grid-template-areas:\n          \"league time home logo-home result logo-guest guest\"\n      }`;\n\n    const containerQuery = `@container (min-width: ${options.breakpoint})`;\n    const responsiveStyles = `\n      ${containerQuery} {\n        ${desktopStyles}\n      }`;\n\n    const fallback = `<p>${options.fallback || \"keine Spiele gefunden\"}</p>`;\n    const lastMatches =\n      options.limitPrevious === undefined || options.limitPrevious > 0\n        ? `<p><strong>Rückschau</strong></p>\n          ${\n            data.lastMatches\n              .slice(-1 * options.limitPrevious)\n              .map((chunk) => renderScheduleChunk(chunk, options))\n              .join(\"\") || fallback\n          }`\n        : \"\";\n\n    const nextMatches =\n      options.limitNext === undefined || options.limitNext > 0\n        ? `<p><strong>Vorschau</strong></p>\n          ${\n            data.nextMatches\n              .slice(0, options.limitNext)\n              .map((chunk) => renderScheduleChunk(chunk, options))\n              .join(\"\") || fallback\n          }`\n        : \"\";\n\n    const html = `\n      <style type=\"text/css\">\n        .tt-win { font-weight: bold; }\n        .tt-logo img { height: 40px; }\n        .tt-game div { align-self: center; }\n        .tt-logo { justify-self: end }\n        .tt-result { text-align: center; }\n        .tt-date { font-weight: bold; margin-bottom: 0 }\n        .tt-result-home { text-align: right; }\n        .tt-result-guest { text-align: right; }\n\n        ${options.variant != \"desktop\" ? mobileStyles : \"\"}\n        .tt-league { grid-area: league; }\n        .tt-time { grid-area: time; }\n        .tt-home { grid-area: home; }\n        .tt-logo-home { grid-area: logo-home; }\n        .tt-result { grid-area: result; }\n        .tt-result-home { grid-area: result-home; }\n        .tt-result-guest { grid-area: result-guest; }\n        .tt-logo-guest { grid-area: logo-guest; }\n        .tt-guest { grid-area: guest; }\n\n        .tt-container { container-type: inline-size; }\n        ${options.variant == \"desktop\" ? desktopStyles : \"\"}\n        ${options.variant == \"responsive\" ? responsiveStyles : \"\"}\n      </style>\n      <div class=\"tt-container\">\n        ${lastMatches}\n        ${nextMatches}\n      </div>`;\n    element.innerHTML = html;\n  }\n\n  function table(url, element, options = {}) {\n    fetch(`${host}league?url=${encodeURIComponent(url)}`)\n      .then((response) => response.json())\n      .then((data) => {\n        renderTable(data.clubs, element, options);\n      });\n  }\n\n  function team(url, element, options = {}) {\n    fetch(`${host}team?url=${encodeURIComponent(url)}`)\n      .then((response) => response.json())\n      .then((data) => {\n        renderTeam(data, element, options);\n      });\n  }\n\n  function schedule(clubId, element, options = {}) {\n    fetch(`${host}club/${clubId}`)\n      .then((response) => response.json())\n      .then((data) => {\n        renderSchedule(data, element, options);\n      });\n  }\n\n  function renderScheduleChunk(chunk, options) {\n    const games = chunk.games.map((game) => renderScheduleRow(game, options));\n\n    // only render title if there are games\n    const title =\n      games.length && options.showDate !== false\n        ? `<p class=\"tt-date\">${chunk.date}</p>`\n        : \"\";\n\n    return `\n      ${title}\n      <div class=\"tt-schedule\">\n        ${games.join(\"\")}\n      </div>`;\n  }\n\n  function clubName(teamName) {\n    const parts = teamName.split(\" \");\n    if (/[IVX]+$/.test(parts[parts.length - 1])) {\n      return parts.slice(0, -1).join(\" \");\n    }\n    return parts.join(\" \");\n  }\n\n  function wrapResult(href, content) {\n    return `<a target=\"_blank\" href=\"https://tt-mobile.ch/game/${encodeURIComponent(\n      href,\n    )}\">${content}</a>`;\n  }\n\n  function renderScheduleRow(row, options) {\n    const scoreHome = row.result ? row.result.split(\":\")[0] : \"-\";\n    const scoreGuest = row.result ? row.result.split(\":\")[1] : \"-\";\n    const result = row.result\n      ? `<div class=\"tt-result\">\n          ${wrapResult(row.href, row.result)}\n        </div>\n        <div class=\"tt-result-home ${\n          scoreHome > scoreGuest ? \"tt-win\" : \"\"\n        }\">${wrapResult(row.href, scoreHome)}</div>\n        <div class=\"tt-result-guest ${\n          scoreHome < scoreGuest ? \"tt-win\" : \"\"\n        }\">${wrapResult(row.href, scoreGuest)}</div>`\n      : `<div class=\"tt-result\">-:-</div>\n        <div class=\"tt-result-home\">-</div>\n        <div class=\"tt-result-guest\">-</div>\n      `;\n\n    return `<div class=\"tt-game\">\n      ${\n        options.showLeague !== false\n          ? `<div class=\"tt-league\">${row.league}</div>`\n          : \"\"\n      }\n      ${\n        options.showTime !== false\n          ? `<div class=\"tt-time\">${row.time}</div>`\n          : \"\"\n      }\n      <div class=\"tt-home ${scoreHome > scoreGuest ? \"tt-win\" : \"\"}\">${\n      row.home\n    }</div>\n      ${\n        options.showLogos !== false\n          ? `<div class=\"tt-logo tt-logo-home\"><img src=\"${host}logo/?name=${clubName(\n              row.home,\n            )}\"></div>`\n          : \"\"\n      }\n      ${result}\n      ${\n        options.showLogos !== false\n          ? `<div class=\"tt-logo tt-logo-guest\"><img src=\"${host}logo/?name=${clubName(\n              row.guest,\n            )}\"></div>`\n          : \"\"\n      }\n      <div class=\"tt-guest ${scoreHome < scoreGuest ? \"tt-win\" : \"\"}\">${\n      row.guest\n    }</div>\n    </div>`;\n  }\n\n  return {\n    table,\n    team,\n    schedule,\n  };\n})({});\n"]}