/* esm.sh - @assistant-ui/tap@0.9.24/dist/react-hooks/useMemo */
import{getCurrentResourceFiber as w}from"../core/helpers/execution-context.mjs";import{isDevelopment as f}from"../core/helpers/env.mjs";import{addCommit as u,addRollback as c}from"../core/helpers/root.mjs";import{throwHookOrderChanged as D,throwRenderedMoreHooks as a}from"./utils/hookErrors.mjs";import{depsShallowEqual as d}from"../hooks/utils/depsShallowEqual.mjs";var m=(s,r)=>{u(s,()=>{r.current=r.wip,r.currentDeps=r.wipDeps,r.wipIsRefreshing=!1,r.isDirty=!1})},I=(s,r)=>{let i=w(),p=i.currentIndex++,t=i.cells[p];if(t===void 0){i.isFirstRender||a();let o=s();return f&&i.devStrictMode&&s(),t={type:"memo",current:o,currentDeps:r,wip:o,wipDeps:r,wipIsRefreshing:!1,isDirty:!1},i.cells[p]=t,o}t.type!=="memo"&&D();let e=t;if(e.wipIsRefreshing&&!i.isRefreshing&&(e.wip=e.current,e.wipDeps=e.currentDeps,e.wipIsRefreshing=!1,e.isDirty=!1),!i.isRefreshing&&d(e.wipDeps,r))return e.isDirty&&m(i,e),e.wip;let n=s();return f&&i.devStrictMode&&s(),e.wip=n,e.wipDeps=r,e.wipIsRefreshing=i.isRefreshing,e.isDirty||(e.isDirty=!0,c(i.root,()=>{e.wip=e.current,e.wipDeps=e.currentDeps,e.wipIsRefreshing=!1,e.isDirty=!1})),m(i,e),n};export{I as useMemo};
//# sourceMappingURL=useMemo.mjs.map