import{t as e}from"./9bCTHkeS.js";function t(){return e(`/api/workspace`)}function n(t){return e(`/api/workspace`,{method:`PUT`,body:JSON.stringify(t)})}function r(){return e(`/api/workspace/mcp-config`)}function i(){return e(`/api/repos`)}function a(t,n,r){return e(`/api/repos`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t,display_name:n||void 0,description:r})})}function o(t,n,r){let i={};return n!==void 0&&n!==t&&(i.name=n),r!==void 0&&(i.display_name=r),e(`/api/repos/${encodeURIComponent(t)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)})}function s(t){return e(`/api/repos/${encodeURIComponent(t)}`,{method:`DELETE`})}function c(t,n,r){let i={path:n};return r!==void 0&&(i.display_name=r),e(`/api/repos/${encodeURIComponent(t)}/folders`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)})}function l(t,n,r,i){let a={from:n,to:r};return i!==void 0&&(a.display_name=i),e(`/api/repos/${encodeURIComponent(t)}/folders`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)})}function u(t,n,r,i){return e(`/api/repos/${encodeURIComponent(t)}/transfer-entities`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({entries:n,targetRepo:r,targetFolder:i})})}function d(t,n,r,i){return e(`/api/repos/${encodeURIComponent(t)}/transfer-folder`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sourceFolder:n,targetRepo:r,targetFolder:i})})}function f(t,n,r=!0){let i=new URLSearchParams({path:n});return r&&i.set(`recursive`,`true`),e(`/api/repos/${encodeURIComponent(t)}/folders?${i.toString()}`,{method:`DELETE`})}function p(t){return e(`/api/repos/${encodeURIComponent(t)}/entities?summary=true`)}function m(){return e(`/api/workspace/entities?summary=true`)}function h(t,n,r,i){return e(`/api/repos/${encodeURIComponent(t)}/entities/${encodeURIComponent(n)}/${encodeURIComponent(r)}`,void 0,i)}function g(t,n,r,i=20){return e(`/api/repos/${encodeURIComponent(t)}/entities/${encodeURIComponent(n)}/${encodeURIComponent(r)}/history?limit=${i}`)}function _(t,n,r,i){return e(`/api/repos/${encodeURIComponent(t)}/entities/${encodeURIComponent(n)}/${encodeURIComponent(r)}/restore`,{method:`POST`,body:JSON.stringify({commitHash:i})})}function v(t,n,r,i,a,o){return e(`/api/repos/${encodeURIComponent(t)}/entities`,{method:`POST`,body:JSON.stringify({entityType:n,entityId:r,data:i,content:a,folder_path:o})})}function y(t,n,r){return e(`/api/repos/${encodeURIComponent(t)}/entities/${encodeURIComponent(n)}/${encodeURIComponent(r)}`,{method:`DELETE`})}function b(t,n,r,i,a){let o={};return a?.baseBodyHash&&(o[`X-Studiograph-Base-Body-Hash`]=a.baseBodyHash),e(`/api/repos/${encodeURIComponent(t)}/entities/${encodeURIComponent(n)}/${encodeURIComponent(r)}`,{method:`PUT`,body:JSON.stringify(i),headers:o})}function x(t,n,r,i){return e(`/api/repos/${encodeURIComponent(t)}/change-type`,{method:`POST`,body:JSON.stringify({entityType:n,entityId:r,newType:i})})}function S(t,n,r,i){return e(`/api/repos/${encodeURIComponent(t)}/rename`,{method:`POST`,body:JSON.stringify({entityType:n,entityId:r,newId:i})})}function C(t,n,r,i,a,o){return e(`/api/repos/${encodeURIComponent(t)}/transfer`,{method:`POST`,body:JSON.stringify({entityType:n,entityId:r,targetRepo:i,mode:a,targetFolderPath:o})})}function w(){return e(`/api/home`)}function T(){return e(`/api/preferences`)}function E(t){return e(`/api/preferences`,{method:`PUT`,body:JSON.stringify(t)})}async function D(){let t=(await e(`/api/preferences/settings`)).sidebar_folder_order;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function O(t){return e(`/api/preferences/settings`,{method:`PATCH`,body:JSON.stringify({sidebar_folder_order:t})})}var k={selectedType:null,groupBy:null,sortKey:`name`,sortAsc:!0,filters:{version:1}};function A(t){return e(`/api/repos/${encodeURIComponent(t)}/commit`,{method:`POST`})}async function*j(e,t){let n=await fetch(`/api/capture/stream`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e,repo:t})});if(!n.ok||!n.body){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error??`Capture stream failed (${n.status})`)}let r=n.body.getReader(),i=new TextDecoder,a=``;for(;;){let{value:e,done:t}=await r.read();if(t)break;a+=i.decode(e,{stream:!0});let n;for(;(n=a.indexOf(`

`))!==-1;){let e=a.slice(0,n);a=a.slice(n+2);let t=e.split(`
`).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trim());if(t.length)try{yield JSON.parse(t.join(`
`))}catch{}}}}export{d as A,o as C,n as D,O as E,u as O,S,E as T,D as _,a,A as b,s as c,h as d,g as f,i as g,T as h,v as i,b as j,C as k,f as l,r as m,j as n,c as o,w as p,x as r,y as s,k as t,p as u,t as v,_ as w,l as x,m as y};