import{$n as e}from"./src-BOCweS1p.js";import{fs as t}from"./app-server-manager-signals-Yn0WSnoY.js";import{A as n,V as r,_ as i,g as a,h as o,lt as s,u as c}from"./vscode-api-DjORcpSo.js";import{t as l}from"./invalidate-queries-and-broadcast-CivBKbpC.js";import{s as u}from"./config-queries-Br8rhpJn.js";var d=`memories`;function f(e,t){return t||e.some(e=>e.name===`memories`&&e.enabled)}var p=`chronicle`,m=s(),h=100,g=[`experimental-features`,`list`];async function _(e){let n=[],r=null;do{let i=await t(`list-experimental-features`,{hostId:e,cursor:r,limit:h});n.push(...i.data),r=i.nextCursor??null}while(r!=null);return n}var v=r(o,e=>({queryKey:[...g,e],queryFn:async()=>{try{return await _(e)}catch(e){return a.error(`Failed to load experimental features`,{safe:{error:String(e)},sensitive:{}}),[]}},staleTime:c.ONE_MINUTE}));function y(r){let o=(0,m.c)(17),{hostId:s}=r,c=n(),d;o[0]===s?d=o[1]:(d=[...g,s],o[0]=s,o[1]=d);let f=d,p=l(),h;o[2]===s?h=o[3]:(h=async n=>{let{featureName:r,enabled:i}=n;return t(`batch-write-config-value`,{hostId:s,edits:[{keyPath:e(r),value:i,mergeStrategy:`upsert`}],filePath:null,expectedVersion:null})},o[2]=s,o[3]=h);let _,v;o[4]!==f||o[5]!==c?(_=e=>{let{featureName:t,enabled:n}=e,r=c.getQueryData(f);return r&&c.setQueryData(f,r.map(e=>e.name===t?{...e,enabled:n}:e)),{previousFeatures:r}},v=(e,t,n)=>{a.error(`Failed to update experimental feature`,{safe:{error:String(e)},sensitive:{}}),n?.previousFeatures&&c.setQueryData(f,n.previousFeatures)},o[4]=f,o[5]=c,o[6]=_,o[7]=v):(_=o[6],v=o[7]);let y;o[8]!==f||o[9]!==p||o[10]!==c?(y=async(e,t,n)=>{await Promise.all([c.invalidateQueries({queryKey:f}),n.featureName===`memories`?p(u):Promise.resolve()])},o[8]=f,o[9]=p,o[10]=c,o[11]=y):y=o[11];let b;return o[12]!==h||o[13]!==_||o[14]!==v||o[15]!==y?(b={mutationFn:h,onMutate:_,onError:v,onSettled:y},o[12]=h,o[13]=_,o[14]=v,o[15]=y,o[16]=b):b=o[16],i(b)}export{d as a,p as i,v as n,f as o,y as r,g as t};
//# sourceMappingURL=experimental-features-queries-DhyNRplU.js.map