{"version":3,"sources":["webpack:///./src/components/Printing/MatchPrint.vue?73cb","webpack:///./src/helpers/MapScoreSheet.js","webpack:///src/components/Printing/MatchPrint.vue","webpack:///./src/components/Printing/MatchPrint.vue?e7de","webpack:///./src/components/Printing/MatchPrint.vue","webpack:///./src/classes/Lineup.js"],"names":["render","_vm","this","_h","$createElement","_c","_self","attrs","fab","small","block","loading","text","xSmall","on","onClick","_v","_e","_s","staticRenderFns","getTeam","id","tournament","teams","find","d","form","division","round","match","homeTeam","awayTeam","pool","teamId","hl","lineups","f","al","homeLineup","Lineup","awayLineup","base","Teams1","TeamName1","Team1_Player1","Team1_Player2","TeamName2","Team2_Player2","Team2_Player1","title","name","team1","team2","ct","court","time","join","teamNames","push","t","isDual","dualMatchN","team1Array","pair","_hl","starters","length","playerIds","players","filter","includes","p1","p1A","firstName","lastName","jersey","p2","p2A","jeresy","team2Array","_al","isPool","pools","field","getDualDesc","number","bracket","displayNumber","getMatchTitle","val","ff","getTextField","setText","props","data","pdfUrl","computed","methods","downloadFile","link","href","URL","createObjectURL","blob","download","fileName","document","body","append","click","remove","setTimeout","printFile","component","VBtn","VIcon","dto","update","JSON","parse","exclude","DtoUpdate","positions","type","startsWith","pairs","replace","Array","keys","map","i","n","x","console","log","p","a","stringify","_type","initPostions","applyAll","flatten","m","forEach"],"mappings":"wIAAA,IAAIA,EAAS,WAAa,IAAIC,EAAIC,KAASC,EAAGF,EAAIG,eAAmBC,EAAGJ,EAAIK,MAAMD,IAAIF,EAAG,OAAOE,EAAG,QAAQ,CAACE,MAAM,CAAC,MAAQ,0BAA0B,IAAMN,EAAIO,IAAI,MAAQP,EAAIQ,MAAM,MAAQR,EAAIS,MAAM,QAAUT,EAAIU,QAAQ,KAAOV,EAAIW,KAAK,UAAUX,EAAIY,QAAQC,GAAG,CAAC,MAAQb,EAAIc,UAAU,CAAEd,EAAO,IAAEI,EAAG,SAAS,CAACJ,EAAIe,GAAG,kBAAkBf,EAAIgB,KAAKhB,EAAIe,GAAG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C,QAAQF,UAAcA,S,0BAInF,MAAO,CACL7C,GAAInB,KAAKmB,GACT6B,KAAMhD,KAAKgD,KACXyE,KAAMzH,KAAKyH,KACXD,UAAWxH,KAAKwH,UAChBzF,OAAQ/B,KAAK+B,OACb2G,SAAU1I,KAAK0I,Y,8BAKjB,OAAOC,eAAQ3I,KAAKwH,UAAUO,KAAI,SAAAa,GAAC,OAAIA,EAAE1E,c,oCAIzC,IAAI+D,EAAI,EAIR,OAHAjI,KAAKwH,UAAUrD,QAAO,SAAAjC,GAAC,MAAI,CAAC,QAAQkC,SAASlC,EAAEuF,SAAOoB,SAAQ,SAAAR,GAC5DJ,GAAoB,SAAXI,EAAEZ,KAAkB,EAAI,KAE5BQ,M","file":"js/chunk-1f1e7bdf.0113140f.js","sourcesContent":["var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('v-btn',{attrs:{\"color\":\"color3 color3Text--text\",\"fab\":_vm.fab,\"small\":_vm.small,\"block\":_vm.block,\"loading\":_vm.loading,\"text\":_vm.text,\"x-small\":_vm.xSmall},on:{\"click\":_vm.onClick}},[(_vm.fab)?_c('v-icon',[_vm._v(\"fas fa-print\")]):_vm._e(),_vm._v(\" \"+_vm._s(_vm.fab ? null : 'Print Score Sheet')+\" \")],1)}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","import Lineup from '@/classes/Lineup.js'\r\nconst getTeam = (id, tournament) => {\r\n  return id ? tournament.teams.find(d => d.id === id) : null\r\n}\r\n\r\nexport default function (form, tournament, division, round, match, homeTeam, awayTeam, pool) {\r\n  awayTeam = match.awayTeam ? getTeam(match.awayTeam.teamId, tournament) : null\r\n  homeTeam = match.homeTeam ? getTeam(match.homeTeam.teamId, tournament) : null\r\n\r\n  const hl = homeTeam && match.lineups && match.lineups.find(f => f.teamId === homeTeam.id)\r\n  const al = awayTeam && match.lineups && match.lineups.find(f => f.teamId === awayTeam.id)\r\n  const homeLineup = hl && new Lineup(hl)\r\n  const awayLineup = al && new Lineup(al)\r\n\r\n  const base = {\r\n    Teams1: null,\r\n    TeamName1: null,\r\n    Team1_Player1: null,\r\n    Team1_Player2: null,\r\n    TeamName2: null,\r\n    Team2_Player2: null,\r\n    Team2_Player1: null,\r\n    title: tournament.name,\r\n    division: division.name,\r\n    round: pool ? `Pool ${pool.name}` : round.name,\r\n    team1: null,\r\n    team2: null,\r\n    // match: null,\r\n    ct: [match.court, match.time].join('\\n')\r\n  }\r\n\r\n  const teamNames = []\r\n  if (homeTeam) {\r\n    teamNames.push(homeTeam.name)\r\n    base.TeamName1 = homeTeam.name\r\n    let t = homeTeam.name\r\n    if (match.isDual) t += ` Pair ${match.dualMatchN}`\r\n    const team1Array = [t]\r\n\r\n    let pair = null\r\n    if (match.isDual) {\r\n      if (homeLineup) {\r\n        const _hl = homeLineup.starters.length > 0 && homeLineup.starters[match.dualMatchN - 1]\r\n        if (_hl) {\r\n          const playerIds = _hl.players\r\n          pair = {\r\n            players: homeTeam.players.filter(f => playerIds.includes(f.id))\r\n          }\r\n        }\r\n      }\r\n    } else {\r\n      pair = homeTeam\r\n    }\r\n\r\n    if (pair) {\r\n      const p1 = pair.players[0]\r\n      if (p1) {\r\n        const p1A = [p1.firstName, p1.lastName]\r\n        if (p1.jersey) p1A.push(`#${p1.jersey}`)\r\n        base.Team1_Player1 = p1A.join(' ')\r\n        team1Array.push(base.Team1_Player1)\r\n      }\r\n\r\n      const p2 = pair.players[1]\r\n      if (p2) {\r\n        const p2A = [p2.firstName, p2.lastName]\r\n        if (p2.jeresy) p2A.push(`#${p2.jersey}`)\r\n        base.Team1_Player2 = p2A.join(' ')\r\n        team1Array.push(base.Team1_Player2)\r\n      }\r\n    }\r\n\r\n    base.team1 = team1Array.join('\\n')\r\n  }\r\n\r\n  if (awayTeam) {\r\n    teamNames.push(awayTeam.name)\r\n    base.TeamName2 = awayTeam.name\r\n    let t = awayTeam.name\r\n    if (match.isDual) t += ` Pair ${match.dualMatchN}`\r\n    const team2Array = [t]\r\n\r\n    let pair = null\r\n    if (match.isDual) {\r\n      if (awayLineup) {\r\n        const _al = awayLineup.starters.length > 0 && awayLineup.starters[match.dualMatchN - 1]\r\n        if (_al) {\r\n          const playerIds = _al.players\r\n          pair = {\r\n            players: awayTeam.players.filter(f => playerIds.includes(f.id))\r\n          }\r\n        }\r\n      }\r\n    } else {\r\n      pair = awayTeam\r\n    }\r\n\r\n    if (pair) {\r\n      const p1 = pair.players[0]\r\n      if (p1) {\r\n        const p1A = [p1.firstName, p1.lastName]\r\n        if (p1.jersey) p1A.push(`#${p1.jersey}`)\r\n        base.Team2_Player1 = p1A.join(' ')\r\n        team2Array.push(base.Team2_Player1)\r\n      }\r\n\r\n      const p2 = pair.players[1]\r\n      if (p2) {\r\n        const p2A = [p2.firstName, p2.lastName]\r\n        if (p2.jersey) p2A.push(`#${p2.jersey}`)\r\n        base.Team2_Player2 = p2A.join(' ')\r\n        team2Array.push(base.Team2_Player2)\r\n      }\r\n    }\r\n\r\n    base.team2 = team2Array.join('\\n')\r\n  }\r\n\r\n  if (teamNames.length === 2) {\r\n    base.Teams1 = `${teamNames[0]} vs ${teamNames[1]}`\r\n  }\r\n\r\n  const isPool = round.pools.length > 0\r\n  if (isPool) {\r\n    base.round = base.round + '\\n' + (match.getDualDesc() || `Match ${match.number}`)\r\n  } else {\r\n    if (round.bracket) {\r\n      base.round = base.round + '\\n' + (match.getDualDesc(round.bracket) || `Match ${match.displayNumber} (${round.bracket.getMatchTitle(match)})`)\r\n    }\r\n  }\r\n\r\n  for (const field in base) {\r\n    const val = base[field]\r\n    if (val) {\r\n      // console.log(val)\r\n      const ff = form.getTextField(field)\r\n      ff.setText(val)\r\n    }\r\n  }\r\n\r\n  return form\r\n}\r\n","<template>\r\n  <v-btn\r\n    color=\"color3 color3Text--text\"\r\n    :fab=\"fab\"\r\n    :small=\"small\"\r\n    :block=\"block\"\r\n    :loading=\"loading\"\r\n    :text=\"text\"\r\n    :x-small=\"xSmall\"\r\n    @click=\"onClick\"\r\n  >\r\n    <v-icon v-if=\"fab\">fas fa-print</v-icon>\r\n    {{ fab ? null : 'Print Score Sheet' }}\r\n  </v-btn>\r\n</template>\r\n\r\n<script>\r\nimport { PDFDocument } from 'pdf-lib'\r\nimport printJS from 'print-js'\r\nimport MapScoreSheet from '@/helpers/MapScoreSheet'\r\n\r\nexport default {\r\n  props: ['fab', 'tournament', 'division', 'round', 'matches', 'pool', 'block', 'text', 'xSmall', 'small', 'bracket'],\r\n  data () {\r\n    return {\r\n      pdfUrl: 'https://vblimages.blob.core.windows.net/files/0a0162c1-a7d4-46bc-bf99-673393096590.pdf',\r\n      loading: false\r\n    }\r\n  },\r\n  computed: {\r\n  },\r\n  methods: {\r\n    async onClick () {\r\n      console.log('print me')\r\n      this.loading = true\r\n      const formPdfBytes = await fetch(this.pdfUrl).then(res => res.arrayBuffer())\r\n      const pdfDoc = await PDFDocument.create()\r\n\r\n      for (const match of this.matches) {\r\n        const page1Doc = await PDFDocument.load(formPdfBytes)\r\n        const form = page1Doc.getForm()\r\n        MapScoreSheet(form, this.tournament, this.division, this.round, match, this.pool)\r\n        await page1Doc.save()\r\n        const [page1] = await pdfDoc.copyPages(page1Doc, [0])\r\n        pdfDoc.addPage(page1)\r\n      }\r\n\r\n      const pdfBytes = await pdfDoc.save()\r\n      const file = new Blob([pdfBytes], { type: 'application/pdf' })\r\n      this.loading = false\r\n      // this.downloadFile(file, 'test.pdf')\r\n      this.printFile(file)\r\n    },\r\n    downloadFile (blob, fileName) {\r\n      const link = document.createElement('a')\r\n      // create a blobURI pointing to our Blob\r\n      link.href = URL.createObjectURL(blob)\r\n      link.download = fileName\r\n      // some browser needs the anchor to be in the doc\r\n      document.body.append(link)\r\n      link.click()\r\n      link.remove()\r\n      // in case the Blob uses a lot of memory\r\n      setTimeout(() => URL.revokeObjectURL(link.href), 7000)\r\n    },\r\n    printFile (blob) {\r\n      printJS(URL.createObjectURL(blob))\r\n    }\r\n  }\r\n}\r\n</script>\r\n","import mod from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--12-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./MatchPrint.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--12-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./MatchPrint.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./MatchPrint.vue?vue&type=template&id=250d509e&\"\nimport script from \"./MatchPrint.vue?vue&type=script&lang=js&\"\nexport * from \"./MatchPrint.vue?vue&type=script&lang=js&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n  script,\n  render,\n  staticRenderFns,\n  false,\n  null,\n  null,\n  null\n  \n)\n\nexport default component.exports\n\n/* vuetify-loader */\nimport installComponents from \"!../../../node_modules/vuetify-loader/lib/runtime/installComponents.js\"\nimport { VBtn } from 'vuetify/lib/components/VBtn';\nimport { VIcon } from 'vuetify/lib/components/VIcon';\ninstallComponents(component, {VBtn,VIcon})\n","import DtoUpdate from './DtoUpdate'\r\nimport flatten from '@/helpers/ArrayFlatten'\r\n\r\nexport default class Lineup {\r\n  id = 0\r\n  name = null\r\n  _type = null\r\n  teamId = null\r\n  positions = []\r\n  applyAll = false\r\n\r\n  constructor (dto) {\r\n    if (dto) {\r\n      this.update(dto)\r\n    }\r\n  }\r\n\r\n  update (dto) {\r\n    if (typeof dto === 'string') dto = JSON.parse(dto)\r\n    const exclude = ['positions']\r\n    DtoUpdate(dto, this, exclude)\r\n\r\n    if (dto.positions) {\r\n      this.positions = dto.positions\r\n    }\r\n\r\n    // this.ensurePositions()\r\n  }\r\n\r\n  get type () {\r\n    return this._type\r\n  }\r\n\r\n  set type (val) {\r\n    this._type = (val || 'lineups-dual-1')\r\n    this.initPostions()\r\n  }\r\n\r\n  initPostions () {\r\n    if (this.type.startsWith('lineups-dual-')) {\r\n      const pairs = +this.type.replace('lineups-dual-', '')\r\n      this.positions = [...Array(pairs).keys()].map(i => {\r\n        return {\r\n          type: 'dual',\r\n          n: ++i,\r\n          players: []\r\n        }\r\n      })\r\n    }\r\n  }\r\n\r\n  ensurePositions () {\r\n    if (this.type.startsWith('lineups-dual-')) {\r\n      const pairs = +this.type.replace('lineups-dual-', '')\r\n      let i = 0\r\n      for (i = 1; i <= pairs; i++) {\r\n        const x = this.positions.find(f => f.type === 'dual' && f.n === i)\r\n        if (!x) {\r\n          console.log('missing position')\r\n          this.positions.push({\r\n            type: 'dual',\r\n            n: i,\r\n            players: []\r\n          })\r\n        }\r\n      }\r\n\r\n      for (i = 1; i <= 6; i++) {\r\n        const x = this.positions.find(f => f.type === 'alt' && f.n === i)\r\n        if (!x) {\r\n          this.positions.push({\r\n            type: 'alt',\r\n            n: i,\r\n            players: []\r\n          })\r\n        }\r\n      }\r\n\r\n      for (i = 1; i <= 6; i++) {\r\n        const x = this.positions.find(f => f.type === 'removed' && f.n === i)\r\n        if (!x) {\r\n          this.positions.push({\r\n            type: 'removed',\r\n            n: i,\r\n            players: []\r\n          })\r\n        }\r\n      }\r\n    }\r\n  }\r\n\r\n  get starters () {\r\n    return this.positions.filter(f => f.type === 'dual')\r\n  }\r\n\r\n  get alternates () {\r\n    return this.positions.filter(f => f.type === 'alt')\r\n  }\r\n\r\n  get removedPlayers () {\r\n    return this.positions.filter(f => f.type === 'removed')\r\n  }\r\n\r\n  get valid () {\r\n    return this.name && this.type && this.starters.filter(f => f.players.length !== 2).length === 0\r\n  }\r\n\r\n  get dto () {\r\n    return {\r\n      id: this.id,\r\n      name: this.name,\r\n      type: this.type,\r\n      positions: this.positions,\r\n      teamId: this.teamId,\r\n      applyAll: this.applyAll\r\n    }\r\n  }\r\n\r\n  get players () {\r\n    return flatten(this.positions.map(m => m.players))\r\n  }\r\n\r\n  get playersNeeded () {\r\n    let n = 0\r\n    this.positions.filter(f => ['dual'].includes(f.type)).forEach(p => {\r\n      n = n + (p.type === 'dual' ? 2 : 1)\r\n    })\r\n    return n\r\n  }\r\n\r\n  removePosition (p) {\r\n    const a = JSON.stringify(p)\r\n    this.positions = this.positions.filter(f => JSON.stringify(f) !== a)\r\n  }\r\n}\r\n"],"sourceRoot":""}