import{n}from"./index-CsRk2AqG.js";const u=["https://kv-service.houlang.cloud","https://kv-service.wuyuan.dev"];function f(t){if(t==="classworkscloud")return[...u];const o=n("server.domain");return o?[o]:[]}async function p(t,o={}){const d=o.provider||n("server.provider"),i=o.onServerTried,a=typeof i=="function",v=f(d),r=[];let c=null;for(const s of v)try{r.push({url:s,status:"trying"}),a&&i({url:s,status:"trying",tried:[...r]});const e=await t(s);return r[r.length-1].status="success",a&&i({url:s,status:"success",tried:[...r]}),e}catch(e){c=e,r[r.length-1].status="failed",r[r.length-1].error=e.message||String(e),a&&i({url:s,status:"failed",error:e,tried:[...r]}),console.warn(`Server ${s} failed:`,e.message)}console.error("All servers failed. Tried:",r);const l=c||new Error("All servers failed");throw l.triedServers=r,l}function S(){return n("server.provider")==="classworkscloud"?u[0]:n("server.domain")||""}function h(){return n("server.provider")==="classworkscloud"}export{S as g,h as i,p as t};
