import {
  TextArea
} from "./chunk-7OYIDM42.js";
import {
  BUTTON_INTENT,
  BUTTON_SIZE,
  Button
} from "./chunk-B4U37WIH.js";
import {
  cn
} from "./chunk-P6GUNIAE.js";

// src/components/ai-elements/prompt-input/prompt-input.tsx
import { forwardRef, useCallback } from "react";

// src/components/ai-elements/prompt-input/types.ts
var CHAT_STATUS = {
  /** Idle / ready to submit. */
  READY: "ready",
  /** The last submission errored — the button shows a retry affordance. */
  ERROR: "error"
};

// src/components/ai-elements/prompt-input/prompt-input.tsx
import { jsx } from "react/jsx-runtime";
var PromptInput = ({ className, onSubmit, disabled, children, ...props }) => {
  const handleSubmit = useCallback(
    (event) => {
      event.preventDefault();
      if (disabled) {
        return;
      }
      const textarea = event.currentTarget.querySelector("textarea");
      const text = textarea?.value ?? "";
      if (!text.trim()) {
        return;
      }
      onSubmit({ text }, event);
    },
    [disabled, onSubmit]
  );
  return /* @__PURE__ */ jsx(
    "form",
    {
      className: cn(
        "flex w-full flex-col overflow-hidden rounded-xl border bg-background shadow-lg shadow-foreground/5",
        className
      ),
      onSubmit: handleSubmit,
      ...props,
      children
    }
  );
};
var PromptInputTextarea = forwardRef(
  function PromptInputTextarea2({ className, onKeyDown, placeholder = "What would you like to know?", ...props }, ref) {
    const handleKeyDown = useCallback(
      (event) => {
        onKeyDown?.(event);
        if (event.defaultPrevented) {
          return;
        }
        if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing) {
          event.preventDefault();
          event.currentTarget.form?.requestSubmit();
        }
      },
      [onKeyDown]
    );
    return /* @__PURE__ */ jsx("div", { className: cn("py-3", className), children: /* @__PURE__ */ jsx(TextArea, { ref, className: "px-4", onKeyDown: handleKeyDown, placeholder, ...props }) });
  }
);
var PromptInputFooter = ({ className, ...props }) => /* @__PURE__ */ jsx("div", { className: cn("flex items-center justify-between gap-1 px-4 pb-3", className), ...props });
var PromptInputTools = ({ className, ...props }) => /* @__PURE__ */ jsx("div", { className: cn("flex min-w-0 items-center gap-1", className), ...props });
var PromptInputSubmit = ({
  label = "Submit",
  status = CHAT_STATUS.READY,
  disabled,
  className
}) => {
  const handleClick = useCallback((event) => {
    event.currentTarget.form?.requestSubmit();
  }, []);
  return /* @__PURE__ */ jsx(
    Button,
    {
      intent: status === CHAT_STATUS.ERROR ? BUTTON_INTENT.ERROR : BUTTON_INTENT.PRIMARY,
      size: BUTTON_SIZE.XS,
      className,
      disabled,
      onClick: handleClick,
      children: label
    }
  );
};

// src/components/ai-elements/mouse-grid/mouse-grid.tsx
import { useEffect, useRef } from "react";

// src/utils/prefers-reduced-motion.ts
function prefersReducedMotion() {
  return typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia("(prefers-reduced-motion: reduce)").matches : false;
}

// src/components/ai-elements/mouse-grid/mouse-grid.tsx
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
function MouseGrid({ glowColor, colorCycleMs = 4e3, autoDrift = false } = {}) {
  const layerRef = useRef(null);
  const glowRef = useRef(null);
  useEffect(() => {
    const driftEnabled = autoDrift && !prefersReducedMotion();
    let raf = 0;
    let driftRaf = 0;
    let lastDriftTime = 0;
    let clientX = 0;
    let clientY = 0;
    let pointerInside = false;
    let centerX = 0;
    let centerY = 0;
    let hasCenter = false;
    function setCenter(x, y) {
      const layer = layerRef.current;
      if (!layer) {
        return;
      }
      centerX = x;
      centerY = y;
      hasCenter = true;
      layer.style.setProperty("--vibe-mx", `${x}px`);
      layer.style.setProperty("--vibe-my", `${y}px`);
    }
    function flush() {
      raf = 0;
      const layer = layerRef.current;
      if (!layer) {
        return;
      }
      if (driftEnabled && !pointerInside) {
        return;
      }
      const rect = layer.getBoundingClientRect();
      setCenter(clientX - rect.left, clientY - rect.top);
    }
    function onMove(event) {
      clientX = event.clientX;
      clientY = event.clientY;
      const layer = layerRef.current;
      if (layer) {
        const rect = layer.getBoundingClientRect();
        pointerInside = clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom;
      }
      if (pointerInside) {
        stopDrift();
      } else {
        startDrift();
      }
      if (raf) {
        return;
      }
      raf = requestAnimationFrame(flush);
    }
    function onPointerLeave() {
      pointerInside = false;
      startDrift();
    }
    function drift(time) {
      const delta = lastDriftTime ? time - lastDriftTime : 16.67;
      lastDriftTime = time;
      driftRaf = requestAnimationFrame(drift);
      const layer = layerRef.current;
      if (!layer) {
        return;
      }
      const { width, height } = layer.getBoundingClientRect();
      if (!hasCenter) {
        centerX = width / 2;
        centerY = height / 2;
      }
      const targetX = width * (0.5 + 0.32 * Math.sin(time * 37e-5) + 0.12 * Math.sin(time * 91e-5));
      const targetY = height * (0.5 + 0.32 * Math.cos(time * 41e-5) + 0.12 * Math.sin(time * 11e-4));
      const alpha = 1 - Math.exp(-25e-4 * delta);
      setCenter(centerX + (targetX - centerX) * alpha, centerY + (targetY - centerY) * alpha);
    }
    function startDrift() {
      if (!driftEnabled || driftRaf) {
        return;
      }
      lastDriftTime = 0;
      driftRaf = requestAnimationFrame(drift);
    }
    function stopDrift() {
      if (driftRaf) {
        cancelAnimationFrame(driftRaf);
        driftRaf = 0;
      }
    }
    window.addEventListener("mousemove", onMove, { passive: true });
    document.documentElement.addEventListener("mouseleave", onPointerLeave);
    startDrift();
    return () => {
      window.removeEventListener("mousemove", onMove);
      document.documentElement.removeEventListener("mouseleave", onPointerLeave);
      if (raf) {
        cancelAnimationFrame(raf);
      }
      stopDrift();
    };
  }, [autoDrift]);
  const colorList = Array.isArray(glowColor) ? glowColor : glowColor != null ? [glowColor] : [];
  const glowColorsKey = JSON.stringify(colorList);
  useEffect(() => {
    const glow = glowRef.current;
    if (!glow) {
      return;
    }
    const colors = JSON.parse(glowColorsKey).filter(Boolean);
    const staticColor = colors[0];
    if (staticColor) {
      glow.style.setProperty("--vibe-glow-color", staticColor);
    }
    const clearColor = () => glow.style.removeProperty("--vibe-glow-color");
    if (colors.length < 2 || prefersReducedMotion()) {
      return staticColor ? clearColor : void 0;
    }
    let index = 0;
    const raf = requestAnimationFrame(() => glow.style.setProperty("--vibe-glow-cycle", `${colorCycleMs}ms`));
    const timer = setInterval(() => {
      index = (index + 1) % colors.length;
      glow.style.setProperty("--vibe-glow-color", colors[index]);
    }, colorCycleMs);
    return () => {
      cancelAnimationFrame(raf);
      clearInterval(timer);
      glow.style.removeProperty("--vibe-glow-cycle");
      clearColor();
    };
  }, [glowColorsKey, colorCycleMs]);
  return /* @__PURE__ */ jsxs("div", { ref: layerRef, "aria-hidden": "true", className: "vibe-mouse-grid-layer", children: [
    /* @__PURE__ */ jsx2("div", { className: "vibe-mouse-grid" }),
    /* @__PURE__ */ jsx2("div", { ref: glowRef, className: "vibe-mouse-glow" })
  ] });
}

// src/components/ai-elements/suggestion/suggestion.tsx
import { useCallback as useCallback2 } from "react";
import { jsx as jsx3 } from "react/jsx-runtime";
var Suggestions = ({ className, ...props }) => /* @__PURE__ */ jsx3("div", { className: cn("flex flex-wrap items-center justify-center gap-3", className), ...props });
var Suggestion = ({ suggestion, onClick, className, children, ...props }) => {
  const handleClick = useCallback2(() => onClick?.(suggestion), [onClick, suggestion]);
  return /* @__PURE__ */ jsx3(
    "button",
    {
      type: "button",
      onClick: handleClick,
      className: cn(
        "cursor-pointer whitespace-nowrap rounded-[12px] border border-brown-30 bg-white px-4 py-2 text-sm text-brown-100 transition-colors hover:bg-brown-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brown-40",
        className
      ),
      ...props,
      children: children ?? suggestion
    }
  );
};

export {
  CHAT_STATUS,
  PromptInput,
  PromptInputTextarea,
  PromptInputFooter,
  PromptInputTools,
  PromptInputSubmit,
  MouseGrid,
  Suggestions,
  Suggestion
};
//# sourceMappingURL=chunk-4VE6ZXXW.js.map