{"version":3,"file":"user-ratings.helper.cjs","names":["parseIdFromUrl","parseFilmType","parseColor","parseDate"],"sources":["../../src/helpers/user-ratings.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { parseColor, parseDate, parseFilmType, parseIdFromUrl } from './global.helper';\n\nexport const getUserRatingId = (el: HTMLElement): number => {\n  const url = el.querySelector('td.name .film-title-name').attributes.href;\n  return parseIdFromUrl(url);\n};\n\nexport const getUserRating = (el: HTMLElement): CSFDStars => {\n  const ratingText = el.querySelector('td.star-rating-only .stars').classNames.split(' ').pop();\n\n  const rating = ratingText.includes('stars-') ? +ratingText.split('-').pop() : 0;\n  return rating as CSFDStars;\n};\n\nexport const getUserRatingType = (el: HTMLElement): CSFDFilmTypes => {\n  const typeNode = el.querySelector('td.name .film-title-info .info ~ .info');\n  return parseFilmType(typeNode ? typeNode.text : 'film');\n};\n\nexport const getUserRatingTitle = (el: HTMLElement): string => {\n  return el.querySelector('td.name .film-title-name').text;\n};\n\nexport const getUserRatingYear = (el: HTMLElement): number | null => {\n  const yearNode = el.querySelector('td.name .film-title-info .info');\n  return yearNode ? +yearNode.text || null : null;\n};\n\nexport const getUserRatingColorRating = (el: HTMLElement): CSFDColorRating => {\n  const color = parseColor(\n    el.querySelector('td.name .icon').classNames.split(' ').pop() as CSFDColors\n  );\n  return color;\n};\n\nexport const getUserRatingDate = (el: HTMLElement): string => {\n  const date = el.querySelector('td.date-only').text.trim();\n  return parseDate(date);\n};\n\nexport const getUserRatingUrl = (el: HTMLElement): string => {\n  const url = el.querySelector('td.name .film-title-name').attributes.href;\n  return `https://www.csfd.cz${url}`;\n};\n"],"mappings":";;AAKA,MAAa,mBAAmB,OAA4B;CAC1D,MAAM,MAAM,GAAG,cAAc,0BAA0B,CAAC,CAAC,WAAW;CACpE,OAAOA,sBAAAA,eAAe,GAAG;AAC3B;AAEA,MAAa,iBAAiB,OAA+B;CAC3D,MAAM,aAAa,GAAG,cAAc,4BAA4B,CAAC,CAAC,WAAW,MAAM,GAAG,CAAC,CAAC,IAAI;CAG5F,OADe,WAAW,SAAS,QAAQ,IAAI,CAAC,WAAW,MAAM,GAAG,CAAC,CAAC,IAAI,IAAI;AAEhF;AAEA,MAAa,qBAAqB,OAAmC;CACnE,MAAM,WAAW,GAAG,cAAc,wCAAwC;CAC1E,OAAOC,sBAAAA,cAAc,WAAW,SAAS,OAAO,MAAM;AACxD;AAEA,MAAa,sBAAsB,OAA4B;CAC7D,OAAO,GAAG,cAAc,0BAA0B,CAAC,CAAC;AACtD;AAEA,MAAa,qBAAqB,OAAmC;CACnE,MAAM,WAAW,GAAG,cAAc,gCAAgC;CAClE,OAAO,WAAW,CAAC,SAAS,QAAQ,OAAO;AAC7C;AAEA,MAAa,4BAA4B,OAAqC;CAI5E,OAHcC,sBAAAA,WACZ,GAAG,cAAc,eAAe,CAAC,CAAC,WAAW,MAAM,GAAG,CAAC,CAAC,IAAI,CAEnD;AACb;AAEA,MAAa,qBAAqB,OAA4B;CAE5D,OAAOC,sBAAAA,UADM,GAAG,cAAc,cAAc,CAAC,CAAC,KAAK,KAC/B,CAAC;AACvB;AAEA,MAAa,oBAAoB,OAA4B;CAE3D,OAAO,sBADK,GAAG,cAAc,0BAA0B,CAAC,CAAC,WAAW;AAEtE"}