const i=window.xzdConfig||{},l=i.restUrl||"/wp-json/xzdbk-ai/v1",a=i.restNonce||"";async function s(e,n,t=null){const u=`${l}${n}`,o={"Content-Type":"application/json"};a&&(o["X-WP-Nonce"]=a);const c={method:e,headers:o,credentials:"same-origin"};t!==null&&e!=="GET"&&(c.body=JSON.stringify(t));try{return await(await fetch(u,c)).json()}catch(r){return window.__XZD_DEBUG__&&console.error(`[API] ${e} ${n} 失败:`,r),{success:!1,data:null,message:r.message||"网络错误",code:"network_error"}}}const p={baseUrl:l,get(e){return s("GET",e)},post(e,n){return s("POST",e,n)},put(e,n){return s("PUT",e,n)},delete(e){return s("DELETE",e)}};export{p as a};
