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