"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const React = require("react");
const index = require("../../../../_vendor/usehooks-ts/dist-index.cjs");
function useCodeBlock({
  defaultExpanded = true,
  defaultCodeExpanded = false,
  onExpandChange,
  onCodeExpandChange,
  scrollToBottom
}) {
  const [isExpanded, setIsExpanded] = React.useState(defaultExpanded);
  const [codeExpanded, setCodeExpanded] = React.useState(defaultCodeExpanded);
  const [copied, setCopied] = React.useState(false);
  const handleExpand = index.useEventCallback(() => {
    const newValue = !isExpanded;
    setIsExpanded(newValue);
    onExpandChange?.(newValue);
  });
  const handleCodeExpand = index.useEventCallback(() => {
    const newValue = !codeExpanded;
    setCodeExpanded(newValue);
    onCodeExpandChange?.(newValue);
    scrollToBottom?.({
      wait: 100
    });
  });
  const handleCopy = index.useEventCallback(async (code) => {
    try {
      await navigator.clipboard.writeText(code);
      setCopied(true);
      setTimeout(() => setCopied(false), 2e3);
    } catch (error) {
      console.error("Failed to copy code:", error);
    }
  });
  return {
    isExpanded,
    codeExpanded,
    copied,
    handleExpand,
    handleCodeExpand,
    handleCopy
  };
}
exports.useCodeBlock = useCodeBlock;
//# sourceMappingURL=use-code-block.cjs.map
