import{Ct as e,D as t,F as n}from"#entry";var r=20,i=`nodePerformanceHistory`,a=n(`nodeRecommendation`,()=>{let n=e(new Map),a=t(`scoringWeights`,{latency:50,stability:30,successRate:20}),o=t(`excludedNodes`,[]),s=t(`autoSwitchToRecommended`,!1),c=t(`minTestInterval`,1),l=e({total:0,completed:0,current:null,isRunning:!1}),u=()=>{try{let e=localStorage.getItem(i);if(e){let t=JSON.parse(e);n.value=new Map(Object.entries(t))}}catch(e){console.warn(`Failed to load node performance data:`,e)}},d=()=>{try{let e=Object.fromEntries(n.value);localStorage.setItem(i,JSON.stringify(e))}catch(e){console.warn(`Failed to save node performance data:`,e)}};return u(),{performanceData:n,scoringWeights:a,excludedNodes:o,autoSwitchEnabled:s,minTestInterval:c,batchTestProgress:l,recordTestResult:(e,t,i)=>{let a=Date.now(),o=n.value.get(e),s={timestamp:a,latency:t,success:i};o?(o.history=[s,...o.history].slice(0,r),o.lastTestTime=a,o.score=null):n.value.set(e,{nodeName:e,history:[s],lastTestTime:a,score:null}),d()},recordBatchResults:e=>{let t=Date.now();for(let[i,a]of Object.entries(e)){let e=a>0,o={timestamp:t,latency:e?a:null,success:e},s=n.value.get(i);s?(s.history=[o,...s.history].slice(0,r),s.lastTestTime=t,s.score=null):n.value.set(i,{nodeName:i,history:[o],lastTestTime:t,score:null})}d()},getNodePerformance:e=>n.value.get(e),isExcluded:e=>o.value.includes(e),toggleExclusion:e=>{let t=o.value.indexOf(e);t>=0?o.value.splice(t,1):o.value.push(e)},clearAllData:()=>{n.value.clear(),localStorage.removeItem(i)},updateWeights:e=>{a.value={...a.value,...e}},loadFromStorage:u,saveToStorage:d}});export{a as t};