/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
import{Derived as t}from"./derived.js";const e=/* @__PURE__ */new WeakMap,n=/* @__PURE__ */new WeakMap,o={current:[]};let r=!1,s=0;const c=/* @__PURE__ */new Set,f=/* @__PURE__ */new Map;function a(r){const s=Array.from(r).sort((e,n)=>e instanceof t&&e.options.deps.includes(n)?1:n instanceof t&&n.options.deps.includes(e)?-1:0);for(const t of s){if(o.current.includes(t))continue;o.current.push(t),t.recompute();const r=n.get(t);if(r)for(const t of r){const n=e.get(t);n&&a(n)}}}function i(t){const e={prevVal:t.prevState,currentVal:t.state};for(const n of t.listeners)n(e)}function u(t){const e={prevVal:t.prevState,currentVal:t.state};for(const n of t.listeners)n(e)}function p(t){if(s>0&&!f.has(t)&&f.set(t,t.prevState),c.add(t),!(s>0||r))try{for(r=!0;c.size>0;){const t=Array.from(c);c.clear();for(const e of t){const t=f.get(e)??e.prevState;e.prevState=t,i(e)}for(const n of t){const t=e.get(n);t&&(o.current.push(n),a(t))}for(const n of t){const t=e.get(n);if(t)for(const e of t)u(e)}}}finally{r=!1,o.current=[],f.clear()}}function l(t){s++;try{t()}finally{if(s--,0===s){const t=c.values().next().value;t&&p(t)}}}export{o as __depsThatHaveWrittenThisTick,n as __derivedToStore,p as __flush,e as __storeToDerived,l as batch};