@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
|
@@ -93,8 +93,8 @@ return T(z,{style:[Uo.gameCard,No,{width:K||void 0,flexGrow:0,flexShrink:0,borde
|
|
|
93
93
|
/* @__PURE__ */T(S,{style:{marginTop:8,fontFamily:F,fontSize:13,letterSpacing:-.52,lineHeight:13},children:[/* @__PURE__ */W(S,{style:{fontWeight:"800",color:w.primary},children:"YES"}),/* @__PURE__ */W(S,{style:{fontWeight:"600",color:Me(w.primary,.85)},children:"NO"})]}),
|
|
94
94
|
/* @__PURE__ */T(z,{style:{marginTop:2,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:6},children:[/* @__PURE__ */W(S,{style:{fontFamily:F,fontWeight:"600",fontSize:G?19:21,color:A,letterSpacing:-.19,lineHeight:1.2*(G?19:21),textAlign:"center",paddingHorizontal:4},children:I(e)}),/* @__PURE__ */W(wt,{variant:"icon",panel:ot(e),content:c||"Pick outcomes and land the payout for this game.",theme:b,title:I(e),label:`How to play ${I(e)}`,extra:/* @__PURE__ */W(Io,{tiers:v?g:[],modes:x,pydDividends:B,onPlayCount:d.length>1?t=>E(e,t):void 0,minBet:D,maxBet:M,colors:w,bodyFont:C,headingFont:F}),colors:w,bodyFont:C,headingFont:F})]}),s?/* @__PURE__ */W(S,{style:{marginTop:6,fontSize:13,lineHeight:17,fontWeight:"700",color:w.primary,textAlign:"center",fontFamily:C},children:s}):null,c?/* @__PURE__ */W(S,{style:{marginTop:8,fontSize:12.5,lineHeight:18,color:w.textMuted,textAlign:"center",fontFamily:C},children:c}):null,a.enabled&&/* @__PURE__ */W(z,{style:[Uo.jackpotBadge,{backgroundColor:`${w.warning}15`,marginTop:8}],children:/* @__PURE__ */T(S,{style:[Uo.jackpotBadgeText,{color:w.warning,fontFamily:C}],children:["★ ",a.progressive?a.amount>0?Zt(a.amount):a.limit>0?`Up to ${Zt(a.limit)}`:"Jackpot":Zt(a.amount)]})}),(u||h)&&/* @__PURE__ */T(z,{style:[Uo.tagsRow,{justifyContent:"center",marginTop:8}],children:[u&&e.category&&/* @__PURE__ */W(z,{style:[Uo.tag,{backgroundColor:w.backgroundAlt}],children:/* @__PURE__ */W(S,{style:[Uo.tagText,{color:oe(b),fontFamily:C}],children:e.category})}),u&&/* @__PURE__ */W(z,{style:[Uo.tag,{backgroundColor:w.backgroundAlt}],children:/* @__PURE__ */W(S,{style:[Uo.tagText,{color:oe(b),fontFamily:C}],children:e.rule})}),u&&e.lotto_type&&/* @__PURE__ */W(z,{style:[Uo.tag,{backgroundColor:w.backgroundAlt}],children:/* @__PURE__ */W(S,{style:[Uo.tagText,{color:oe(b),fontFamily:C}],children:e.lotto_type})}),h&&null!=e.tier&&/* @__PURE__ */W(z,{style:[Uo.tag,{backgroundColor:w.backgroundAlt}],children:/* @__PURE__ */T(S,{style:[Uo.tagText,{color:oe(b),fontFamily:C}],children:["Tier ",e.tier]})})]}),0===d.length&&/* @__PURE__ */W(z,{style:{marginTop:8,width:"100%"},children:/* @__PURE__ */W(lt,{theme:b,variant:"primary",size:"sm",onPress:()=>{n(e),p?.()},children:"Select game"})}),H?/* @__PURE__ */W(z,{style:{marginTop:"auto",width:"100%",paddingTop:12},children:/* @__PURE__ */W(S,{style:{fontSize:11,lineHeight:15,fontWeight:"600",color:w.text,textAlign:"center",fontFamily:C},children:H})}):null]},l)})}),J&&/* @__PURE__ */W(v,{children:[-1,1].map(e=>{const t=e<0?_>0:_<O.length-1;/* @__PURE__ */
|
|
95
95
|
return W(B,{accessibilityRole:"button",accessibilityLabel:e<0?"Previous game":"Next game",onPress:()=>te(_+e),disabled:!t,style:{position:"absolute",top:"38%",left:e<0?2:void 0,right:e>0?2:void 0,width:44,height:44,borderRadius:22,borderWidth:1,borderColor:w.border,backgroundColor:Me(w.background??"#fff",.94),alignItems:"center",justifyContent:"center",opacity:t?1:.3,zIndex:1,...re},children:/* @__PURE__ */W(S,{style:{fontSize:18,lineHeight:20,color:w.primary,fontFamily:C},children:e<0?"‹":"›"})},e)})})]}),O.length>0&&Q&&/* @__PURE__ */W(z,{style:{flexDirection:"row",justifyContent:"center",flexWrap:"wrap",paddingTop:4,paddingBottom:8},children:O.map((e,t)=>/* @__PURE__ */W(B,{accessibilityRole:"button",accessibilityLabel:`Go to ${I(e)}`,onPress:()=>te(t),style:{paddingVertical:18.5,paddingHorizontal:5,marginVertical:-18.5,alignItems:"center",justifyContent:"center"},children:/* @__PURE__ */W(z,{style:{width:t===_?22:7,height:7,borderRadius:999,backgroundColor:t===_?w.primary:Me(w.primary,.25)}})},e.id))}),O.length>0&&Q&&/* @__PURE__ */T(z,{style:{borderTopWidth:1,borderTopColor:w.border,paddingTop:10,marginTop:2},children:[/* @__PURE__ */W(S,{style:{fontSize:10,fontWeight:"700",textTransform:"uppercase",letterSpacing:1.6,color:w.textMuted,fontFamily:F,marginBottom:8},children:"All games"}),/* @__PURE__ */W(z,{style:{flexDirection:"row",flexWrap:"wrap",gap:4},children:O.map((e,t)=>{const n=wn(e);/* @__PURE__ */
|
|
96
|
-
return T(B,{accessibilityRole:"button",accessibilityState:{selected:t===_,disabled:!n},onPress:()=>(e=>{E(e,Oo(e,m?.[e.id]).maxLegCount)})(e),disabled:!n,style:{alignItems:"center",gap:4,paddingHorizontal:4,paddingVertical:6,borderRadius:16,borderWidth:1,borderColor:t===_?w.primary:"transparent",opacity:n?1:.5,width:Z},children:[/* @__PURE__ */W(Go,{iconUrl:qe(e),size:G?44:52,brandColor:w.primary,iconColor:w.primaryText,accentColor:L}),/* @__PURE__ */W(S,{numberOfLines:2,style:{fontSize:11,fontWeight:"700",lineHeight:13,textAlign:"center",letterSpacing:-.11,color:t===_?w.primary:A,fontFamily:F},children:I(e)})]},e.id)})})]})]})}var Uo=k.create({centerContainer:{alignItems:"center",justifyContent:"center",padding:32,gap:8},gameCard:{flexDirection:"column",alignItems:"center",borderWidth:1,borderRadius:24,paddingHorizontal:20,paddingTop:22,paddingBottom:20},jackpotBadge:{alignSelf:"center",flexDirection:"row",alignItems:"center",gap:2,paddingHorizontal:8,paddingVertical:2,borderRadius:999},jackpotBadgeText:{fontSize:10,fontWeight:"700"},tagsRow:{flexDirection:"row",flexWrap:"wrap",gap:4},tag:{paddingHorizontal:6,paddingVertical:2,borderRadius:4},tagText:{fontSize:12}}),Zo=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(),i="GET"===r,l=i,a=!i&&!n?.idempotent,c=`${r} ${o}`;if(l){const e=this.cache.get(c);if(e&&Date.now()-e.at<5e3)return e.value;const t=this.inflight.get(c);if(t)return t}const s=l?this.cache.get(c):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??{},...s?.etag?{"If-None-Match":s.etag}:{},...t?.headers}})}catch(r){throw r}if(304===e.status&&s)return l&&this.cache.set(c,{at:Date.now(),value:s.value,etag:s.etag}),s.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(l){const t=e.headers.get("ETag")??void 0;this.cache.set(c,{at:Date.now(),value:n,etag:t})}return n})();return l?(this.inflight.set(c,d),d.catch(()=>{}).finally(()=>{this.inflight.delete(c)})):a&&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[i,l]of Object.entries(o.payload||{}))r[Number(i)]=l;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 Ko(e,t,o){const[i,l]=c([]),[s,d]=c(null),[h,u]=c(!o?.skip),[f,g]=c(null),p=t?`${t.category||""}_${t.jurisdiction||""}_${t.sport||""}`:"",y=a(t);y.current=t;const m=o?.skip??!1,b=n(async()=>{if(!m)try{u(!0),g(null);const t=await e.getGames(y.current);l(t.games),d(t.howToPlayMarkdown)}catch(t){g(t instanceof Error?t.message:"Failed to fetch games")}finally{u(!1)}},[e,p,m]);return r(()=>{b()},[b]),{games:i,howToPlayMarkdown:s,loading:h,error:f,refetch:n(async()=>{e.invalidate(),await b()},[e,b])}}function qo(e,t,o){const[i,l]=c([]),[s,d]=c(!o?.skip),[h,u]=c(null),f=o?.skip??!1,g=t?`${t.event_id||""}_${t.sport||""}_${t.category||""}`:"",p=a(t);p.current=t;const y=n(async()=>{if(!f)try{d(!0),u(null);const t=await e.getPropositions(p.current);l(t)}catch(t){u(t instanceof Error?t.message:"Failed to fetch propositions")}finally{d(!1)}},[e,g,f]);return r(()=>{y()},[y]),{propositions:i,loading:s,error:h,refetch:n(async()=>{e.invalidate(),await y()},[e,y])}}function Xo(e,t){const[o,i]=c([]),[l,a]=c(!t?.skip),[s,d]=c(null),h=t?.skip??!1,u=n(async()=>{if(!h)try{a(!0),d(null),i(await e.getSports())}catch(t){d(t instanceof Error?t.message:"Failed to fetch sports")}finally{a(!1)}},[e,h]);return r(()=>{u()},[u]),{sports:o,loading:l,error:s,refetch:n(async()=>{e.invalidate(),await u()},[e,u])}}function Qo(e,t,o){const[i,l]=c([]),[s,d]=c(!o?.skip),[h,u]=c(null),f=o?.skip??!1,g=t?`${t.user_id??""}_${t.pending??""}`:"",p=a(t);p.current=t;const y=n(async()=>{if(!f)try{d(!0),u(null);const t=await e.getGameEntries(p.current);l(t)}catch(t){u(t instanceof Error?t.message:"Failed to fetch entries")}finally{d(!1)}},[e,g,f]);return r(()=>{y()},[y]),{entries:i,loading:s,error:h,refetch:n(async()=>{e.invalidate(),await y()},[e,y])}}function Jo(e,t,o){const[i,l]=c({}),[s,d]=c(!1),h=o?.skip??!1,u=o?.betAmount,f=a(/* @__PURE__ */new Set);return r(()=>{if(h||0===t.length)return;const n=t.filter(e=>!(e.id in i)&&!f.current.has(e.id));if(0===n.length)return;for(const e of n)f.current.add(e.id);let o=!1;return d(!0),(async()=>{try{const t=await e.getGamesMaxPayouts(n.map(e=>e.id),u);o||l(e=>({...e,...t}))}catch{}finally{o||d(!1)}})(),()=>{o=!0}},[e,t.map(e=>e.id).join(","),h,u]),{maxPayouts:i,loading:s,refetchGame:n(async(t,n)=>{if(!h)try{const o=await e.getGamesMaxPayouts([t],n??u);o[t]&&l(e=>({...e,[t]:o[t]}))}catch{}},[e,h,u])}}function $o(e){const[t,n]=c(!1),[o,r]=c(null),[i,l]=c(null);return{createEntry:async t=>{try{n(!0),r(null);const o=await e.createGameEntry(t);return l(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:i}}function _o(e){const[t,n]=c(e?"sport":"game"),[o,r]=c(null),[i,l]=c({}),[a,s]=c(null);return{step:t,selectedGame:o,selections:i,placedEntry:a,setGameOnly:e=>{r(e)},clearSelectedGame:()=>{r(null),l({})},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),l({}))},reset:()=>{n("game"),r(null),l({}),s(null)},toggleSelection:(e,t)=>{l(n=>{const o={...n};return o[e]===t?delete o[e]:o[e]=t,o})}}}function er(e){const[t,o]=c(!1),[r,i]=c(null),[l,a]=c(null);return{evaluate:n(async(t,n)=>{try{o(!0),i(null);const r=await e.evaluateRule(t,n);return a(r),r}catch(r){const e=r instanceof Error?r.message:"Failed to evaluate rule";throw i(e),new Error(e)}finally{o(!1)}},[e]),loading:t,error:r,result:l}}function tr(e){const[t,o]=c(!1),[r,i]=c(null),[l,a]=c(null);return{calculate:n(async(t,n)=>{try{o(!0),i(null);const r=await e.calculatePayout(t,n);return a(r),r}catch(r){const e=r instanceof Error?r.message:"Failed to calculate payout";throw i(e),new Error(e)}finally{o(!1)}},[e]),loading:t,error:r,result:l}}function nr(e){const[t,o]=c(!1),[r,i]=c(null),[l,a]=c(null);return{preview:n(async(t,n)=>{try{o(!0),i(null);const r=await e.getEntryPreview(t,n);return a(r),r}catch(r){const e=r instanceof Error?r.message:"Failed to preview entry";throw i(e),new Error(e)}finally{o(!1)}},[e]),loading:t,error:r,result:l}}var or=t(null),rr={};function ir(){const e=o(or);if(!e)throw new Error("usePlaceEntry must be used within a <PlaceEntryProvider>");return e}function lr({apiUrl:t,apiKey:o,fetchImpl:i,getAuthHeaders:s,userId:d,getUserBalance:h,children:u,theme:f,colorScheme:g,demoGames:p,demoPropositions:y,demoEntries:m,demoMaxPayouts:b,gameCategory:w,jurisdiction:x,initialGameId:k,filterSport:S,initialSport:C,initialEventId:B,initialEventLabel:z,sportBaseKey:F,disableQuickPick:v=!1,renderTeamLogo:T,onEntryPlaced:A,onBeforeSubmit:R,onCancel:L,onShare:D,onRecharge:M,onClearEventFilter:P,screenSize:H="desktop",howToPlayMarkdown:O,sportDisplayNames:I,categoryDisplayNames:E}){const j=De(f,g),N=Ne(j),G=Ge(j),Y=!(!p||!y),V=l(()=>new Zo({apiUrl:t,apiKey:o,fetchImpl:i,getAuthHeaders:s}),[t,o,i,s]),[U,Z]=c(0),K=a(0),[q,X]=c(0),[Q,J]=c([]),[$,_]=c({}),[ee,te]=c({}),[ne,oe]=c(void 0),[re,ie]=c(null),[le,ae]=c(void 0),ce=e.useCallback(async()=>{if(h)try{const e=await h();"number"==typeof e&&Number.isFinite(e)&&ae(e)}catch(e){}},[h]);r(()=>{h?ce():ae(void 0)},[h,ce]);const se=a(null),[de,he]=c(null),[ue,fe]=c(C??null),[ge,pe]=c(B??null);r(()=>{C&&fe(C)},[C]),r(()=>{pe(B??null)},[B]);const[ye,me]=c(B),be=a(!1);r(()=>{if(!B)return me(void 0),void(be.current=!1);be.current||me(B)},[B]);const we=w??de??void 0,xe=S??C??void 0,ke=sn(ue??xe,F),Se=sn(xe,F)??xe,Ce=ue??void 0,{games:Be,howToPlayMarkdown:ze,loading:Fe,error:ve}=Ko(V,{category:we,jurisdiction:x,sport:ke},{skip:Y}),{propositions:We,loading:Te,error:Ae}=qo(V,{category:we,sport:Se,event_id:ye},{skip:Y}),{sports:Re,loading:Le}=Xo(V,{skip:Y}),{createEntry:Me,loading:Pe,error:He}=$o(V),{preview:Oe}=nr(V),Ie=l(()=>mn((Y?p:Be)??[],{category:we,sport:ke??Ce,sportBaseKey:F}),[Y,p,Be,we,ke,Ce,F]),Ee=O??ze??null,{maxPayouts:je,refetchGame:Ye}=Jo(V,Ie??[],{skip:Y,betAmount:20}),Ve=Y?b??rr:je,Ue=Y?y:We,Ze=S?(Ue??[]).filter(e=>e.sport===S):Ue,Ke=l(()=>en(Ze??[]),[Ze]),qe=l(()=>we||(1===Ke.length?Ke[0]:void 0),[we,Ke]),Xe=l(()=>{const e=Ze??[];return qe?fn(e,{category:qe,sportBaseKey:F}):e},[Ze,qe,F]),Qe=l(()=>Ce?fn(Xe,{sport:Ce,sportBaseKey:F}):Xe,[Xe,Ce,F]),Je=l(()=>({category:qe,sport:Ce,sportBaseKey:F}),[qe,Ce,F]),$e=l(()=>{const e=(Ie??[]).filter(e=>e.active);if(!qe&&Ke.length>1)return[];const t=qe?mn(e,Je):e;return qe||Ce?function(e,t,n){return n?.category||n?.sport?e.filter(e=>yn(e,t,n)):e}(t,Qe,Je):t},[Ie,Qe,Je,qe,Ce,Ke.length]),{step:_e,selectedGame:et,selections:tt,placedEntry:nt,setGameOnly:ot,clearSelectedGame:rt,goToSportSelection:it,goToConfirmation:lt,goToSuccess:at,goBack:ct,reset:st,toggleSelection:dt}=_o(k),ht=e.useCallback(()=>{be.current=!0,me(void 0),st(),P?.()},[st,P]),ut=!!ye,ft=ut?z:void 0,gt=!Y&&(et?Fe||Te||Le:Fe),pt=Y?null:et?ve||Ae:ve,yt=l(()=>et?bn(Qe,et,F):Qe,[et,Qe,F]),mt=l(()=>et?yt:Xe,[et,yt,Xe]),bt=l(()=>fn(et?yt:Xe,{category:qe}),[et,yt,Xe,qe]),wt=l(()=>{const e=new Set(bt.map(e=>e.sport).filter(Boolean));return Re.filter(t=>e.has(t.key))},[Re,bt]),xt=l(()=>fn(yt,{category:qe,sport:ue}),[yt,qe,ue]),kt=l(()=>{if(!et||!qn(et))return[];const{min:e}=on(et,ne),t=ne??e;return Qn(xt).filter(e=>e.propositionCount>=t)},[et,ne,xt]),St=l(()=>qn(et)?to(xt,ge):xt,[et,xt,ge]),Ct=Object.keys(tt).map(Number),Bt=Ct.length,zt=l(()=>xt.filter(e=>Ct.includes(e.id)),[xt,Ct]);r(()=>{w||de||1===Ke.length&&he(Ke[0])},[w,de,Ke]),r(()=>{if(!et)return;const e=yt,t=new Set(e.map(Jt));let n=de;n&&t.has(n)||(n=1===t.size?Array.from(t)[0]:null,n!==de&&he(n));const o=n?e.filter(e=>Jt(e)===n):e,r=new Set(function(e){const t=/* @__PURE__ */new Set;for(const n of e){const o=Xt(n,e);"Other"!==o&&t.add(o)}return[...t]}(o)),i=et.allowed_sports;fe(e=>e&&r.has(e)?e:1===i?.length&&r.has(i[0])?i[0]:i&&i.length>1?e&&i.includes(e)&&r.has(e)?e:null:1===r.size?Array.from(r)[0]:null)},[et?.id,yt,de]),r(()=>{et&&qe&&(gn(et,qe)||rt())},[et,qe,rt]),r(()=>{et&&(yn(et,Qe,{category:qe,sport:ue,sportBaseKey:F})||rt())},[et,qe,ue,F,Qe,rt]),r(()=>{if(et){if(X(0),se.current){const{count:e}=se.current;return se.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 Ft=(e,t,n)=>{const o=(Ve[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};r(()=>{if("sport"!==_e&&"confirm"!==_e||!et||Y)return;const e=qn(et)&&ge?St.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}=on(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]=Ft(et.id,o,20);te(n)},[_e,et,ne,ge,St.length,Y,Ve]),r(()=>{if("confirm"!==_e||!et)return;const e=Ct.length;if(0===e)return;let t=!1;const n={};for(let r=0;r<=e;r++)n[r]=Ft(et.id,r,q);_(n),e!==K.current?(K.current=e,Z(e)):(U>e||U<=0&&e>0)&&Z(e);const o=q>0?q:Math.max(et.min_bet??20,.01);return(async()=>{try{const n=await Oe(et.id,{actual:U,predicted:U,total:e,bet_amount:o});if(t)return;J(n.winning_counts)}catch{t||J([])}})(),()=>{t=!0}},[_e,et,Ct.length,U,q,Oe,Ve]);const vt=l(()=>{return t=re,(e=et)&&null!=t?e.permitted_rules?.find(e=>e.id===t)??null:null;var e,t},[et,re]),Wt=!qn(et)||no(zt,ge),Tt=et?on(et,void 0,vt):null,At=!(!et||!Wt)&&(et.allowed_propositions&&et.allowed_propositions.length>0?null!=ne&&Bt===ne&&nn(Bt,Tt?.min,Tt?.max):nn(Bt,Tt?.min,Tt?.max)),Rt=et?.min_bet??0,Lt=Math.max(Rt,.01),Dt=null==le||q<=le,Mt=!Pe&&q>=Lt&&At&&Dt,Pt=e=>{oe(e),Z(e);for(const t of Object.keys(tt))dt(Number(t),tt[Number(t)])},Ht=e=>{oe(e),Z(e)},Ot=e=>{pe(qn(e)?B??null:null),ot(e)},It=e=>{if(e!==ge){for(const e of Object.keys(tt)){const t=Number(e);dt(t,tt[t])}pe(e)}},Et=(e,t)=>{se.current={count:t},ot(e),Ye(e.id);const n=e.allowed_sports??[];let o=null;ue&&n.some(e=>dn(ue,e,F))?o=ue:1===n.length&&(o=n[0]),fe(o);for(const a of Object.keys(tt)){const e=Number(a);dt(e,tt[e])}let r=fn(bn(Ze??[],e,F),{category:qe,sport:o,sportBaseKey:F});const i=Math.max(0,Math.min(t,r.length)),l=[...r].sort(()=>Math.random()-.5).slice(0,i);for(const a of l)dt(a.id,Math.random()<.5?"yes":"no");lt()},jt=async()=>{if(et&&At){if(Y){const e={id:Math.floor(1e4*Math.random()),game_id:et.id,user_id:d,proposition_ids:Ct,selections:tt,pending:!0,expected_correct:U,bet_amount:q};return A?.(e),at(e),void ce()}try{R&&await R(q);const e=await Me({game_id:et.id,user_id:d,proposition_ids:Ct,selections:tt,stake:q,rule_id:vt?.id??null});A?.(e),at(e),ce()}catch(e){}}},Nt=n(e=>I?.[e]??wt.find(t=>t.key===e)?.label??an(e,void 0,F),[I,wt,F]),Gt=n(e=>cn(e,E),[E]),Yt=l(()=>({theme:j,bodyFont:N,headingFont:G,games:$e,propositions:St,propositionsForCategoryPicker:mt,propositionsForSportPicker:bt,sportSummaries:wt,loading:gt,error:pt,step:_e,selectedGame:et,selections:tt,placedEntry:nt,selectedPropositionIds:Ct,selectedPropositions:zt,selectionValid:At,selectedRuleId:re,setSelectedRuleId:ie,selectedRule:vt,answeredCount:Bt,betAmount:q,setBetAmount:X,expectedCorrect:U,setExpectedCorrect:Z,selectedPropositionCount:ne,handlePropositionCountChange:Pt,upgradePropositionCount:Ht,winningCounts:Q,payouts:$,overloadPayouts:ee,submitting:Pe,submitError:He,canSubmit:Mt,gamePrice:Rt,userBalance:le,hasSufficientBalance:Dt,refreshUserBalance:ce,handleSubmit:jt,selectGame:Ot,goToSportSelection:it,goToConfirmation:lt,goBack:ct,reset:st,clearSelectedGame:rt,toggleSelection:dt,quickPickGame:Et,selectedCategory:de,setSelectedCategory:he,selectedSport:ue,setSelectedSport:fe,selectedEventId:ge,sameGameMultiEvents:kt,selectSameGameMultiEvent:It,apiUrl:t,apiKey:o,fetchImpl:i,getAuthHeaders:s,userId:d,disableQuickPick:v,renderTeamLogo:T,filterSport:S,initialSport:C,initialEventId:B,sportBaseKey:F,gameCategory:w,eventFilterActive:ut,eventFilterLabel:ft,clearEventFilter:ht,screenSize:H,displaySportName:Nt,displayCategoryName:Gt,maxPayouts:Ve??{},howToPlayMarkdown:Ee,onEntryPlaced:A,onCancel:L,onShare:D,onRecharge:M,demoEntries:m,demoGames:p,demoPropositions:y}),[j,N,G,$e,St,mt,bt,wt,gt,pt,_e,et,tt,nt,Ct,zt,At,Bt,q,U,ne,re,vt,Q,$,ee,Pe,He,Mt,Rt,t,o,d,le,i,s,v,T,S,C,B,F,w,H,ut,ft,ht,de,ue,ge,kt,Ve,Ee,A,L,D,M,P,m,p,y,Pt,Nt,Gt]);/* @__PURE__ */
|
|
97
|
-
return W(or.Provider,{value:
|
|
96
|
+
return T(B,{accessibilityRole:"button",accessibilityState:{selected:t===_,disabled:!n},onPress:()=>(e=>{E(e,Oo(e,m?.[e.id]).maxLegCount)})(e),disabled:!n,style:{alignItems:"center",gap:4,paddingHorizontal:4,paddingVertical:6,borderRadius:16,borderWidth:1,borderColor:t===_?w.primary:"transparent",opacity:n?1:.5,width:Z},children:[/* @__PURE__ */W(Go,{iconUrl:qe(e),size:G?44:52,brandColor:w.primary,iconColor:w.primaryText,accentColor:L}),/* @__PURE__ */W(S,{numberOfLines:2,style:{fontSize:11,fontWeight:"700",lineHeight:13,textAlign:"center",letterSpacing:-.11,color:t===_?w.primary:A,fontFamily:F},children:I(e)})]},e.id)})})]})]})}var Uo=k.create({centerContainer:{alignItems:"center",justifyContent:"center",padding:32,gap:8},gameCard:{flexDirection:"column",alignItems:"center",borderWidth:1,borderRadius:24,paddingHorizontal:20,paddingTop:22,paddingBottom:20},jackpotBadge:{alignSelf:"center",flexDirection:"row",alignItems:"center",gap:2,paddingHorizontal:8,paddingVertical:2,borderRadius:999},jackpotBadgeText:{fontSize:10,fontWeight:"700"},tagsRow:{flexDirection:"row",flexWrap:"wrap",gap:4},tag:{paddingHorizontal:6,paddingVertical:2,borderRadius:4},tagText:{fontSize:12}}),Zo=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(),i="GET"===r,l=i,a=!i&&!n?.idempotent,c=`${r} ${o}`;if(l){const e=this.cache.get(c);if(e&&Date.now()-e.at<5e3)return e.value;const t=this.inflight.get(c);if(t)return t}const s=l?this.cache.get(c):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??{},...s?.etag?{"If-None-Match":s.etag}:{},...t?.headers}})}catch(r){throw r}if(304===e.status&&s)return l&&this.cache.set(c,{at:Date.now(),value:s.value,etag:s.etag}),s.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(l){const t=e.headers.get("ETag")??void 0;this.cache.set(c,{at:Date.now(),value:n,etag:t})}return n})();return l?(this.inflight.set(c,d),d.catch(()=>{}).finally(()=>{this.inflight.delete(c)})):a&&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[i,l]of Object.entries(o.payload||{}))r[Number(i)]=l;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 Ko(e,t,o){const[i,l]=c([]),[s,d]=c(null),[h,u]=c(!o?.skip),[f,g]=c(null),p=t?`${t.category||""}_${t.jurisdiction||""}_${t.sport||""}`:"",y=a(t);y.current=t;const m=o?.skip??!1,b=n(async()=>{if(!m)try{u(!0),g(null);const t=await e.getGames(y.current);l(t.games),d(t.howToPlayMarkdown)}catch(t){g(t instanceof Error?t.message:"Failed to fetch games")}finally{u(!1)}},[e,p,m]);return r(()=>{b()},[b]),{games:i,howToPlayMarkdown:s,loading:h,error:f,refetch:n(async()=>{e.invalidate(),await b()},[e,b])}}function qo(e,t,o){const[i,l]=c([]),[s,d]=c(!o?.skip),[h,u]=c(null),f=o?.skip??!1,g=t?`${t.event_id||""}_${t.sport||""}_${t.category||""}`:"",p=a(t);p.current=t;const y=n(async()=>{if(!f)try{d(!0),u(null);const t=await e.getPropositions(p.current);l(t)}catch(t){u(t instanceof Error?t.message:"Failed to fetch propositions")}finally{d(!1)}},[e,g,f]);return r(()=>{y()},[y]),{propositions:i,loading:s,error:h,refetch:n(async()=>{e.invalidate(),await y()},[e,y])}}function Xo(e,t){const[o,i]=c([]),[l,a]=c(!t?.skip),[s,d]=c(null),h=t?.skip??!1,u=n(async()=>{if(!h)try{a(!0),d(null),i(await e.getSports())}catch(t){d(t instanceof Error?t.message:"Failed to fetch sports")}finally{a(!1)}},[e,h]);return r(()=>{u()},[u]),{sports:o,loading:l,error:s,refetch:n(async()=>{e.invalidate(),await u()},[e,u])}}function Qo(e,t,o){const[i,l]=c([]),[s,d]=c(!o?.skip),[h,u]=c(null),f=o?.skip??!1,g=t?`${t.user_id??""}_${t.pending??""}`:"",p=a(t);p.current=t;const y=n(async()=>{if(!f)try{d(!0),u(null);const t=await e.getGameEntries(p.current);l(t)}catch(t){u(t instanceof Error?t.message:"Failed to fetch entries")}finally{d(!1)}},[e,g,f]);return r(()=>{y()},[y]),{entries:i,loading:s,error:h,refetch:n(async()=>{e.invalidate(),await y()},[e,y])}}function Jo(e,t,o){const[i,l]=c({}),[s,d]=c(!1),h=o?.skip??!1,u=o?.betAmount,f=a(/* @__PURE__ */new Set);return r(()=>{if(h||0===t.length)return;const n=t.filter(e=>!(e.id in i)&&!f.current.has(e.id));if(0===n.length)return;for(const e of n)f.current.add(e.id);let o=!1;return d(!0),(async()=>{try{const t=await e.getGamesMaxPayouts(n.map(e=>e.id),u);o||l(e=>({...e,...t}))}catch{}finally{o||d(!1)}})(),()=>{o=!0}},[e,t.map(e=>e.id).join(","),h,u]),{maxPayouts:i,loading:s,refetchGame:n(async(t,n)=>{if(!h)try{const o=await e.getGamesMaxPayouts([t],n??u);o[t]&&l(e=>({...e,[t]:o[t]}))}catch{}},[e,h,u])}}function $o(e){const[t,n]=c(!1),[o,r]=c(null),[i,l]=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 l(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:i}}function _o(e){const[t,n]=c(e?"sport":"game"),[o,r]=c(null),[i,l]=c({}),[a,s]=c(null);return{step:t,selectedGame:o,selections:i,placedEntry:a,setGameOnly:e=>{r(e)},clearSelectedGame:()=>{r(null),l({})},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),l({}))},reset:()=>{n("game"),r(null),l({}),s(null)},toggleSelection:(e,t)=>{l(n=>{const o={...n};return o[e]===t?delete o[e]:o[e]=t,o})}}}function er(e){const[t,o]=c(!1),[r,i]=c(null),[l,a]=c(null);return{evaluate:n(async(t,n)=>{try{o(!0),i(null);const r=await e.evaluateRule(t,n);return a(r),r}catch(r){const e=r instanceof Error?r.message:"Failed to evaluate rule";throw i(e),new Error(e)}finally{o(!1)}},[e]),loading:t,error:r,result:l}}function tr(e){const[t,o]=c(!1),[r,i]=c(null),[l,a]=c(null);return{calculate:n(async(t,n)=>{try{o(!0),i(null);const r=await e.calculatePayout(t,n);return a(r),r}catch(r){const e=r instanceof Error?r.message:"Failed to calculate payout";throw i(e),new Error(e)}finally{o(!1)}},[e]),loading:t,error:r,result:l}}function nr(e){const[t,o]=c(!1),[r,i]=c(null),[l,a]=c(null);return{preview:n(async(t,n)=>{try{o(!0),i(null);const r=await e.getEntryPreview(t,n);return a(r),r}catch(r){const e=r instanceof Error?r.message:"Failed to preview entry";throw i(e),new Error(e)}finally{o(!1)}},[e]),loading:t,error:r,result:l}}var or=t(null),rr={};function ir(){const e=o(or);if(!e)throw new Error("usePlaceEntry must be used within a <PlaceEntryProvider>");return e}function lr({apiUrl:t,apiKey:o,fetchImpl:i,getAuthHeaders:s,userId:d,getUserBalance:h,children:u,theme:f,colorScheme:g,demoGames:p,demoPropositions:y,demoEntries:m,demoMaxPayouts:b,gameCategory:w,jurisdiction:x,initialGameId:k,filterSport:S,initialSport:C,initialEventId:B,initialEventLabel:z,sportBaseKey:F,disableQuickPick:v=!1,renderTeamLogo:T,onEntryPlaced:A,onBeforeSubmit:R,onCancel:L,onShare:D,onRecharge:M,onClearEventFilter:P,screenSize:H="desktop",howToPlayMarkdown:O,sportDisplayNames:I,categoryDisplayNames:E}){const j=De(f,g),N=Ne(j),G=Ge(j),Y=!(!p||!y),V=l(()=>new Zo({apiUrl:t,apiKey:o,fetchImpl:i,getAuthHeaders:s}),[t,o,i,s]),[U,Z]=c(0),K=a(0),[q,X]=c(0),[Q,J]=c([]),[$,_]=c({}),[ee,te]=c({}),[ne,oe]=c(void 0),[re,ie]=c(null),[le,ae]=c(void 0),ce=e.useCallback(async()=>{if(h)try{const e=await h();"number"==typeof e&&Number.isFinite(e)&&ae(e)}catch(e){}},[h]);r(()=>{h?ce():ae(void 0)},[h,ce]);const se=a(null),[de,he]=c(null),[ue,fe]=c(C??null),[ge,pe]=c(B??null);r(()=>{C&&fe(C)},[C]),r(()=>{pe(B??null)},[B]);const[ye,me]=c(B),be=a(!1);r(()=>{if(!B)return me(void 0),void(be.current=!1);be.current||me(B)},[B]);const we=w??de??void 0,xe=S??C??void 0,ke=sn(ue??xe,F),Se=sn(xe,F)??xe,Ce=ue??void 0,{games:Be,howToPlayMarkdown:ze,loading:Fe,error:ve}=Ko(V,{category:we,jurisdiction:x,sport:ke},{skip:Y}),{propositions:We,loading:Te,error:Ae}=qo(V,{category:we,sport:Se,event_id:ye},{skip:Y}),{sports:Re,loading:Le}=Xo(V,{skip:Y}),{createEntry:Me,loading:Pe,error:He}=$o(V),{preview:Oe}=nr(V),Ie=l(()=>mn((Y?p:Be)??[],{category:we,sport:ke??Ce,sportBaseKey:F}),[Y,p,Be,we,ke,Ce,F]),Ee=O??ze??null,{maxPayouts:je,refetchGame:Ye}=Jo(V,Ie??[],{skip:Y,betAmount:20}),Ve=Y?b??rr:je,Ue=Y?y:We,Ze=S?(Ue??[]).filter(e=>e.sport===S):Ue,Ke=l(()=>en(Ze??[]),[Ze]),qe=l(()=>we||(1===Ke.length?Ke[0]:void 0),[we,Ke]),Xe=l(()=>{const e=Ze??[];return qe?fn(e,{category:qe,sportBaseKey:F}):e},[Ze,qe,F]),Qe=l(()=>Ce?fn(Xe,{sport:Ce,sportBaseKey:F}):Xe,[Xe,Ce,F]),Je=l(()=>({category:qe,sport:Ce,sportBaseKey:F}),[qe,Ce,F]),$e=l(()=>{const e=(Ie??[]).filter(e=>e.active);if(!qe&&Ke.length>1)return[];const t=qe?mn(e,Je):e;return qe||Ce?function(e,t,n){return n?.category||n?.sport?e.filter(e=>yn(e,t,n)):e}(t,Qe,Je):t},[Ie,Qe,Je,qe,Ce,Ke.length]),{step:_e,selectedGame:et,selections:tt,placedEntry:nt,setGameOnly:ot,clearSelectedGame:rt,goToSportSelection:it,goToConfirmation:lt,goToSuccess:at,goBack:ct,reset:st,toggleSelection:dt}=_o(k),ht=e.useCallback(()=>{be.current=!0,me(void 0),st(),P?.()},[st,P]),ut=!!ye,ft=ut?z:void 0,gt=!Y&&(Fe||Te||!!et&&Le),pt=Y?null:et?ve||Ae:ve,yt=l(()=>et?bn(Qe,et,F):Qe,[et,Qe,F]),mt=l(()=>et?yt:Xe,[et,yt,Xe]),bt=l(()=>fn(et?yt:Xe,{category:qe}),[et,yt,Xe,qe]),wt=l(()=>{const e=new Set(bt.map(e=>e.sport).filter(Boolean));return Re.filter(t=>e.has(t.key))},[Re,bt]),xt=l(()=>fn(yt,{category:qe,sport:ue}),[yt,qe,ue]),kt=l(()=>{if(!et||!qn(et))return[];const{min:e}=on(et,ne),t=ne??e;return Qn(xt).filter(e=>e.propositionCount>=t)},[et,ne,xt]),St=l(()=>qn(et)?to(xt,ge):xt,[et,xt,ge]),Ct=Object.keys(tt).map(Number),Bt=Ct.length,zt=l(()=>xt.filter(e=>Ct.includes(e.id)),[xt,Ct]);r(()=>{w||de||1===Ke.length&&he(Ke[0])},[w,de,Ke]),r(()=>{if(!et)return;const e=yt,t=new Set(e.map(Jt));let n=de;n&&t.has(n)||(n=1===t.size?Array.from(t)[0]:null,n!==de&&he(n));const o=n?e.filter(e=>Jt(e)===n):e,r=new Set(function(e){const t=/* @__PURE__ */new Set;for(const n of e){const o=Xt(n,e);"Other"!==o&&t.add(o)}return[...t]}(o)),i=et.allowed_sports;fe(e=>e&&r.has(e)?e:1===i?.length&&r.has(i[0])?i[0]:i&&i.length>1?e&&i.includes(e)&&r.has(e)?e:null:1===r.size?Array.from(r)[0]:null)},[et?.id,yt,de]),r(()=>{et&&qe&&(gn(et,qe)||rt())},[et,qe,rt]),r(()=>{et&&(yn(et,Qe,{category:qe,sport:ue,sportBaseKey:F})||rt())},[et,qe,ue,F,Qe,rt]),r(()=>{if(et){if(X(0),se.current){const{count:e}=se.current;return se.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 Ft=(e,t,n)=>{const o=(Ve[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};r(()=>{if("sport"!==_e&&"confirm"!==_e||!et||Y)return;const e=qn(et)&&ge?St.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}=on(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]=Ft(et.id,o,20);te(n)},[_e,et,ne,ge,St.length,Y,Ve]),r(()=>{if("confirm"!==_e||!et)return;const e=Ct.length;if(0===e)return;let t=!1;const n={};for(let r=0;r<=e;r++)n[r]=Ft(et.id,r,q);_(n),e!==K.current?(K.current=e,Z(e)):(U>e||U<=0&&e>0)&&Z(e);const o=q>0?q:Math.max(et.min_bet??20,.01);return(async()=>{try{const n=await Oe(et.id,{actual:U,predicted:U,total:e,bet_amount:o});if(t)return;J(n.winning_counts)}catch{t||J([])}})(),()=>{t=!0}},[_e,et,Ct.length,U,q,Oe,Ve]);const vt=l(()=>{return t=re,(e=et)&&null!=t?e.permitted_rules?.find(e=>e.id===t)??null:null;var e,t},[et,re]),Wt=!qn(et)||no(zt,ge),Tt=et?on(et,void 0,vt):null,At=!(!et||!Wt)&&(et.allowed_propositions&&et.allowed_propositions.length>0?null!=ne&&Bt===ne&&nn(Bt,Tt?.min,Tt?.max):nn(Bt,Tt?.min,Tt?.max)),Rt=et?.min_bet??0,Lt=Math.max(Rt,.01),Dt=null==le||q<=le,Mt=!Pe&&q>=Lt&&At&&Dt,Pt=e=>{oe(e),Z(e);for(const t of Object.keys(tt))dt(Number(t),tt[Number(t)])},Ht=e=>{oe(e),Z(e)},Ot=e=>{pe(qn(e)?B??null:null),ot(e)},It=e=>{if(e!==ge){for(const e of Object.keys(tt)){const t=Number(e);dt(t,tt[t])}pe(e)}},Et=(e,t)=>{se.current={count:t},ot(e),Ye(e.id);const n=e.allowed_sports??[];let o=null;ue&&n.some(e=>dn(ue,e,F))?o=ue:1===n.length&&(o=n[0]),fe(o);for(const a of Object.keys(tt)){const e=Number(a);dt(e,tt[e])}let r=fn(bn(Ze??[],e,F),{category:qe,sport:o,sportBaseKey:F});const i=Math.max(0,Math.min(t,r.length)),l=[...r].sort(()=>Math.random()-.5).slice(0,i);for(const a of l)dt(a.id,Math.random()<.5?"yes":"no");lt()},jt=a(!1),Nt=async()=>{if(et&&At&&!jt.current){if(Y){const e={id:Math.floor(1e4*Math.random()),game_id:et.id,user_id:d,proposition_ids:Ct,selections:tt,pending:!0,expected_correct:U,bet_amount:q};return A?.(e),at(e),void ce()}jt.current=!0;try{R&&await R(q);const e=await Me({game_id:et.id,user_id:d,proposition_ids:Ct,selections:tt,stake:q,rule_id:vt?.id??null});A?.(e),at(e),ce()}catch(e){}finally{jt.current=!1}}},Gt=n(e=>I?.[e]??wt.find(t=>t.key===e)?.label??an(e,void 0,F),[I,wt,F]),Yt=n(e=>cn(e,E),[E]),Vt=l(()=>({theme:j,bodyFont:N,headingFont:G,games:$e,propositions:St,propositionsForCategoryPicker:mt,propositionsForSportPicker:bt,sportSummaries:wt,loading:gt,error:pt,step:_e,selectedGame:et,selections:tt,placedEntry:nt,selectedPropositionIds:Ct,selectedPropositions:zt,selectionValid:At,selectedRuleId:re,setSelectedRuleId:ie,selectedRule:vt,answeredCount:Bt,betAmount:q,setBetAmount:X,expectedCorrect:U,setExpectedCorrect:Z,selectedPropositionCount:ne,handlePropositionCountChange:Pt,upgradePropositionCount:Ht,winningCounts:Q,payouts:$,overloadPayouts:ee,submitting:Pe,submitError:He,canSubmit:Mt,gamePrice:Rt,userBalance:le,hasSufficientBalance:Dt,refreshUserBalance:ce,handleSubmit:Nt,selectGame:Ot,goToSportSelection:it,goToConfirmation:lt,goBack:ct,reset:st,clearSelectedGame:rt,toggleSelection:dt,quickPickGame:Et,selectedCategory:de,setSelectedCategory:he,selectedSport:ue,setSelectedSport:fe,selectedEventId:ge,sameGameMultiEvents:kt,selectSameGameMultiEvent:It,apiUrl:t,apiKey:o,fetchImpl:i,getAuthHeaders:s,userId:d,disableQuickPick:v,renderTeamLogo:T,filterSport:S,initialSport:C,initialEventId:B,sportBaseKey:F,gameCategory:w,eventFilterActive:ut,eventFilterLabel:ft,clearEventFilter:ht,screenSize:H,displaySportName:Gt,displayCategoryName:Yt,maxPayouts:Ve??{},howToPlayMarkdown:Ee,onEntryPlaced:A,onCancel:L,onShare:D,onRecharge:M,demoEntries:m,demoGames:p,demoPropositions:y}),[j,N,G,$e,St,mt,bt,wt,gt,pt,_e,et,tt,nt,Ct,zt,At,Bt,q,U,ne,re,vt,Q,$,ee,Pe,He,Mt,Rt,t,o,d,le,i,s,v,T,S,C,B,F,w,H,ut,ft,ht,de,ue,ge,kt,Ve,Ee,A,L,D,M,P,m,p,y,Pt,Gt,Yt]);/* @__PURE__ */
|
|
97
|
+
return W(or.Provider,{value:Vt,children:u})}function ar({onPress:e,onDoubleClick:t,label:n="QUICKPICK",size:r="md",yesColor:i,noColor:l,theme:c}){const s=o(or),d=c??s?.theme??me,h=Ee(d),u=d.colors,f=i??ie(d),g=l??le(d),p="sm"===r,y=p?h.space.xs:h.space.sm,m=p?6:8,b=p?h.fontSize.sm:h.fontSize.md,w=p?8.5:10,x=a(0);/* @__PURE__ */
|
|
98
98
|
return T(B,{onPress:()=>{if(e(),t){const e=Date.now();e-x.current<300?(x.current=0,t()):x.current=e}},activeOpacity:.8,accessibilityRole:"button",accessibilityLabel:n,style:[cr.container,{borderColor:Me(u.border,.6),borderRadius:h.radius.sm,minHeight:h.touchTarget.min}],children:[/* @__PURE__ */T(z,{style:cr.topRow,children:[
|
|
99
99
|
/* @__PURE__ */T(A,{style:k.absoluteFill,viewBox:"0 0 100 100",preserveAspectRatio:"none",children:[
|
|
100
100
|
/* @__PURE__ */W(O,{points:"0,0 53,0 47,100 0,100",fill:f}),
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simple-parlay/components",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.5",
|
|
4
4
|
"description": "UI components, hooks, and utilities for React and React Native",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/index.d.ts",
|