// @bun
var{defineProperty:P,getOwnPropertyNames:k,getOwnPropertyDescriptor:V}=Object,m=Object.prototype.hasOwnProperty;function b(z){return this[z]}var r=(z)=>{var G=(j??=new WeakMap).get(z),B;if(G)return G;if(G=P({},"__esModule",{value:!0}),z&&typeof z==="object"||typeof z==="function"){for(var H of k(z))if(!m.call(G,H))P(G,H,{get:b.bind(z,H),enumerable:!(B=V(z,H))||B.enumerable})}return j.set(z,G),G},j;var v=(z)=>z;function f(z,G){this[z]=v.bind(null,G)}var d=(z,G)=>{for(var B in G)P(z,B,{get:G[B],enumerable:!0,configurable:!0,set:f.bind(G,B)})};var p=(z,G)=>()=>(z&&(G=z(z=0)),G);var c=import.meta.require;var i={};d(i,{watchMultiple:()=>C,watchEffect:()=>R,watch:()=>y,unref:()=>D,toRefs:()=>x,throttledComputed:()=>w,stxWatchMultiple:()=>C,stxWatchEffect:()=>R,stxWatch:()=>y,stxUnref:()=>D,stxToRefs:()=>x,stxThrottledComputed:()=>w,stxShallowRef:()=>E,stxRef:()=>M,stxIsRef:()=>$,stxDebouncedComputed:()=>g,stxComputed:()=>S,shallowRef:()=>E,ref:()=>M,processWatchDirectives:()=>h,processComputedDirectives:()=>O,isRef:()=>$,default:()=>n,debouncedComputed:()=>g,computed:()=>S});function M(z){let G=z,B=new Set,H={get value(){if(Y){let J=I.get(H);if(!J)J=new Set,I.set(H,J);J.add(Y)}return G},set value(J){if(!Object.is(G,J)){G=J,B.forEach((K)=>K(J));let L=I.get(H);if(L)L.forEach((K)=>K())}},subscribe(J){return B.add(J),()=>B.delete(J)},peek(){return G}};return H}function $(z){return z!==null&&typeof z==="object"&&"value"in z&&"subscribe"in z&&"peek"in z}function D(z){return $(z)?z.value:z}function x(z){let G={};for(let B in z)if(Object.prototype.hasOwnProperty.call(z,B))G[B]=M(z[B]);return G}function E(z){return M(z)}function S(z){let G=typeof z==="function",B=G?z:z.get,H=G?void 0:z.set,J=G?Object.is:z.equals||Object.is,L,K=!0,Q=new Set,X=new Set,_=()=>{if(K=!0,X.size>0){let N=T.value;X.forEach((q)=>q(N))}};function Z(){Q.clear();let N=Y;Y=_,U.push(_);try{return B()}finally{U.pop(),Y=N}}let T={get value(){if(Y){let N=I.get(T);if(!N)N=new Set,I.set(T,N);N.add(Y)}if(K){let N=Z();if(!J(L,N))L=N;K=!1}return L},set value(N){if(H)H(N);else console.warn("Computed property is readonly")},subscribe(N){return X.add(N),()=>X.delete(N)},peek(){if(K)L=B(),K=!1;return L},invalidate(){K=!0},get dirty(){return K},get deps(){return Q}};return T}function y(z,G,B={}){let{immediate:H=!1,deep:J=!1,flush:L="pre",once:K=!1}=B,Q,X=!0,_=!1,Z=()=>{if($(z))return J?W(z.value):z.value;return z()},T=()=>{if(!X||_)return;let F=Z();if(Q!==void 0&&Object.is(Q,F)&&!J)return;let A=()=>{if(G(F,Q),Q=J?W(F):F,K)q()};if(L==="sync")A();else if(L==="post")queueMicrotask(A);else Promise.resolve().then(A)},N=null;if($(z))N=z.subscribe(()=>T());else N=S(z).subscribe(()=>T());if(H)Q=void 0,T();else Q=Z();let q=()=>{if(X=!1,N)N(),N=null};return q.pause=()=>{_=!0},q.resume=()=>{_=!1},q}function C(z,G,B={}){let{immediate:H=!1,once:J=!1}=B,L=z.map((T)=>$(T)?T.value:void 0),K=!0,Q=!1,X=()=>{if(!K||Q)return;let T=z.map((N)=>$(N)?N.value:void 0);if(G(T,L),L=[...T],J)Z()},_=z.map((T)=>{if($(T))return T.subscribe(()=>X());return()=>{}});if(H)X();let Z=()=>{K=!1,_.forEach((T)=>T())};return Z.pause=()=>{Q=!0},Z.resume=()=>{Q=!1},Z}function R(z,G={}){let{flush:B="pre"}=G,H,J=!0,L=!1,K=()=>{if(!J||L)return;if(H)H();let X=Y;Y=K,U.push(K);try{H=z()}finally{U.pop(),Y=X}};if(B==="sync")K();else if(B==="post")queueMicrotask(K);else Promise.resolve().then(K);let Q=()=>{if(J=!1,H)H()};return Q.pause=()=>{L=!0},Q.resume=()=>{L=!1},Q}function O(z,G={},B){let H=/@computed\s*\(\s*(\w+)\s*,\s*(.+?)\s*\)/gi;return z.replace(H,(J,L,K)=>{try{let X=Function(...Object.keys(G),`return ${K}`)(...Object.values(G));return G[L]=X,`<!-- computed: ${L} = ${X} -->`}catch(Q){return`<!-- computed error: ${L} - ${Q} -->`}})}function h(z,G={},B){let H=/@watch\s*\(\s*(\w+)\s*\)\s*([\s\S]*?)@endwatch/gi;return z.replace(H,(J,L,K)=>{return`
      <script data-watch="${`watch-${Math.random().toString(36).substring(2,9)}`}">
        (function() {
          // Watch implementation for ${L}
          const handler = ${K.trim()};
          if (window.__stxState && window.__stxState['${L}']) {
            window.__stxState['${L}'].subscribe(function(newValue) {
              handler(newValue);
            });
          }
        })();
      </script>
    `})}function W(z){if(z===null||typeof z!=="object")return z;if(Array.isArray(z))return z.map((B)=>W(B));if(z instanceof Date)return new Date(z.getTime());if(z instanceof Map){let B=new Map;return z.forEach((H,J)=>B.set(W(J),W(H))),B}if(z instanceof Set){let B=new Set;return z.forEach((H)=>B.add(W(H))),B}let G={};for(let B in z)if(Object.prototype.hasOwnProperty.call(z,B))G[B]=W(z[B]);return G}function g(z,G=100){let B=M(z()),H=null,J=()=>{if(H)clearTimeout(H);H=setTimeout(()=>{B.value=z()},G)};return S(z).subscribe(()=>J()),{get value(){return B.value},set value(K){console.warn("Debounced computed is readonly")},subscribe:B.subscribe,peek:B.peek,invalidate(){J()},get dirty(){return!1},get deps(){return new Set}}}function w(z,G=100){let B=M(z()),H=0,J=()=>{let K=Date.now();if(K-H>=G)H=K,B.value=z()};return S(z).subscribe(()=>J()),{get value(){return B.value},set value(K){console.warn("Throttled computed is readonly")},subscribe:B.subscribe,peek:B.peek,invalidate(){J()},get dirty(){return!1},get deps(){return new Set}}}var Y=null,U,I,n;var o=p(()=>{U=[],I=new WeakMap;n={ref:M,computed:S,watch:y,watchMultiple:C,watchEffect:R,isRef:$,unref:D,toRefs:x,shallowRef:E,debouncedComputed:g,throttledComputed:w,processComputedDirectives:O,processWatchDirectives:h}});o();export{C as watchMultiple,R as watchEffect,y as watch,D as unref,x as toRefs,w as throttledComputed,C as stxWatchMultiple,R as stxWatchEffect,y as stxWatch,D as stxUnref,x as stxToRefs,w as stxThrottledComputed,E as stxShallowRef,M as stxRef,$ as stxIsRef,g as stxDebouncedComputed,S as stxComputed,E as shallowRef,M as ref,h as processWatchDirectives,O as processComputedDirectives,$ as isRef,n as default,g as debouncedComputed,S as computed};
