import{s as e}from"./chunk-Bj-mKKzh.js";import{kt as t}from"./src-BOCweS1p.js";import{$ as n,H as ee,W as r,fs as i}from"./app-server-manager-signals-Yn0WSnoY.js";import{n as a}from"./jsx-runtime-CiQ1k8xo.js";import{I as te,P as o,_ as s,lt as c}from"./vscode-api-DjORcpSo.js";import{c as ne,o as l,r as u}from"./statsig-BP9zNYqZ.js";import{t as re}from"./invalidate-queries-and-broadcast-CivBKbpC.js";import{s as ie,w as ae}from"./config-queries-Br8rhpJn.js";var oe=c(),d=e(a(),1),f=`personality`,p=`model_personality`,se=`default_personality`;function m(e){let a=(0,oe.c)(67),{conversationId:c,hostId:m}=e,h=c===void 0?null:c,g=l(`1444479692`),_=ne(),v=re(),y=te(n),b;a[0]!==m||a[1]!==y?(b=y.includes(m),a[0]=m,a[1]=y,a[2]=b):b=a[2];let x=b,{data:S,isLoading:C}=o(ae,m),w=o(ee,h),T=o(r,h),E=S?.config?.[f],D;a[3]===E?D=a[4]:(D=t(E),a[3]=E,a[4]=D);let O=D,k=S?.config?.[p],A;a[5]===k?A=a[6]:(A=t(k),a[5]=k,a[6]=A);let j=A,M;a[7]===S?M=a[8]:(M=S?.config!=null&&Object.prototype.hasOwnProperty.call(S.config,p),a[7]=S,a[8]=M);let N=M,P=!1,F;if(a[9]!==_||a[10]!==O||a[11]!==g||a[12]!==C||a[13]!==j){if(F=O??j,!g)F=null;else if(P=!C&&F==null,P){let e;a[16]===_?e=a[17]:(e=t(u(_,`1867347216`).get(se,null)),a[16]=_,a[17]=e),F=e??`friendly`}a[9]=_,a[10]=O,a[11]=g,a[12]=C,a[13]=j,a[14]=F,a[15]=P}else F=a[14],P=a[15];let I=F;h!=null&&w?.personality!==void 0?I=w.personality:h!=null&&T?.params.personality!=null&&(I=T.params.personality),g||(I=null);let L=(0,d.useRef)(null),R;a[18]===v?R=a[19]:(R=async()=>{await Promise.all([v(ie),v([`user-saved-config`])])},a[18]=v,a[19]=R);let z=R,B;a[20]!==m||a[21]!==x||a[22]!==S?.configWriteTarget?.expectedVersion||a[23]!==S?.configWriteTarget?.filePath?(B=async e=>{x&&await i(`batch-write-config-value`,{hostId:m,edits:[{keyPath:f,value:e,mergeStrategy:`upsert`}],filePath:S?.configWriteTarget?.filePath??null,expectedVersion:S?.configWriteTarget?.expectedVersion??null})},a[20]=m,a[21]=x,a[22]=S?.configWriteTarget?.expectedVersion,a[23]=S?.configWriteTarget?.filePath,a[24]=B):B=a[24];let V;a[25]!==z||a[26]!==B?(V={mutationFn:B,onSettled:z},a[25]=z,a[26]=B,a[27]=V):V=a[27];let H=s(V),U;a[28]!==O||a[29]!==N||a[30]!==m||a[31]!==x||a[32]!==j||a[33]!==S?.configWriteTarget?.expectedVersion||a[34]!==S?.configWriteTarget?.filePath?(U=async()=>{if(!x||!N)return;let e=[{keyPath:p,value:null,mergeStrategy:`replace`}];O==null&&j!=null&&e.unshift({keyPath:f,value:j,mergeStrategy:`upsert`}),await i(`batch-write-config-value`,{hostId:m,edits:e,filePath:S?.configWriteTarget?.filePath??null,expectedVersion:S?.configWriteTarget?.expectedVersion??null})},a[28]=O,a[29]=N,a[30]=m,a[31]=x,a[32]=j,a[33]=S?.configWriteTarget?.expectedVersion,a[34]=S?.configWriteTarget?.filePath,a[35]=U):U=a[35];let W;a[36]!==z||a[37]!==U?(W={mutationFn:U,onSettled:z},a[36]=z,a[37]=U,a[38]=W):W=a[38];let G=s(W),K,q;a[39]!==G||a[40]!==N||a[41]!==m||a[42]!==x?(K=()=>{!x||!N||L.current===m||(L.current=m,G.mutate())},q=[G,N,m,x],a[39]=G,a[40]=N,a[41]=m,a[42]=x,a[43]=K,a[44]=q):(K=a[43],q=a[44]),(0,d.useEffect)(K,q);let J;a[45]!==F||a[46]!==m||a[47]!==x||a[48]!==C?(J=()=>{C||!x||i(`set-personality`,{hostId:m,personality:F})},a[45]=F,a[46]=m,a[47]=x,a[48]=C,a[49]=J):J=a[49];let Y=(0,d.useEffectEvent)(J),X;a[50]===Y?X=a[51]:(X=()=>{Y()},a[50]=Y,a[51]=X);let Z;a[52]!==F||a[53]!==m||a[54]!==x||a[55]!==C||a[56]!==P?(Z=[m,x,C,F,P],a[52]=F,a[53]=m,a[54]=x,a[55]=C,a[56]=P,a[57]=Z):Z=a[57],(0,d.useEffect)(X,Z);let Q;a[58]!==h||a[59]!==m||a[60]!==x||a[61]!==H?(Q=e=>{x&&(Promise.all([i(`set-personality`,{hostId:m,personality:e}),...h==null?[]:[i(`update-thread-settings-for-next-turn`,{conversationId:h,threadSettings:{personality:e}})]]),H.mutate(e))},a[58]=h,a[59]=m,a[60]=x,a[61]=H,a[62]=Q):Q=a[62];let $;return a[63]!==g||a[64]!==I||a[65]!==Q?($={isPersonalityEnabled:g,personality:I,setPersonality:Q},a[63]=g,a[64]=I,a[65]=Q,a[66]=$):$=a[66],$}export{m as t};
//# sourceMappingURL=use-personality-Bbe1ncVk.js.map