import{cn as e,tr as t}from"./state-sIHsFpDu.js";import{As as n,Cc as r,It as i,Lt as a,Rt as o,Ss as s,Ts as c,dc as l,on as u,yc as d}from"./paths-Ci1iwL5Y.js";import{J as f,U as p}from"./debug-otxXY3j-.js";import{o as m,s as h}from"./log-DSV4Ht5l.js";import{Ca as g,Ta as _}from"./loadAgentsDir-C_wFhytF.js";import{d as v,m as y,p as b}from"./rcDebugLog-C42A0pX1.js";e(),u(),d(),p(),m(),_(),s(),v();function x(e){return t=>({...t,...typeof e.permission_mode==`string`?{toolPermissionContext:{...t.toolPermissionContext,mode:c(e.permission_mode)}}:{},...typeof e.is_ultraplan_mode==`boolean`?{isUltraplanMode:e.is_ultraplan_mode}:{}})}function S({newState:e,oldState:s}){let c=s.toolPermissionContext.mode,u=e.toolPermissionContext.mode;if(c!==u){let t=n(c),r=n(u);t!==r&&y({permission_mode:r,is_ultraplan_mode:r===`plan`&&e.isUltraplanMode&&!s.isUltraplanMode?!0:null}),b(u)}if(e.mainLoopModel!==s.mainLoopModel&&t(e.mainLoopModel),e.expandedView!==s.expandedView){let t=e.expandedView===`tasks`,n=e.expandedView===`teammates`;(l().showExpandedTodos!==t||l().showSpinnerTree!==n)&&r(e=>({...e,showExpandedTodos:t,showSpinnerTree:n}))}if(e.verbose!==s.verbose&&l().verbose!==e.verbose){let t=e.verbose;r(e=>({...e,verbose:t}))}if(process.env.USER_TYPE===`ant`&&e.tungstenPanelVisible!==s.tungstenPanelVisible&&e.tungstenPanelVisible!==void 0&&l().tungstenPanelVisible!==e.tungstenPanelVisible){let t=e.tungstenPanelVisible;r(e=>({...e,tungstenPanelVisible:t}))}if(e.settings!==s.settings)try{i(),a(),o(),e.settings.env!==s.settings.env&&g()}catch(e){h(f(e))}}export{S as n,x as t};