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