import{u as c,b as s,c as o}from"./query-Bw69rE6b.js";import{b as a}from"./index-CoUu6FiM.js";const u=["pages","list"],r=e=>["pages","detail",e];function f(){return c({queryKey:u,queryFn:()=>a("/api/pages")})}const m=["pages","intent-templates"];function l(){return c({queryKey:m,queryFn:()=>a("/api/pages/intent-templates"),staleTime:5*60*1e3})}function q(e){return c({queryKey:r(e??""),queryFn:()=>a(`/api/pages/${encodeURIComponent(e??"")}`),enabled:!!e})}function K(){const e=s();return o({mutationFn:t=>a("/api/pages",{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{e.invalidateQueries({queryKey:u})}})}function S(e){const t=s();return o({mutationFn:()=>a(`/api/pages/${encodeURIComponent(e)}/generate`,{method:"POST"}),onSuccess:n=>{t.setQueryData(r(e),n),t.invalidateQueries({queryKey:u})}})}function P(e){const t=s();return o({mutationFn:n=>a(`/api/pages/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(n)}),onSuccess:n=>{t.setQueryData(r(e),n),t.invalidateQueries({queryKey:u})}})}function F(e){const t=s();return o({mutationFn:()=>a(`/api/pages/${encodeURIComponent(e)}`,{method:"DELETE"}),onSuccess:()=>{t.invalidateQueries({queryKey:u}),t.removeQueries({queryKey:r(e)})}})}function Q(e){const t=s();return o({mutationFn:async n=>{const p=new FormData;p.append("file",n);const i=await fetch(`/api/pages/${encodeURIComponent(e)}/sources`,{method:"POST",body:p});if(!i.ok){const y=await i.text();throw new Error(y||i.statusText)}return await i.json()},onSuccess:()=>{t.invalidateQueries({queryKey:r(e)})}})}export{F as a,K as b,l as c,S as d,q as e,P as f,Q as g,f as u};
