import{c as t}from"./zustand-CKShojR_.js";var e=(t,e,a)=>(s,r)=>({pastStates:a?.pastStates||[],futureStates:a?.futureStates||[],undo:(S=1)=>{if(r().pastStates.length){const i=a?.partialize?.(e())||e(),n=r().pastStates.splice(-S,S),p=n.shift();t(p),s({pastStates:r().pastStates,futureStates:r().futureStates.concat(a?.diff?.(i,p)||i,n.reverse())})}},redo:(S=1)=>{if(r().futureStates.length){const i=a?.partialize?.(e())||e(),n=r().futureStates.splice(-S,S),p=n.shift();t(p),s({pastStates:r().pastStates.concat(a?.diff?.(i,p)||i,n.reverse()),futureStates:r().futureStates})}},clear:()=>s({pastStates:[],futureStates:[]}),isTracking:!0,pause:()=>s({isTracking:!1}),resume:()=>s({isTracking:!0}),setOnSave:t=>s({_onSave:t}),_onSave:a?.onSave,_handleSet:(t,e,S,i)=>{a?.limit&&r().pastStates.length>=a?.limit&&r().pastStates.shift(),r()._onSave?.(t,S),s({pastStates:r().pastStates.concat(i||t),futureStates:[]})}}),a=(a,s)=>(r,S,i)=>{i.temporal=t(s?.wrapTemporal?.(e(r,S,s))||e(r,S,s));const n=s?.handleSet?.(i.temporal.getState()._handleSet)||i.temporal.getState()._handleSet,p=t=>{if(!i.temporal.getState().isTracking)return;const e=s?.partialize?.(S())||S(),a=s?.diff?.(t,e);null===a||s?.equality?.(t,e)||n(t,void 0,e,a)},u=i.setState;return i.setState=(...t)=>{const e=s?.partialize?.(S())||S();u(...t),p(e)},a((...t)=>{const e=s?.partialize?.(S())||S();r(...t),p(e)},S,i)};export{a as t};
