// @bun
var{defineProperty:K,getOwnPropertyNames:N,getOwnPropertyDescriptor:O}=Object,P=Object.prototype.hasOwnProperty;function Q(b){return this[b]}var U=(b)=>{var k=(M??=new WeakMap).get(b),q;if(k)return k;if(k=K({},"__esModule",{value:!0}),b&&typeof b==="object"||typeof b==="function"){for(var z of N(b))if(!P.call(k,z))K(k,z,{get:Q.bind(b,z),enumerable:!(q=O(b,z))||q.enumerable})}return M.set(b,k),k},M;var R=(b)=>b;function T(b,k){this[b]=R.bind(null,k)}var V=(b,k)=>{for(var q in k)K(b,q,{get:k[q],enumerable:!0,configurable:!0,set:T.bind(k,q)})};var X=(b,k)=>()=>(b&&(k=b(b=0)),k);var Y=import.meta.require;function _(b=!1){let k=b,q=new Set,z=()=>q.forEach((E)=>E(k));return[{get value(){return k},subscribe(E){return q.add(E),()=>{q.delete(E)}}},()=>{k=!k,z()},(E)=>{if(E!==k)k=E,z()}]}function $(b=0,k={}){let{min:q=-1/0,max:z=1/0}=k,D=E(b,q,z),H=new Set,I=()=>H.forEach((G)=>G(D));function E(G,C,J){return Math.min(J,Math.max(C,G))}return{get count(){return D},inc(G=1){D=E(D+G,q,z),I()},dec(G=1){D=E(D-G,q,z),I()},set(G){D=E(G,q,z),I()},reset(){D=E(b,q,z),I()},subscribe(G){return H.add(G),()=>{H.delete(G)}}}}function j(b,k){if(typeof window>"u")return{remove:()=>{}};let q=(D)=>{let H=typeof b==="string"?document.querySelector(b):b;if(!H)return;if(H===D.target||H.contains(D.target))return;k(D)};document.addEventListener("pointerdown",q,!0);let z=()=>{document.removeEventListener("pointerdown",q,!0)};if(typeof globalThis.onDestroy==="function")globalThis.onDestroy(z);return{remove:z}}function w(b){if(typeof window>"u")return{get isFocused(){return!1},focus:()=>{},blur:()=>{},subscribe:()=>()=>{}};let k=!1,q=new Set,z=()=>typeof b==="string"?document.querySelector(b):b,D=(C)=>{if(C!==k)k=C,q.forEach((J)=>J(k))},H=()=>D(!0),I=()=>D(!1),E=z();if(E)E.addEventListener("focus",H),E.addEventListener("blur",I),k=document.activeElement===E;let G=()=>{let C=z();if(C)C.removeEventListener("focus",H),C.removeEventListener("blur",I);q.clear()};if(typeof globalThis.onDestroy==="function")globalThis.onDestroy(G);return{get isFocused(){return k},focus(){let C=z();if(C&&typeof C.focus==="function")C.focus()},blur(){let C=z();if(C&&typeof C.blur==="function")C.blur()},subscribe(C){return q.add(C),()=>{q.delete(C)}}}}function A(b,k={}){let q="idle",z=null,D=null,H=new Set,I=()=>{let G={state:q,data:z,error:D};H.forEach((C)=>C(G))},E=async(...G)=>{q="loading",D=null,I();try{return z=await b(...G),q="success",I(),z}catch(C){return D=C instanceof Error?C:Error(String(C)),q="error",I(),null}};if(k.immediate)E();return{get state(){return q},get isLoading(){return q==="loading"},get error(){return D},get data(){return z},execute:E,subscribe(G){return H.add(G),()=>{H.delete(G)}}}}export{_ as useToggle,w as useFocus,$ as useCounter,j as useClickOutside,A as useAsync};
