/* esm.sh - @assistant-ui/tap@0.9.24/dist/react-hooks/useSyncExternalStore */
import{getCurrentResourceFiber as m}from"../core/helpers/execution-context.mjs";import{isDevelopment as a}from"../core/helpers/env.mjs";import{useEffect as f}from"./useEffect.mjs";import{useRef as l}from"./useRef.mjs";import{useReducer as p}from"./useReducer.mjs";import{useEffectEvent as h}from"./useEffectEvent.mjs";var d=!1,j=(t,e,c=e)=>{let n=m().isNeverMounted,r=n?c():e();a&&!d&&(!n||c===e)&&(Object.is(r,e())||(d=!0,console.error("The result of getSnapshot should be cached to avoid an infinite loop")));let[,i]=p(s=>s+1,0),o=l(0),u=h(()=>{try{if(Object.is(r,e()))return o.current=0,!1}catch{}return!0});return f(()=>t(()=>{u()&&i()}),[t]),f(()=>{if(u()){if(++o.current>50)throw o.current=0,new Error("Maximum update depth exceeded. The result of getSnapshot should be cached to avoid an infinite loop.");i()}},[t,r,e]),r};export{j as useSyncExternalStore};
//# sourceMappingURL=useSyncExternalStore.mjs.map