import{f2 as d,J as F,f3 as E,p as h,W as T,m as f,dp as j,H as P,q as y,s as p,f4 as q,d$ as A,aA as v,au as g,f5 as x,av as I,dl as O}from"./index-ea7817a2.js";import{g as l,a as R}from"./file-utils-a5f053e8.js";const S={[d.READ_ONLY]:"read-only",[d.EDITABLE_BY_OWNERS]:"data owner edit",[d.EDITABLE]:"full edit"},L={[d.READ_ONLY]:"light",[d.EDITABLE_BY_OWNERS]:"default",[d.EDITABLE]:"label"},k=F(S),B={[E.FEATURESTORE]:"feature store"},D=o=>o.split("::")[0],C=o=>"featurestore",U=h.injectEndpoints({endpoints:o=>({getSharedFrom:o.query({query:e=>({url:`project/${e}/dataset?expand=users`}),transformResponse:T(P([],"items"),j(e=>e.shared&&e.name.includes("_featurestore")),f(e=>({...e,projectName:D(e.name)}))),keepUnusedDataFor:600,providesTags:y.providesList(p.ProjectTags.MultiStore)}),getArtifacts:o.query({query:({id:e,modelName:r,modelVersion:t})=>{const s=encodeURIComponent(`Models/${r}/${t}/Artifacts`);return{url:`project/${e}/dataset/${s}?action=listing&expand=inodes`}},transformResponse:e=>e.items??[],extraOptions:{skipError:!0},providesTags:y.providesList(p.ProjectTags.Artifacts)}),getArtifactVersion:o.query({query:({id:e,modelName:r,modelVersion:t,artifactVersion:s})=>{const a=encodeURIComponent(`Models/${r}/${t}/Artifacts/${s}`);return{url:`project/${e}/dataset/${a}?action=listing&expand=inodes`}},extraOptions:{skipError:!0},transformResponse:e=>{const r=e.items.map(a=>a.attributes),t=r.find(({name:a})=>a.startsWith("transformer-")),s=r.find(({name:a})=>a.startsWith("predictor-"));return{transformer:t==null?void 0:t.path,predictor:s==null?void 0:s.path}},providesTags:y.cacheByIdArgProperty(p.ProjectTags.Artifacts)}),getFileExplorerDataset:o.query({queryFn({id:e,path:r,fileType:t="DATASET",limit:s=1e3,skipError:a=!1},n,i,c){const u=t!==null?`&type=${t}`:"";return new O().rtkQuery({url:`project/${e}/dataset/${encodeURIComponent(r)}?action=listing&expand=inodes&offset=0&sort_by=name:asc&limit=${s}${u}`},n,{skipError:a})},providesTags:(e,r,t)=>[{id:q("/",t.path)||"root",type:p.ProjectTags.FileExplorer}],keepUnusedDataFor:600}),getFile:o.query({query:({id:e,path:r})=>({url:`/project/${e}/dataset/${encodeURIComponent(r)}?action=blob&expand=inodes&mode=head`}),extraOptions:{skipError:!0}}),getFileStat:o.query({query:({id:e,path:r})=>({url:`/project/${e}/dataset/${encodeURIComponent(r)}`,params:{action:"stat",expand:"inodes"}}),providesTags:(e,r,t)=>[{id:t.path||"root",type:p.ProjectTags.FileStat}]}),PostActionOnFile:o.mutation({query:({id:e,path:r,params:t})=>{const s=A.stringify(t),a=encodeURIComponent(r);return{url:`/project/${e}/dataset/${a}?${s}`,method:"post"}},invalidatesTags:(e,r,{params:t,path:s})=>{const{action:a,destination_path:n}=t;if(v("zip",a))return[];const c=l(n??s),u=a==="create"?R(s):l(s),m=g([c,u]),_=p.ProjectTags.FileExplorer;return m.map($=>({type:_,id:$}))}}),PostActionOnFiles:o.mutation({async queryFn({id:e,pathes:r,params:t},s,a,n){const i=r.map(({path:c,destination_path:u})=>{const m=A.stringify({...t,destination_path:u});return n({url:`/project/${e}/dataset/${encodeURIComponent(c)}?${m}`,method:"post"})});try{return await Promise.all(i),{data:void 0}}catch(c){return{error:c}}},invalidatesTags:(e,r,{pathes:t})=>{const s=T(x((n,{path:i,destination_path:c})=>I(n,[i,c]),[]),f(l),g)(t),a=p.ProjectTags.FileExplorer;return s.map(n=>({type:a,id:n}))}}),deleteFile:o.mutation({query:({id:e,path:r})=>({url:`/project/${e}/dataset/${encodeURIComponent(r)}`,method:"delete"}),invalidatesTags:(e,r,{path:t})=>{const s=l(t);return[{type:p.ProjectTags.FileExplorer,id:s}]}}),deleteFiles:o.mutation({async queryFn({id:e,pathes:r},t,s,a){const n=r.map(i=>a({url:`/project/${e}/dataset/${encodeURIComponent(i)}`,method:"delete"}));try{return await Promise.all(n),{data:void 0}}catch(i){return{error:i}}},invalidatesTags:(e,r,{pathes:t})=>{const s=g(t.map(l)),a=p.ProjectTags.FileExplorer;return s.map(n=>({type:a,id:n}))}})})}),{useGetSharedFromQuery:b,useGetArtifactsQuery:G,useGetArtifactVersionQuery:N,useGetFileExplorerDatasetQuery:W,useGetFileQuery:w,useGetFileStatQuery:Y,usePostActionOnFileMutation:V,usePostActionOnFilesMutation:z,useDeleteFileMutation:H,useDeleteFilesMutation:J,util:K,endpoints:X}=U;export{G as a,N as b,V as c,K as d,z as e,X as f,w as g,L as h,C as i,D as j,H as k,k as l,J as m,W as n,Y as o,S as p,B as s,b as u};
