1import{d as i}from"./index-CIhbGVJX.js";import{C as p}from"./copaApiService-HhxEReRX.js";async function C(c,a){const{error:e}=await i.from("copa_predictions").upsert({user_id:c,champion:a.champion,match_results:a.matchResults,round32:a.round32,round16:a.round16,quarters:a.quarters,semis:a.semis},{onConflict:"user_id"});if(e)throw e}async function S(c){if(c.length===0)return[];const{data:a,error:e}=await i.from("copa_predictions").select("user_id, champion, match_results, round32, round16, quarters, semis, updated_at").in("user_id",c);if(e)throw e;return(a??[]).map(t=>({userId:t.user_id,champion:t.champion,matchResults:t.match_results??{},round32:t.round32??{},round16:t.round16??{},quarters:t.quarters??{},semis:t.semis??{},updatedAt:t.updated_at}))}async function q(c){if(c.length===0)return[];const{data:a,error:e}=await i.rpc("get_squad_copa_summary",{p_user_ids:c});if(e)throw e;return(a??[]).map(t=>({userId:t.user_id,champion:t.champion,predictedCount:t.predicted_count??0,correctCount:t.correct_count??0}))}function A(c,a){return c.map(e=>{let t=0,s=0;const m=e.matchResults?Object.keys(e.matchResults).length:0;for(const[h,l]of Object.entries(e.matchResults)){const f=Number(h),u=p.find(n=>n.id===f);if(!u)continue;const r=a.find(n=>n.home===u.home&&n.away===u.away);if(!r?.isFinished||r.homeScore===null||r.awayScore===null)continue;let o;r.homeScore>r.awayScore?o="H":r.homeScore<r.awayScore?o="A":o="D",s++,l===o&&t++}const d=s>0?Math.round(t/s*100):0;return{userId:e.userId,correct:t,total:s,accuracy:d,champion:e.champion,matchCount:m}})}export{A as calculatePredictionAccuracy,S as fetchCopaPredictions,q as fetchCopaPredictionsSummary,C as saveCopaPrediction};
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.