import{S as e}from"./p-CV0Pyo1O.js";const t=(()=>{let e;return(...t)=>{e&&clearTimeout(e),e=setTimeout((()=>{e=0,(e=>{for(let t of e.keys()){const n=e.get(t).filter((e=>{const t=e.deref();return t&&(!("isConnected"in(n=t))||n.isConnected);var n}));e.set(t,n)}})(...t)}),2e3)}})(),n=e.forceUpdate,o=e.getRenderingRef,r=(e,t)=>{const n=e.indexOf(t);n>=0&&(e[n]=e[e.length-1],e.length--)},s=(e,s)=>{const c=((e,t=(e,t)=>e!==t)=>{const n=()=>{return("function"==typeof(t=e)?t():t)??{};var t},o=n();let s=new Map(Object.entries(o));const c="undefined"!=typeof Proxy,u=c?null:{},f={dispose:[],get:[],set:[],reset:[]},a=new Map,i=()=>{s=new Map(Object.entries(n())),c||b(),f.reset.forEach((e=>e()))},p=e=>(f.get.forEach((t=>t(e))),s.get(e)),l=(e,n)=>{const o=s.get(e);t(n,o,e)&&(s.set(e,n),c||y(e),f.set.forEach((t=>t(e,n,o))))},d=c?new Proxy(o,{get:(e,t)=>p(t),ownKeys:()=>Array.from(s.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(e,t)=>s.has(t),set:(e,t,n)=>(l(t,n),!0)}):(b(),u),g=(e,t)=>(f[e].push(t),()=>{r(f[e],t)});function y(e){!c&&u&&(Object.prototype.hasOwnProperty.call(u,e)||Object.defineProperty(u,e,{configurable:!0,enumerable:!0,get:()=>p(e),set(t){l(e,t)}}))}function b(){if(c||!u)return;const e=new Set(s.keys());for(const t of Object.keys(u))e.has(t)||delete u[t];for(const t of e)y(t)}return{state:d,get:p,set:l,on:g,onChange:(e,t)=>{const o=(n,o)=>{n===e&&t(o)},r=()=>{const o=n();t(o[e])},s=g("set",o),c=g("reset",r);return a.set(t,{setHandler:o,resetHandler:r,propName:e}),()=>{s(),c(),a.delete(t)}},use:(...e)=>{const t=e.reduce(((e,t)=>(t.set&&e.push(g("set",t.set)),t.get&&e.push(g("get",t.get)),t.reset&&e.push(g("reset",t.reset)),t.dispose&&e.push(g("dispose",t.dispose)),e)),[]);return()=>t.forEach((e=>e()))},dispose:()=>{f.dispose.forEach((e=>e())),i()},reset:i,forceUpdate:e=>{const t=s.get(e);f.set.forEach((n=>n(e,t,t)))},removeListener:(e,t)=>{const n=a.get(t);n&&n.propName===e&&(r(f.set,n.setHandler),r(f.reset,n.resetHandler),a.delete(t))}}})(e,s);return c.use((()=>{if("function"!=typeof o||"function"!=typeof n)return{};const e=n,r=o,s=new Map;return{dispose:()=>s.clear(),get:e=>{const t=r();t&&((e,t,n)=>{let o=e.get(t);o||(o=[],e.set(t,o)),o.some((e=>e.deref()===n))||o.push(new WeakRef(n))})(s,e,t)},set:n=>{const o=s.get(n);if(o){const t=o.filter((t=>{const n=t.deref();return!!n&&e(n)}));s.set(n,t)}t(s)},reset:()=>{s.forEach((t=>{t.forEach((t=>{const n=t.deref();n&&e(n)}))})),t(s)}}})()),c};export{s as c}