import{a as l}from"./index-DZ_Kha3d.js";const a=l.create({baseURL:"/api",timeout:3e4});a.interceptors.request.use(t=>{const n=localStorage.getItem("admin_token");return n&&(t.headers.Authorization=`Bearer ${n}`),t});a.interceptors.response.use(t=>t,t=>{var n,e,o;return((n=t.response)==null?void 0:n.status)===401&&(localStorage.removeItem("admin_token"),!window.location.pathname.startsWith("/admin/login")&&!((o=(e=t.config)==null?void 0:e.url)!=null&&o.includes("/admin/login"))&&(window.location.href="/admin/login")),Promise.reject(t)});async function h(t,n=1){const{data:e}=await a.post("/query",{q:t,page:n});return e}async function v(t,n){var r,c,d;const e=localStorage.getItem("admin_token"),o={"Content-Type":"application/json"};e&&(o.Authorization=`Bearer ${e}`);try{const s=await fetch("/api/query",{method:"POST",headers:o,body:JSON.stringify({q:t})});if(!s.ok)throw new Error(`HTTP ${s.status}`);const u=s.body.getReader(),g=new TextDecoder;let f="";for(;;){const{done:y,value:w}=await u.read();if(y)break;f+=g.decode(w,{stream:!0});const m=f.split(`
`);f=m.pop()||"";for(const p of m)if(p.trim())try{const i=JSON.parse(p);switch(i.type){case"searching":(r=n.onSearching)==null||r.call(n);break;case"saved":(c=n.onSaved)==null||c.call(n,i);break;case"stats":n.onStats(i);break;case"result":n.onResult(i.id,i.valid,i.message);break;case"complete":n.onComplete(i);break}}catch{}}}catch(s){(d=n.onError)==null||d.call(n,s)}}async function S(t){const{data:n}=await a.post("/save",t);return n}async function T(t){const{data:n}=await a.post("/video/save-to-cloud",t);return n}async function $(){const{data:t}=await a.get("/rankings/categorized");return t}async function x(t,n){const{data:e}=await a.post("/admin/login",{username:t,password:n});return e}async function P(){const{data:t}=await a.get("/admin/cloud-configs");return t}async function R(t){const{data:n}=await a.post("/admin/cloud-configs",t);return n}async function q(t){const{data:n}=await a.put(`/admin/cloud-configs/${t.id}`,t);return n}async function z(t,n,e){const{data:o}=await a.post(`/admin/cloud-configs/${t}/test`,{cookie:n,id:e});return o}async function A(t){await a.delete(`/admin/cloud-configs/${t}`)}async function N(t,n){const{data:e}=await a.put(`/admin/cloud-configs/${t}/primary`,{primary:n});return e}async function j(t){const n={};t&&(n.days=t);const{data:e}=await a.get("/admin/stats",{params:n});return e}async function B(t=1,n=20,e,o,r,c,d){const s={page:t,pageSize:n};e&&(s.startDate=e),o&&(s.endDate=o),r&&(s.status=r),c&&(s.sourceType=c),d&&(s.keyword=d);const{data:u}=await a.get("/admin/save-records",{params:s});return u}async function D(){const{data:t}=await a.get("/admin/notify/providers");return t}async function E(t,n,e){const{data:o}=await a.post("/admin/notify/test",{channelType:t,configId:n,params:e});return o}async function I(){const{data:t}=await a.get("/admin/system-configs");return t}async function L(t){await a.put("/admin/system-configs",{entries:t})}async function O(){const{data:t}=await a.get("/admin/cloud-types");return t}async function _(t,n){await a.put("/admin/cloud-types",{type:t,enabled:n})}async function J(t,n){const{data:e}=await a.post("/admin/change-password",{oldPassword:t,newPassword:n});return e}async function F(t,n){await a.put("/admin/system-configs",{entries:[{key:t,value:n}]})}async function H(t){const n=new FormData;n.append("image",t);const{data:e}=await a.post("/admin/upload-logo",n,{headers:{"Content-Type":"multipart/form-data"}});return e}async function U(){const{data:t}=await a.get("/site-config");return t}async function V(t){const{data:n}=await a.post("/admin/test-redis",{url:t});return n}async function W(t){const{data:n}=await a.post("/admin/test-external-service",t);return n}async function G(){const{data:t}=await a.get("/admin/db-status");return t}async function K(){const{data:t}=await a.post("/admin/cleanup/run");return t}async function M(){const{data:t}=await a.post("/admin/cleanup/empty-trash");return t}export{H as A,F as B,E as C,U as a,O as b,S as c,T as d,P as e,x as f,$ as g,j as h,B as i,I as j,z as k,N as l,R as m,A as n,L as o,M as p,h as q,K as r,v as s,_ as t,q as u,G as v,D as w,V as x,W as y,J as z};
