1import{j as s}from"./vendor-ui-DmxUTIY7.js";import{l as P,b as le}from"./vendor-utils-BvE5qV1I.js";import{r as p,d as ee,L as se}from"./vendor-react-BDhT9ybw.js";import{A as ae,o as K,B as ce,j as oe,k as Q,q as ie}from"./index-BFdn852Z.js";import{g as X,s as de}from"./indexedDB-CPQKKXcx.js";const V=({data:j,type:h,sportsType:M,sportsId:B,handelAddMultiMarket:C,setLoading:T,parlyTab:F})=>{let{user:b,profileData:z,scoreAll:x,setParly:Y}=p.useContext(ae);const R=ee(),w=p.useRef({}),A=p.useMemo(()=>{const e={};return x&&Array.isArray(x)&&x.forEach(c=>{const f=String((c==null?void 0:c.eventId)??"");f&&(e[f]=c)}),e},[x]),m=p.useMemo(()=>j.filter(e=>e.eventType==B).map(e=>{var L;const c=String((e==null?void 0:e.eventId)??""),f=A[c];let k=(f==null?void 0:f.current_score)??(f==null?void 0:f.score)??(e==null?void 0:e.score);k&&((e==null?void 0:e.gameType)==="cricket"||(f==null?void 0:f.sportName)==="Cricket")&&(k=((L=String(k).split(" || ")[0])==null?void 0:L.trim())??k);const S=k==0||k===""?"":k??"",O=(f==null?void 0:f.timeElapsed)??(e==null?void 0:e.timeElapsed)??"";(S||O)&&(w.current[c]={score:S,timeElapsed:O});const I=w.current[c],N=(e==null?void 0:e.eventName)??"",_=N.split(/\s+v\s+/i),G=(_[0]??"").trim(),$=(_[1]??"").trim();return{...e,displayScore:S||(I==null?void 0:I.score)||"",displayTimeElapsed:O||(I==null?void 0:I.timeElapsed)||"",eventNameFirst:G,eventNameSecond:$,eventNameFallback:_.length<2?N:null}}),[j,B,A]);return s.jsx("div",{className:"wrap-highlight_list",id:"inPlayData",children:s.jsxs("div",{id:"inPlayEventType_4",style:{display:"block",position:"relative"},children:[M=="Cricket"&&s.jsxs("div",{style:{display:"flex",alignItems:"center",marginRight:"unset",padding:"unset",marginLeft:".2rem",position:"absolute",top:".3rem"},className:"parlay-checkbox d-flex",children:[s.jsx("input",{type:"checkbox",checked:F,onChange:()=>{P.isEmpty(b)?R("/login"):Y(!F)},className:"parly-check"}),s.jsx("span",{style:{fontSize:"14px",fontWeight:600,color:F?"#ffc800":""},children:"Parlay"})]}),s.jsx("h3",{className:"inppayTitle",children:M}),s.jsx("ul",{className:"highlight-list",id:"inPlayList_4",children:m.map(e=>{let c=K.diffToDuration(e==null?void 0:e.eventDateTime,new Date);return s.jsxs("li",{id:"inPlayEvent_-10362833",className:`inplay-on ${h=="inplay"?"inplay-dot-true":"inplay-dot-false"}`,children:[s.jsxs(se,{id:"info",state:e,to:`/match-details/${e.eventId}/${e.marketId}`,children:[(e==null?void 0:e.gameType)==="cricket"&&s.jsx("span",{className:"inplay_event"}),(e==null?void 0:e.gameType)==="soccer"&&s.jsx("span",{className:"inplay_event"}),(e==null?void 0:e.gameType)==="tennis"&&s.jsx("span",{className:"inplay_event"}),s.jsxs("dl",{children:[s.jsxs("dt",{children:[(e==null?void 0:e.channel)!=="false"&&s.jsx("span",{id:"streamingIcon",className:"game-live",style:{display:"flex"},children:"game-live"}),(e==null?void 0:e.bookMaker)==="on"&&s.jsxs("span",{id:"bookMakerIcon",className:"game-bookmaker in-play",style:{display:"flex"},children:[s.jsx("pre",{children:"in-play"})," BookMaker"]}),(e==null?void 0:e.fancy)==="on"&&s.jsxs("span",{id:"fancyBetIcon",className:"game-fancy in-play",style:{display:"flex"},children:[s.jsx("pre",{children:"in-play"})," Fancy"]}),(e==null?void 0:e.premiumFancy)==="on"&&s.jsx("span",{id:"feedingSiteIcon",className:"game-sportsbook",style:{display:"flex"},children:"Sportsbook"}),c.days==0&&c.hours==0&&(c==null?void 0:c.years)==0&&(c==null?void 0:c.months)==0&&c.minutes>0&&(c==null?void 0:c.minutes)<(z==null?void 0:z.beforeInPlay)?s.jsxs("span",{id:"dateTimeInfo",className:"time",children:["Starting in ",c==null?void 0:c.minutes,"'"]}):e.status=="in_play"?(e==null?void 0:e.gameType)==="soccer"?s.jsxs("span",{id:"dateTimeInfo",className:"time",children:["In-Play ",e.displayTimeElapsed||""]}):s.jsx("span",{id:"dateTimeInfo",className:"time",children:"In-Play"}):s.jsx("span",{id:"dateTimeInfo",className:"time",children:K.matchDateTime(e.eventDateTime)}),(e==null?void 0:e.gameType)==="cricket"&&e.eventNameFirst.toLowerCase().includes("srl")?s.jsxs("span",{id:"sportsBookEIcon_4",className:"game-E",children:[s.jsx("i",{}),"Cricket"]}):(e==null?void 0:e.gameType)==="soccer"&&e.eventNameFirst.toLowerCase().includes("srl")?s.jsxs("span",{id:"sportsBookEIcon_1",className:"game-E",children:[s.jsx("i",{}),"Soccer"]}):(e==null?void 0:e.gameType)==="tennis"&&e.eventNameFirst.toLowerCase().includes("srl")?s.jsxs("span",{id:"sportsBookEIcon_2",className:"game-E",children:[s.jsx("i",{}),"Tennis"]}):""]}),s.jsx("dd",{id:"eventName",children:e.displayScore?s.jsxs(s.Fragment,{children:[e.eventNameFirst,s.jsxs("span",{style:{color:"#2789ce",fontWeight:"700"},children:[" ",e.displayScore," "]}),e.eventNameSecond]}):e.eventNameFallback!=null?e.eventNameFallback:s.jsxs(s.Fragment,{children:[e.eventNameFirst,s.jsx("span",{style:{color:"#2789ce",fontWeight:"700"},children:" v "}),e.eventNameSecond]})})]})]}),s.jsx("a",{id:"multiMarketPin",onClick:()=>{P.isEmpty(b)?R("/login"):(C(e.eventId),T(!0))},className:e.multi_market>0?"pin-on":"pin-off",href:"javascript:void(0)",children:" "})]},(e==null?void 0:e.eventId)??(e==null?void 0:e.eventName))})})]})})};function ve(){var Z,H,J;ee();const j={IN_PLAY:"in_play",TODAY:"today",TOMORROW:"tomorrow"},[h,M]=p.useState(j.IN_PLAY),B=p.useRef(h);p.useEffect(()=>{B.current=h},[h]);const C=p.useRef([]);
1let{user:T,setSearchToogle:F,setLoader:b,launchCasino:z,parly:x,setInplaySocket:Y,inplaySocket:R}=p.useContext(ae),{handelAddMultiMarket:w}=p.useContext(ce);const[A,m]=p.useState(!1),[e,c]=p.useState([]),[f,k]=p.useState([]),[S,O]=p.useState({}),[I,N]=p.useState(!0),_=async()=>{var l,r;N(!1),P.isEmpty(S)||S.disconnect(),P.isEmpty(R)||R.disconnect();let n=(l=T==null?void 0:T.user)!=null&&l._id?(r=T==null?void 0:T.user)==null?void 0:r._id:112233;const t=le(`https://apiv2.9tens.live:5020/?token=${n}&userType=front`,{transports:["websocket"]});m(!1),Y(t),O(t);const o=a=>{k(a)};return t.on("scoreAll",o),t.on("disconnect",function(){N(!0)}),()=>t.disconnect()},G=n=>{if(!n)return null;const t=n,o=r=>{switch(r){case 1:return"soccer";case 2:return"tennis";case 4:return"cricket";default:return"cricket"}},l=r=>r.map(a=>{var v;const E=(v=a.market)!=null&&v.selections?a.market.selections.map(i=>({SelectionId:i.selectionId,RunnerName:i.runnerName})):[];return{_id:a.id.toString(),eventId:a.eventId.toString(),centralizedId:a.eventId.toString(),eventDateTime:new Date(a.openDateTime).toISOString(),eventName:a.name,eventType:a.eventType.toString(),gameType:o(a.eventType),marketCount:a.markets?a.markets.length:0,marketId:a.market?a.market.marketId:"",seriesId:a.competitionId.toString(),seriesName:a.competitionName,status:a.isInPlay===1?"in_play":"upcoming",timeZone:a.timezone||"GMT",runners:E,premiumFancy:a.hasSportsBookMarkets||a.hasOwSportsBookMarkets||a.hasGeniusSportsMarkets?"on":"off",bookMaker:a.hasBookMakerMarkets||a.hasInPlayBookMakerMarkets?"on":"off",fancy:a.hasFancyBetMarkets||a.hasInPlayFancyBetMarkets?"on":"off"}});return{success:n.status,message:n.message,results:l(t)}},$=async(n=!0)=>{T&&`${T.user._id}`;const t=B.current,o=await X("sportsData");if(o)try{o!=null&&o.status&&(b(!1),m(!1),L(t,o))}catch{console.error("Invalid localStorage data")}try{const{status:l,data:r}=await oe(Q.matchList+"?game_type=all");l===200&&r.status&&(await de("sportsData",r),L(t,r))}catch(l){console.error(l)}m(!1),b(!1)},L=async(n,t)=>{var E;const o=((E=t==null?void 0:t.data)==null?void 0:E.matches)||[];let l=n&&n!=="all"?o.filter(v=>v.type===n):o,a=G(l).results||[];a=a.sort((v,i)=>{var u,y;const g=(u=v.seriesName)==null?void 0:u.toLowerCase().includes("virtual"),d=(y=i.seriesName)==null?void 0:y.toLowerCase().includes("virtual");return g!==d?g?1:-1:new Date(v.eventDateTime).getTime()-new Date(i.eventDateTime).getTime()}),c((v=[])=>{const i=new Map(v.map(d=>[String(d.eventId),d])),g=new Map((f||[]).map(d=>[String(d.eventId),d]));return a.map(d=>{const u=i.get(String(d.eventId)),y=g.get(String(d.eventId));return{...d,...u&&{back_odds:u.back_odds,lay_odds:u.lay_odds,totalMatched:u.totalMatched,matchOddsData:u.matchOddsData},score:y!=null&&y.score&&y.score!==0?y.score:"",timeElapsed:(y==null?void 0:y.timeElapsed)||""}})}),b(!1)},ne=n=>{if(!n)return null;const t=n.status==="OPEN"?1:n.status==="SUSPENDED"?3:1,o=n.selections.map(r=>({selectionId:r.selectionId,handicap:r.handicap,status:r.status,lastPriceTraded:r.lastPriceTraded,totalMatched:r.totalMatched,adjustmentFactor:0,ex:{availableToBack:r.availableToBack.length>0?r.availableToBack:[{price:0,size:0},{price:0,size:0},{price:0,size:0}],availableToLay:r.availableToLay.length>0?r.availableToLay:[{price:0,size:0},{price:0,size:0},{price:0,size:0}]}}));let l=[];return n.selections.forEach(r=>{if(r.availableToBack&&r.availableToBack.length>0)r.availableToBack.forEach(a=>{l.push({ri:r.selectionId,rt:a.price,bv:a.size,ib:!0})});else for(let a=0;a<3;a++)l.push({ri:r.selectionId,rt:0,bv:0,ib:!0});if(r.availableToLay&&r.availableToLay.length>0)r.availableToLay.forEach(a=>{l.push({ri:r.selectionId,rt:a.price,bv:a.size,ib:!1})});else for(let a=0;a<3;a++)l.push({ri:r.selectionId,rt:0,bv:0,ib:!1})}),{mi:n.marketId,ms:t,totalMatched:n.totalMatched,rt:l,runners:o,lastMatchTime:n.lastMatchTime,ts:new Date().toISOString().replace("T"," ").substring(0,19),eventId:n.eventId,eventType:n.eventType}},te=async n=>{var t;if(!(!n||n.length===0))try{const{status:o,data:l}=await ie(Q.getMatchOdds+`?match_ids=${n.join(",")}`);if(o===200&&l.status&&l.data){const r={};(t=C.current)==null||t.forEach(i=>
1{r[i.eventId]=i.eventType});const a={};l.data.forEach(i=>{a[i.eventId]||(a[i.eventId]=[]),a[i.eventId].push(i)});const E={};Object.keys(a).forEach(i=>{const g=a[i],d=r[i];let u;d===1&&g.length>1,u=g[0],E[i]=ne(u)});const v=Object.values(E).filter(i=>i!==null);v&&v.length>0&&c(i=>i==null?void 0:i.map(g=>{var u,y;const d=v.find(W=>String(W.eventId)===String(g.eventId));if(d){const W=((u=d==null?void 0:d.rt)==null?void 0:u.filter(U=>U.ib))||[],re=((y=d==null?void 0:d.rt)==null?void 0:y.filter(U=>!U.ib))||[];return{...g,back_odds:W,lay_odds:re,totalMatched:d==null?void 0:d.totalMatched,matchOddsData:d}}return g}))}}catch(o){console.error("Error fetching match odds:",o)}};p.useEffect(()=>{C.current=e},[e]),p.useEffect(()=>{A&&($(),_())},[A]),p.useEffect(()=>{if(!(f!=null&&f.length))return;const n=new Map(f.map(t=>[t.eventId,t]));c(t=>t.map(o=>{const l=n.get(o.eventId);return{...o,score:l!=null&&l.score&&l.score!==0?l.score:"",timeElapsed:(l==null?void 0:l.timeElapsed)||""}}))},[f]),p.useEffect(()=>{I&&_()},[I]),p.useEffect(()=>{(async()=>{const t=await X("sportsData");t!=null&&t.status&&L(h,t)})()},[h]),p.useEffect(()=>{let n=!1;const t=async()=>{n||document.hidden||(n=!0,await $(!1),n=!1)};t();const o=setInterval(t,6e4);return()=>clearInterval(o)},[]);const q=p.useRef(!1),D=p.useRef(null);return p.useEffect(()=>{const n=()=>{const t=C.current;if(!t||t.length===0)return;const o=t.map(l=>l.eventId).filter(l=>l);o&&o.length>0&&te(o)};return e&&e.length>0&&!q.current&&(q.current=!0,n()),D.current||(D.current=setInterval(n,15e3)),()=>{clearInterval(D.current),D.current=null}},[e]),document.addEventListener("visibilitychange",function(){!document.hidden&&!I?(P.isEmpty(S)||S.disconnect(),N(!0)):N(!1)}),s.jsx(s.Fragment,{children:s.jsxs("div",{className:"mian-wrap",children:[s.jsxs("div",{className:"tab-wrap",children:[s.jsxs("ul",{children:[s.jsx("li",{id:"inplay",className:h=="in_play"?"select":"",onClick:()=>{M(j.IN_PLAY)},children:s.jsx("a",{href:"javascript:void(0)",neua:"In-Play",children:"In-Play"})}),s.jsx("li",{id:"today",className:h=="today"?"select":"",onClick:()=>{M(j.TODAY)},children:s.jsx("a",{href:"javascript:void(0)",children:"Today"})}),s.jsx("li",{id:"tomorrow",className:h=="tomorrow"?"select":"",onClick:()=>{M(j.TOMORROW)},children:s.jsx("a",{href:"javascript:void(0)",children:"Tomorrow"})}),s.jsx("li",{id:"result",children:s.jsx(se,{to:P.isEmpty(T)?"/login":"/result",children:"Result"})})]}),s.jsx("a",{className:"a-search",onClick:()=>F(!0),href:"javascript:void(0)",children:"Search"})]}),e&&e.length>0&&s.jsxs(s.Fragment,{children:[((Z=e==null?void 0:e.filter(n=>n.gameType=="cricket"))==null?void 0:Z.length)>0&&s.jsx(V,{type:h,parlyTab:x,data:e||[],handelAddMultiMarket:w,setLoading:m,sportsType:"Cricket",sportsId:4}),((H=e==null?void 0:e.filter(n=>n.gameType=="soccer"))==null?void 0:H.length)>0&&s.jsx(V,{type:h,parlyTab:x,data:e||[],handelAddMultiMarket:w,setLoading:m,sportsType:"Soccer",sportsId:1}),((J=e==null?void 0:e.filter(n=>n.gameType=="tennis"))==null?void 0:J.length)>0&&s.jsx(V,{type:h,parlyTab:x,data:e||[],handelAddMultiMarket:w,setLoading:m,sportsType:"Tennis",sportsId:2})]})]})})}export{ve as default};
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.