1import{P as t}from"./p-B3rt3ERk.js";import{P as i}from"./p-D0wAz_bu.js";import{n as l,A as e,F as o,o as a,p as n,q as s,s as r,i as u,u as d,t as c,v as m,w as v,B as g,a as f,x as h,y as b,z as p}from"./p-BStZpeKB.js";import{d as T}from"./p-AuPLCHfl.js";import"./p-CLQce7zD.js";import{g as C}from"./p-Bq1nO_4k.js";import{g as $}from"./p-1JSYZCwG.js";import{e as w}from"./p-BdH5Dk23.js";import{s as y}from"./p-CsX23o6S.js";import{H as k}from"./p-T0dcI-Ru.js";class R{static async fromGames(t,i,a){if(!t||0===t.length)return[];let n=t.map((t=>Object.assign({},t)));const s="SHOW_RESULTS_ON_PLAYSITE";if(a)return Promise.all(n.map((async t=>{const e=t.uiConfigId?await l.getUiConfigById(t.uiConfigId):void 0;return this.fromGame(t,i,e)})));if(e.currentUser&&y.showResults)if(o.siteHasFeature(s)){const t=await o.getSiteFeatureByName(s,e.siteConfig.siteId);if(t){const i=w(t,"COMPETITION_IDS");n=n.map((t=>{var l;return 0===i.length||i.includes(null===(l=null==t?void 0:t.competition)||void 0===l?void 0:l.id)||delete t.score,t}))}}else n=n.map((t=>(delete t.score,t)));else n=n.map((t=>(delete t.score,t)));return Promise.all(n.map((async t=>{const e=t.uiConfigId?await l.getUiConfigById(t.uiConfigId):void 0;return this.fromGame(t,i,e)})))}static fromGame(l,e,o){var s,r,u,d,c;e||(e={showTitle:!0,showSubtitle:!0,showCardLowerText:!0});let m=[];(null===(s=null==l?void 0:l.competition)||void 0===s?void 0:s.playerLevel)&&m.push({text:l.competition.playerLevel.name}),(null===(r=null==l?void 0:l.tags)||void 0===r?void 0:r.includes(a.PPV))&&m.push({text:"PPV",color:"tertiary"}),0===m.length&&(m=null);let v=!1;const g=new Date,f=new Date(l.start)||new Date(l.viewerStartTime)||null;if(!l.live&&g<f&&(v=!0),l)return{title:e.showTitle?$(l):null,bgImage:(null===(u=l.image)||void 0===u?void 0:u.url)?l.image.url:(null==o?void 0:o.bgImage)?n(o.bgImage).src:null,bgColor:(null==o?void 0:o.bgColor)||null,dimmed:v,image:(null===(d=l.image)||void 0===d?void 0:d.id)&&l.image?n(l.image):null,thumbnails:this.getThumbnails(l),subTitle:e.showSubtitle?l.viewerStartTime?C(T.parseISO(l.viewerStartTime)):l.start?C(l.start):"":null,badgesTopLeft:m,badgesTopRight:l.live?[{text:"LIVE",color:"danger"}]:l.isOffline&&(null==e?void 0:e.showVenueStatus)?[{icon:"cloud-offline",color:"danger"}]:[],iconBottomRight:(null===(c=l.tags)||void 0===c?void 0:c.includes(a.PA))&&{icon:"phone-landscape-outline"},lowerCardText:this.getGameImageText(l,e.showCardLowerText),data:l,handleClick:()=>i.goTo(`game/${l.id}`),type:t.GAME}}static getThumbnails(t){var i;if(!e.siteConfig.hideThumbnailLogos||!(null===(i=t.image)||void 0===i?void 0:i.url))return(null==t?void 0:t.teams)?t.teams.map((t=>s(t))):[s(t.homeTeam),s(t.awayTeam)]}static getGameImageText(t,i){return t.score?`${t.score.home} - ${t.score.away} `:!t.live&&t.viewerStartTime&&T.isFuture(T.parseISO(t.viewerStartTime))?C(T.parseISO(t.viewerStartTime)):!t.live&&T.isFuture(t.start)||!t.live&&i?C(t.start):null}static shiftPrefKickbacksToTopOfList(t){if(t){const i=null==t?void 0:t.filter((t=>!0===t.data.prefKickback)),l=null==t?void 0:t.filter((t=>!t.data.prefKickback));t=[...i,...l]}return t}static fromGroups(t){return Promise.all(null==t?void 0:t.map((async t=>{switch(null==t.type&&(t.type=r.CLUB),t.type){case r.TEAM:return this.fromTeam(t);case r.CLUB:return this.fromGroup(t);case r.DISTRICT:case r.NATIONAL:return this.fromDistrict(t)}})))}static fromKickbackGroups(t){return Promise.all(t.map((async t=>this.fromKickbackGroup(t))))}static fromKickbackGroup(t){return{title:(null==t?void 0:t.longName)?t.longName:null==t?void 0:t.name,image:s(t),data:t,handleClick:()=>i.goTo(`club/${t.slug}`)}}static fromGroup(t){return{title:null==t?void 0:t.name,image:s(t),data:t,handleClick:()=>i.goTo(`club/${t.slug}`)}}static async fromTeam(t){return{title:t.name,image:await s(t),lowerCardText:{text:t.subCategory,style:"large"},data:t,handleClick:()=>i.goTo(`club/${t.slug}/${t.subCategory}`)}}static async fromFavorite(t,l){return{title:t.name,image:d(t),data:t,badgesTopLeft:[{text:u(`USER_FAVORITE.${t.type}`).toUpperCase()}],handleClick:()=>i.goTo(l)}}static async fromPlayer(t,l){return{title:`${t.firstName} ${t.lastName}`,image:d(t),data:t,badgesTopLeft:[{text:u(`USER_FAVORITE.${t.type}`).toUpperCase()}],handleClick:()=>i.goTo(l)}}static async fromDistrict(t){return{title:t.name,image:await s(t),bgImage:"/assets/images/default-poster.svg",data:t,handleClick:()=>i.goTo(`${t.slug}/games`)}}static async fromSubCategories(t,l){return Promise.all(l.map((async l=>({imageText:{text:l,style:"large"},image:await s(t),handleClick:()=>i.goTo(`club/${t.slug}/${l}`)}))))}static fromSiteItems(t,i){return Promise.all(t.map((t=>this.fromSiteItem(t,i))))}static async fromSiteItem(t,l){let e=await c(t,!0);return e=(null==e?void 0:e.src)?e:l,{title:t.name,image:t.bgImageUrl?n(t.image):e,bgImage:await m(t),data:t,handleClick:()=>i.goTo(`content/${t.slug}`)}}static async fromCompetitions(t){return t&&0!==t.length?Promise.all(t.map((async t=>{const i=t.uiConfigId?await l.getUiConfigById(t.uiConfigId):void 0;return this.fromCompetition(t,null,i)}))):[]}static async fromCompetition(l,e,o){return{title:l.name,data:l,type:t.COMPETITION,image:n(l.image),bgImage:(null==o?void 0:o.bgImage)&&n(o.bgImage).src,bgColor:(null==o?void 0:o.bgColor)||null,badgesTopLeft:[{text:u("USER_FAVORITE.COMPETITION").toUpperCase()}],handleClick:()=>i.goTo(e||`competition/${l.id}`)}}static fromContentItems(t,i){return Promise.all(t.map((t=>{if(t)return this.fromContentItem(t,i)})))}static async fromContentItem(t,l){var e,o;if((null===(e=t.target)||void 0===e?void 0:e.type)!==v.GAME){let{image:e,backgroundImage:o}=h(t,null==l?void 0:l.useLargeImage);return{title:t.title,bgImage:o||null,image:e||null,subTitle:t.text,isNotClickable:t.target.type===v.TEXT_ONLY||t.target.type===v.IMAGE_ONLY,data:t,handleClick:()=>{t.target.type===v.SITE_ITEM?i.goTo(`content/${t.target.targetId}`):t.target.type===v.GAME?i.goTo(`${(null==l?void 0:l.useBroadcast)?"broadcast":"game"}/${t.target.targetId}`):t.target.type===v.CLUB?i.goTo(`club/${t.target.targetId}`):t.target.type===v.COMPETITION?i.goTo(`competition/${t.target.targetId}`):t.target.type===v.EXTERNAL_LINK&&(window.location.href=t.target.targetId)}}}try{const i=await g.getBroadcastById(null===(o=t.target)||void 0===o?void 0:o.targetId);if(i)return this.fromGame(i)}catch(t){const i=t.error.message?u("ERROR_CODES.TECHNICAL_ERROR")+": "+t.error.message:u("ERROR_CODES.TECHNICAL_ERROR");f.presentErrorToast({message:i,duration:3e3})}}static fromUserFavorites(t=[]){return Promise.all(null==t?void 0:t.map((t=>this.fromUserFavorite(t))))}static async fromUserFavorite(t){switch(t.type){case b.CLUB:const i=await this.fromFavorite(t,`club/${t.slug}`);return i.badgesTopLeft=[{text:u("START_PAGE.CLUB").toUpperCase()}],i;case b.TEAM:const l=await this.fromFavorite(t,`club/${t.slug}/${t.playerLevelName}`);return l.badgesTopLeft=t.playerLevelName?[{text:t.playerLevelName}]:l.badgesTopLeft,l;case b.PERSON:return this.fromPlayer(t,`player-detail/${t.personId}`);case b.SITE_ITEM:return this.fromSiteItem(t);case b.COMPETITION:return this.fromCompetition(t,`competition/${t.competitionId}`);default:console.error("TYPE: "+t.type+" is not handled")}}static fromVenues(t){return t.map((t=>this.fromVenue(t)))}static fromVenue([t,i]){return{title:t,subTitle:i,isNotClickable:!0}}static fromVideoClips(t){return Promise.all(null==t?void 0:t.map((t=>this.fromVideoClip(t))))}static async fromVideoClip(t){var i,l;
1return{title:$(t.broadcast),image:(null===(i=t.broadcast)||void 0===i?void 0:i.image)?n(t.broadcast.image):void 0,thumbnails:t.broadcast.homeTeam||t.broadcast.awayTeam?[s(t.broadcast.homeTeam),s(t.broadcast.awayTeam)]:null===(l=t.broadcast.teams)||void 0===l?void 0:l.map((t=>s(t))),subTitle:p.isMobile()?t.header.substring(0,23):t.header,iconBottomRight:{icon:p.isMobile()?"":"bookmark-outline"},data:t}}static fromMatchEvent(t,i){var l,e,o,a,r,u,d,c,m,v,g,f,h;return{title:$(t.broadcast)||"",image:(null===(l=t.broadcast)||void 0===l?void 0:l.image)?n(t.broadcast.image):void 0,thumbnails:(null===(e=t.broadcast)||void 0===e?void 0:e.homeTeam)||(null===(o=t.broadcast)||void 0===o?void 0:o.awayTeam)?[s(null===(a=t.broadcast)||void 0===a?void 0:a.homeTeam),s(null===(r=t.broadcast)||void 0===r?void 0:r.awayTeam)]:null===(d=null===(u=t.broadcast)||void 0===u?void 0:u.teams)||void 0===d?void 0:d.map((t=>s(t))),subTitle:(null===(c=null==t?void 0:t.actionPlayer)||void 0===c?void 0:c.firstName)&&(null===(m=null==t?void 0:t.actionPlayer)||void 0===m?void 0:m.lastName)?p.isMobile()?`${t.actionPlayer.firstName} ${t.actionPlayer.lastName}`.substring(0,26):`${t.actionPlayer.firstName} ${t.actionPlayer.lastName}`:"",secondSubTitle:(null==t?void 0:t.assistingPlayers)&&(p.isMobile()?`${null===(v=t.assistingPlayers)||void 0===v?void 0:v.map((t=>(null==t?void 0:t.firstName)&&" "+(null==t?void 0:t.firstName)+" "+(null==t?void 0:t.lastName)))}`.substring(0,26):`${null===(g=t.assistingPlayers)||void 0===g?void 0:g.map((t=>(null==t?void 0:t.firstName)&&" "+(null==t?void 0:t.firstName)+" "+(null==t?void 0:t.lastName)))}`),badgesTopLeft:t.homeGoals&&t.awayGoals?[{text:`${t.homeGoals} - ${t.awayGoals}`}]:[],badgesTopRight:[{text:p.isMobile()?"":`${(null==t?void 0:t.period)?"P"+(null==t?void 0:t.period)+" ":""}${(null==t?void 0:t.minutes)||(null==t?void 0:t.seconds)?`${(null==t?void 0:t.minutes)?1===(null===(f=null==t?void 0:t.minutes)||void 0===f?void 0:f.toString().length)?`0${null==t?void 0:t.minutes}:`:`${null==t?void 0:t.minutes}:`:"00:"}${1===(null===(h=null==t?void 0:t.seconds)||void 0===h?void 0:h.toString().length)?`0${null==t?void 0:t.seconds}`:null==t?void 0:t.seconds}`:""}`}],handleClick:i,data:t}}static fromHighlight(i,l){if(!i.matchEvent)return{title:k.getTeamsString(i),image:n(i.image),type:t.HIGHLIGHT,data:{homeTeam:i.homeTeam,awayTeam:i.awayTeam},thumbnails:(i.homeTeam||i.awayTeam)&&[s(null==i?void 0:i.homeTeam),s(null==i?void 0:i.awayTeam)],handleClick:l};i.matchEvent.broadcast={image:i.image};const e=this.fromMatchEvent(i.matchEvent,l);return Object.assign(Object.assign({},e),{title:e.subTitle||k.getTeamsString(i),subTitle:null,image:n(i.image),thumbnails:(i.homeTeam||i.awayTeam)&&[s(null==i?void 0:i.homeTeam),s(null==i?void 0:i.awayTeam)],thirdSubTitle:i.homeTeam&&i.awayTeam?i.homeTeam.name+" - "+i.awayTeam.name:"",data:Object.assign(Object.assign({},e.data),{timeStamp:i.timestamp})})}}export{R as C}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.