@simple-parlay/components 1.30.3 → 1.30.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +3 -3
- package/dist/react/index.js +1 -1
- package/dist/react/index.mjs +2 -2
- package/dist/react-native/index.js +1 -1
- package/dist/react-native/index.mjs +2 -2
- package/package.json +2 -2
package/dist/react/index.mjs
CHANGED
|
@@ -93,8 +93,8 @@ return m("article",{className:"flex flex-col items-center text-center",style:{fl
|
|
|
93
93
|
/* @__PURE__ */m("div",{className:"mt-2",style:{fontFamily:C,fontSize:13,letterSpacing:"-0.04em",lineHeight:1},children:[/* @__PURE__ */u("span",{style:{fontWeight:800,color:N.primary},children:"YES"}),/* @__PURE__ */u("span",{style:{fontWeight:600,color:ce(N.primary,.85)},children:"NO"})]}),
|
|
94
94
|
/* @__PURE__ */m("h3",{className:"flex items-center justify-center gap-1.5 font-semibold leading-tight px-1 mt-0.5",style:{fontFamily:C,fontSize:J?19:21,color:A,letterSpacing:"-0.01em"},children:[X(e),/* @__PURE__ */u(Ke,{variant:"icon",panel:Ee(e),content:i||"Pick outcomes and land the payout for this game.",theme:v,title:X(e),label:`How to play ${X(e)}`,extra:/* @__PURE__ */u(so,{tiers:y?p:[],modes:f,pydDividends:g,onPlayCount:c.length>1?t=>Z(e,t):void 0,minBet:b,maxBet:S,colors:N,bodyFont:B,headingFont:C}),colors:N,bodyFont:B,headingFont:C})]}),s&&/* @__PURE__ */u("p",{className:"mt-1.5 font-bold leading-snug",style:{fontSize:13,color:N.primary,maxWidth:"30ch"},children:s}),i&&/* @__PURE__ */u("p",{className:"mt-2 leading-relaxed",style:{fontSize:12.5,color:N.textMuted,maxWidth:"34ch"},children:i}),a.enabled&&/* @__PURE__ */m("span",{className:"inline-flex w-fit items-center gap-0.5 px-2 py-0.5 rounded-full mt-2",style:{backgroundColor:`${N.warning}15`,color:N.warning,fontSize:10,fontWeight:700},children:["★ ",a.progressive?a.amount>0?ht(a.amount):a.limit>0?`Up to ${ht(a.limit)}`:"Jackpot":ht(a.amount)]}),(x||h)&&/* @__PURE__ */m("div",{className:"flex flex-wrap gap-1 justify-center mt-2",children:[x&&e.category&&/* @__PURE__ */u("span",{className:"px-1.5 py-0.5 rounded text-xs",style:{backgroundColor:N.backgroundAlt,color:P(v)},children:e.category}),x&&/* @__PURE__ */u("span",{className:"px-1.5 py-0.5 rounded text-xs",style:{backgroundColor:N.backgroundAlt,color:P(v)},children:e.rule}),x&&e.lotto_type&&/* @__PURE__ */u("span",{className:"px-1.5 py-0.5 rounded text-xs",style:{backgroundColor:N.backgroundAlt,color:P(v)},children:e.lotto_type}),h&&null!=e.tier&&/* @__PURE__ */m("span",{className:"px-1.5 py-0.5 rounded text-xs",style:{backgroundColor:N.backgroundAlt,color:P(v)},children:["Tier ",e.tier]})]}),D&&/* @__PURE__ */u("div",{style:{marginTop:"auto",width:"100%",paddingTop:12},children:/* @__PURE__ */u("span",{className:"text-[11px] font-semibold leading-snug",style:{color:N.text},children:D})})]},l)})}),oe&&/* @__PURE__ */m(d,{children:[/* @__PURE__ */u("button",{type:"button","aria-label":"Previous game",onClick:()=>Q(U-1),style:{...re(U>0),left:2},children:"‹"}),/* @__PURE__ */u("button",{type:"button","aria-label":"Next game",onClick:()=>Q(U+1),style:{...re(U<j.length-1),right:2},children:"›"})]})]}),ne&&/* @__PURE__ */u("div",{className:"flex justify-center flex-wrap pt-1 pb-2",children:j.map((e,t)=>/* @__PURE__ */u("button",{type:"button","aria-label":`Go to ${X(e)}`,onClick:()=>Q(t),style:{padding:"18.5px 5px",margin:"-18.5px 0",background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center"},children:/* @__PURE__ */u("span",{style:{display:"block",width:t===U?22:7,height:7,borderRadius:999,backgroundColor:t===U?N.primary:ce(N.primary,.25),transition:"width 200ms ease, background-color 200ms ease"}})},e.id))}),ne&&/* @__PURE__ */m("div",{style:{borderTop:`1px solid ${N.border}`,paddingTop:10,marginTop:2},children:[/* @__PURE__ */u("div",{className:"text-[10px] font-bold uppercase mb-2",style:{color:N.textMuted,letterSpacing:"0.16em",fontFamily:C},children:"All games"}),/* @__PURE__ */u("div",{className:"grid gap-1",style:{gridTemplateColumns:`repeat(${dt(j.length,G)}, minmax(0, 1fr))`},children:j.map((e,t)=>{const n=Gt(e);/* @__PURE__ */
|
|
95
95
|
return m("button",{type:"button",onClick:()=>$(e),disabled:!n,"aria-current":t===U,className:"flex flex-col items-center gap-1 px-1 py-1.5 rounded-2xl",style:{border:`1px solid ${t===U?N.primary:"transparent"}`,cursor:n?"pointer":"not-allowed",opacity:n?1:.5,background:"transparent",transition:"border-color 150ms ease"},children:[/* @__PURE__ */u(uo,{iconUrl:Ae(e),size:J?44:52,brandColor:N.primary,iconColor:N.primaryText,accentColor:z}),/* @__PURE__ */u("span",{className:"text-[11px] font-bold leading-tight",style:{color:t===U?N.primary:A,fontFamily:C,letterSpacing:"-0.01em",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:2,overflow:"hidden"},children:X(e)})]},e.id)})})]})]}),
|
|
96
|
-
/* @__PURE__ */u("style",{children:".blade-game-track::-webkit-scrollbar{display:none}"})]})}var fo=class{constructor(e){this.inflight=/* @__PURE__ */new Map,this.cache=/* @__PURE__ */new Map,this.apiUrl=e.apiUrl,this.apiKey=e.apiKey,this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.getAuthHeaders=e.getAuthHeaders}invalidateCache(){this.cache.clear()}invalidate(){this.invalidateCache()}async request(e,t,n){const o=`${this.apiUrl}${e}`,r=(t?.method??"GET").toUpperCase(),l="GET"===r,a=l,i=!l&&!n?.idempotent,s=`${r} ${o}`;if(a){const e=this.cache.get(s);if(e&&Date.now()-e.at<5e3)return e.value;const t=this.inflight.get(s);if(t)return t}const c=a?this.cache.get(s):void 0,d=(async()=>{let e;try{const n=this.getAuthHeaders?await this.getAuthHeaders():void 0;e=await this.fetchImpl(o,{...t,headers:{"Content-Type":"application/json",...this.apiKey?{"X-API-Key":this.apiKey}:{},...n??{},...c?.etag?{"If-None-Match":c.etag}:{},...t?.headers}})}catch(r){throw r}if(304===e.status&&c)return a&&this.cache.set(s,{at:Date.now(),value:c.value,etag:c.etag}),c.value;if(!e.ok){let t=`API request failed: ${e.status} ${e.statusText}`;try{const n=await e.json();422===e.status&&n.detail?Array.isArray(n.detail)?t=n.detail.map(e=>`${Array.isArray(e.loc)?e.loc.join("."):"field"}: ${e.msg}`).join("; "):"string"==typeof n.detail?t=n.detail:"object"==typeof n.detail&&(t=JSON.stringify(n.detail)):n.message?t=n.message:n.error&&(t=n.error)}catch{}throw new Error(t)}const n=await e.json();if(a){const t=e.headers.get("ETag")??void 0;this.cache.set(s,{at:Date.now(),value:n,etag:t})}return n})();return a?(this.inflight.set(s,d),d.catch(()=>{}).finally(()=>{this.inflight.delete(s)})):i&&d.finally(()=>this.invalidateCache()).catch(()=>{}),d}async getGames(e){const t=new URLSearchParams;e?.category&&t.append("category",e.category),e?.jurisdiction&&t.append("jurisdiction",e.jurisdiction),e?.sport&&t.append("sport",e.sport);const n=t.toString(),o=n?`/games?${n}`:"/games",r=await this.request(o);return{games:r.payload||[],howToPlayMarkdown:r.how_to_play_markdown??null}}async getGame(e){return(await this.request(`/games/${e}`)).payload}async getPropositions(e){const t=new URLSearchParams;e?.event_id&&t.append("event_id",e.event_id),e?.sport&&t.append("sport",e.sport),e?.category&&t.append("category",e.category);const n=t.toString(),o=n?`/propositions?${n}`:"/propositions";return(await this.request(o)).payload||[]}async getSports(){return(await this.request("/propositions/sports")).sports||[]}async getPropositionsByIds(e){if(0===e.length)return[];const t=new URLSearchParams({ids:e.join(","),include_expired:"true"});return(await this.request(`/propositions?${t.toString()}`)).payload||[]}async getProposition(e){const t=(await this.request(`/propositions/${e}?include_expired=true`)).payload;return Array.isArray(t)?t.find(t=>t.id===e)??t[0]:t}async getGameEntries(e){const t=new URLSearchParams;null!=e?.user_id&&t.append("user_id",String(e.user_id)),null!=e?.pending&&t.append("pending",String(e.pending));const n=t.toString(),o=n?`/game-entries?${n}`:"/game-entries";return((await this.request(o)).payload||[]).map(e=>{const t={...e};return!t.created_at&&t.entry_date&&(t.created_at=t.entry_date),null!=t.stake&&null==t.bet_amount&&(t.bet_amount=Number(t.stake)),(!t.proposition_ids||0===t.proposition_ids.length)&&t.propositions&&t.propositions.length>0&&(t.proposition_ids=t.propositions.map(e=>e.id)),t})}async createGameEntry(e){const t=e.proposition_ids.map(t=>({proposition_id:t,user_prediction:e.selections?.[t]??"yes"})),n={game_id:e.game_id,user_id:e.user_id,propositions:t};null!=e.stake&&(n.stake=e.stake),null!=e.rule_id&&(n.rule_id=e.rule_id);const o=(await this.request("/game-entries",{method:"POST",body:JSON.stringify(n)})).payload;return null!=o.stake&&null==o.bet_amount&&(o.bet_amount=Number(o.stake)),o}async getPayoutsDue(e){const t=new URLSearchParams;null!=e?.game_id&&t.set("game_id",String(e.game_id)),null!=e?.limit&&t.set("limit",String(e.limit)),null!=e?.offset&&t.set("offset",String(e.offset));const n=t.toString();return await this.request(n?`/game-entries/payouts/due?${n}`:"/game-entries/payouts/due")}async getEntryPayout(e){return(await this.request(`/game-entries/${e}/payout`)).payload}async markEntryPaidOut(e){const t=await this.request(`/game-entries/${e}/payout/mark-paid-out`,{method:"POST",body:JSON.stringify({})});return this.invalidate(),t.payload}async updateGameEntryResult(e,t){return(await this.request(`/game-entries/${e}/result`,{method:"POST",body:JSON.stringify(t)})).payload}async getGameMaxPayout(e,t){const n=null!=t?`?bet_amount=${encodeURIComponent(String(t))}`:"";return(await this.request(`/games/${e}/max-payout${n}`)).payload}async getGamesMaxPayouts(e,t){if(0===e.length)return{};const n=new URLSearchParams({ids:e.join(",")});null!=t&&n.set("bet_amount",String(t));const o=await this.request(`/games/max-payouts?${n.toString()}`),r={};for(const[l,a]of Object.entries(o.payload||{}))r[Number(l)]=a;return r}async getEntryPreview(e,t){return(await this.request(`/games/${e}/preview`,{method:"POST",body:JSON.stringify(t)},{idempotent:!0})).payload}async evaluateRule(e,t){return(await this.request(`/games/${e}/evaluate-rule`,{method:"POST",body:JSON.stringify(t)},{idempotent:!0})).payload}async calculatePayout(e,t){return(await this.request(`/games/${e}/calculate-payout`,{method:"POST",body:JSON.stringify(t)},{idempotent:!0})).payload}};function ho(e,t,n){const[r,a]=c([]),[i,d]=c(null),[u,m]=c(!n?.skip),[p,f]=c(null),h=t?`${t.category||""}_${t.jurisdiction||""}_${t.sport||""}`:"",x=s(t);x.current=t;const g=n?.skip??!1,y=o(async()=>{if(!g)try{m(!0),f(null);const t=await e.getGames(x.current);a(t.games),d(t.howToPlayMarkdown)}catch(t){f(t instanceof Error?t.message:"Failed to fetch games")}finally{m(!1)}},[e,h,g]);return l(()=>{y()},[y]),{games:r,howToPlayMarkdown:i,loading:u,error:p,refetch:o(async()=>{e.invalidate(),await y()},[e,y])}}function xo(e,t,n){const[r,a]=c([]),[i,d]=c(!n?.skip),[u,m]=c(null),p=n?.skip??!1,f=t?`${t.event_id||""}_${t.sport||""}_${t.category||""}`:"",h=s(t);h.current=t;const x=o(async()=>{if(!p)try{d(!0),m(null);const t=await e.getPropositions(h.current);a(t)}catch(t){m(t instanceof Error?t.message:"Failed to fetch propositions")}finally{d(!1)}},[e,f,p]);return l(()=>{x()},[x]),{propositions:r,loading:i,error:u,refetch:o(async()=>{e.invalidate(),await x()},[e,x])}}function go(e,t){const[n,r]=c([]),[a,i]=c(!t?.skip),[s,d]=c(null),u=t?.skip??!1,m=o(async()=>{if(!u)try{i(!0),d(null),r(await e.getSports())}catch(t){d(t instanceof Error?t.message:"Failed to fetch sports")}finally{i(!1)}},[e,u]);return l(()=>{m()},[m]),{sports:n,loading:a,error:s,refetch:o(async()=>{e.invalidate(),await m()},[e,m])}}function yo(e,t,n){const[r,a]=c([]),[i,d]=c(!n?.skip),[u,m]=c(null),p=n?.skip??!1,f=t?`${t.user_id??""}_${t.pending??""}`:"",h=s(t);h.current=t;const x=o(async()=>{if(!p)try{d(!0),m(null);const t=await e.getGameEntries(h.current);a(t)}catch(t){m(t instanceof Error?t.message:"Failed to fetch entries")}finally{d(!1)}},[e,f,p]);return l(()=>{x()},[x]),{entries:r,loading:i,error:u,refetch:o(async()=>{e.invalidate(),await x()},[e,x])}}function bo(e,t,n){const[r,a]=c({}),[i,d]=c(!1),u=n?.skip??!1,m=n?.betAmount,p=s(/* @__PURE__ */new Set);return l(()=>{if(u||0===t.length)return;const n=t.filter(e=>!(e.id in r)&&!p.current.has(e.id));if(0===n.length)return;for(const e of n)p.current.add(e.id);let o=!1;return d(!0),(async()=>{try{const t=await e.getGamesMaxPayouts(n.map(e=>e.id),m);o||a(e=>({...e,...t}))}catch{}finally{o||d(!1)}})(),()=>{o=!0}},[e,t.map(e=>e.id).join(","),u,m]),{maxPayouts:r,loading:i,refetchGame:o(async(t,n)=>{if(!u)try{const o=await e.getGamesMaxPayouts([t],n??m);o[t]&&a(e=>({...e,[t]:o[t]}))}catch{}},[e,u,m])}}function wo(e){const[t,n]=c(!1),[o,r]=c(null),[l,a]=c(null);return{createEntry:async t=>{try{n(!0),r(null);const o=await e.createGameEntry(t);return a(o),o}catch(o){const e=o instanceof Error?o.message:"Failed to create entry";throw r(e),new Error(e)}finally{n(!1)}},loading:t,error:o,entry:l}}function ko(e){const[t,n]=c(e?"sport":"game"),[o,r]=c(null),[l,a]=c({}),[i,s]=c(null);return{step:t,selectedGame:o,selections:l,placedEntry:i,setGameOnly:e=>{r(e)},clearSelectedGame:()=>{r(null),a({})},goToSportSelection:e=>{e&&r(e),n("sport")},goToConfirmation:()=>{n("confirm")},goToSuccess:e=>{s(e),n("success")},goBack:()=>{"confirm"===t?n("sport"):"sport"===t&&(n("game"),r(null),a({}))},reset:()=>{n("game"),r(null),a({}),s(null)},toggleSelection:(e,t)=>{a(n=>{const o={...n};return o[e]===t?delete o[e]:o[e]=t,o})}}}function vo(e){const[t,n]=c(!1),[r,l]=c(null),[a,i]=c(null);return{evaluate:o(async(t,o)=>{try{n(!0),l(null);const r=await e.evaluateRule(t,o);return i(r),r}catch(r){const e=r instanceof Error?r.message:"Failed to evaluate rule";throw l(e),new Error(e)}finally{n(!1)}},[e]),loading:t,error:r,result:a}}function No(e){const[t,n]=c(!1),[r,l]=c(null),[a,i]=c(null);return{calculate:o(async(t,o)=>{try{n(!0),l(null);const r=await e.calculatePayout(t,o);return i(r),r}catch(r){const e=r instanceof Error?r.message:"Failed to calculate payout";throw l(e),new Error(e)}finally{n(!1)}},[e]),loading:t,error:r,result:a}}function Fo(e){const[t,n]=c(!1),[r,l]=c(null),[a,i]=c(null);return{preview:o(async(t,o)=>{try{n(!0),l(null);const r=await e.getEntryPreview(t,o);return i(r),r}catch(r){const e=r instanceof Error?r.message:"Failed to preview entry";throw l(e),new Error(e)}finally{n(!1)}},[e]),loading:t,error:r,result:a}}var Bo={today:"Today",weekend:"This weekend",next7:"Next 7 days"},Co=["today","weekend","next7"];function Ao(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}function Mo(e,t,n){if(!e)return!1;const o=new Date(e);if(Number.isNaN(o.getTime()))return!1;const{start:r,end:l}=function(e,t){const n=function(e){const t=new Date(e);return t.setHours(0,0,0,0),t}(t);switch(e){case"today":return{start:n,end:Ao(n,1)};case"weekend":{const e=n.getDay(),t=Ao(n,0===e?-1:(6-e)%7);return{start:t<n?n:t,end:Ao(t,2)}}case"next7":return{start:n,end:Ao(n,7)}}}(t,n);return o>=r&&o<l}var So=t(null),zo={};function Lo(){const e=r(So);if(!e)throw new Error("usePlaceEntry must be used within a <PlaceEntryProvider>");return e}function Po({apiUrl:t,apiKey:n,fetchImpl:r,getAuthHeaders:a,userId:d,getUserBalance:m,children:p,theme:f,colorScheme:h,demoGames:x,demoPropositions:g,demoEntries:y,demoMaxPayouts:b,gameCategory:w,jurisdiction:k,initialGameId:v,filterSport:N,initialSport:F,initialEventId:B,initialEventLabel:C,sportBaseKey:A,disableQuickPick:M=!1,renderTeamLogo:S,onEntryPlaced:z,onBeforeSubmit:L,onCancel:P,onShare:D,onRecharge:O,onClearEventFilter:T,screenSize:E="desktop",howToPlayMarkdown:j,sportDisplayNames:Y,categoryDisplayNames:H}){const R=se(f,h),G=ye(R),W=be(R),I=!(!x||!g),U=i(()=>new fo({apiUrl:t,apiKey:n,fetchImpl:r,getAuthHeaders:a}),[t,n,r,a]),[K,Z]=c(0),$=s(0),[q,V]=c(0),[X,Q]=c([]),[J,_]=c({}),[ee,te]=c({}),[ne,oe]=c(void 0),[re,le]=c(null),[ae,ie]=c(void 0),ce=e.useCallback(async()=>{if(m)try{const e=await m();"number"==typeof e&&Number.isFinite(e)&&ie(e)}catch(e){}},[m]);l(()=>{m?ce():ie(void 0)},[m,ce]);const de=s(null),[ue,me]=c(null),[pe,fe]=c(F??null),[he,xe]=c(B??null);l(()=>{F&&fe(F)},[F]),l(()=>{xe(B??null)},[B]);const[ge,we]=c(B),ke=s(!1);l(()=>{if(!B)return we(void 0),void(ke.current=!1);ke.current||we(B)},[B]);const ve=w??ue??void 0,Ne=N??F??void 0,Fe=Lt(pe??Ne,A),Be=Lt(Ne,A)??Ne,Ce=pe??void 0,{games:Ae,howToPlayMarkdown:Me,loading:Se,error:ze}=ho(U,{category:ve,jurisdiction:k,sport:Fe},{skip:I}),{propositions:Le,loading:Pe,error:De}=xo(U,{category:ve,sport:Be,event_id:ge},{skip:I}),{sports:Oe,loading:Te}=go(U,{skip:I}),{createEntry:Ee,loading:je,error:Ye}=wo(U),{preview:He}=Fo(U),Re=i(()=>Ht((I?x:Ae)??[],{category:ve,sport:Fe??Ce,sportBaseKey:A}),[I,x,Ae,ve,Fe,Ce,A]),Ge=j??Me??null,{maxPayouts:We,refetchGame:Ie}=bo(U,Re??[],{skip:I,betAmount:20}),Ue=I?b??zo:We,Ke=I?g:Le,Ze=N?(Ke??[]).filter(e=>e.sport===N):Ke,$e=i(()=>Nt(Ze??[]),[Ze]),qe=i(()=>ve||(1===$e.length?$e[0]:void 0),[ve,$e]),Ve=i(()=>{const e=Ze??[];return qe?Tt(e,{category:qe,sportBaseKey:A}):e},[Ze,qe,A]),Xe=i(()=>Ce?Tt(Ve,{sport:Ce,sportBaseKey:A}):Ve,[Ve,Ce,A]),Qe=i(()=>({category:qe,sport:Ce,sportBaseKey:A}),[qe,Ce,A]),Je=i(()=>{const e=(Re??[]).filter(e=>e.active);if(!qe&&$e.length>1)return[];const t=qe?Ht(e,Qe):e;return qe||Ce?function(e,t,n){return n?.category||n?.sport?e.filter(e=>Yt(e,t,n)):e}(t,Xe,Qe):t},[Re,Xe,Qe,qe,Ce,$e.length]),{step:_e,selectedGame:et,selections:tt,placedEntry:nt,setGameOnly:ot,clearSelectedGame:rt,goToSportSelection:lt,goToConfirmation:at,goToSuccess:it,goBack:st,reset:ct,toggleSelection:dt}=ko(v),ut=e.useCallback(()=>{ke.current=!0,we(void 0),ct(),T?.()},[ct,T]),mt=!!ge,pt=mt?C:void 0,ft=!I&&(et?Se||Pe||Te:Se),ht=I?null:et?ze||De:ze,xt=i(()=>et?Rt(Xe,et,A):Xe,[et,Xe,A]),gt=i(()=>et?xt:Ve,[et,xt,Ve]),bt=i(()=>Tt(et?xt:Ve,{category:qe}),[et,xt,Ve,qe]),kt=i(()=>{const e=new Set(bt.map(e=>e.sport).filter(Boolean));return Oe.filter(t=>e.has(t.key))},[Oe,bt]),vt=i(()=>Tt(xt,{category:qe,sport:pe}),[xt,qe,pe]),Ft=i(()=>{if(!et||!bn(et))return[];const{min:e}=Ct(et,ne),t=ne??e;return kn(vt).filter(e=>e.propositionCount>=t)},[et,ne,vt]),At=i(()=>bn(et)?Cn(vt,he):vt,[et,vt,he]),Mt=Object.keys(tt).map(Number),Dt=Mt.length,Ot=i(()=>vt.filter(e=>Mt.includes(e.id)),[vt,Mt]);l(()=>{w||ue||1===$e.length&&me($e[0])},[w,ue,$e]),l(()=>{if(!et)return;const e=xt,t=new Set(e.map(wt));let n=ue;n&&t.has(n)||(n=1===t.size?Array.from(t)[0]:null,n!==ue&&me(n));const o=n?e.filter(e=>wt(e)===n):e,r=new Set(function(e){const t=/* @__PURE__ */new Set;for(const n of e){const o=yt(n,e);"Other"!==o&&t.add(o)}return[...t]}(o)),l=et.allowed_sports;fe(e=>e&&r.has(e)?e:1===l?.length&&r.has(l[0])?l[0]:l&&l.length>1?e&&l.includes(e)&&r.has(e)?e:null:1===r.size?Array.from(r)[0]:null)},[et?.id,xt,ue]),l(()=>{et&&qe&&(Et(et,qe)||rt())},[et,qe,rt]),l(()=>{et&&(Yt(et,Xe,{category:qe,sport:pe,sportBaseKey:A})||rt())},[et,qe,pe,A,Xe,rt]),l(()=>{if(et){if(V(0),de.current){const{count:e}=de.current;return de.current=null,oe(e),void Z(e)}if(et.allowed_propositions&&et.allowed_propositions.length>0){const e=ne;null!=e&&et.allowed_propositions.includes(e)?Z(e):(oe(void 0),Z(0))}else oe(void 0),Z(et.num_propositions||et.max_propositions||0)}},[et]);const jt=(e,t,n)=>{const o=(Ue[e]?.top_payouts??[]).find(e=>e.proposition_count===t);if(!o)return 0;const r=o.bet_amount&&o.bet_amount>0?o.bet_amount:20;return r<=0?0:o.net_payout/r*n};l(()=>{if("sport"!==_e&&"confirm"!==_e||!et||I)return;const e=bn(et)&&he?At.length:Number.MAX_SAFE_INTEGER;let t;if(et.allowed_propositions&&et.allowed_propositions.length>0){const n=et.allowed_propositions?[...et.allowed_propositions].filter(t=>t<=e).sort((e,t)=>e-t):[];if(0===n.length)return void te({});const o=ne??n[0],r=n.filter(e=>e>o);if(0===r.length)return void te({});t=[o,...r]}else{const{min:n,max:o}=Ct(et),r=Math.min(o,e);if(n<=0||r<=n)return void te({});t=Array.from({length:r-n+1},(e,t)=>n+t)}const n={};for(const o of t)n[o]=jt(et.id,o,20);te(n)},[_e,et,ne,he,At.length,I,Ue]),l(()=>{if("confirm"!==_e||!et)return;const e=Mt.length;if(0===e)return;let t=!1;const n={};for(let r=0;r<=e;r++)n[r]=jt(et.id,r,q);_(n),e!==$.current?($.current=e,Z(e)):(K>e||K<=0&&e>0)&&Z(e);const o=q>0?q:Math.max(et.min_bet??20,.01);return(async()=>{try{const n=await He(et.id,{actual:K,predicted:K,total:e,bet_amount:o});if(t)return;Q(n.winning_counts)}catch{t||Q([])}})(),()=>{t=!0}},[_e,et,Mt.length,K,q,He,Ue]);const Gt=i(()=>{return t=re,(e=et)&&null!=t?e.permitted_rules?.find(e=>e.id===t)??null:null;var e,t},[et,re]),Wt=!bn(et)||An(Ot,he),It=et?Ct(et,void 0,Gt):null,Ut=!(!et||!Wt)&&(et.allowed_propositions&&et.allowed_propositions.length>0?null!=ne&&Dt===ne&&Bt(Dt,It?.min,It?.max):Bt(Dt,It?.min,It?.max)),Kt=et?.min_bet??0,Zt=Math.max(Kt,.01),$t=null==ae||q<=ae,qt=!je&&q>=Zt&&Ut&&$t,Vt=e=>{oe(e),Z(e);for(const t of Object.keys(tt))dt(Number(t),tt[Number(t)])},Xt=e=>{oe(e),Z(e)},Qt=e=>{xe(bn(e)?B??null:null),ot(e)},Jt=e=>{if(e!==he){for(const e of Object.keys(tt)){const t=Number(e);dt(t,tt[t])}xe(e)}},_t=(e,t)=>{de.current={count:t},ot(e),Ie(e.id);const n=e.allowed_sports??[];let o=null;pe&&n.some(e=>Pt(pe,e,A))?o=pe:1===n.length&&(o=n[0]),fe(o);for(const i of Object.keys(tt)){const e=Number(i);dt(e,tt[e])}let r=Tt(Rt(Ze??[],e,A),{category:qe,sport:o,sportBaseKey:A});const l=Math.max(0,Math.min(t,r.length)),a=[...r].sort(()=>Math.random()-.5).slice(0,l);for(const i of a)dt(i.id,Math.random()<.5?"yes":"no");at()},en=async()=>{if(et&&Ut){if(I){const e={id:Math.floor(1e4*Math.random()),game_id:et.id,user_id:d,proposition_ids:Mt,selections:tt,pending:!0,expected_correct:K,bet_amount:q};return z?.(e),it(e),void ce()}try{L&&await L(q);const e=await Ee({game_id:et.id,user_id:d,proposition_ids:Mt,selections:tt,stake:q,rule_id:Gt?.id??null});z?.(e),it(e),ce()}catch(e){}}},tn=o(e=>Y?.[e]??kt.find(t=>t.key===e)?.label??St(e,void 0,A),[Y,kt,A]),nn=o(e=>zt(e,H),[H]),on=i(()=>({theme:R,bodyFont:G,headingFont:W,games:Je,propositions:At,propositionsForCategoryPicker:gt,propositionsForSportPicker:bt,sportSummaries:kt,loading:ft,error:ht,step:_e,selectedGame:et,selections:tt,placedEntry:nt,selectedPropositionIds:Mt,selectedPropositions:Ot,selectionValid:Ut,selectedRuleId:re,setSelectedRuleId:le,selectedRule:Gt,answeredCount:Dt,betAmount:q,setBetAmount:V,expectedCorrect:K,setExpectedCorrect:Z,selectedPropositionCount:ne,handlePropositionCountChange:Vt,upgradePropositionCount:Xt,winningCounts:X,payouts:J,overloadPayouts:ee,submitting:je,submitError:Ye,canSubmit:qt,gamePrice:Kt,userBalance:ae,hasSufficientBalance:$t,refreshUserBalance:ce,handleSubmit:en,selectGame:Qt,goToSportSelection:()=>lt(),goToConfirmation:at,goBack:st,reset:ct,clearSelectedGame:rt,toggleSelection:dt,quickPickGame:_t,selectedCategory:ue,setSelectedCategory:me,selectedSport:pe,setSelectedSport:fe,selectedEventId:he,sameGameMultiEvents:Ft,selectSameGameMultiEvent:Jt,apiUrl:t,apiKey:n,fetchImpl:r,getAuthHeaders:a,userId:d,disableQuickPick:M,renderTeamLogo:S,filterSport:N,initialSport:F,initialEventId:B,sportBaseKey:A,gameCategory:w,eventFilterActive:mt,eventFilterLabel:pt,clearEventFilter:ut,screenSize:E,displaySportName:tn,displayCategoryName:nn,maxPayouts:Ue??{},howToPlayMarkdown:Ge,onEntryPlaced:z,onCancel:P,onShare:D,onRecharge:O,demoEntries:y,demoGames:x,demoPropositions:g}),[R,G,W,Je,At,gt,bt,kt,ft,ht,_e,et,tt,nt,Mt,Ot,Ut,Dt,q,K,ne,re,Gt,X,J,ee,je,Ye,qt,Kt,t,n,d,ae,r,a,M,S,N,F,B,A,w,E,mt,pt,ut,ue,pe,he,Ft,Ue,Ge,z,P,D,O,T,y,x,g,tn,nn]);/* @__PURE__ */
|
|
97
|
-
return u(So.Provider,{value:
|
|
96
|
+
/* @__PURE__ */u("style",{children:".blade-game-track::-webkit-scrollbar{display:none}"})]})}var fo=class{constructor(e){this.inflight=/* @__PURE__ */new Map,this.cache=/* @__PURE__ */new Map,this.apiUrl=e.apiUrl,this.apiKey=e.apiKey,this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.getAuthHeaders=e.getAuthHeaders}invalidateCache(){this.cache.clear()}invalidate(){this.invalidateCache()}async request(e,t,n){const o=`${this.apiUrl}${e}`,r=(t?.method??"GET").toUpperCase(),l="GET"===r,a=l,i=!l&&!n?.idempotent,s=`${r} ${o}`;if(a){const e=this.cache.get(s);if(e&&Date.now()-e.at<5e3)return e.value;const t=this.inflight.get(s);if(t)return t}const c=a?this.cache.get(s):void 0,d=(async()=>{let e;try{const n=this.getAuthHeaders?await this.getAuthHeaders():void 0;e=await this.fetchImpl(o,{...t,headers:{"Content-Type":"application/json",...this.apiKey?{"X-API-Key":this.apiKey}:{},...n??{},...c?.etag?{"If-None-Match":c.etag}:{},...t?.headers}})}catch(r){throw r}if(304===e.status&&c)return a&&this.cache.set(s,{at:Date.now(),value:c.value,etag:c.etag}),c.value;if(!e.ok){let t=`API request failed: ${e.status} ${e.statusText}`;try{const n=await e.json();422===e.status&&n.detail?Array.isArray(n.detail)?t=n.detail.map(e=>`${Array.isArray(e.loc)?e.loc.join("."):"field"}: ${e.msg}`).join("; "):"string"==typeof n.detail?t=n.detail:"object"==typeof n.detail&&(t=JSON.stringify(n.detail)):n.message?t=n.message:n.error&&(t=n.error)}catch{}throw new Error(t)}const n=await e.json();if(a){const t=e.headers.get("ETag")??void 0;this.cache.set(s,{at:Date.now(),value:n,etag:t})}return n})();return a?(this.inflight.set(s,d),d.catch(()=>{}).finally(()=>{this.inflight.delete(s)})):i&&d.finally(()=>this.invalidateCache()).catch(()=>{}),d}async getGames(e){const t=new URLSearchParams;e?.category&&t.append("category",e.category),e?.jurisdiction&&t.append("jurisdiction",e.jurisdiction),e?.sport&&t.append("sport",e.sport);const n=t.toString(),o=n?`/games?${n}`:"/games",r=await this.request(o);return{games:r.payload||[],howToPlayMarkdown:r.how_to_play_markdown??null}}async getGame(e){return(await this.request(`/games/${e}`)).payload}async getPropositions(e){const t=new URLSearchParams;e?.event_id&&t.append("event_id",e.event_id),e?.sport&&t.append("sport",e.sport),e?.category&&t.append("category",e.category);const n=t.toString(),o=n?`/propositions?${n}`:"/propositions";return(await this.request(o)).payload||[]}async getSports(){return(await this.request("/propositions/sports")).sports||[]}async getPropositionsByIds(e){if(0===e.length)return[];const t=new URLSearchParams({ids:e.join(","),include_expired:"true"});return(await this.request(`/propositions?${t.toString()}`)).payload||[]}async getProposition(e){const t=(await this.request(`/propositions/${e}?include_expired=true`)).payload;return Array.isArray(t)?t.find(t=>t.id===e)??t[0]:t}async getGameEntries(e){const t=new URLSearchParams;null!=e?.user_id&&t.append("user_id",String(e.user_id)),null!=e?.pending&&t.append("pending",String(e.pending));const n=t.toString(),o=n?`/game-entries?${n}`:"/game-entries";return((await this.request(o)).payload||[]).map(e=>{const t={...e};return!t.created_at&&t.entry_date&&(t.created_at=t.entry_date),null!=t.stake&&null==t.bet_amount&&(t.bet_amount=Number(t.stake)),(!t.proposition_ids||0===t.proposition_ids.length)&&t.propositions&&t.propositions.length>0&&(t.proposition_ids=t.propositions.map(e=>e.id)),t})}async createGameEntry(e){const t=e.proposition_ids.map(t=>({proposition_id:t,user_prediction:e.selections?.[t]??"yes"})),n={game_id:e.game_id,user_id:e.user_id,propositions:t};null!=e.stake&&(n.stake=e.stake),null!=e.rule_id&&(n.rule_id=e.rule_id);const o=(await this.request("/game-entries",{method:"POST",body:JSON.stringify(n)})).payload;return null!=o.stake&&null==o.bet_amount&&(o.bet_amount=Number(o.stake)),o}async getPayoutsDue(e){const t=new URLSearchParams;null!=e?.game_id&&t.set("game_id",String(e.game_id)),null!=e?.limit&&t.set("limit",String(e.limit)),null!=e?.offset&&t.set("offset",String(e.offset));const n=t.toString();return await this.request(n?`/game-entries/payouts/due?${n}`:"/game-entries/payouts/due")}async getEntryPayout(e){return(await this.request(`/game-entries/${e}/payout`)).payload}async markEntryPaidOut(e){const t=await this.request(`/game-entries/${e}/payout/mark-paid-out`,{method:"POST",body:JSON.stringify({})});return this.invalidate(),t.payload}async updateGameEntryResult(e,t){return(await this.request(`/game-entries/${e}/result`,{method:"POST",body:JSON.stringify(t)})).payload}async getGameMaxPayout(e,t){const n=null!=t?`?bet_amount=${encodeURIComponent(String(t))}`:"";return(await this.request(`/games/${e}/max-payout${n}`)).payload}async getGamesMaxPayouts(e,t){if(0===e.length)return{};const n=new URLSearchParams({ids:e.join(",")});null!=t&&n.set("bet_amount",String(t));const o=await this.request(`/games/max-payouts?${n.toString()}`),r={};for(const[l,a]of Object.entries(o.payload||{}))r[Number(l)]=a;return r}async getEntryPreview(e,t){return(await this.request(`/games/${e}/preview`,{method:"POST",body:JSON.stringify(t)},{idempotent:!0})).payload}async evaluateRule(e,t){return(await this.request(`/games/${e}/evaluate-rule`,{method:"POST",body:JSON.stringify(t)},{idempotent:!0})).payload}async calculatePayout(e,t){return(await this.request(`/games/${e}/calculate-payout`,{method:"POST",body:JSON.stringify(t)},{idempotent:!0})).payload}};function ho(e,t,n){const[r,a]=c([]),[i,d]=c(null),[u,m]=c(!n?.skip),[p,f]=c(null),h=t?`${t.category||""}_${t.jurisdiction||""}_${t.sport||""}`:"",x=s(t);x.current=t;const g=n?.skip??!1,y=o(async()=>{if(!g)try{m(!0),f(null);const t=await e.getGames(x.current);a(t.games),d(t.howToPlayMarkdown)}catch(t){f(t instanceof Error?t.message:"Failed to fetch games")}finally{m(!1)}},[e,h,g]);return l(()=>{y()},[y]),{games:r,howToPlayMarkdown:i,loading:u,error:p,refetch:o(async()=>{e.invalidate(),await y()},[e,y])}}function xo(e,t,n){const[r,a]=c([]),[i,d]=c(!n?.skip),[u,m]=c(null),p=n?.skip??!1,f=t?`${t.event_id||""}_${t.sport||""}_${t.category||""}`:"",h=s(t);h.current=t;const x=o(async()=>{if(!p)try{d(!0),m(null);const t=await e.getPropositions(h.current);a(t)}catch(t){m(t instanceof Error?t.message:"Failed to fetch propositions")}finally{d(!1)}},[e,f,p]);return l(()=>{x()},[x]),{propositions:r,loading:i,error:u,refetch:o(async()=>{e.invalidate(),await x()},[e,x])}}function go(e,t){const[n,r]=c([]),[a,i]=c(!t?.skip),[s,d]=c(null),u=t?.skip??!1,m=o(async()=>{if(!u)try{i(!0),d(null),r(await e.getSports())}catch(t){d(t instanceof Error?t.message:"Failed to fetch sports")}finally{i(!1)}},[e,u]);return l(()=>{m()},[m]),{sports:n,loading:a,error:s,refetch:o(async()=>{e.invalidate(),await m()},[e,m])}}function yo(e,t,n){const[r,a]=c([]),[i,d]=c(!n?.skip),[u,m]=c(null),p=n?.skip??!1,f=t?`${t.user_id??""}_${t.pending??""}`:"",h=s(t);h.current=t;const x=o(async()=>{if(!p)try{d(!0),m(null);const t=await e.getGameEntries(h.current);a(t)}catch(t){m(t instanceof Error?t.message:"Failed to fetch entries")}finally{d(!1)}},[e,f,p]);return l(()=>{x()},[x]),{entries:r,loading:i,error:u,refetch:o(async()=>{e.invalidate(),await x()},[e,x])}}function bo(e,t,n){const[r,a]=c({}),[i,d]=c(!1),u=n?.skip??!1,m=n?.betAmount,p=s(/* @__PURE__ */new Set);return l(()=>{if(u||0===t.length)return;const n=t.filter(e=>!(e.id in r)&&!p.current.has(e.id));if(0===n.length)return;for(const e of n)p.current.add(e.id);let o=!1;return d(!0),(async()=>{try{const t=await e.getGamesMaxPayouts(n.map(e=>e.id),m);o||a(e=>({...e,...t}))}catch{}finally{o||d(!1)}})(),()=>{o=!0}},[e,t.map(e=>e.id).join(","),u,m]),{maxPayouts:r,loading:i,refetchGame:o(async(t,n)=>{if(!u)try{const o=await e.getGamesMaxPayouts([t],n??m);o[t]&&a(e=>({...e,[t]:o[t]}))}catch{}},[e,u,m])}}function wo(e){const[t,n]=c(!1),[o,r]=c(null),[l,a]=c(null);return{createEntry:async t=>{try{n(!0),r(null),await function(e=15e3){return"undefined"==typeof navigator||!1!==navigator.onLine||"undefined"==typeof window||"function"!=typeof window.addEventListener?Promise.resolve():new Promise(t=>{const n=()=>{window.removeEventListener("online",n),clearTimeout(o),t()},o=setTimeout(n,e);window.addEventListener("online",n)})}();const o=await e.createGameEntry(t);return a(o),o}catch(o){const e=o instanceof Error?o.message:"Failed to create entry";throw r(e),new Error(e)}finally{n(!1)}},loading:t,error:o,entry:l}}function ko(e){const[t,n]=c(e?"sport":"game"),[o,r]=c(null),[l,a]=c({}),[i,s]=c(null);return{step:t,selectedGame:o,selections:l,placedEntry:i,setGameOnly:e=>{r(e)},clearSelectedGame:()=>{r(null),a({})},goToSportSelection:e=>{e&&r(e),n("sport")},goToConfirmation:()=>{n("confirm")},goToSuccess:e=>{s(e),n("success")},goBack:()=>{"confirm"===t?n("sport"):"sport"===t&&(n("game"),r(null),a({}))},reset:()=>{n("game"),r(null),a({}),s(null)},toggleSelection:(e,t)=>{a(n=>{const o={...n};return o[e]===t?delete o[e]:o[e]=t,o})}}}function vo(e){const[t,n]=c(!1),[r,l]=c(null),[a,i]=c(null);return{evaluate:o(async(t,o)=>{try{n(!0),l(null);const r=await e.evaluateRule(t,o);return i(r),r}catch(r){const e=r instanceof Error?r.message:"Failed to evaluate rule";throw l(e),new Error(e)}finally{n(!1)}},[e]),loading:t,error:r,result:a}}function No(e){const[t,n]=c(!1),[r,l]=c(null),[a,i]=c(null);return{calculate:o(async(t,o)=>{try{n(!0),l(null);const r=await e.calculatePayout(t,o);return i(r),r}catch(r){const e=r instanceof Error?r.message:"Failed to calculate payout";throw l(e),new Error(e)}finally{n(!1)}},[e]),loading:t,error:r,result:a}}function Fo(e){const[t,n]=c(!1),[r,l]=c(null),[a,i]=c(null);return{preview:o(async(t,o)=>{try{n(!0),l(null);const r=await e.getEntryPreview(t,o);return i(r),r}catch(r){const e=r instanceof Error?r.message:"Failed to preview entry";throw l(e),new Error(e)}finally{n(!1)}},[e]),loading:t,error:r,result:a}}var Bo={today:"Today",weekend:"This weekend",next7:"Next 7 days"},Co=["today","weekend","next7"];function Ao(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}function Mo(e,t,n){if(!e)return!1;const o=new Date(e);if(Number.isNaN(o.getTime()))return!1;const{start:r,end:l}=function(e,t){const n=function(e){const t=new Date(e);return t.setHours(0,0,0,0),t}(t);switch(e){case"today":return{start:n,end:Ao(n,1)};case"weekend":{const e=n.getDay(),t=Ao(n,0===e?-1:(6-e)%7);return{start:t<n?n:t,end:Ao(t,2)}}case"next7":return{start:n,end:Ao(n,7)}}}(t,n);return o>=r&&o<l}var So=t(null),zo={};function Lo(){const e=r(So);if(!e)throw new Error("usePlaceEntry must be used within a <PlaceEntryProvider>");return e}function Po({apiUrl:t,apiKey:n,fetchImpl:r,getAuthHeaders:a,userId:d,getUserBalance:m,children:p,theme:f,colorScheme:h,demoGames:x,demoPropositions:g,demoEntries:y,demoMaxPayouts:b,gameCategory:w,jurisdiction:k,initialGameId:v,filterSport:N,initialSport:F,initialEventId:B,initialEventLabel:C,sportBaseKey:A,disableQuickPick:M=!1,renderTeamLogo:S,onEntryPlaced:z,onBeforeSubmit:L,onCancel:P,onShare:D,onRecharge:O,onClearEventFilter:T,screenSize:E="desktop",howToPlayMarkdown:j,sportDisplayNames:Y,categoryDisplayNames:H}){const R=se(f,h),G=ye(R),W=be(R),I=!(!x||!g),U=i(()=>new fo({apiUrl:t,apiKey:n,fetchImpl:r,getAuthHeaders:a}),[t,n,r,a]),[K,Z]=c(0),$=s(0),[q,V]=c(0),[X,Q]=c([]),[J,_]=c({}),[ee,te]=c({}),[ne,oe]=c(void 0),[re,le]=c(null),[ae,ie]=c(void 0),ce=e.useCallback(async()=>{if(m)try{const e=await m();"number"==typeof e&&Number.isFinite(e)&&ie(e)}catch(e){}},[m]);l(()=>{m?ce():ie(void 0)},[m,ce]);const de=s(null),[ue,me]=c(null),[pe,fe]=c(F??null),[he,xe]=c(B??null);l(()=>{F&&fe(F)},[F]),l(()=>{xe(B??null)},[B]);const[ge,we]=c(B),ke=s(!1);l(()=>{if(!B)return we(void 0),void(ke.current=!1);ke.current||we(B)},[B]);const ve=w??ue??void 0,Ne=N??F??void 0,Fe=Lt(pe??Ne,A),Be=Lt(Ne,A)??Ne,Ce=pe??void 0,{games:Ae,howToPlayMarkdown:Me,loading:Se,error:ze}=ho(U,{category:ve,jurisdiction:k,sport:Fe},{skip:I}),{propositions:Le,loading:Pe,error:De}=xo(U,{category:ve,sport:Be,event_id:ge},{skip:I}),{sports:Oe,loading:Te}=go(U,{skip:I}),{createEntry:Ee,loading:je,error:Ye}=wo(U),{preview:He}=Fo(U),Re=i(()=>Ht((I?x:Ae)??[],{category:ve,sport:Fe??Ce,sportBaseKey:A}),[I,x,Ae,ve,Fe,Ce,A]),Ge=j??Me??null,{maxPayouts:We,refetchGame:Ie}=bo(U,Re??[],{skip:I,betAmount:20}),Ue=I?b??zo:We,Ke=I?g:Le,Ze=N?(Ke??[]).filter(e=>e.sport===N):Ke,$e=i(()=>Nt(Ze??[]),[Ze]),qe=i(()=>ve||(1===$e.length?$e[0]:void 0),[ve,$e]),Ve=i(()=>{const e=Ze??[];return qe?Tt(e,{category:qe,sportBaseKey:A}):e},[Ze,qe,A]),Xe=i(()=>Ce?Tt(Ve,{sport:Ce,sportBaseKey:A}):Ve,[Ve,Ce,A]),Qe=i(()=>({category:qe,sport:Ce,sportBaseKey:A}),[qe,Ce,A]),Je=i(()=>{const e=(Re??[]).filter(e=>e.active);if(!qe&&$e.length>1)return[];const t=qe?Ht(e,Qe):e;return qe||Ce?function(e,t,n){return n?.category||n?.sport?e.filter(e=>Yt(e,t,n)):e}(t,Xe,Qe):t},[Re,Xe,Qe,qe,Ce,$e.length]),{step:_e,selectedGame:et,selections:tt,placedEntry:nt,setGameOnly:ot,clearSelectedGame:rt,goToSportSelection:lt,goToConfirmation:at,goToSuccess:it,goBack:st,reset:ct,toggleSelection:dt}=ko(v),ut=e.useCallback(()=>{ke.current=!0,we(void 0),ct(),T?.()},[ct,T]),mt=!!ge,pt=mt?C:void 0,ft=!I&&(Se||Pe||!!et&&Te),ht=I?null:et?ze||De:ze,xt=i(()=>et?Rt(Xe,et,A):Xe,[et,Xe,A]),gt=i(()=>et?xt:Ve,[et,xt,Ve]),bt=i(()=>Tt(et?xt:Ve,{category:qe}),[et,xt,Ve,qe]),kt=i(()=>{const e=new Set(bt.map(e=>e.sport).filter(Boolean));return Oe.filter(t=>e.has(t.key))},[Oe,bt]),vt=i(()=>Tt(xt,{category:qe,sport:pe}),[xt,qe,pe]),Ft=i(()=>{if(!et||!bn(et))return[];const{min:e}=Ct(et,ne),t=ne??e;return kn(vt).filter(e=>e.propositionCount>=t)},[et,ne,vt]),At=i(()=>bn(et)?Cn(vt,he):vt,[et,vt,he]),Mt=Object.keys(tt).map(Number),Dt=Mt.length,Ot=i(()=>vt.filter(e=>Mt.includes(e.id)),[vt,Mt]);l(()=>{w||ue||1===$e.length&&me($e[0])},[w,ue,$e]),l(()=>{if(!et)return;const e=xt,t=new Set(e.map(wt));let n=ue;n&&t.has(n)||(n=1===t.size?Array.from(t)[0]:null,n!==ue&&me(n));const o=n?e.filter(e=>wt(e)===n):e,r=new Set(function(e){const t=/* @__PURE__ */new Set;for(const n of e){const o=yt(n,e);"Other"!==o&&t.add(o)}return[...t]}(o)),l=et.allowed_sports;fe(e=>e&&r.has(e)?e:1===l?.length&&r.has(l[0])?l[0]:l&&l.length>1?e&&l.includes(e)&&r.has(e)?e:null:1===r.size?Array.from(r)[0]:null)},[et?.id,xt,ue]),l(()=>{et&&qe&&(Et(et,qe)||rt())},[et,qe,rt]),l(()=>{et&&(Yt(et,Xe,{category:qe,sport:pe,sportBaseKey:A})||rt())},[et,qe,pe,A,Xe,rt]),l(()=>{if(et){if(V(0),de.current){const{count:e}=de.current;return de.current=null,oe(e),void Z(e)}if(et.allowed_propositions&&et.allowed_propositions.length>0){const e=ne;null!=e&&et.allowed_propositions.includes(e)?Z(e):(oe(void 0),Z(0))}else oe(void 0),Z(et.num_propositions||et.max_propositions||0)}},[et]);const jt=(e,t,n)=>{const o=(Ue[e]?.top_payouts??[]).find(e=>e.proposition_count===t);if(!o)return 0;const r=o.bet_amount&&o.bet_amount>0?o.bet_amount:20;return r<=0?0:o.net_payout/r*n};l(()=>{if("sport"!==_e&&"confirm"!==_e||!et||I)return;const e=bn(et)&&he?At.length:Number.MAX_SAFE_INTEGER;let t;if(et.allowed_propositions&&et.allowed_propositions.length>0){const n=et.allowed_propositions?[...et.allowed_propositions].filter(t=>t<=e).sort((e,t)=>e-t):[];if(0===n.length)return void te({});const o=ne??n[0],r=n.filter(e=>e>o);if(0===r.length)return void te({});t=[o,...r]}else{const{min:n,max:o}=Ct(et),r=Math.min(o,e);if(n<=0||r<=n)return void te({});t=Array.from({length:r-n+1},(e,t)=>n+t)}const n={};for(const o of t)n[o]=jt(et.id,o,20);te(n)},[_e,et,ne,he,At.length,I,Ue]),l(()=>{if("confirm"!==_e||!et)return;const e=Mt.length;if(0===e)return;let t=!1;const n={};for(let r=0;r<=e;r++)n[r]=jt(et.id,r,q);_(n),e!==$.current?($.current=e,Z(e)):(K>e||K<=0&&e>0)&&Z(e);const o=q>0?q:Math.max(et.min_bet??20,.01);return(async()=>{try{const n=await He(et.id,{actual:K,predicted:K,total:e,bet_amount:o});if(t)return;Q(n.winning_counts)}catch{t||Q([])}})(),()=>{t=!0}},[_e,et,Mt.length,K,q,He,Ue]);const Gt=i(()=>{return t=re,(e=et)&&null!=t?e.permitted_rules?.find(e=>e.id===t)??null:null;var e,t},[et,re]),Wt=!bn(et)||An(Ot,he),It=et?Ct(et,void 0,Gt):null,Ut=!(!et||!Wt)&&(et.allowed_propositions&&et.allowed_propositions.length>0?null!=ne&&Dt===ne&&Bt(Dt,It?.min,It?.max):Bt(Dt,It?.min,It?.max)),Kt=et?.min_bet??0,Zt=Math.max(Kt,.01),$t=null==ae||q<=ae,qt=!je&&q>=Zt&&Ut&&$t,Vt=e=>{oe(e),Z(e);for(const t of Object.keys(tt))dt(Number(t),tt[Number(t)])},Xt=e=>{oe(e),Z(e)},Qt=e=>{xe(bn(e)?B??null:null),ot(e)},Jt=e=>{if(e!==he){for(const e of Object.keys(tt)){const t=Number(e);dt(t,tt[t])}xe(e)}},_t=(e,t)=>{de.current={count:t},ot(e),Ie(e.id);const n=e.allowed_sports??[];let o=null;pe&&n.some(e=>Pt(pe,e,A))?o=pe:1===n.length&&(o=n[0]),fe(o);for(const i of Object.keys(tt)){const e=Number(i);dt(e,tt[e])}let r=Tt(Rt(Ze??[],e,A),{category:qe,sport:o,sportBaseKey:A});const l=Math.max(0,Math.min(t,r.length)),a=[...r].sort(()=>Math.random()-.5).slice(0,l);for(const i of a)dt(i.id,Math.random()<.5?"yes":"no");at()},en=s(!1),tn=async()=>{if(et&&Ut&&!en.current){if(I){const e={id:Math.floor(1e4*Math.random()),game_id:et.id,user_id:d,proposition_ids:Mt,selections:tt,pending:!0,expected_correct:K,bet_amount:q};return z?.(e),it(e),void ce()}en.current=!0;try{L&&await L(q);const e=await Ee({game_id:et.id,user_id:d,proposition_ids:Mt,selections:tt,stake:q,rule_id:Gt?.id??null});z?.(e),it(e),ce()}catch(e){}finally{en.current=!1}}},nn=o(e=>Y?.[e]??kt.find(t=>t.key===e)?.label??St(e,void 0,A),[Y,kt,A]),on=o(e=>zt(e,H),[H]),rn=i(()=>({theme:R,bodyFont:G,headingFont:W,games:Je,propositions:At,propositionsForCategoryPicker:gt,propositionsForSportPicker:bt,sportSummaries:kt,loading:ft,error:ht,step:_e,selectedGame:et,selections:tt,placedEntry:nt,selectedPropositionIds:Mt,selectedPropositions:Ot,selectionValid:Ut,selectedRuleId:re,setSelectedRuleId:le,selectedRule:Gt,answeredCount:Dt,betAmount:q,setBetAmount:V,expectedCorrect:K,setExpectedCorrect:Z,selectedPropositionCount:ne,handlePropositionCountChange:Vt,upgradePropositionCount:Xt,winningCounts:X,payouts:J,overloadPayouts:ee,submitting:je,submitError:Ye,canSubmit:qt,gamePrice:Kt,userBalance:ae,hasSufficientBalance:$t,refreshUserBalance:ce,handleSubmit:tn,selectGame:Qt,goToSportSelection:()=>lt(),goToConfirmation:at,goBack:st,reset:ct,clearSelectedGame:rt,toggleSelection:dt,quickPickGame:_t,selectedCategory:ue,setSelectedCategory:me,selectedSport:pe,setSelectedSport:fe,selectedEventId:he,sameGameMultiEvents:Ft,selectSameGameMultiEvent:Jt,apiUrl:t,apiKey:n,fetchImpl:r,getAuthHeaders:a,userId:d,disableQuickPick:M,renderTeamLogo:S,filterSport:N,initialSport:F,initialEventId:B,sportBaseKey:A,gameCategory:w,eventFilterActive:mt,eventFilterLabel:pt,clearEventFilter:ut,screenSize:E,displaySportName:nn,displayCategoryName:on,maxPayouts:Ue??{},howToPlayMarkdown:Ge,onEntryPlaced:z,onCancel:P,onShare:D,onRecharge:O,demoEntries:y,demoGames:x,demoPropositions:g}),[R,G,W,Je,At,gt,bt,kt,ft,ht,_e,et,tt,nt,Mt,Ot,Ut,Dt,q,K,ne,re,Gt,X,J,ee,je,Ye,qt,Kt,t,n,d,ae,r,a,M,S,N,F,B,A,w,E,mt,pt,ut,ue,pe,he,Ft,Ue,Ge,z,P,D,O,T,y,x,g,nn,on]);/* @__PURE__ */
|
|
97
|
+
return u(So.Provider,{value:rn,children:p})}function Do({onPress:t,onDoubleClick:n,label:o="QUICKPICK",size:l="md",yesColor:a,noColor:i,theme:s}){const c=r(So),d=s??c?.theme??Z,p=fe(d),f=d.colors,h=a??O(d),x=i??T(d),g="sm"===l,y=g?p.space.xs:p.space.sm,b=g?6:8,w=g?p.fontSize.sm:p.fontSize.md,k=g?8.5:10,[v,N]=e.useState(!1),[F,B]=e.useState(!1);/* @__PURE__ */
|
|
98
98
|
return m("button",{type:"button",onClick:t,onDoubleClick:n,onMouseDown:()=>N(!0),onMouseUp:()=>N(!1),onMouseLeave:()=>N(!1),onFocus:e=>{e.target.matches(":focus-visible")&&B(!0)},onBlur:()=>B(!1),style:{appearance:"none",display:"inline-flex",flexDirection:"column",width:"100%",minWidth:92,padding:0,margin:0,border:`1px solid ${ce(f.border,.6)}`,background:"transparent",borderRadius:p.radius.sm,overflow:"hidden",cursor:"pointer",fontFamily:"inherit",transform:v?"scale(0.985)":"scale(1)",transition:`transform ${p.motion.durationFast}ms ${p.motion.easing}, box-shadow ${p.motion.durationFast}ms ${p.motion.easing}`,boxShadow:F?ge(d):"none",outline:"none",minHeight:p.touchTarget.min},children:[/* @__PURE__ */m("span",{style:{position:"relative",display:"flex",flex:1},children:[
|
|
99
99
|
/* @__PURE__ */u("span",{"aria-hidden":!0,style:{position:"absolute",inset:0,background:h,clipPath:"polygon(0 0, 53% 0, 47% 100%, 0 100%)"}}),
|
|
100
100
|
/* @__PURE__ */u("span",{"aria-hidden":!0,style:{position:"absolute",inset:0,background:x,clipPath:"polygon(53% 0, 100% 0, 100% 100%, 47% 100%)"}}),
|