import{b4 as t}from"./index-D5GfLbIx.js";const s="/sl/projection/map-edit",n="/sl/projection/ai-config";async function a(e){const{data:o}=await e;if(!o?.success)throw new Error(o?.message??"request failed");return o.data}const m={createSite:e=>a(t.post(`${s}/objects/site`,e)),createTrack:(e,o)=>a(t.post(`${s}/objects/${e}`,o)),createImage:e=>a(t.post(`${s}/objects/image`,e)),createText:e=>a(t.post(`${s}/objects/text`,e)),createModel:e=>a(t.post(`${s}/objects/model`,e)),createCar:e=>a(t.post(`${s}/objects/car`,e)),deleteObject:(e,o)=>a(t.delete(`${s}/objects/${e}/${o}`)),batch:e=>a(t.post(`${s}/objects/batch`,{ops:e})),copyFieldsTo:(e,o,c,r)=>a(t.post(`${s}/objects/${e}/${o}/fields/copy-to`,{fieldNames:c,targets:r})),pick:()=>a(t.post(`${s}/pick`)),dashboardSummary:()=>a(t.get(`${s}/dashboard/summary`)),uploadAsset:(e,o)=>a(t.post(`${s}/assets/upload`,{filename:e,data:o},{headers:{"Content-Type":"multipart/form-data"}})),aiMapGenerate:e=>a(t.post(`${s}/ai/map-generate`,e)),projectSave:e=>a(t.post(`${s}/project/save`,{path:e??""})),projectLoad:e=>a(t.post(`${s}/project/load`,{path:e})),projectCurrent:()=>a(t.get(`${s}/project/current`)),projectBrowse:e=>a(t.get(`${s}/project/browse`,{params:e?{dir:e}:{}})),projectNativePickOpen:e=>a(t.post(`${s}/project/native-pick-open`,{initialDir:e??""})),projectNativePickSave:(e,o)=>a(t.post(`${s}/project/native-pick-save`,{initialDir:e??"",suggestedFileName:o??"project.current.json"})),sampleSitesAlongTrack:(e,o)=>a(t.post(`${s}/objects/track/${e}/sample-sites`,o)),getViewFilter:()=>a(t.get(`${s}/view-filter`)),setViewFilter:e=>a(t.post(`${s}/view-filter`,e))},d={get:()=>a(t.get(`${n}/`)),save:e=>a(t.post(`${n}/`,e))},$={list:()=>a(t.get(`${s}/maps`)),readContent:e=>t.get(`/maps/${encodeURIComponent(e)}/content`).then(o=>o.data),sceneTaskStatus:()=>a(t.get(`${s}/maps/scene-task-status`)),async save(e,o=!1){try{const{data:c}=await t.post(`${s}/maps/save`,{name:e,overwrite:o});return c?.success?{ok:!0,data:c.data}:{ok:!1,conflict:c?.code===409,message:c?.message??"保存失败"}}catch(c){const r=c,p=r.response?.data;if(r.response?.status===409||p?.code===409)return{ok:!1,conflict:!0,message:p?.message??"地图已存在"};throw c}},open:e=>a(t.post(`${s}/maps/open`,{name:e})),use:e=>a(t.post(`${s}/maps/use`,{name:e})),delete:e=>a(t.delete(`${s}/maps/${encodeURIComponent(e)}`)),rename:(e,o)=>a(t.post(`${s}/maps/rename`,{from:e,to:o})),async merge(e,o,c=!1){const{data:r}=await t.post(`${s}/maps/merge`,{sources:e,target:o,overwrite:c});return r?.success?{ok:!0,data:r.data}:{ok:!1,conflict:r?.code===409&&(r?.message??"").includes("已存在"),message:r?.message??"合并失败"}}};export{d as a,$ as b,m};
