import{s as c}from"./service-Cm5JamJJ.js";import{y as d}from"./main.js";const l={serviceNameParam:"",groupNameParam:"",ignoreEmptyService:!0},S=d((e,n)=>({services:[],loading:!1,total:0,pageNo:1,pageSize:10,...l,currentService:null,detailLoading:!1,selectorTypes:[],error:null,fetchServices:async a=>{e({loading:!0,error:null});try{const{serviceNameParam:r,groupNameParam:o,ignoreEmptyService:s,pageNo:t,pageSize:p}=n(),i=(await c.listServices({namespaceId:a,serviceNameParam:r||void 0,groupNameParam:o||void 0,ignoreEmptyService:s,pageNo:t,pageSize:p})).data;e({services:i.pageItems||[],total:i.totalCount||0,loading:!1})}catch(r){e({loading:!1,error:r.response?.data?.message||"Failed to fetch services",services:[],total:0})}},setSearchParams:a=>{e(r=>({...r,...a,pageNo:1}))},setPage:(a,r)=>{e(o=>({pageNo:a,pageSize:r??o.pageSize}))},resetSearch:()=>{e({...l,pageNo:1})},fetchServiceDetail:async(a,r,o)=>{e({detailLoading:!0,error:null});try{const t=await c.getService({namespaceId:a,serviceName:r,groupName:o});e({currentService:t.data,detailLoading:!1})}catch(s){e({detailLoading:!1,error:s.response?.data?.message||"Failed to fetch service detail",currentService:null})}},deleteService:async(a,r,o)=>{try{return await c.deleteService({namespaceId:a,serviceName:r,groupName:o}),!0}catch(s){return e({error:s.response?.data?.message||"Failed to delete service"}),!1}},fetchSelectorTypes:async()=>{try{const r=await c.getSelectorTypes();e({selectorTypes:r.data||[]})}catch{e({selectorTypes:["none","label"]})}},clearCurrentService:()=>{e({currentService:null})},clearError:()=>{e({error:null})}}));export{S as u};
