// src/lib/hooks/use-breakpoint.ts
import { useSyncExternalStore } from "react";
var screens = {
  sm: "640px",
  md: "768px",
  lg: "1024px",
  xl: "1280px",
  "2xl": "1536px"
};
var useBreakpoint = (size) => {
  return useSyncExternalStore(
    (onStoreChange) => {
      if (typeof window === "undefined") {
        return () => {
        };
      }
      const breakpoint = window.matchMedia(`(min-width: ${screens[size]})`);
      breakpoint.addEventListener("change", onStoreChange);
      return () => breakpoint.removeEventListener("change", onStoreChange);
    },
    () => {
      if (typeof window === "undefined") {
        return true;
      }
      return window.matchMedia(`(min-width: ${screens[size]})`).matches;
    },
    () => true
  );
};

// src/lib/hooks/use-clipboard.ts
import { useCallback, useState } from "react";
var DEFAULT_TIMEOUT = 2e3;
var useClipboard = () => {
  const [copied, setCopied] = useState(false);
  const fallback = (text, id) => {
    try {
      const textArea = document.createElement("textarea");
      textArea.value = text;
      textArea.style.position = "absolute";
      textArea.style.left = "-99999px";
      document.body.appendChild(textArea);
      textArea.select();
      const success = document.execCommand("copy");
      textArea.remove();
      setCopied(id || true);
      setTimeout(() => setCopied(false), DEFAULT_TIMEOUT);
      return success ? { success: true } : { success: false, error: new Error("execCommand returned false") };
    } catch (err) {
      return {
        success: false,
        error: err instanceof Error ? err : new Error("Fallback copy failed")
      };
    }
  };
  const copy = useCallback(async (text, id) => {
    if (navigator.clipboard && window.isSecureContext) {
      try {
        await navigator.clipboard.writeText(text);
        setCopied(id || true);
        setTimeout(() => setCopied(false), DEFAULT_TIMEOUT);
        return { success: true };
      } catch (e) {
        return fallback(text, id);
      }
    }
    return fallback(text);
  }, []);
  return { copied, copy };
};

// src/lib/hooks/use-resize-observer.ts
import { useEffect } from "react";
function hasResizeObserver() {
  return typeof window.ResizeObserver !== "undefined";
}
function useResizeObserver(options) {
  const { ref, box, onResize } = options;
  useEffect(() => {
    const element = ref == null ? void 0 : ref.current;
    if (!element) {
      return;
    }
    if (!hasResizeObserver()) {
      window.addEventListener("resize", onResize, false);
      return () => {
        window.removeEventListener("resize", onResize, false);
      };
    } else {
      const resizeObserverInstance = new window.ResizeObserver((entries) => {
        if (!entries.length) {
          return;
        }
        onResize();
      });
      resizeObserverInstance.observe(element, { box });
      return () => {
        if (element) {
          resizeObserverInstance.unobserve(element);
        }
      };
    }
  }, [onResize, ref, box]);
}
export {
  useBreakpoint,
  useClipboard,
  useResizeObserver
};
//# sourceMappingURL=index.js.map