import{au as N,M as P,u as O,aE as _,r as h,cV as L,bU as B,F as $,j as e,L as T,aR as A,aF as F,da as w,s as j,q as D,i as k,aY as q,ap as x,ba as z,hJ as V,b0 as H,b1 as U,ab as W,aO as Y,af as J,am as X,ao as Q,an as Z,aW as M,aX as y,C as I,fu as d}from"./index-CXyQ5sGC.js";import{s as ee}from"./lodash-CQGrF3PQ.js";import{S as se}from"./SportCompetition-rYdwnsGr.js";import{u as te}from"./useSportDataByGameIds-heAml6nv.js";import{C as ae}from"./CompetitionDetailsGame-dyyklMsG.js";import"./VerticationNavigationListGroupItem-BMKOjpXg.js";/* empty css */const oe=()=>{const o=N(),{language:t}=P(),a=O(),{favorite_casino_games:u,toggleFavoriteCasinoGame:l,removeResourceFavorites:g}=_(),m=u.configs,[v,p]=h.useState({loading:!0,games:[]}),{openGameDetails:n}=L();h.useEffect(()=>{const s=Object.keys(m);s.length?B.loadGames({language:t,gameExternalIds:s}).then(c=>{if(o.current){const{games:i}=c;p({loading:!1,games:i}),s.length>i.length&&s.filter(f=>!i.find($("extearnal_game_id",f))).forEach(f=>l(f,m[f].categoryId))}}).catch(c=>{o.current&&(c==="noSuchGame"&&s.forEach(i=>l(i,m[i].categoryId)),p({loading:!1,games:[]}))}):p({loading:!1,games:[]})},[m,o,t,l]);const{loading:S,games:r}=v;return S?e.jsx(T,{}):r.length?e.jsxs("div",{children:[e.jsx(A,{onRemove:()=>g(F.CasinoGames)}),e.jsx("div",{className:"casino-category-games",children:r.map((s,c)=>e.jsx(w,{game:s,lazyLoadImage:c>10,onGameSelect:()=>j.dispatchEvent("hideAll"),onInfoClick:()=>{j.dispatchEvent("hideAll"),n({game:s,categoryId:m[s.extearnal_game_id].categoryId})}},s.id))})]}):e.jsx("p",{className:"empty-b-text-v-bc",children:a("no_favorite_casino_games_description")})};function ne(o){return{source:"betting",what:{sport:["alias"],region:["alias"],competition:["id","order","name"],game:["is_live"]},where:{competition:{id:{"@in":o}}}}}const ie=()=>{const o=N(),{sportCompetitions:t,toggleFavoriteCompetition:a,removeResourceFavorites:u}=_(),[l,g]=h.useState({loading:t.length>0,competitions:[]}),m=D(),v=O();h.useEffect(()=>{if(t.length){const r=i=>{if(o.current){const f=[];for(const C of Object.values(i.sport))for(const R of Object.values(C.region))for(const b of Object.values(R.competition)){const G={order:b.order,id:b.id,name:b.name,sportAlias:C.alias,regionAlias:R.alias,liveGamesCount:0,prematchGamesCount:0};for(const K of Object.values(b.game))K.is_live?G.liveGamesCount++:G.prematchGamesCount++;f.push(G)}g({loading:!1,competitions:ee(f,"order")})}},s=ne(t),c=k.subscribe(s,r);return()=>{k.unsubscribe(c)}}else g({loading:!1,competitions:[]})},[o,t]);const{competitions:p,loading:n}=l;h.useEffect(function(){!n&&p.length{p.some(c=>c.id===s)||a(s)})},[p,n,t,a]);const S=h.useCallback((r,s,c,i,f)=>()=>{j.dispatchEvent("hideAll"),m.push(`/sports/${i}/${q.EventView}/${c}/${s}/${i===x.Prematch&&f?`${r}/${z(f)}`:""}`)},[m]);return n?e.jsx(T,{}):p.length?e.jsxs(e.Fragment,{children:[e.jsx(A,{onRemove:()=>u(F.SportCompetition)}),p.map(({id:r,prematchGamesCount:s,liveGamesCount:c,name:i,regionAlias:f,sportAlias:C})=>e.jsx(se,{id:r,name:i,gamesCount:s,liveGamesCount:c,showArrowIcon:!1,sportAlias:C,onCompetitionClick:S(r,f,C,s?x.Prematch:x.Live,i),onLiveGamesCountClick:S(r,f,C,x.Live)},r))]}):e.jsx("p",{className:"empty-b-text-v-bc",children:v(V)})},E={display_key:H.Winner,display_sub_key:U.Match},re=1,ce=()=>{const{sportGames:o,removeResourceFavorites:t}=_(),{getCompetitionName:a}=W(),{data:u,isLoading:l}=te({gameIds:o,marketFilter:E,getOnlyGameData:!0,sortGamesBy:Y}),g=O(),m=D();if(l)return e.jsx(T,{});if(u.length===0)return e.jsx("p",{className:"empty-b-text-v-bc",children:g("no_favorite_sport_games_description")});const v=J(u,E.display_key),p=(n,S,r,s,c,i)=>{j.dispatchEvent("hideAll"),m.push(X({competitionId:r,gameId:s,isLive:c,regionAlias:S,sportAlias:n,esportsAvailable:Q.getInstance().esportsAvailable,competitionName:a(r),gameName:Z(i)}))};return e.jsxs(e.Fragment,{children:[e.jsx(A,{onRemove:()=>t(F.SportGames)}),u.map(n=>e.jsx(ae,{selectedMarketFilterOption:E.display_key,eventTypes:v,isDynamicPartLoading:!1,onGameSelect:()=>p(n.sport_alias,n.region_alias,n._parent_id,n.id,n.is_live,n.teams_info),game:n,onSwipedAnimationThreshold:re},n.id))]})},le=h.memo(ce),me=({gamesCount:o,competitionsCount:t})=>{const[a,u]=h.useState(o>0||!t?1:0),l=O();return e.jsxs(e.Fragment,{children:[e.jsxs(M,{secondaryStyle:!0,children:[e.jsxs(y,{isActive:a===0,onClick:()=>u(0),children:[e.jsx("span",{children:l("Competition")}),e.jsxs("span",{children:["(",t,")"]})]}),e.jsxs(y,{isActive:a===1,onClick:()=>u(1),children:[e.jsx("span",{children:l("Match")}),e.jsxs("span",{children:["(",o,")"]})]})]}),a===0&&e.jsx(ie,{}),a===1&&e.jsx(le,{})]})},pe=({show:o})=>{const[t,a]=h.useState(),u=O(),{personalizationDataCount:{sportFavoriteGames:l,casinoFavoriteGames:g,sportFavoriteCompetition:m}}=_(),{productType:v}=P(),p=I.sportsbook.enabled&&I.casino.enabled;return h.useEffect(function(){if(o){const S=l+m;switch(!0){case!p:a(I.sportsbook.enabled?d.SPORTSBOOK:d.CASINO);break;case(v===d.CASINO&&g>0):a(d.CASINO);break;case(v===d.SPORTSBOOK&&S>0):a(d.SPORTSBOOK);break;case g>0:a(d.CASINO);break;case S>0:a(d.SPORTSBOOK);break;default:a(v)}}},[o]),o?e.jsxs("div",{className:"smart-panel-tabs-bc",children:[p&&e.jsxs(M,{secondaryStyle:!0,children:[e.jsxs(y,{isActive:t===d.SPORTSBOOK,onClick:()=>a(d.SPORTSBOOK),children:[e.jsx("span",{children:u("Sport")}),e.jsxs("span",{children:["(",l+m,")"]})]}),e.jsxs(y,{isActive:t===d.CASINO,onClick:()=>a(d.CASINO),children:[e.jsx("span",{children:u("Casino")}),e.jsxs("span",{children:["(",g,")"]})]})]}),e.jsxs("div",{className:"sp-fav-body-bc",children:[t===d.SPORTSBOOK&&e.jsx(me,{competitionsCount:m,gamesCount:l}),t===d.CASINO&&e.jsx(oe,{})]})]}):null},Ce=h.memo(pe);export{Ce as default};